diff options
Diffstat (limited to 'debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug')
300 files changed, 13014 insertions, 12904 deletions
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImageDescriptorRegistry.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImageDescriptorRegistry.java index faefa107202..566e5da6037 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImageDescriptorRegistry.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImageDescriptorRegistry.java @@ -37,7 +37,7 @@ public class CDebugImageDescriptorRegistry { /** * 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 diaplay * the display the images managed by this registry are allocated for */ @@ -49,7 +49,7 @@ public class CDebugImageDescriptorRegistry { /** * Returns the image associated 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 @@ -61,7 +61,8 @@ public class CDebugImageDescriptorRegistry { Image result = fRegistry.get(descriptor); if (result != null) return result; - Assert.isTrue(fDisplay == CDebugUIPlugin.getStandardDisplay(), CDebugUIMessages.getString("CDebugImageDescriptorRegistry.0")); //$NON-NLS-1$ + Assert.isTrue(fDisplay == CDebugUIPlugin.getStandardDisplay(), + CDebugUIMessages.getString("CDebugImageDescriptorRegistry.0")); //$NON-NLS-1$ result = descriptor.createImage(); if (result != null) fRegistry.put(descriptor, result); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java index b86a34b8793..5551a3c4e30 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java @@ -29,7 +29,7 @@ import org.eclipse.swt.graphics.Image; /** * Bundle of most images used by the C/C++ debug plug-in. - * + * * @since Aug 30, 2002 */ public class CDebugImages { @@ -53,7 +53,7 @@ public class CDebugImages { /* * Available cached Images in the C/C++ debug plug-in image registry. - */ + */ public static final String IMG_OVRS_BREAKPOINT_INSTALLED = NAME_PREFIX + "installed_ovr.gif"; //$NON-NLS-1$ public static final String IMG_OVRS_BREAKPOINT_INSTALLED_DISABLED = NAME_PREFIX + "installed_ovr_disabled.gif"; //$NON-NLS-1$ public static final String IMG_OVRS_BREAKPOINT_CONDITIONAL = NAME_PREFIX + "conditional_ovr.gif"; //$NON-NLS-1$ @@ -69,77 +69,77 @@ public class CDebugImages { public static final String IMG_OVRS_VARIABLE_CASTED = NAME_PREFIX + "casttype_ovr.gif"; //$NON-NLS-1$ public static final String IMG_OVRS_ARGUMENT = NAME_PREFIX + "argument_ovr.gif"; //$NON-NLS-1$ public static final String IMG_OVRS_GLOBAL = NAME_PREFIX + "global_ovr.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_BREAKPOINT_ENABLED = NAME_PREFIX + "brkp_obj.png"; //$NON-NLS-1$ - public static final String IMG_OBJS_BREAKPOINT_DISABLED = NAME_PREFIX + "brkpd_obj.png"; //$NON-NLS-1$ - public static final String IMG_OBJS_HWBREAKPOINT_ENABLED = NAME_PREFIX + "hwbrkp_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_HWBREAKPOINT_DISABLED = NAME_PREFIX + "hwbrkpd_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_ADDRESS_BREAKPOINT_ENABLED = NAME_PREFIX + "addrbrkp_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_ADDRESS_BREAKPOINT_DISABLED = NAME_PREFIX + "addrbrkpd_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_FUNCTION_BREAKPOINT_ENABLED = NAME_PREFIX + "funbrkp_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_FUNCTION_BREAKPOINT_DISABLED = NAME_PREFIX + "funbrkpd_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_TRACEPOINT_ENABLED = NAME_PREFIX + "trcp_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_TRACEPOINT_DISABLED = NAME_PREFIX + "trcpd_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_DYNAMICPRINTF_ENABLED = NAME_PREFIX + "dprintf_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_DYNAMICPRINTF_DISABLED = NAME_PREFIX + "dprintfd_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_WATCHPOINT_ENABLED = NAME_PREFIX + "readwrite_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_WATCHPOINT_DISABLED = NAME_PREFIX + "readwrite_obj_disabled.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_EVENTBREAKPOINT_ENABLED = NAME_PREFIX + "eventbreakpoint_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_EVENTBREAKPOINT_DISABLED = NAME_PREFIX + "eventbreakpointd_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_READ_WATCHPOINT_ENABLED = NAME_PREFIX + "read_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_READ_WATCHPOINT_DISABLED = NAME_PREFIX + "read_obj_disabled.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_WRITE_WATCHPOINT_ENABLED = NAME_PREFIX + "write_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_WRITE_WATCHPOINT_DISABLED = NAME_PREFIX + "write_obj_disabled.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_VARIABLE_SIMPLE = NAME_PREFIX + "var_simple.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_VARIABLE_SIMPLE_DISABLED = NAME_PREFIX + "vard_simple.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_VARIABLE_AGGREGATE = NAME_PREFIX + "var_aggr.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_VARIABLE_AGGREGATE_DISABLED = NAME_PREFIX + "vard_aggr.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_VARIABLE_POINTER = NAME_PREFIX + "var_pointer.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_VARIABLE_POINTER_DISABLED = NAME_PREFIX + "vard_pointer.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_VARIABLE_STRING = NAME_PREFIX + "var_string.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_REGISTER_GROUP = NAME_PREFIX + "registergroup_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_REGISTER_GROUP_DISABLED = NAME_PREFIX + "registergroupd_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_REGISTER = NAME_PREFIX + "register_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_REGISTER_DISABLED = NAME_PREFIX + "registerd_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_DISASSEMBLY = NAME_PREFIX + "disassembly_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_PROJECT = NAME_PREFIX + "project_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_CLOSED_PROJECT = NAME_PREFIX + "cproject_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_FOLDER = NAME_PREFIX + "folder_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_EXECUTABLE_WITH_SYMBOLS = NAME_PREFIX + "exec_dbg_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_EXECUTABLE = NAME_PREFIX + "exec_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_SHARED_LIBRARY_WITH_SYMBOLS = NAME_PREFIX + "library_syms_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_SHARED_LIBRARY = NAME_PREFIX + "library_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_SIGNAL = NAME_PREFIX + "signal_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_WORKSPACE_SOURCE_FILE = NAME_PREFIX + "prj_file_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_EXTERNAL_SOURCE_FILE = NAME_PREFIX + "ext_file_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_PATH_MAPPING = NAME_PREFIX + "mapping_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_PATH_MAP_ENTRY = NAME_PREFIX + "mapentry_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_BREAKPOINT_ENABLED = NAME_PREFIX + "brkp_obj.png"; //$NON-NLS-1$ + public static final String IMG_OBJS_BREAKPOINT_DISABLED = NAME_PREFIX + "brkpd_obj.png"; //$NON-NLS-1$ + public static final String IMG_OBJS_HWBREAKPOINT_ENABLED = NAME_PREFIX + "hwbrkp_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_HWBREAKPOINT_DISABLED = NAME_PREFIX + "hwbrkpd_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_ADDRESS_BREAKPOINT_ENABLED = NAME_PREFIX + "addrbrkp_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_ADDRESS_BREAKPOINT_DISABLED = NAME_PREFIX + "addrbrkpd_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_FUNCTION_BREAKPOINT_ENABLED = NAME_PREFIX + "funbrkp_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_FUNCTION_BREAKPOINT_DISABLED = NAME_PREFIX + "funbrkpd_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_TRACEPOINT_ENABLED = NAME_PREFIX + "trcp_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_TRACEPOINT_DISABLED = NAME_PREFIX + "trcpd_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_DYNAMICPRINTF_ENABLED = NAME_PREFIX + "dprintf_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_DYNAMICPRINTF_DISABLED = NAME_PREFIX + "dprintfd_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_WATCHPOINT_ENABLED = NAME_PREFIX + "readwrite_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_WATCHPOINT_DISABLED = NAME_PREFIX + "readwrite_obj_disabled.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_EVENTBREAKPOINT_ENABLED = NAME_PREFIX + "eventbreakpoint_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_EVENTBREAKPOINT_DISABLED = NAME_PREFIX + "eventbreakpointd_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_READ_WATCHPOINT_ENABLED = NAME_PREFIX + "read_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_READ_WATCHPOINT_DISABLED = NAME_PREFIX + "read_obj_disabled.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_WRITE_WATCHPOINT_ENABLED = NAME_PREFIX + "write_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_WRITE_WATCHPOINT_DISABLED = NAME_PREFIX + "write_obj_disabled.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_VARIABLE_SIMPLE = NAME_PREFIX + "var_simple.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_VARIABLE_SIMPLE_DISABLED = NAME_PREFIX + "vard_simple.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_VARIABLE_AGGREGATE = NAME_PREFIX + "var_aggr.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_VARIABLE_AGGREGATE_DISABLED = NAME_PREFIX + "vard_aggr.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_VARIABLE_POINTER = NAME_PREFIX + "var_pointer.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_VARIABLE_POINTER_DISABLED = NAME_PREFIX + "vard_pointer.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_VARIABLE_STRING = NAME_PREFIX + "var_string.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_REGISTER_GROUP = NAME_PREFIX + "registergroup_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_REGISTER_GROUP_DISABLED = NAME_PREFIX + "registergroupd_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_REGISTER = NAME_PREFIX + "register_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_REGISTER_DISABLED = NAME_PREFIX + "registerd_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_DISASSEMBLY = NAME_PREFIX + "disassembly_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_PROJECT = NAME_PREFIX + "project_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_CLOSED_PROJECT = NAME_PREFIX + "cproject_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_FOLDER = NAME_PREFIX + "folder_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_EXECUTABLE_WITH_SYMBOLS = NAME_PREFIX + "exec_dbg_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_EXECUTABLE = NAME_PREFIX + "exec_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_SHARED_LIBRARY_WITH_SYMBOLS = NAME_PREFIX + "library_syms_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_SHARED_LIBRARY = NAME_PREFIX + "library_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_SIGNAL = NAME_PREFIX + "signal_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_WORKSPACE_SOURCE_FILE = NAME_PREFIX + "prj_file_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_EXTERNAL_SOURCE_FILE = NAME_PREFIX + "ext_file_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_PATH_MAPPING = NAME_PREFIX + "mapping_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_PATH_MAP_ENTRY = NAME_PREFIX + "mapentry_obj.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_COMMON_TAB = NAME_PREFIX + "common_tab.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_ARRAY_PARTITION = NAME_PREFIX + "arraypartition_obj.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_C_APP = NAME_PREFIX + "c_app.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_CDT_LOGO = NAME_PREFIX + "cdt_logo_16.png"; //$NON-NLS-1$ - public static final String IMG_LCL_TYPE_NAMES = NAME_PREFIX + "tnames_co.gif"; //$NON-NLS-1$ - public static final String IMG_LCL_CHANGE_REGISTER_VALUE = NAME_PREFIX + "change_reg_value_co.gif"; //$NON-NLS-1$ - public static final String IMG_LCL_AUTO_REFRESH = NAME_PREFIX + "auto_refresh_co.gif"; //$NON-NLS-1$ - public static final String IMG_LCL_REFRESH = NAME_PREFIX + "refresh_co.gif"; //$NON-NLS-1$ - public static final String IMG_LCL_MEMORY_SAVE = NAME_PREFIX + "memory_update.gif"; //$NON-NLS-1$ - public static final String IMG_LCL_MEMORY_CLEAR = NAME_PREFIX + "memory_clear.gif"; //$NON-NLS-1$ - public static final String IMG_LCL_SHOW_ASCII = NAME_PREFIX + "show_ascii.gif"; //$NON-NLS-1$ - public static final String IMG_LCL_LOAD_ALL_SYMBOLS = NAME_PREFIX + "load_all_symbols_co.gif"; //$NON-NLS-1$ - public static final String IMG_LCL_CAST_TO_TYPE = NAME_PREFIX + "casttotype_co.gif"; //$NON-NLS-1$ - public static final String IMG_LCL_DISPLAY_AS_ARRAY = NAME_PREFIX + "showasarray_co.gif"; //$NON-NLS-1$ - public static final String IMG_LCL_DETAIL_PANE_UNDER = NAME_PREFIX + "det_pane_under.gif"; //$NON-NLS-1$ - public static final String IMG_LCL_DETAIL_PANE_RIGHT = NAME_PREFIX + "det_pane_right.gif"; //$NON-NLS-1$ - public static final String IMG_LCL_DETAIL_PANE_HIDE = NAME_PREFIX + "det_pane_hide.gif"; //$NON-NLS-1$ - public static final String IMG_LCL_COLLAPSE_ALL = NAME_PREFIX + "collapseall.gif"; //$NON-NLS-1$ - public static final String IMG_LCL_OPEN_NEW_VIEW = NAME_PREFIX + "open_new.gif"; //$NON-NLS-1$ - public static final String IMG_LCL_PIN_VIEW = NAME_PREFIX + "toolbar_pinned.gif"; //$NON-NLS-1$ + public static final String IMG_LCL_TYPE_NAMES = NAME_PREFIX + "tnames_co.gif"; //$NON-NLS-1$ + public static final String IMG_LCL_CHANGE_REGISTER_VALUE = NAME_PREFIX + "change_reg_value_co.gif"; //$NON-NLS-1$ + public static final String IMG_LCL_AUTO_REFRESH = NAME_PREFIX + "auto_refresh_co.gif"; //$NON-NLS-1$ + public static final String IMG_LCL_REFRESH = NAME_PREFIX + "refresh_co.gif"; //$NON-NLS-1$ + public static final String IMG_LCL_MEMORY_SAVE = NAME_PREFIX + "memory_update.gif"; //$NON-NLS-1$ + public static final String IMG_LCL_MEMORY_CLEAR = NAME_PREFIX + "memory_clear.gif"; //$NON-NLS-1$ + public static final String IMG_LCL_SHOW_ASCII = NAME_PREFIX + "show_ascii.gif"; //$NON-NLS-1$ + public static final String IMG_LCL_LOAD_ALL_SYMBOLS = NAME_PREFIX + "load_all_symbols_co.gif"; //$NON-NLS-1$ + public static final String IMG_LCL_CAST_TO_TYPE = NAME_PREFIX + "casttotype_co.gif"; //$NON-NLS-1$ + public static final String IMG_LCL_DISPLAY_AS_ARRAY = NAME_PREFIX + "showasarray_co.gif"; //$NON-NLS-1$ + public static final String IMG_LCL_DETAIL_PANE_UNDER = NAME_PREFIX + "det_pane_under.gif"; //$NON-NLS-1$ + public static final String IMG_LCL_DETAIL_PANE_RIGHT = NAME_PREFIX + "det_pane_right.gif"; //$NON-NLS-1$ + public static final String IMG_LCL_DETAIL_PANE_HIDE = NAME_PREFIX + "det_pane_hide.gif"; //$NON-NLS-1$ + public static final String IMG_LCL_COLLAPSE_ALL = NAME_PREFIX + "collapseall.gif"; //$NON-NLS-1$ + public static final String IMG_LCL_OPEN_NEW_VIEW = NAME_PREFIX + "open_new.gif"; //$NON-NLS-1$ + public static final String IMG_LCL_PIN_VIEW = NAME_PREFIX + "toolbar_pinned.gif"; //$NON-NLS-1$ - public static final String IMG_WIZBAN_ADD_SOURCE = NAME_PREFIX + "addsrcloc_wiz.gif"; //$NON-NLS-1$ - public static final String IMG_WIZBAN_PATH_MAPPING = NAME_PREFIX + "mapping_wiz.gif"; //$NON-NLS-1$ - public static final String IMG_WIZBAN_PATH_MAP_ENTRY = NAME_PREFIX + "mapentry_wiz.gif"; //$NON-NLS-1$ + public static final String IMG_WIZBAN_ADD_SOURCE = NAME_PREFIX + "addsrcloc_wiz.gif"; //$NON-NLS-1$ + public static final String IMG_WIZBAN_PATH_MAPPING = NAME_PREFIX + "mapping_wiz.gif"; //$NON-NLS-1$ + public static final String IMG_WIZBAN_PATH_MAP_ENTRY = NAME_PREFIX + "mapentry_wiz.gif"; //$NON-NLS-1$ - public static final String IMG_DEBUGGER_CONSOLE_SELECT = NAME_PREFIX + "debugger_console_select.gif"; //$NON-NLS-1$ + public static final String IMG_DEBUGGER_CONSOLE_SELECT = NAME_PREFIX + "debugger_console_select.gif"; //$NON-NLS-1$ /* * Set of predefined Image Descriptors. @@ -150,67 +150,103 @@ public class CDebugImages { private static final String T_LCL = "lcl16"; //$NON-NLS-1$ private static final String T_ELCL = "elcl16"; //$NON-NLS-1$ private static final String T_DLCL = "dlcl16"; //$NON-NLS-1$ -// private static final String T_DTOOL = "dtool16"; //$NON-NLS-1$ -// private static final String T_ETOOL = "etool16"; //$NON-NLS-1$ + // private static final String T_DTOOL = "dtool16"; //$NON-NLS-1$ + // private static final String T_ETOOL = "etool16"; //$NON-NLS-1$ public static final ImageDescriptor DESC_OVRS_ERROR = createManaged(T_OVR, IMG_OVRS_ERROR); public static final ImageDescriptor DESC_OVRS_WARNING = createManaged(T_OVR, IMG_OVRS_WARNING); - public static final ImageDescriptor DESC_OVRS_BREAKPOINT_INSTALLED = createManaged(T_OVR, IMG_OVRS_BREAKPOINT_INSTALLED); - public static final ImageDescriptor DESC_OVRS_BREAKPOINT_INSTALLED_DISABLED = createManaged(T_OVR, IMG_OVRS_BREAKPOINT_INSTALLED_DISABLED); - public static final ImageDescriptor DESC_OVRS_BREAKPOINT_CONDITIONAL = createManaged(T_OVR, IMG_OVRS_BREAKPOINT_CONDITIONAL); - public static final ImageDescriptor DESC_OVRS_BREAKPOINT_CONDITIONAL_DISABLED = createManaged(T_OVR, IMG_OVRS_BREAKPOINT_CONDITIONAL_DISABLED); - public static final ImageDescriptor DESC_OVRS_BREAKPOINT_WITH_ACTIONS = createManaged(T_OVR, IMG_OVRS_BREAKPOINT_WITH_ACTIONS); - public static final ImageDescriptor DESC_OVRS_BREAKPOINT_WITH_ACTIONS_DISABLED = createManaged(T_OVR, IMG_OVRS_BREAKPOINT_WITH_ACTIONS_DISABLED); - public static final ImageDescriptor DESC_OVRS_ADDRESS_BREAKPOINT = createManaged(T_OVR, IMG_OVRS_ADDRESS_BREAKPOINT); - public static final ImageDescriptor DESC_OVRS_ADDRESS_BREAKPOINT_DISABLED = createManaged(T_OVR, IMG_OVRS_ADDRESS_BREAKPOINT_DISABLED); - public static final ImageDescriptor DESC_OVRS_FUNCTION_BREAKPOINT = createManaged(T_OVR, IMG_OVRS_FUNCTION_BREAKPOINT); - public static final ImageDescriptor DESC_OVRS_FUNCTION_BREAKPOINT_DISABLED = createManaged(T_OVR, IMG_OVRS_FUNCTION_BREAKPOINT_DISABLED); + public static final ImageDescriptor DESC_OVRS_BREAKPOINT_INSTALLED = createManaged(T_OVR, + IMG_OVRS_BREAKPOINT_INSTALLED); + public static final ImageDescriptor DESC_OVRS_BREAKPOINT_INSTALLED_DISABLED = createManaged(T_OVR, + IMG_OVRS_BREAKPOINT_INSTALLED_DISABLED); + public static final ImageDescriptor DESC_OVRS_BREAKPOINT_CONDITIONAL = createManaged(T_OVR, + IMG_OVRS_BREAKPOINT_CONDITIONAL); + public static final ImageDescriptor DESC_OVRS_BREAKPOINT_CONDITIONAL_DISABLED = createManaged(T_OVR, + IMG_OVRS_BREAKPOINT_CONDITIONAL_DISABLED); + public static final ImageDescriptor DESC_OVRS_BREAKPOINT_WITH_ACTIONS = createManaged(T_OVR, + IMG_OVRS_BREAKPOINT_WITH_ACTIONS); + public static final ImageDescriptor DESC_OVRS_BREAKPOINT_WITH_ACTIONS_DISABLED = createManaged(T_OVR, + IMG_OVRS_BREAKPOINT_WITH_ACTIONS_DISABLED); + public static final ImageDescriptor DESC_OVRS_ADDRESS_BREAKPOINT = createManaged(T_OVR, + IMG_OVRS_ADDRESS_BREAKPOINT); + public static final ImageDescriptor DESC_OVRS_ADDRESS_BREAKPOINT_DISABLED = createManaged(T_OVR, + IMG_OVRS_ADDRESS_BREAKPOINT_DISABLED); + public static final ImageDescriptor DESC_OVRS_FUNCTION_BREAKPOINT = createManaged(T_OVR, + IMG_OVRS_FUNCTION_BREAKPOINT); + public static final ImageDescriptor DESC_OVRS_FUNCTION_BREAKPOINT_DISABLED = createManaged(T_OVR, + IMG_OVRS_FUNCTION_BREAKPOINT_DISABLED); public static final ImageDescriptor DESC_OVRS_VARIABLE_CASTED = createManaged(T_OVR, IMG_OVRS_VARIABLE_CASTED); public static final ImageDescriptor DESC_OVRS_ARGUMENT = createManaged(T_OVR, IMG_OVRS_ARGUMENT); public static final ImageDescriptor DESC_OVRS_GLOBAL = createManaged(T_OVR, IMG_OVRS_GLOBAL); - public static final ImageDescriptor DESC_OBJS_BREAKPOINT_ENABLED = createManaged(T_OBJ, IMG_OBJS_BREAKPOINT_ENABLED); - public static final ImageDescriptor DESC_OBJS_BREAKPOINT_DISABLED = createManaged(T_OBJ, IMG_OBJS_BREAKPOINT_DISABLED); - public static final ImageDescriptor DESC_OBJS_HWBREAKPOINT_ENABLED = createManaged(T_OBJ, IMG_OBJS_HWBREAKPOINT_ENABLED); - public static final ImageDescriptor DESC_OBJS_HWBREAKPOINT_DISABLED = createManaged(T_OBJ, IMG_OBJS_HWBREAKPOINT_DISABLED); - public static final ImageDescriptor DESC_OBJS_TRACEPOINT_ENABLED = createManaged(T_ELCL, IMG_OBJS_TRACEPOINT_ENABLED); - public static final ImageDescriptor DESC_OBJS_TRACEPOINT_DISABLED = createManaged(T_DLCL, IMG_OBJS_TRACEPOINT_DISABLED); - public static final ImageDescriptor DESC_OBJS_DYNAMICPRINTF_ENABLED = createManaged(T_ELCL, IMG_OBJS_DYNAMICPRINTF_ENABLED); - public static final ImageDescriptor DESC_OBJS_DYNAMICPRINTF_DISABLED = createManaged(T_DLCL, IMG_OBJS_DYNAMICPRINTF_DISABLED); - public static final ImageDescriptor DESC_OBJS_WATCHPOINT_ENABLED = createManaged(T_OBJ, IMG_OBJS_WATCHPOINT_ENABLED); - public static final ImageDescriptor DESC_OBJS_WATCHPOINT_DISABLED = createManaged(T_OBJ, IMG_OBJS_WATCHPOINT_DISABLED); - public static final ImageDescriptor DESC_OBJS_EVENTBREAKPOINT_ENABLED = createManaged(T_OBJ, IMG_OBJS_EVENTBREAKPOINT_ENABLED); - public static final ImageDescriptor DESC_OBJS_EVENTBREAKPOINT_DISABLED = createManaged(T_OBJ, IMG_OBJS_EVENTBREAKPOINT_DISABLED); - public static final ImageDescriptor DESC_OBJS_READ_WATCHPOINT_ENABLED = createManaged(T_OBJ, IMG_OBJS_READ_WATCHPOINT_ENABLED); - public static final ImageDescriptor DESC_OBJS_READ_WATCHPOINT_DISABLED = createManaged(T_OBJ, IMG_OBJS_READ_WATCHPOINT_DISABLED); - public static final ImageDescriptor DESC_OBJS_WRITE_WATCHPOINT_ENABLED = createManaged(T_OBJ, IMG_OBJS_WRITE_WATCHPOINT_ENABLED); - public static final ImageDescriptor DESC_OBJS_WRITE_WATCHPOINT_DISABLED = createManaged(T_OBJ, IMG_OBJS_WRITE_WATCHPOINT_DISABLED); + public static final ImageDescriptor DESC_OBJS_BREAKPOINT_ENABLED = createManaged(T_OBJ, + IMG_OBJS_BREAKPOINT_ENABLED); + public static final ImageDescriptor DESC_OBJS_BREAKPOINT_DISABLED = createManaged(T_OBJ, + IMG_OBJS_BREAKPOINT_DISABLED); + public static final ImageDescriptor DESC_OBJS_HWBREAKPOINT_ENABLED = createManaged(T_OBJ, + IMG_OBJS_HWBREAKPOINT_ENABLED); + public static final ImageDescriptor DESC_OBJS_HWBREAKPOINT_DISABLED = createManaged(T_OBJ, + IMG_OBJS_HWBREAKPOINT_DISABLED); + public static final ImageDescriptor DESC_OBJS_TRACEPOINT_ENABLED = createManaged(T_ELCL, + IMG_OBJS_TRACEPOINT_ENABLED); + public static final ImageDescriptor DESC_OBJS_TRACEPOINT_DISABLED = createManaged(T_DLCL, + IMG_OBJS_TRACEPOINT_DISABLED); + public static final ImageDescriptor DESC_OBJS_DYNAMICPRINTF_ENABLED = createManaged(T_ELCL, + IMG_OBJS_DYNAMICPRINTF_ENABLED); + public static final ImageDescriptor DESC_OBJS_DYNAMICPRINTF_DISABLED = createManaged(T_DLCL, + IMG_OBJS_DYNAMICPRINTF_DISABLED); + public static final ImageDescriptor DESC_OBJS_WATCHPOINT_ENABLED = createManaged(T_OBJ, + IMG_OBJS_WATCHPOINT_ENABLED); + public static final ImageDescriptor DESC_OBJS_WATCHPOINT_DISABLED = createManaged(T_OBJ, + IMG_OBJS_WATCHPOINT_DISABLED); + public static final ImageDescriptor DESC_OBJS_EVENTBREAKPOINT_ENABLED = createManaged(T_OBJ, + IMG_OBJS_EVENTBREAKPOINT_ENABLED); + public static final ImageDescriptor DESC_OBJS_EVENTBREAKPOINT_DISABLED = createManaged(T_OBJ, + IMG_OBJS_EVENTBREAKPOINT_DISABLED); + public static final ImageDescriptor DESC_OBJS_READ_WATCHPOINT_ENABLED = createManaged(T_OBJ, + IMG_OBJS_READ_WATCHPOINT_ENABLED); + public static final ImageDescriptor DESC_OBJS_READ_WATCHPOINT_DISABLED = createManaged(T_OBJ, + IMG_OBJS_READ_WATCHPOINT_DISABLED); + public static final ImageDescriptor DESC_OBJS_WRITE_WATCHPOINT_ENABLED = createManaged(T_OBJ, + IMG_OBJS_WRITE_WATCHPOINT_ENABLED); + public static final ImageDescriptor DESC_OBJS_WRITE_WATCHPOINT_DISABLED = createManaged(T_OBJ, + IMG_OBJS_WRITE_WATCHPOINT_DISABLED); public static final ImageDescriptor DESC_OBJS_VARIABLE_SIMPLE = createManaged(T_OBJ, IMG_OBJS_VARIABLE_SIMPLE); - public static final ImageDescriptor DESC_OBJS_VARIABLE_SIMPLE_DISABLED = createManaged(T_OBJ, IMG_OBJS_VARIABLE_SIMPLE_DISABLED); - public static final ImageDescriptor DESC_OBJS_VARIABLE_AGGREGATE = createManaged(T_OBJ, IMG_OBJS_VARIABLE_AGGREGATE); - public static final ImageDescriptor DESC_OBJS_VARIABLE_AGGREGATE_DISABLED = createManaged(T_OBJ, IMG_OBJS_VARIABLE_AGGREGATE_DISABLED); + public static final ImageDescriptor DESC_OBJS_VARIABLE_SIMPLE_DISABLED = createManaged(T_OBJ, + IMG_OBJS_VARIABLE_SIMPLE_DISABLED); + public static final ImageDescriptor DESC_OBJS_VARIABLE_AGGREGATE = createManaged(T_OBJ, + IMG_OBJS_VARIABLE_AGGREGATE); + public static final ImageDescriptor DESC_OBJS_VARIABLE_AGGREGATE_DISABLED = createManaged(T_OBJ, + IMG_OBJS_VARIABLE_AGGREGATE_DISABLED); public static final ImageDescriptor DESC_OBJS_VARIABLE_POINTER = createManaged(T_OBJ, IMG_OBJS_VARIABLE_POINTER); - public static final ImageDescriptor DESC_OBJS_VARIABLE_POINTER_DISABLED = createManaged(T_OBJ, IMG_OBJS_VARIABLE_POINTER_DISABLED); + public static final ImageDescriptor DESC_OBJS_VARIABLE_POINTER_DISABLED = createManaged(T_OBJ, + IMG_OBJS_VARIABLE_POINTER_DISABLED); public static final ImageDescriptor DESC_OBJS_VARIABLE_STRING = createManaged(T_OBJ, IMG_OBJS_VARIABLE_STRING); public static final ImageDescriptor DESC_OBJS_REGISTER_GROUP = createManaged(T_OBJ, IMG_OBJS_REGISTER_GROUP); - public static final ImageDescriptor DESC_OBJS_REGISTER_GROUP_DISABLED = createManaged(T_OBJ, IMG_OBJS_REGISTER_GROUP_DISABLED); + public static final ImageDescriptor DESC_OBJS_REGISTER_GROUP_DISABLED = createManaged(T_OBJ, + IMG_OBJS_REGISTER_GROUP_DISABLED); public static final ImageDescriptor DESC_OBJS_REGISTER = createManaged(T_OBJ, IMG_OBJS_REGISTER); public static final ImageDescriptor DESC_OBJS_REGISTER_DISABLED = createManaged(T_OBJ, IMG_OBJS_REGISTER_DISABLED); public static final ImageDescriptor DESC_OBJS_DISASSEMBLY = createManaged(T_OBJ, IMG_OBJS_DISASSEMBLY); public static final ImageDescriptor DESC_OBJS_PROJECT = createManaged(T_OBJ, IMG_OBJS_PROJECT); public static final ImageDescriptor DESC_OBJS_CLOSED_PROJECT = createManaged(T_OBJ, IMG_OBJS_CLOSED_PROJECT); public static final ImageDescriptor DESC_OBJS_FOLDER = createManaged(T_OBJ, IMG_OBJS_FOLDER); - public static final ImageDescriptor DESC_OBJS_EXECUTABLE_WITH_SYMBOLS = createManaged(T_OBJ, IMG_OBJS_EXECUTABLE_WITH_SYMBOLS); + public static final ImageDescriptor DESC_OBJS_EXECUTABLE_WITH_SYMBOLS = createManaged(T_OBJ, + IMG_OBJS_EXECUTABLE_WITH_SYMBOLS); public static final ImageDescriptor DESC_OBJS_EXECUTABLE = createManaged(T_OBJ, IMG_OBJS_EXECUTABLE); - public static final ImageDescriptor DESC_OBJS_SHARED_LIBRARY_WITH_SYMBOLS = createManaged(T_OBJ, IMG_OBJS_SHARED_LIBRARY_WITH_SYMBOLS); + public static final ImageDescriptor DESC_OBJS_SHARED_LIBRARY_WITH_SYMBOLS = createManaged(T_OBJ, + IMG_OBJS_SHARED_LIBRARY_WITH_SYMBOLS); public static final ImageDescriptor DESC_OBJS_SHARED_LIBRARY = createManaged(T_OBJ, IMG_OBJS_SHARED_LIBRARY); public static final ImageDescriptor DESC_OBJS_SIGNAL = createManaged(T_OBJ, IMG_OBJS_SIGNAL); - public static final ImageDescriptor DESC_OBJS_WORKSPACE_SOURCE_FILE = createManaged(T_OBJ, IMG_OBJS_WORKSPACE_SOURCE_FILE); - public static final ImageDescriptor DESC_OBJS_EXTERNAL_SOURCE_FILE = createManaged(T_OBJ, IMG_OBJS_EXTERNAL_SOURCE_FILE); + public static final ImageDescriptor DESC_OBJS_WORKSPACE_SOURCE_FILE = createManaged(T_OBJ, + IMG_OBJS_WORKSPACE_SOURCE_FILE); + public static final ImageDescriptor DESC_OBJS_EXTERNAL_SOURCE_FILE = createManaged(T_OBJ, + IMG_OBJS_EXTERNAL_SOURCE_FILE); public static final ImageDescriptor DESC_OBJS_PATH_MAPPING = createManaged(T_OBJ, IMG_OBJS_PATH_MAPPING); - public static final ImageDescriptor DESC_OBJS_PATH_MAP_ENTRY = createManaged(T_OBJ, IMG_OBJS_PATH_MAP_ENTRY); - public static final ImageDescriptor DESC_OBJS_COMMON_TAB = createManaged(T_OBJ, IMG_OBJS_COMMON_TAB); - public static final ImageDescriptor DESC_OBJS_ARRAY_PARTITION = createManaged(T_OBJ, IMG_OBJS_ARRAY_PARTITION); - public static final ImageDescriptor DESC_OBJS_DEBUGGER_CONSOLE_SELECT = createManaged(T_OBJ, IMG_DEBUGGER_CONSOLE_SELECT); + public static final ImageDescriptor DESC_OBJS_PATH_MAP_ENTRY = createManaged(T_OBJ, IMG_OBJS_PATH_MAP_ENTRY); + public static final ImageDescriptor DESC_OBJS_COMMON_TAB = createManaged(T_OBJ, IMG_OBJS_COMMON_TAB); + public static final ImageDescriptor DESC_OBJS_ARRAY_PARTITION = createManaged(T_OBJ, IMG_OBJS_ARRAY_PARTITION); + public static final ImageDescriptor DESC_OBJS_DEBUGGER_CONSOLE_SELECT = createManaged(T_OBJ, + IMG_DEBUGGER_CONSOLE_SELECT); public static final ImageDescriptor DESC_OBJS_C_APP = createManaged(T_OBJ, IMG_OBJS_C_APP); public static final ImageDescriptor DESC_OBJS_CDT_LOGO = createManaged(T_OBJ, IMG_OBJS_CDT_LOGO); public static final ImageDescriptor DESC_WIZBAN_ADD_SOURCE = createManaged(T_WIZBAN, IMG_WIZBAN_ADD_SOURCE); @@ -219,11 +255,14 @@ public class CDebugImages { public static final ImageDescriptor DESC_LCL_CAST_TO_TYPE = createManaged(T_ELCL, IMG_LCL_CAST_TO_TYPE); public static final ImageDescriptor DESC_LCL_DISPLAY_AS_ARRAY = createManaged(T_ELCL, IMG_LCL_DISPLAY_AS_ARRAY); public static final ImageDescriptor DESC_LCL_DETAIL_PANE_UNDER = createManaged(T_ELCL, IMG_LCL_DETAIL_PANE_UNDER); - public static final ImageDescriptor DESC_LCL_DETAIL_PANE_UNDER_DISABLED = createManaged(T_DLCL, IMG_LCL_DETAIL_PANE_UNDER); + public static final ImageDescriptor DESC_LCL_DETAIL_PANE_UNDER_DISABLED = createManaged(T_DLCL, + IMG_LCL_DETAIL_PANE_UNDER); public static final ImageDescriptor DESC_LCL_DETAIL_PANE_RIGHT = createManaged(T_ELCL, IMG_LCL_DETAIL_PANE_RIGHT); - public static final ImageDescriptor DESC_LCL_DETAIL_PANE_RIGHT_DISABLED = createManaged(T_DLCL, IMG_LCL_DETAIL_PANE_RIGHT); + public static final ImageDescriptor DESC_LCL_DETAIL_PANE_RIGHT_DISABLED = createManaged(T_DLCL, + IMG_LCL_DETAIL_PANE_RIGHT); public static final ImageDescriptor DESC_LCL_DETAIL_PANE_HIDE = createManaged(T_ELCL, IMG_LCL_DETAIL_PANE_HIDE); - public static final ImageDescriptor DESC_LCL_DETAIL_PANE_HIDE_DISABLED = createManaged(T_DLCL, IMG_LCL_DETAIL_PANE_HIDE); + public static final ImageDescriptor DESC_LCL_DETAIL_PANE_HIDE_DISABLED = createManaged(T_DLCL, + IMG_LCL_DETAIL_PANE_HIDE); public static final ImageDescriptor DESC_LCL_COLLAPSE_ALL = createManaged(T_ELCL, IMG_LCL_COLLAPSE_ALL); public static final ImageDescriptor DESC_LCL_COLLAPSE_ALL_DISABLED = createManaged(T_DLCL, IMG_LCL_COLLAPSE_ALL); public static final ImageDescriptor DESC_LCL_OPEN_NEW_VIEW = createManaged(T_ELCL, IMG_LCL_OPEN_NEW_VIEW); @@ -231,10 +270,10 @@ public class CDebugImages { /** * Returns the image managed under the given key in this registry. - * + * * @param key the image's key * @return the image managed under the given key - */ + */ public static Image get(String key) { return getImageRegistry().get(key); } @@ -294,7 +333,8 @@ public class CDebugImages { private static ImageDescriptor createManaged(String prefix, String name) { try { - ImageDescriptor result = ImageDescriptor.createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH))); + ImageDescriptor result = ImageDescriptor + .createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH))); if (fgAvoidSWTErrorMap == null) { fgAvoidSWTErrorMap = new HashMap<>(); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java index d3ff21df1cf..3c59d2ec333 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java @@ -108,16 +108,16 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode private static final String DUMMY_STACKFRAME_LABEL = "..."; //$NON-NLS-1$ - protected HashMap<String, Object> fAttributes = new HashMap<String, Object>( 3 ); + protected HashMap<String, Object> fAttributes = new HashMap<String, Object>(3); protected CDebugImageDescriptorRegistry fDebugImageRegistry = CDebugUIPlugin.getImageDescriptorRegistry(); private OverlayImageCache fImageCache = new OverlayImageCache(); - + private static CDebugModelPresentation gfInstance = null; public static CDebugModelPresentation getDefault() { - if ( gfInstance == null ) + if (gfInstance == null) gfInstance = new CDebugModelPresentation(); return gfInstance; } @@ -126,35 +126,35 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode * @see org.eclipse.debug.ui.IDebugModelPresentation#setAttribute(java.lang.String, java.lang.Object) */ @Override - public void setAttribute( String attribute, Object value ) { - if ( value == null ) + public void setAttribute(String attribute, Object value) { + if (value == null) return; - getAttributes().put( attribute, value ); + getAttributes().put(attribute, value); } /* (non-Javadoc) * @see org.eclipse.debug.ui.IDebugModelPresentation#computeDetail(org.eclipse.debug.core.model.IValue, org.eclipse.debug.ui.IValueDetailListener) */ @Override - public void computeDetail( IValue value, IValueDetailListener listener ) { - CValueDetailProvider.getDefault().computeDetail( value, listener ); + public void computeDetail(IValue value, IValueDetailListener listener) { + CValueDetailProvider.getDefault().computeDetail(value, listener); } /* (non-Javadoc) * @see org.eclipse.debug.ui.ISourcePresentation#getEditorInput(java.lang.Object) */ @Override - public IEditorInput getEditorInput( Object element ) { - if ( element instanceof IMarker ) { - IResource resource = ((IMarker)element).getResource(); - if ( resource instanceof IFile ) - return new FileEditorInput( (IFile)resource ); + public IEditorInput getEditorInput(Object element) { + if (element instanceof IMarker) { + IResource resource = ((IMarker) element).getResource(); + if (resource instanceof IFile) + return new FileEditorInput((IFile) resource); } - if ( element instanceof IFile ) { - return new FileEditorInput( (IFile)element ); + if (element instanceof IFile) { + return new FileEditorInput((IFile) element); } - if ( element instanceof ICBreakpoint ) { - ICBreakpoint b = (ICBreakpoint)element; + if (element instanceof ICBreakpoint) { + ICBreakpoint b = (ICBreakpoint) element; IMarker marker = b.getMarker(); if (marker == null || !marker.exists()) return null; @@ -171,47 +171,46 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode file = ResourceLookup.selectFileForLocation(path, project); if (file == null || !file.isAccessible()) { // Try resolving the path to a real io.File - File fsfile = new File( handle ); - if ( fsfile.isFile() && fsfile.exists() ) { + File fsfile = new File(handle); + if (fsfile.isFile() && fsfile.exists()) { // create an ExternalEditorInput with an external tu so when you // open the file from the breakpoints view it opens in the // proper editor. if (project != null) { ICProject cproject = CoreModel.getDefault().create(project); String id = CoreModel.getRegistedContentTypeId(project, path.lastSegment()); - ExternalTranslationUnit tu = new ExternalTranslationUnit(cproject, URIUtil.toURI(path), id); - return new ExternalEditorInput( tu ); - } - else { - return new ExternalEditorInput(path); + ExternalTranslationUnit tu = new ExternalTranslationUnit(cproject, + URIUtil.toURI(path), id); + return new ExternalEditorInput(tu); + } else { + return new ExternalEditorInput(path); } } } } - } catch(CoreException e) { + } catch (CoreException e) { CDebugCorePlugin.log(e); } } - if ( file != null ) - return new FileEditorInput( file ); + if (file != null) + return new FileEditorInput(file); // There is no file associated with this breakpoint. See if another editor is available from an adapter ISourcePresentation srcPres = Platform.getAdapterManager().getAdapter(b, ISourcePresentation.class); - if ( srcPres != null ) { + if (srcPres != null) { IEditorInput editor = srcPres.getEditorInput(b); - if ( editor != null ) { + if (editor != null) { return editor; } } } - if ( element instanceof FileStorage || element instanceof LocalFileStorage ) { - return new ExternalEditorInput( ((IStorage) element).getFullPath() ); + if (element instanceof FileStorage || element instanceof LocalFileStorage) { + return new ExternalEditorInput(((IStorage) element).getFullPath()); } - if ( element instanceof ExternalTranslationUnit ) { + if (element instanceof ExternalTranslationUnit) { ExternalTranslationUnit etu = (ExternalTranslationUnit) element; - return new ExternalEditorInput( etu ); + return new ExternalEditorInput(etu); } - if (element instanceof CSourceNotFoundElement) - { + if (element instanceof CSourceNotFoundElement) { return new CSourceNotFoundEditorInput(element); } return null; @@ -221,7 +220,7 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode * @see org.eclipse.debug.ui.ISourcePresentation#getEditorId(org.eclipse.ui.IEditorInput, java.lang.Object) */ @Override - public String getEditorId( IEditorInput input, Object element ) { + public String getEditorId(IEditorInput input, Object element) { if (element instanceof CSourceNotFoundElement) return ICDebugUIConstants.CSOURCENOTFOUND_EDITOR_ID; String id = null; @@ -243,8 +242,7 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode } if (id == null) { if (descriptor == null) { - IEditorRegistry registry = PlatformUI.getWorkbench() - .getEditorRegistry(); + IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry(); descriptor = registry.getDefaultEditor(input.getName()); } @@ -256,10 +254,11 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode if (id == null && element instanceof ICBreakpoint) { // There is no associated editor ID for this breakpoint, see if an alternative can be supplied from an adapter. - ISourcePresentation sourcePres = Platform.getAdapterManager().getAdapter(element, ISourcePresentation.class); - if ( sourcePres != null ) { + ISourcePresentation sourcePres = Platform.getAdapterManager().getAdapter(element, + ISourcePresentation.class); + if (sourcePres != null) { String lid = sourcePres.getEditorId(input, element); - if ( lid != null ) { + if (lid != null) { id = lid; } } @@ -269,278 +268,277 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode } @Override - public Image getImage( Object element ) { - Image baseImage = getBaseImage( element ); - if ( baseImage != null ) { - ImageDescriptor[] overlays = new ImageDescriptor[]{ null, null, null, null }; - if ( element instanceof ICDebugElementStatus && !((ICDebugElementStatus)element).isOK() ) { - switch( ((ICDebugElementStatus)element).getSeverity() ) { - case ICDebugElementStatus.WARNING: - overlays[OverlayImageDescriptor.BOTTOM_LEFT] = CDebugImages.DESC_OVRS_WARNING; - break; - case ICDebugElementStatus.ERROR: - overlays[OverlayImageDescriptor.BOTTOM_LEFT] = CDebugImages.DESC_OVRS_ERROR; - break; + public Image getImage(Object element) { + Image baseImage = getBaseImage(element); + if (baseImage != null) { + ImageDescriptor[] overlays = new ImageDescriptor[] { null, null, null, null }; + if (element instanceof ICDebugElementStatus && !((ICDebugElementStatus) element).isOK()) { + switch (((ICDebugElementStatus) element).getSeverity()) { + case ICDebugElementStatus.WARNING: + overlays[OverlayImageDescriptor.BOTTOM_LEFT] = CDebugImages.DESC_OVRS_WARNING; + break; + case ICDebugElementStatus.ERROR: + overlays[OverlayImageDescriptor.BOTTOM_LEFT] = CDebugImages.DESC_OVRS_ERROR; + break; } } - if ( element instanceof IWatchExpression && ((IWatchExpression)element).hasErrors() ) + if (element instanceof IWatchExpression && ((IWatchExpression) element).hasErrors()) overlays[OverlayImageDescriptor.BOTTOM_LEFT] = CDebugImages.DESC_OVRS_ERROR; - return getImageCache().getImageFor( new OverlayImageDescriptor( baseImage, overlays ) ); + return getImageCache().getImageFor(new OverlayImageDescriptor(baseImage, overlays)); } return null; } - private Image getBaseImage( Object element ) { - if ( element instanceof IMarker ) { - IBreakpoint bp = getBreakpoint( (IMarker)element ); - if ( bp != null && bp instanceof ICBreakpoint ) { - return getBreakpointImage( (ICBreakpoint)bp ); + private Image getBaseImage(Object element) { + if (element instanceof IMarker) { + IBreakpoint bp = getBreakpoint((IMarker) element); + if (bp != null && bp instanceof ICBreakpoint) { + return getBreakpointImage((ICBreakpoint) bp); } } - if ( element instanceof ICBreakpoint ) { - return getBreakpointImage( (ICBreakpoint)element ); + if (element instanceof ICBreakpoint) { + return getBreakpointImage((ICBreakpoint) element); } - if ( element instanceof IRegisterGroup ) { - return getRegisterGroupImage( (IRegisterGroup)element ); + if (element instanceof IRegisterGroup) { + return getRegisterGroupImage((IRegisterGroup) element); } - if ( element instanceof IExpression ) { - return getExpressionImage( (IExpression)element ); + if (element instanceof IExpression) { + return getExpressionImage((IExpression) element); } - if ( element instanceof ICModule ) { - return getModuleImage( (ICModule)element ); + if (element instanceof ICModule) { + return getModuleImage((ICModule) element); } - if ( element instanceof ICSignal ) { - return getSignalImage( (ICSignal)element ); + if (element instanceof ICSignal) { + return getSignalImage((ICSignal) element); } - return super.getImage( element ); + return super.getImage(element); } - protected Image getSignalImage( ICSignal signal ) { - return CDebugUIPlugin.getImageDescriptorRegistry().get( CDebugImages.DESC_OBJS_SIGNAL ); + protected Image getSignalImage(ICSignal signal) { + return CDebugUIPlugin.getImageDescriptorRegistry().get(CDebugImages.DESC_OBJS_SIGNAL); } - protected Image getRegisterGroupImage( IRegisterGroup element ) { - IEnableDisableTarget target = element.getAdapter( IEnableDisableTarget.class ); - if ( target != null && !target.isEnabled() ) - return fDebugImageRegistry.get( CDebugImages.DESC_OBJS_REGISTER_GROUP_DISABLED ); - return fDebugImageRegistry.get( CDebugImages.DESC_OBJS_REGISTER_GROUP ); + protected Image getRegisterGroupImage(IRegisterGroup element) { + IEnableDisableTarget target = element.getAdapter(IEnableDisableTarget.class); + if (target != null && !target.isEnabled()) + return fDebugImageRegistry.get(CDebugImages.DESC_OBJS_REGISTER_GROUP_DISABLED); + return fDebugImageRegistry.get(CDebugImages.DESC_OBJS_REGISTER_GROUP); } - protected Image getBreakpointImage( ICBreakpoint breakpoint ) { + protected Image getBreakpointImage(ICBreakpoint breakpoint) { // if adapter installed for breakpoint, call the adapter ILabelProvider adapter = Platform.getAdapterManager().getAdapter(breakpoint, ILabelProvider.class); - if (adapter!=null) { + if (adapter != null) { Image image = adapter.getImage(breakpoint); - if (image!=null) return image; + if (image != null) + return image; } try { // Check for ICTracepoint first because they are also ICLineBreakpoint - if ( breakpoint instanceof ICTracepoint ) { - return getTracepointImage( (ICTracepoint)breakpoint ); + if (breakpoint instanceof ICTracepoint) { + return getTracepointImage((ICTracepoint) breakpoint); } // Check for ICDynamicPrintf first because they are also ICLineBreakpoint - if ( breakpoint instanceof ICDynamicPrintf ) { - return getDynamicPrintfImage( (ICDynamicPrintf)breakpoint ); + if (breakpoint instanceof ICDynamicPrintf) { + return getDynamicPrintfImage((ICDynamicPrintf) breakpoint); } - if ( breakpoint instanceof ICLineBreakpoint ) { + if (breakpoint instanceof ICLineBreakpoint) { // checks if the breakpoint type is a hardware breakpoint, // if so, return the hardware breakpoint image - if( breakpoint instanceof ICBreakpointType) { + if (breakpoint instanceof ICBreakpointType) { ICBreakpointType breakpointType = (ICBreakpointType) breakpoint; - if( (breakpointType.getType() & ICBreakpointType.HARDWARE) != 0) - return getHWBreakpointImage( (ICLineBreakpoint) breakpoint); + if ((breakpointType.getType() & ICBreakpointType.HARDWARE) != 0) + return getHWBreakpointImage((ICLineBreakpoint) breakpoint); } - return getLineBreakpointImage( (ICLineBreakpoint)breakpoint ); + return getLineBreakpointImage((ICLineBreakpoint) breakpoint); } - if ( breakpoint instanceof ICWatchpoint ) { - return getWatchpointImage( (ICWatchpoint)breakpoint ); + if (breakpoint instanceof ICWatchpoint) { + return getWatchpointImage((ICWatchpoint) breakpoint); } - if ( breakpoint instanceof ICEventBreakpoint ) { - return getEventBreakpointImage( (ICEventBreakpoint)breakpoint ); + if (breakpoint instanceof ICEventBreakpoint) { + return getEventBreakpointImage((ICEventBreakpoint) breakpoint); } - - } - catch( CoreException e ) { + + } catch (CoreException e) { } return null; } protected Image getHWBreakpointImage(ICLineBreakpoint breakpoint) throws CoreException { ImageDescriptor descriptor = null; - if ( breakpoint.isEnabled() ) { + if (breakpoint.isEnabled()) { descriptor = CDebugImages.DESC_OBJS_HWBREAKPOINT_ENABLED; - } - else { + } else { descriptor = CDebugImages.DESC_OBJS_HWBREAKPOINT_DISABLED; } - return getImageCache().getImageFor( new OverlayImageDescriptor( fDebugImageRegistry.get( descriptor ), computeOverlays( breakpoint ) ) ); + return getImageCache().getImageFor( + new OverlayImageDescriptor(fDebugImageRegistry.get(descriptor), computeOverlays(breakpoint))); } - protected Image getDynamicPrintfImage( ICDynamicPrintf dynamicPrintf ) throws CoreException { + protected Image getDynamicPrintfImage(ICDynamicPrintf dynamicPrintf) throws CoreException { ImageDescriptor descriptor = null; - if ( dynamicPrintf.isEnabled() ) { + if (dynamicPrintf.isEnabled()) { descriptor = CDebugImages.DESC_OBJS_DYNAMICPRINTF_ENABLED; - } - else { + } else { descriptor = CDebugImages.DESC_OBJS_DYNAMICPRINTF_DISABLED; } - return getImageCache().getImageFor( new OverlayImageDescriptor( fDebugImageRegistry.get( descriptor ), computeOverlays( dynamicPrintf ) ) ); + return getImageCache().getImageFor( + new OverlayImageDescriptor(fDebugImageRegistry.get(descriptor), computeOverlays(dynamicPrintf))); } - protected Image getTracepointImage( ICTracepoint tracepoint ) throws CoreException { + protected Image getTracepointImage(ICTracepoint tracepoint) throws CoreException { ImageDescriptor descriptor = null; - if ( tracepoint.isEnabled() ) { + if (tracepoint.isEnabled()) { descriptor = CDebugImages.DESC_OBJS_TRACEPOINT_ENABLED; - } - else { + } else { descriptor = CDebugImages.DESC_OBJS_TRACEPOINT_DISABLED; } - return getImageCache().getImageFor( new OverlayImageDescriptor( fDebugImageRegistry.get( descriptor ), computeOverlays( tracepoint ) ) ); + return getImageCache().getImageFor( + new OverlayImageDescriptor(fDebugImageRegistry.get(descriptor), computeOverlays(tracepoint))); } - protected Image getLineBreakpointImage( ICLineBreakpoint breakpoint ) throws CoreException { + protected Image getLineBreakpointImage(ICLineBreakpoint breakpoint) throws CoreException { ImageDescriptor descriptor = null; - if ( breakpoint.isEnabled() ) { + if (breakpoint.isEnabled()) { descriptor = CDebugImages.DESC_OBJS_BREAKPOINT_ENABLED; - } - else { + } else { descriptor = CDebugImages.DESC_OBJS_BREAKPOINT_DISABLED; } - return getImageCache().getImageFor( new OverlayImageDescriptor( fDebugImageRegistry.get( descriptor ), computeOverlays( breakpoint ) ) ); + return getImageCache().getImageFor( + new OverlayImageDescriptor(fDebugImageRegistry.get(descriptor), computeOverlays(breakpoint))); } - protected Image getWatchpointImage( ICWatchpoint watchpoint ) throws CoreException { + protected Image getWatchpointImage(ICWatchpoint watchpoint) throws CoreException { ImageDescriptor descriptor = null; - if ( watchpoint.isEnabled() ) { - if ( watchpoint.isReadType() && !watchpoint.isWriteType() ) + if (watchpoint.isEnabled()) { + if (watchpoint.isReadType() && !watchpoint.isWriteType()) descriptor = CDebugImages.DESC_OBJS_READ_WATCHPOINT_ENABLED; - else if ( !watchpoint.isReadType() && watchpoint.isWriteType() ) + else if (!watchpoint.isReadType() && watchpoint.isWriteType()) descriptor = CDebugImages.DESC_OBJS_WRITE_WATCHPOINT_ENABLED; else descriptor = CDebugImages.DESC_OBJS_WATCHPOINT_ENABLED; - } - else { - if ( watchpoint.isReadType() && !watchpoint.isWriteType() ) + } else { + if (watchpoint.isReadType() && !watchpoint.isWriteType()) descriptor = CDebugImages.DESC_OBJS_READ_WATCHPOINT_DISABLED; - else if ( !watchpoint.isReadType() && watchpoint.isWriteType() ) + else if (!watchpoint.isReadType() && watchpoint.isWriteType()) descriptor = CDebugImages.DESC_OBJS_WRITE_WATCHPOINT_DISABLED; else descriptor = CDebugImages.DESC_OBJS_WATCHPOINT_DISABLED; } - return getImageCache().getImageFor( new OverlayImageDescriptor( fDebugImageRegistry.get( descriptor ), computeOverlays( watchpoint ) ) ); + return getImageCache().getImageFor( + new OverlayImageDescriptor(fDebugImageRegistry.get(descriptor), computeOverlays(watchpoint))); } - protected Image getEventBreakpointImage( ICEventBreakpoint evtBreakpoint ) throws CoreException { - ImageDescriptor descriptor = evtBreakpoint.isEnabled() ? CDebugImages.DESC_OBJS_EVENTBREAKPOINT_ENABLED : CDebugImages.DESC_OBJS_EVENTBREAKPOINT_DISABLED; - return getImageCache().getImageFor( new OverlayImageDescriptor( fDebugImageRegistry.get( descriptor ), computeOverlays( evtBreakpoint ) ) ); + protected Image getEventBreakpointImage(ICEventBreakpoint evtBreakpoint) throws CoreException { + ImageDescriptor descriptor = evtBreakpoint.isEnabled() ? CDebugImages.DESC_OBJS_EVENTBREAKPOINT_ENABLED + : CDebugImages.DESC_OBJS_EVENTBREAKPOINT_DISABLED; + return getImageCache().getImageFor( + new OverlayImageDescriptor(fDebugImageRegistry.get(descriptor), computeOverlays(evtBreakpoint))); } - + @Override - public String getText( Object element ) { - String bt = getBaseText( element ); - if ( bt == null ) + public String getText(Object element) { + String bt = getBaseText(element); + if (bt == null) return null; - return CDebugUIUtils.decorateText( element, bt ); + return CDebugUIUtils.decorateText(element, bt); } - private String getBaseText( Object element ) { + private String getBaseText(Object element) { boolean showQualified = isShowQualifiedNames(); StringBuilder label = new StringBuilder(); try { - if ( element instanceof ICModule ) { - label.append( getModuleText( (ICModule)element, showQualified ) ); + if (element instanceof ICModule) { + label.append(getModuleText((ICModule) element, showQualified)); return label.toString(); } - if ( element instanceof ICSignal ) { - label.append( getSignalText( (ICSignal)element ) ); + if (element instanceof ICSignal) { + label.append(getSignalText((ICSignal) element)); return label.toString(); } - if ( element instanceof IRegisterGroup ) { - label.append( ((IRegisterGroup)element).getName() ); + if (element instanceof IRegisterGroup) { + label.append(((IRegisterGroup) element).getName()); return label.toString(); } - if ( element instanceof IWatchExpression ) { - return getWatchExpressionText( (IWatchExpression)element ); + if (element instanceof IWatchExpression) { + return getWatchExpressionText((IWatchExpression) element); } - if ( element instanceof IValue ) { - label.append( getValueText( (IValue)element ) ); + if (element instanceof IValue) { + label.append(getValueText((IValue) element)); return label.toString(); } - if ( element instanceof IStackFrame ) { - label.append( getStackFrameText( (IStackFrame)element, showQualified ) ); + if (element instanceof IStackFrame) { + label.append(getStackFrameText((IStackFrame) element, showQualified)); return label.toString(); } - if ( element instanceof CSourceNotFoundElement ) { - return getBaseText(((CSourceNotFoundElement)element).getElement()); + if (element instanceof CSourceNotFoundElement) { + return getBaseText(((CSourceNotFoundElement) element).getElement()); } - if ( element instanceof IMarker ) { - IBreakpoint breakpoint = getBreakpoint( (IMarker)element ); - if ( breakpoint != null ) { - return CDebugUtils.getBreakpointText( breakpoint, showQualified ); + if (element instanceof IMarker) { + IBreakpoint breakpoint = getBreakpoint((IMarker) element); + if (breakpoint != null) { + return CDebugUtils.getBreakpointText(breakpoint, showQualified); } return null; } - if ( element instanceof IBreakpoint ) { + if (element instanceof IBreakpoint) { // if adapter installed for breakpoint, call adapter ILabelProvider adapter = Platform.getAdapterManager().getAdapter(element, ILabelProvider.class); - if (adapter!=null) { + if (adapter != null) { String text = adapter.getText(element); - if (text!=null) return text; + if (text != null) + return text; } - return CDebugUtils.getBreakpointText( (IBreakpoint)element, showQualified ); + return CDebugUtils.getBreakpointText((IBreakpoint) element, showQualified); } - if ( element instanceof IDebugTarget ) - label.append( getTargetText( (IDebugTarget)element, showQualified ) ); - if ( element instanceof ITerminate ) { - if ( ((ITerminate)element).isTerminated() ) { - label.insert( 0, CDebugUIMessages.getString( "CDTDebugModelPresentation.0" ) ); //$NON-NLS-1$ + if (element instanceof IDebugTarget) + label.append(getTargetText((IDebugTarget) element, showQualified)); + if (element instanceof ITerminate) { + if (((ITerminate) element).isTerminated()) { + label.insert(0, CDebugUIMessages.getString("CDTDebugModelPresentation.0")); //$NON-NLS-1$ return label.toString(); } } - if ( element instanceof IDisconnect ) { - if ( ((IDisconnect)element).isDisconnected() ) { - label.insert( 0, CDebugUIMessages.getString( "CDTDebugModelPresentation.1" ) ); //$NON-NLS-1$ + if (element instanceof IDisconnect) { + if (((IDisconnect) element).isDisconnected()) { + label.insert(0, CDebugUIMessages.getString("CDTDebugModelPresentation.1")); //$NON-NLS-1$ return label.toString(); } } - if ( label.length() > 0 ) { + if (label.length() > 0) { return label.toString(); } - } - catch( DebugException e ) { - return MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.2" ), e.getMessage() ); //$NON-NLS-1$ - } - catch( CoreException e ) { - CDebugUIPlugin.log( e ); + } catch (DebugException e) { + return MessageFormat.format(CDebugUIMessages.getString("CDTDebugModelPresentation.2"), e.getMessage()); //$NON-NLS-1$ + } catch (CoreException e) { + CDebugUIPlugin.log(e); } return null; } - protected String getModuleText( ICModule module, boolean qualified ) { + protected String getModuleText(ICModule module, boolean qualified) { StringBuilder sb = new StringBuilder(); IPath path = module.getImageName(); - if ( !path.isEmpty() ) { - sb.append( path.lastSegment() ); - } - else { - sb.append( CDebugUIMessages.getString( "CDebugModelPresentation.unknown_1" ) ); //$NON-NLS-1$ + if (!path.isEmpty()) { + sb.append(path.lastSegment()); + } else { + sb.append(CDebugUIMessages.getString("CDebugModelPresentation.unknown_1")); //$NON-NLS-1$ } return sb.toString(); } - protected String getRegisterGroupText( IRegisterGroup group ) { - String name = CDebugUIMessages.getString( "CDebugModelPresentation.not_available_1" ); //$NON-NLS-1$ + protected String getRegisterGroupText(IRegisterGroup group) { + String name = CDebugUIMessages.getString("CDebugModelPresentation.not_available_1"); //$NON-NLS-1$ try { name = group.getName(); - } - catch( DebugException e ) { - CDebugUIPlugin.log( e.getStatus() ); + } catch (DebugException e) { + CDebugUIPlugin.log(e.getStatus()); } return name; } protected boolean isShowQualifiedNames() { - Boolean showQualified = (Boolean)getAttributes().get( DISPLAY_FULL_PATHS ); + Boolean showQualified = (Boolean) getAttributes().get(DISPLAY_FULL_PATHS); showQualified = showQualified == null ? Boolean.FALSE : showQualified; return showQualified.booleanValue(); } @@ -553,170 +551,176 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode return this.fImageCache; } - private boolean isEmpty( String string ) { - return ( string == null || string.trim().length() == 0 ); + private boolean isEmpty(String string) { + return (string == null || string.trim().length() == 0); } - protected IBreakpoint getBreakpoint( IMarker marker ) { - return DebugPlugin.getDefault().getBreakpointManager().getBreakpoint( marker ); + protected IBreakpoint getBreakpoint(IMarker marker) { + return DebugPlugin.getDefault().getBreakpointManager().getBreakpoint(marker); } - private ImageDescriptor[] computeOverlays( ICBreakpoint breakpoint ) { - ImageDescriptor[] overlays = new ImageDescriptor[]{ null, null, null, null }; + private ImageDescriptor[] computeOverlays(ICBreakpoint breakpoint) { + ImageDescriptor[] overlays = new ImageDescriptor[] { null, null, null, null }; try { - if ( CDebugCorePlugin.getDefault().getBreakpointActionManager().breakpointHasActions(breakpoint) ) { - overlays[OverlayImageDescriptor.BOTTOM_RIGHT] = (breakpoint.isEnabled()) ? CDebugImages.DESC_OVRS_BREAKPOINT_WITH_ACTIONS : CDebugImages.DESC_OVRS_BREAKPOINT_WITH_ACTIONS_DISABLED; - } - if ( breakpoint.isConditional() ) { - overlays[OverlayImageDescriptor.TOP_LEFT] = (breakpoint.isEnabled()) ? CDebugImages.DESC_OVRS_BREAKPOINT_CONDITIONAL : CDebugImages.DESC_OVRS_BREAKPOINT_CONDITIONAL_DISABLED; - } - if ( breakpoint.isInstalled() ) { - overlays[OverlayImageDescriptor.BOTTOM_LEFT] = (breakpoint.isEnabled()) ? CDebugImages.DESC_OVRS_BREAKPOINT_INSTALLED : CDebugImages.DESC_OVRS_BREAKPOINT_INSTALLED_DISABLED; - } - if ( breakpoint instanceof ICAddressBreakpoint ) { - overlays[OverlayImageDescriptor.TOP_RIGHT] = (breakpoint.isEnabled()) ? CDebugImages.DESC_OVRS_ADDRESS_BREAKPOINT : CDebugImages.DESC_OVRS_ADDRESS_BREAKPOINT_DISABLED; - } - if ( breakpoint instanceof ICFunctionBreakpoint ) { - overlays[OverlayImageDescriptor.TOP_RIGHT] = (breakpoint.isEnabled()) ? CDebugImages.DESC_OVRS_FUNCTION_BREAKPOINT : CDebugImages.DESC_OVRS_FUNCTION_BREAKPOINT_DISABLED; - } - } - catch( CoreException e ) { - CDebugUIPlugin.log( e ); + if (CDebugCorePlugin.getDefault().getBreakpointActionManager().breakpointHasActions(breakpoint)) { + overlays[OverlayImageDescriptor.BOTTOM_RIGHT] = (breakpoint.isEnabled()) + ? CDebugImages.DESC_OVRS_BREAKPOINT_WITH_ACTIONS + : CDebugImages.DESC_OVRS_BREAKPOINT_WITH_ACTIONS_DISABLED; + } + if (breakpoint.isConditional()) { + overlays[OverlayImageDescriptor.TOP_LEFT] = (breakpoint.isEnabled()) + ? CDebugImages.DESC_OVRS_BREAKPOINT_CONDITIONAL + : CDebugImages.DESC_OVRS_BREAKPOINT_CONDITIONAL_DISABLED; + } + if (breakpoint.isInstalled()) { + overlays[OverlayImageDescriptor.BOTTOM_LEFT] = (breakpoint.isEnabled()) + ? CDebugImages.DESC_OVRS_BREAKPOINT_INSTALLED + : CDebugImages.DESC_OVRS_BREAKPOINT_INSTALLED_DISABLED; + } + if (breakpoint instanceof ICAddressBreakpoint) { + overlays[OverlayImageDescriptor.TOP_RIGHT] = (breakpoint.isEnabled()) + ? CDebugImages.DESC_OVRS_ADDRESS_BREAKPOINT + : CDebugImages.DESC_OVRS_ADDRESS_BREAKPOINT_DISABLED; + } + if (breakpoint instanceof ICFunctionBreakpoint) { + overlays[OverlayImageDescriptor.TOP_RIGHT] = (breakpoint.isEnabled()) + ? CDebugImages.DESC_OVRS_FUNCTION_BREAKPOINT + : CDebugImages.DESC_OVRS_FUNCTION_BREAKPOINT_DISABLED; + } + } catch (CoreException e) { + CDebugUIPlugin.log(e); } return overlays; } - protected Image getExpressionImage( IExpression element ) { - return fDebugImageRegistry.get( DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_EXPRESSION ) ); + protected Image getExpressionImage(IExpression element) { + return fDebugImageRegistry.get(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_EXPRESSION)); } - protected Image getModuleImage( ICModule element ) { - switch( element.getType() ) { - case ICModule.EXECUTABLE: - if ( element.areSymbolsLoaded() ) { - return CDebugUIPlugin.getImageDescriptorRegistry().get( CDebugImages.DESC_OBJS_EXECUTABLE_WITH_SYMBOLS ); - } - return CDebugUIPlugin.getImageDescriptorRegistry().get( CDebugImages.DESC_OBJS_EXECUTABLE ); - case ICModule.SHARED_LIBRARY: - if ( element.areSymbolsLoaded() ) { - return CDebugUIPlugin.getImageDescriptorRegistry().get( CDebugImages.DESC_OBJS_SHARED_LIBRARY_WITH_SYMBOLS ); - } - return CDebugUIPlugin.getImageDescriptorRegistry().get( CDebugImages.DESC_OBJS_SHARED_LIBRARY ); + protected Image getModuleImage(ICModule element) { + switch (element.getType()) { + case ICModule.EXECUTABLE: + if (element.areSymbolsLoaded()) { + return CDebugUIPlugin.getImageDescriptorRegistry().get(CDebugImages.DESC_OBJS_EXECUTABLE_WITH_SYMBOLS); + } + return CDebugUIPlugin.getImageDescriptorRegistry().get(CDebugImages.DESC_OBJS_EXECUTABLE); + case ICModule.SHARED_LIBRARY: + if (element.areSymbolsLoaded()) { + return CDebugUIPlugin.getImageDescriptorRegistry() + .get(CDebugImages.DESC_OBJS_SHARED_LIBRARY_WITH_SYMBOLS); + } + return CDebugUIPlugin.getImageDescriptorRegistry().get(CDebugImages.DESC_OBJS_SHARED_LIBRARY); } return null; } - protected String getValueText( IValue value ) { - return CDebugUIUtils.getValueText( value ); + protected String getValueText(IValue value) { + return CDebugUIUtils.getValueText(value); } - protected String getSignalText( ICSignal signal ) { - StringBuilder sb = new StringBuilder( CDebugUIMessages.getString( "CDTDebugModelPresentation.12" ) ); //$NON-NLS-1$ + protected String getSignalText(ICSignal signal) { + StringBuilder sb = new StringBuilder(CDebugUIMessages.getString("CDTDebugModelPresentation.12")); //$NON-NLS-1$ try { String name = signal.getName(); - sb.append( " \'" ).append( name ).append( '\'' ); //$NON-NLS-1$ - } - catch( DebugException e ) { + sb.append(" \'").append(name).append('\''); //$NON-NLS-1$ + } catch (DebugException e) { } return sb.toString(); } - protected String getWatchExpressionText( IWatchExpression expression ) { + protected String getWatchExpressionText(IWatchExpression expression) { StringBuilder result = new StringBuilder(); - result.append( '"' ).append( expression.getExpressionText() ).append( '"' ); - if ( expression.isPending() ) { - result.append( " = " ).append( "..." ); //$NON-NLS-1$//$NON-NLS-2$ - } - else { + result.append('"').append(expression.getExpressionText()).append('"'); + if (expression.isPending()) { + result.append(" = ").append("..."); //$NON-NLS-1$//$NON-NLS-2$ + } else { IValue value = expression.getValue(); - if ( value instanceof ICValue ) { + if (value instanceof ICValue) { ICType type = null; try { - type = ((ICValue)value).getType(); - } - catch( DebugException e1 ) { + type = ((ICValue) value).getType(); + } catch (DebugException e1) { } - if ( type != null && isShowVariableTypeNames() ) { - String typeName = CDebugUIUtils.getVariableTypeName( type ); - if ( !isEmpty( typeName ) ) { - result.insert( 0, typeName + ' ' ); + if (type != null && isShowVariableTypeNames()) { + String typeName = CDebugUIUtils.getVariableTypeName(type); + if (!isEmpty(typeName)) { + result.insert(0, typeName + ' '); } } - if ( expression.isEnabled() ) { - String valueString = getValueText( value ); - if ( valueString.length() > 0 ) { - result.append( " = " ).append( valueString ); //$NON-NLS-1$ + if (expression.isEnabled()) { + String valueString = getValueText(value); + if (valueString.length() > 0) { + result.append(" = ").append(valueString); //$NON-NLS-1$ } } } } - if ( !expression.isEnabled() ) { - result.append( ' ' ); - result.append( CDebugUIMessages.getString( "CDTDebugModelPresentation.22" ) ); //$NON-NLS-1$ + if (!expression.isEnabled()) { + result.append(' '); + result.append(CDebugUIMessages.getString("CDTDebugModelPresentation.22")); //$NON-NLS-1$ } return result.toString(); } - protected String getTargetText( IDebugTarget target, boolean qualified ) throws DebugException { + protected String getTargetText(IDebugTarget target, boolean qualified) throws DebugException { return target.getName(); } - protected String getStackFrameText( IStackFrame f, boolean qualified ) throws DebugException { - if ( f instanceof ICStackFrame ) { - ICStackFrame frame = (ICStackFrame)f; + protected String getStackFrameText(IStackFrame f, boolean qualified) throws DebugException { + if (f instanceof ICStackFrame) { + ICStackFrame frame = (ICStackFrame) f; StringBuilder label = new StringBuilder(); - label.append( frame.getLevel() ); - label.append( ' ' ); + label.append(frame.getLevel()); + label.append(' '); String function = frame.getFunction(); - if ( isEmpty( function ) ) { - label.append( CDebugUIMessages.getString( "CDTDebugModelPresentation.21" ) ); //$NON-NLS-1$ - } - else { + if (isEmpty(function)) { + label.append(CDebugUIMessages.getString("CDTDebugModelPresentation.21")); //$NON-NLS-1$ + } else { function = function.trim(); - label.append( function ); - label.append( "() " ); //$NON-NLS-1$ - if ( frame.getFile() != null ) { - IPath path = new Path( frame.getFile() ); - if ( !path.isEmpty() ) { - label.append( (qualified ? path.toOSString() : path.lastSegment()) ); - label.append( ':' ); - if ( frame.getFrameLineNumber() != 0 ) - label.append( frame.getFrameLineNumber() ); + label.append(function); + label.append("() "); //$NON-NLS-1$ + if (frame.getFile() != null) { + IPath path = new Path(frame.getFile()); + if (!path.isEmpty()) { + label.append((qualified ? path.toOSString() : path.lastSegment())); + label.append(':'); + if (frame.getFrameLineNumber() != 0) + label.append(frame.getFrameLineNumber()); } } } IAddress address = frame.getAddress(); - if ( address != null ) { - label.append( ' ' ); - label.append( address.toHexAddressString() ); + if (address != null) { + label.append(' '); + label.append(address.toHexAddressString()); } return label.toString(); } - return (f.getAdapter( IDummyStackFrame.class ) != null) ? getDummyStackFrameLabel( f ) : f.getName(); + return (f.getAdapter(IDummyStackFrame.class) != null) ? getDummyStackFrameLabel(f) : f.getName(); } - private String getDummyStackFrameLabel( IStackFrame stackFrame ) { + private String getDummyStackFrameLabel(IStackFrame stackFrame) { return DUMMY_STACKFRAME_LABEL; } protected boolean isShowVariableTypeNames() { - Boolean show = (Boolean)fAttributes.get( DISPLAY_VARIABLE_TYPE_NAMES ); + Boolean show = (Boolean) fAttributes.get(DISPLAY_VARIABLE_TYPE_NAMES); show = show == null ? Boolean.FALSE : show; return show.booleanValue(); } - public static String getFormattedString( String key, String arg ) { - return getFormattedString( key, new String[]{ arg } ); + public static String getFormattedString(String key, String arg) { + return getFormattedString(key, new String[] { arg }); } - public static String getFormattedString( String string, String[] args ) { - return MessageFormat.format( string, (Object[]) args ); + public static String getFormattedString(String string, String[] args) { + return MessageFormat.format(string, (Object[]) args); } @Override public Color getForeground(Object element) { IColorProvider colorProv = Platform.getAdapterManager().getAdapter(element, IColorProvider.class); - if ( colorProv != null ) { + if (colorProv != null) { return colorProv.getForeground(element); } return null; @@ -725,7 +729,7 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode @Override public Color getBackground(Object element) { IColorProvider colorProv = Platform.getAdapterManager().getAdapter(element, IColorProvider.class); - if ( colorProv != null ) { + if (colorProv != null) { return colorProv.getBackground(element); } return null; diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIMessages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIMessages.java index 711849e6814..e8ad9555b5f 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIMessages.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIMessages.java @@ -20,16 +20,15 @@ public class CDebugUIMessages { private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.CDebugUIMessages"; //$NON-NLS-1$ - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); private CDebugUIMessages() { } - public static String getString( String key ) { + public static String getString(String key) { try { - return RESOURCE_BUNDLE.getString( key ); - } - catch( MissingResourceException e ) { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { return '!' + key + '!'; } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIPreferenceInitializer.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIPreferenceInitializer.java index 99595d94a6f..42971ed3fa9 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIPreferenceInitializer.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIPreferenceInitializer.java @@ -11,7 +11,7 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui; +package org.eclipse.cdt.debug.internal.ui; import org.eclipse.cdt.debug.internal.ui.preferences.CDebugPreferencePage; import org.eclipse.cdt.debug.internal.ui.preferences.ICDebugPreferenceConstants; @@ -24,20 +24,20 @@ import org.eclipse.jface.preference.IPreferenceStore; */ public class CDebugUIPreferenceInitializer extends AbstractPreferenceInitializer { - /** - * Constructor for CDebugUIPreferenceInitializer. + /** + * Constructor for CDebugUIPreferenceInitializer. */ public CDebugUIPreferenceInitializer() { super(); } @Override - public void initializeDefaultPreferences() { + public void initializeDefaultPreferences() { IPreferenceStore pstore = CDebugUIPlugin.getDefault().getPreferenceStore(); - CDebugPreferencePage.initDefaults( pstore ); - pstore.setDefault( ICDebugPreferenceConstants.PREF_DISASM_OPEN_NO_SOURCE_INFO, true ); - pstore.setDefault( ICDebugPreferenceConstants.PREF_DISASM_OPEN_SOURCE_NOT_FOUND, false ); - pstore.setDefault( ICDebugPreferenceConstants.PREF_DISASM_SHOW_INSTRUCTIONS, true ); - pstore.setDefault( ICDebugPreferenceConstants.PREF_DISASM_SHOW_SOURCE, true ); + CDebugPreferencePage.initDefaults(pstore); + pstore.setDefault(ICDebugPreferenceConstants.PREF_DISASM_OPEN_NO_SOURCE_INFO, true); + pstore.setDefault(ICDebugPreferenceConstants.PREF_DISASM_OPEN_SOURCE_NOT_FOUND, false); + pstore.setDefault(ICDebugPreferenceConstants.PREF_DISASM_SHOW_INSTRUCTIONS, true); + pstore.setDefault(ICDebugPreferenceConstants.PREF_DISASM_SHOW_SOURCE, true); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIUtils.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIUtils.java index ccfbb20130d..4952956f273 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIUtils.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIUtils.java @@ -90,113 +90,109 @@ import com.ibm.icu.text.MessageFormat; */ public class CDebugUIUtils { - static public IRegion findWord( IDocument document, int offset ) { + static public IRegion findWord(IDocument document, int offset) { int start = -1; int end = -1; try { int pos = offset; char c; - while( pos >= 0 ) { - c = document.getChar( pos ); - if ( !Character.isJavaIdentifierPart( c ) ) + while (pos >= 0) { + c = document.getChar(pos); + if (!Character.isJavaIdentifierPart(c)) break; --pos; } start = pos; pos = offset; int length = document.getLength(); - while( pos < length ) { - c = document.getChar( pos ); - if ( !Character.isJavaIdentifierPart( c ) ) + while (pos < length) { + c = document.getChar(pos); + if (!Character.isJavaIdentifierPart(c)) break; ++pos; } end = pos; + } catch (BadLocationException x) { } - 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 ); + 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 new Region(start + 1, end - start - 1); } return null; } /** - * Returns the currently selected stack frame or the topmost frame - * in the currently selected thread in the Debug view - * of the current workbench page. Returns <code>null</code> + * Returns the currently selected stack frame or the topmost frame + * in the currently selected thread in the Debug view + * of the current workbench page. Returns <code>null</code> * if no stack frame or thread is selected, or if not called from the UI thread. - * - * @return the currently selected stack frame or the topmost frame + * + * @return the currently selected stack frame or the topmost frame * in the currently selected thread */ static public ICStackFrame getCurrentStackFrame() { IAdaptable context = DebugUITools.getDebugContext(); - return ( context != null ) ? (ICStackFrame)context.getAdapter( ICStackFrame.class ) : null; + return (context != null) ? (ICStackFrame) context.getAdapter(ICStackFrame.class) : null; } /** * Moved from CDebugModelPresentation because it is also used by CVariableLabelProvider. */ - static public String getValueText( IValue value ) { + static public String getValueText(IValue value) { StringBuilder label = new StringBuilder(); - if ( value instanceof ICDebugElementStatus && !((ICDebugElementStatus)value).isOK() ) { - label.append( MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.4" ), (Object[]) new String[] { ((ICDebugElementStatus)value).getMessage() } ) ); //$NON-NLS-1$ - } - else if ( value instanceof ICValue ) { + if (value instanceof ICDebugElementStatus && !((ICDebugElementStatus) value).isOK()) { + label.append(MessageFormat.format(CDebugUIMessages.getString("CDTDebugModelPresentation.4"), //$NON-NLS-1$ + (Object[]) new String[] { ((ICDebugElementStatus) value).getMessage() })); + } else if (value instanceof ICValue) { ICType type = null; try { - type = ((ICValue)value).getType(); - } - catch( DebugException e ) { + type = ((ICValue) value).getType(); + } catch (DebugException e) { } try { String valueString = value.getValueString(); - if ( valueString != null ) { + if (valueString != null) { valueString = valueString.trim(); - if ( type != null && type.isCharacter() ) { - if ( valueString.length() == 0 ) + if (type != null && type.isCharacter()) { + if (valueString.length() == 0) valueString = "."; //$NON-NLS-1$ - label.append( valueString ); - } - else if ( valueString.length() > 0 ) { - label.append( valueString ); + label.append(valueString); + } else if (valueString.length() > 0) { + label.append(valueString); } } + } catch (DebugException e1) { } - catch( DebugException e1 ) { - } - } + } return label.toString(); } /** * Moved from CDebugModelPresentation because it is also used by CVariableLabelProvider. */ - public static String getVariableTypeName( ICType type ) { + public static String getVariableTypeName(ICType type) { StringBuilder result = new StringBuilder(); - if ( type != null ) { + if (type != null) { String typeName = type.getName(); - if ( typeName != null ) + if (typeName != null) typeName = typeName.trim(); - if ( type.isArray() && typeName != null ) { - int index = typeName.indexOf( '[' ); - if ( index != -1 ) - typeName = typeName.substring( 0, index ).trim(); + if (type.isArray() && typeName != null) { + int index = typeName.indexOf('['); + if (index != -1) + typeName = typeName.substring(0, index).trim(); } - if ( typeName != null && typeName.length() > 0 ) { - result.append( typeName ); - if ( type.isArray() ) { + if (typeName != null && typeName.length() > 0) { + result.append(typeName); + if (type.isArray()) { int[] dims = type.getArrayDimensions(); - for( int i = 0; i < dims.length; ++i ) { - result.append( '[' ); - result.append( dims[i] ); - result.append( ']' ); + for (int i = 0; i < dims.length; ++i) { + result.append('['); + result.append(dims[i]); + result.append(']'); } } } @@ -204,17 +200,17 @@ public class CDebugUIUtils { return result.toString(); } - public static String getVariableName( IVariable variable ) throws DebugException { - return decorateText( variable, variable.getName() ); + public static String getVariableName(IVariable variable) throws DebugException { + return decorateText(variable, variable.getName()); } - public static String getEditorFilePath( IEditorInput input ) throws CoreException { - if ( input instanceof IFileEditorInput ) { - IPath location = ((IFileEditorInput)input).getFile().getLocation(); + public static String getEditorFilePath(IEditorInput input) throws CoreException { + if (input instanceof IFileEditorInput) { + IPath location = ((IFileEditorInput) input).getFile().getLocation(); if (location != null) { return location.toOSString(); } - URI locationURI = ((IFileEditorInput)input).getFile().getLocationURI(); + URI locationURI = ((IFileEditorInput) input).getFile().getLocationURI(); if (locationURI != null) { IPath uriPath = URIUtil.toPath(locationURI); if (uriPath != null) { @@ -223,34 +219,34 @@ public class CDebugUIUtils { } return ""; //$NON-NLS-1$ } - if ( input instanceof IStorageEditorInput ) { - return ((IStorageEditorInput)input).getStorage().getFullPath().toOSString(); + if (input instanceof IStorageEditorInput) { + return ((IStorageEditorInput) input).getStorage().getFullPath().toOSString(); } - if ( input instanceof IPathEditorInput ) { - return ((IPathEditorInput)input).getPath().toOSString(); + if (input instanceof IPathEditorInput) { + return ((IPathEditorInput) input).getPath().toOSString(); } - if ( input instanceof IURIEditorInput) - { - IPath uriPath = URIUtil.toPath(((IURIEditorInput)input).getURI()); + if (input instanceof IURIEditorInput) { + IPath uriPath = URIUtil.toPath(((IURIEditorInput) input).getURI()); if (uriPath != null) return uriPath.toOSString(); } return ""; //$NON-NLS-1$ } - public static String decorateText( Object element, String text ) { - if ( text == null ) + public static String decorateText(Object element, String text) { + if (text == null) return null; - StringBuilder baseText = new StringBuilder( text ); - if ( element instanceof ICDebugElementStatus && !((ICDebugElementStatus)element).isOK() ) { - baseText.append( MessageFormat.format( " <{0}>", new Object[] { ((ICDebugElementStatus)element).getMessage() } ) ); //$NON-NLS-1$ + StringBuilder baseText = new StringBuilder(text); + if (element instanceof ICDebugElementStatus && !((ICDebugElementStatus) element).isOK()) { + baseText.append( + MessageFormat.format(" <{0}>", new Object[] { ((ICDebugElementStatus) element).getMessage() })); //$NON-NLS-1$ } - if ( element instanceof IAdaptable ) { - IEnableDisableTarget target = ((IAdaptable)element).getAdapter( IEnableDisableTarget.class ); - if ( target != null ) { - if ( !target.isEnabled() ) { - baseText.append( ' ' ); - baseText.append( CDebugUIMessages.getString( "CDTDebugModelPresentation.25" ) ); //$NON-NLS-1$ + if (element instanceof IAdaptable) { + IEnableDisableTarget target = ((IAdaptable) element).getAdapter(IEnableDisableTarget.class); + if (target != null) { + if (!target.isEnabled()) { + baseText.append(' '); + baseText.append(CDebugUIMessages.getString("CDTDebugModelPresentation.25")); //$NON-NLS-1$ } } } @@ -263,9 +259,8 @@ public class CDebugUIUtils { * @param message * @param e */ - static public void openError (final String title, final String message, final Exception e) - { - UIJob uiJob = new UIJob("open error"){ //$NON-NLS-1$ + static public void openError(final String title, final String message, final Exception e) { + UIJob uiJob = new UIJob("open error") { //$NON-NLS-1$ @Override public IStatus runInUIThread(IProgressMonitor monitor) { @@ -276,96 +271,111 @@ public class CDebugUIUtils { Shell shell = CDebugUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(); - MessageDialog.openError( - shell, - title, - message + "\n" + detail); //$NON-NLS-1$ + MessageDialog.openError(shell, title, message + "\n" + detail); //$NON-NLS-1$ return Status.OK_STATUS; - }}; - uiJob.setSystem(true); - uiJob.schedule(); + } + }; + uiJob.setSystem(true); + uiJob.schedule(); + } + + /** + * Resolves the {@link IBreakpoint} from the given editor and ruler information. Returns <code>null</code> + * if no breakpoint exists or the operation fails. + * + * @param editor the editor + * @param info the current ruler information + * @return the {@link IBreakpoint} from the current editor position or <code>null</code> + */ + public static IBreakpoint getBreakpointFromEditor(ITextEditor editor, IVerticalRulerInfo info) { + IAnnotationModel annotationModel = editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput()); + IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput()); + if (annotationModel != null) { + Iterator<Annotation> iterator = annotationModel.getAnnotationIterator(); + while (iterator.hasNext()) { + Object object = iterator.next(); + if (object instanceof SimpleMarkerAnnotation) { + SimpleMarkerAnnotation markerAnnotation = (SimpleMarkerAnnotation) object; + IMarker marker = markerAnnotation.getMarker(); + try { + if (marker.isSubtypeOf(IBreakpoint.BREAKPOINT_MARKER)) { + Position position = annotationModel.getPosition(markerAnnotation); + int line = document.getLineOfOffset(position.getOffset()); + if (line == info.getLineOfLastMouseButtonActivity()) { + IBreakpoint breakpoint = DebugPlugin.getDefault().getBreakpointManager() + .getBreakpoint(marker); + if (breakpoint != null) { + return breakpoint; + } + } + } + } catch (CoreException e) { + } catch (BadLocationException e) { + } + } + } + } + return null; + } + + public static void editBreakpointProperties(IWorkbenchPart part, final ICBreakpoint bp) { + final ISelection debugContext = DebugUITools.getDebugContextForPart(part); + CBreakpointPropertyDialogAction propertiesAction = new CBreakpointPropertyDialogAction(part.getSite(), + new ISelectionProvider() { + @Override + public ISelection getSelection() { + return new StructuredSelection(bp); + } + + @Override + public void addSelectionChangedListener(ISelectionChangedListener listener) { + } + + @Override + public void removeSelectionChangedListener(ISelectionChangedListener listener) { + } + + @Override + public void setSelection(ISelection selection) { + } + }, new IDebugContextProvider() { + @Override + public ISelection getActiveContext() { + return debugContext; + } + + @Override + public void addDebugContextListener(IDebugContextListener listener) { + } + + @Override + public void removeDebugContextListener(IDebugContextListener listener) { + } + + @Override + public IWorkbenchPart getPart() { + return null; + } + + }); + propertiesAction.run(); + propertiesAction.dispose(); + } + + /** + * Formats the given key stroke or click name and the modifier keys + * to a key binding string that can be used in action texts. + * + * @param modifierKeys the modifier keys + * @param keyOrClick a key stroke or click, e.g. "Double Click" + * @return the formatted keyboard shortcut string, e.g. "Shift+Double Click" + * + * @since 8.1 + */ + public static final String formatKeyBindingString(int modifierKeys, String keyOrClick) { + // this should actually all be delegated to KeyStroke class + return KeyStroke.getInstance(modifierKeys, KeyStroke.NO_KEY).format() + keyOrClick; } - - /** - * Resolves the {@link IBreakpoint} from the given editor and ruler information. Returns <code>null</code> - * if no breakpoint exists or the operation fails. - * - * @param editor the editor - * @param info the current ruler information - * @return the {@link IBreakpoint} from the current editor position or <code>null</code> - */ - public static IBreakpoint getBreakpointFromEditor(ITextEditor editor, IVerticalRulerInfo info) { - IAnnotationModel annotationModel = editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput()); - IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput()); - if (annotationModel != null) { - Iterator<Annotation> iterator = annotationModel.getAnnotationIterator(); - while (iterator.hasNext()) { - Object object = iterator.next(); - if (object instanceof SimpleMarkerAnnotation) { - SimpleMarkerAnnotation markerAnnotation = (SimpleMarkerAnnotation) object; - IMarker marker = markerAnnotation.getMarker(); - try { - if (marker.isSubtypeOf(IBreakpoint.BREAKPOINT_MARKER)) { - Position position = annotationModel.getPosition(markerAnnotation); - int line = document.getLineOfOffset(position.getOffset()); - if (line == info.getLineOfLastMouseButtonActivity()) { - IBreakpoint breakpoint = DebugPlugin.getDefault().getBreakpointManager().getBreakpoint(marker); - if (breakpoint != null) { - return breakpoint; - } - } - } - } catch (CoreException e) { - } catch (BadLocationException e) { - } - } - } - } - return null; - } - - public static void editBreakpointProperties(IWorkbenchPart part, final ICBreakpoint bp) { - final ISelection debugContext = DebugUITools.getDebugContextForPart(part); - CBreakpointPropertyDialogAction propertiesAction = new CBreakpointPropertyDialogAction( - part.getSite(), - new ISelectionProvider() { - @Override - public ISelection getSelection() { - return new StructuredSelection( bp ); - } - @Override public void addSelectionChangedListener( ISelectionChangedListener listener ) {} - @Override public void removeSelectionChangedListener( ISelectionChangedListener listener ) {} - @Override public void setSelection( ISelection selection ) {} - }, - new IDebugContextProvider() { - @Override - public ISelection getActiveContext() { - return debugContext; - } - @Override public void addDebugContextListener(IDebugContextListener listener) {} - @Override public void removeDebugContextListener(IDebugContextListener listener) {} - @Override public IWorkbenchPart getPart() { return null; } - - } - ); - propertiesAction.run(); - propertiesAction.dispose(); - } - - /** - * Formats the given key stroke or click name and the modifier keys - * to a key binding string that can be used in action texts. - * - * @param modifierKeys the modifier keys - * @param keyOrClick a key stroke or click, e.g. "Double Click" - * @return the formatted keyboard shortcut string, e.g. "Shift+Double Click" - * - * @since 8.1 - */ - public static final String formatKeyBindingString(int modifierKeys, String keyOrClick) { - // this should actually all be delegated to KeyStroke class - return KeyStroke.getInstance(modifierKeys, KeyStroke.NO_KEY).format() + keyOrClick; - } /** * Returns an editor id appropriate for opening the given file @@ -388,8 +398,8 @@ public class CDebugUIUtils { * default text editor is available.</li> * </ol> * </p> - * - * @param fileStore + * + * @param fileStore * the file store * @return the id of an editor, appropriate for opening the file * @throws PartInitException @@ -425,14 +435,15 @@ public class CDebugUIUtils { IEditorRegistry editorReg = PlatformUI.getWorkbench().getEditorRegistry(); IEditorDescriptor defaultEditor = editorReg.getDefaultEditor(name, contentType); - defaultEditor = IDE.overrideDefaultEditorAssociation(new FileStoreEditorInput(fileStore), contentType, defaultEditor); + defaultEditor = IDE.overrideDefaultEditorAssociation(new FileStoreEditorInput(fileStore), contentType, + defaultEditor); return getEditorDescriptor(name, editorReg, defaultEditor, allowInteractive).getId(); } /** * Get the editor descriptor for a given name using the editorDescriptor * passed in as a default as a starting point. - * + * * @param name * The name of the element to open. * @param editorReg @@ -442,15 +453,14 @@ public class CDebugUIUtils { * @return IEditorDescriptor * @throws PartInitException * if no valid editor can be found - * + * * @todo The IDE class has this method as a private, copied here so that it can be * exposed via getEditorId. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=516470 * @deprecated Deprecated on creation as this is waiting for Bug 516470 to be resolved */ @Deprecated - private static IEditorDescriptor getEditorDescriptor(String name, - IEditorRegistry editorReg, IEditorDescriptor defaultDescriptor, boolean allowInteractive) - throws PartInitException { + private static IEditorDescriptor getEditorDescriptor(String name, IEditorRegistry editorReg, + IEditorDescriptor defaultDescriptor, boolean allowInteractive) throws PartInitException { if (defaultDescriptor != null) { return defaultDescriptor; @@ -466,8 +476,7 @@ public class CDebugUIUtils { // if no valid editor found, bail out if (editorDesc == null) { - throw new PartInitException( - IDEWorkbenchMessages.IDE_noFileEditorFound); + throw new PartInitException(IDEWorkbenchMessages.IDE_noFileEditorFound); } return editorDesc; @@ -479,7 +488,7 @@ public class CDebugUIUtils { * @return The strategy to use in order to open unknown file. Either as set * by preference, or a {@link SystemEditorOrTextEditorStrategy} if * none is explicitly configured. Never returns {@code null}. - * + * * @todo The IDE class has this method as a private, copied here so that it can be * exposed via getEditorId. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=516470 * @deprecated Deprecated on creation as this is waiting for Bug 516470 to be resolved @@ -499,5 +508,4 @@ public class CDebugUIUtils { return res; } - } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebuggerPageAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebuggerPageAdapter.java index 74ab7a6bfff..36106cbab30 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebuggerPageAdapter.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebuggerPageAdapter.java @@ -11,7 +11,7 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui; +package org.eclipse.cdt.debug.internal.ui; import org.eclipse.cdt.debug.ui.ICDebuggerPage; import org.eclipse.debug.core.ILaunch; @@ -22,10 +22,10 @@ import org.eclipse.debug.ui.ILaunchConfigurationTab; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; - + /** * Migration from <code>AbstractLaunchConfigurationTab</code> to <code>ICDebuggerPage</code>. - * + * * @since 3.1 */ public class CDebuggerPageAdapter implements ICDebuggerPage { @@ -33,10 +33,10 @@ public class CDebuggerPageAdapter implements ICDebuggerPage { private ILaunchConfigurationTab fDelegate; private String fDebuggerId; - /** - * Constructor for CDebuggerPageAdapter. + /** + * Constructor for CDebuggerPageAdapter. */ - public CDebuggerPageAdapter( ILaunchConfigurationTab tab ) { + public CDebuggerPageAdapter(ILaunchConfigurationTab tab) { fDelegate = tab; } @@ -44,7 +44,7 @@ public class CDebuggerPageAdapter implements ICDebuggerPage { * @see org.eclipse.cdt.debug.ui.ICDebuggerPage#init(java.lang.String) */ @Override - public void init( String debuggerID ) { + public void init(String debuggerID) { fDebuggerId = debuggerID; } @@ -60,8 +60,8 @@ public class CDebuggerPageAdapter implements ICDebuggerPage { * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite) */ @Override - public void createControl( Composite parent ) { - fDelegate.createControl( parent ); + public void createControl(Composite parent) { + fDelegate.createControl(parent); } /* (non-Javadoc) @@ -76,16 +76,16 @@ public class CDebuggerPageAdapter implements ICDebuggerPage { * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) */ @Override - public void setDefaults( ILaunchConfigurationWorkingCopy configuration ) { - fDelegate.setDefaults( configuration ); + public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { + fDelegate.setDefaults(configuration); } /* (non-Javadoc) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) */ @Override - public void initializeFrom( ILaunchConfiguration configuration ) { - fDelegate.initializeFrom( configuration ); + public void initializeFrom(ILaunchConfiguration configuration) { + fDelegate.initializeFrom(configuration); } /* (non-Javadoc) @@ -100,8 +100,8 @@ public class CDebuggerPageAdapter implements ICDebuggerPage { * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) */ @Override - public void performApply( ILaunchConfigurationWorkingCopy configuration ) { - fDelegate.performApply( configuration ); + public void performApply(ILaunchConfigurationWorkingCopy configuration) { + fDelegate.performApply(configuration); } /* (non-Javadoc) @@ -124,8 +124,8 @@ public class CDebuggerPageAdapter implements ICDebuggerPage { * @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration) */ @Override - public boolean isValid( ILaunchConfiguration launchConfig ) { - return fDelegate.isValid( launchConfig ); + public boolean isValid(ILaunchConfiguration launchConfig) { + return fDelegate.isValid(launchConfig); } /* (non-Javadoc) @@ -140,16 +140,16 @@ public class CDebuggerPageAdapter implements ICDebuggerPage { * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setLaunchConfigurationDialog(org.eclipse.debug.ui.ILaunchConfigurationDialog) */ @Override - public void setLaunchConfigurationDialog( ILaunchConfigurationDialog dialog ) { - fDelegate.setLaunchConfigurationDialog( dialog ); + public void setLaunchConfigurationDialog(ILaunchConfigurationDialog dialog) { + fDelegate.setLaunchConfigurationDialog(dialog); } /* (non-Javadoc) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#launched(org.eclipse.debug.core.ILaunch) */ @Override - public void launched( ILaunch launch ) { - fDelegate.launched( launch ); + public void launched(ILaunch launch) { + fDelegate.launched(launch); } /* (non-Javadoc) @@ -172,15 +172,15 @@ public class CDebuggerPageAdapter implements ICDebuggerPage { * @see org.eclipse.debug.ui.ILaunchConfigurationTab#activated(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) */ @Override - public void activated( ILaunchConfigurationWorkingCopy workingCopy ) { - fDelegate.activated( workingCopy ); + public void activated(ILaunchConfigurationWorkingCopy workingCopy) { + fDelegate.activated(workingCopy); } /* (non-Javadoc) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#deactivated(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) */ @Override - public void deactivated( ILaunchConfigurationWorkingCopy workingCopy ) { - fDelegate.deactivated( workingCopy ); + public void deactivated(ILaunchConfigurationWorkingCopy workingCopy) { + fDelegate.deactivated(workingCopy); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CValueDetailProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CValueDetailProvider.java index 513208ff122..4a62ec8a96d 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CValueDetailProvider.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CValueDetailProvider.java @@ -28,26 +28,25 @@ public class CValueDetailProvider { private static CValueDetailProvider fInstance = null; public static CValueDetailProvider getDefault() { - if ( fInstance == null ) { + if (fInstance == null) { fInstance = new CValueDetailProvider(); } return fInstance; } - public void computeDetail( final IValue value, final IValueDetailListener listener ) { - if ( value instanceof ICValue ) { + public void computeDetail(final IValue value, final IValueDetailListener listener) { + if (value instanceof ICValue) { final ICStackFrame frame = CDebugUIUtils.getCurrentStackFrame(); - if ( frame != null ) { - DebugPlugin.getDefault().asyncExec( new Runnable() { - + if (frame != null) { + DebugPlugin.getDefault().asyncExec(new Runnable() { + @Override public void run() { - listener.detailComputed( value, ((ICValue)value).evaluateAsExpression( frame ) ); + listener.detailComputed(value, ((ICValue) value).evaluateAsExpression(frame)); } - } ); - } - else { // no valid stack frame, clear detail pane - listener.detailComputed( value, "" ); //$NON-NLS-1$ + }); + } else { // no valid stack frame, clear detail pane + listener.detailComputed(value, ""); //$NON-NLS-1$ } } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CWatchExpressionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CWatchExpressionDelegate.java index 884ef3b5058..febe28e85fc 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CWatchExpressionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CWatchExpressionDelegate.java @@ -11,7 +11,7 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui; +package org.eclipse.cdt.debug.internal.ui; import org.eclipse.cdt.debug.core.model.ICStackFrame; import org.eclipse.debug.core.DebugException; @@ -21,55 +21,56 @@ import org.eclipse.debug.core.model.IValue; import org.eclipse.debug.core.model.IWatchExpressionDelegate; import org.eclipse.debug.core.model.IWatchExpressionListener; import org.eclipse.debug.core.model.IWatchExpressionResult; - + public class CWatchExpressionDelegate implements IWatchExpressionDelegate { /* (non-Javadoc) * @see org.eclipse.debug.core.model.IWatchExpressionDelegate#evaluateExpression(java.lang.String, org.eclipse.debug.core.model.IDebugElement, org.eclipse.debug.core.model.IWatchExpressionListener) */ @Override - public void evaluateExpression( final String expression, IDebugElement context, final IWatchExpressionListener listener ) { - if ( !(context instanceof ICStackFrame) ) { - listener.watchEvaluationFinished( null ); + public void evaluateExpression(final String expression, IDebugElement context, + final IWatchExpressionListener listener) { + if (!(context instanceof ICStackFrame)) { + listener.watchEvaluationFinished(null); return; } - final ICStackFrame frame = (ICStackFrame)context; + final ICStackFrame frame = (ICStackFrame) context; Runnable runnable = new Runnable() { @Override public void run() { IValue value = null; DebugException de = null; try { - value = frame.evaluateExpression( expression ); - } - catch( DebugException e ) { + value = frame.evaluateExpression(expression); + } catch (DebugException e) { de = e; } - IWatchExpressionResult result = evaluationComplete( expression, value, de ); - listener.watchEvaluationFinished( result ); + IWatchExpressionResult result = evaluationComplete(expression, value, de); + listener.watchEvaluationFinished(result); } }; - DebugPlugin.getDefault().asyncExec( runnable ); + DebugPlugin.getDefault().asyncExec(runnable); } - protected IWatchExpressionResult evaluationComplete( final String expression, final IValue value, final DebugException de ) { + protected IWatchExpressionResult evaluationComplete(final String expression, final IValue value, + final DebugException de) { return new IWatchExpressionResult() { - + @Override public IValue getValue() { return value; } - + @Override public boolean hasErrors() { - return ( de != null ); + return (de != null); } - + @Override public String getExpressionText() { return expression; } - + /* (non-Javadoc) * @see org.eclipse.debug.core.model.IWatchExpressionResult#getException() */ @@ -80,7 +81,7 @@ public class CWatchExpressionDelegate implements IWatchExpressionDelegate { @Override public String[] getErrorMessages() { - return ( de != null ) ? new String[] { de.getMessage() } : new String[0]; + return (de != null) ? new String[] { de.getMessage() } : new String[0]; } }; } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ColorManager.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ColorManager.java index be754be8a17..0ff06bddf52 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ColorManager.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ColorManager.java @@ -23,7 +23,7 @@ import org.eclipse.swt.widgets.Display; /** * Color manager for C/C++ Debug UI. - * + * * @since Jul 23, 2002 */ public class ColorManager { @@ -53,6 +53,6 @@ public class ColorManager { public void dispose() { Iterator<Color> e = fColorTable.values().iterator(); while (e.hasNext()) - e.next().dispose(); + e.next().dispose(); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/DebugMarkerAnnotationModel.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/DebugMarkerAnnotationModel.java index c435ea7f565..ff5aea57e39 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/DebugMarkerAnnotationModel.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/DebugMarkerAnnotationModel.java @@ -12,7 +12,7 @@ * QNX Software Systems - Initial API and implementation * Anton Leherbauer (Wind River Systems) *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui; +package org.eclipse.cdt.debug.internal.ui; import java.io.File; import org.eclipse.cdt.debug.core.model.ICBreakpoint; @@ -23,12 +23,12 @@ import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.IBreakpointsListener; import org.eclipse.debug.core.model.IBreakpoint; import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel; - + public class DebugMarkerAnnotationModel extends AbstractMarkerAnnotationModel implements IBreakpointsListener { private final File fFile; - public DebugMarkerAnnotationModel( File file ) { + public DebugMarkerAnnotationModel(File file) { super(); fFile = file; } @@ -37,30 +37,30 @@ public class DebugMarkerAnnotationModel extends AbstractMarkerAnnotationModel im protected IMarker[] retrieveMarkers() throws CoreException { IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(); IMarker[] markers = new IMarker[breakpoints.length]; - for ( int i = 0; i < markers.length; ++i ) { + for (int i = 0; i < markers.length; ++i) { markers[i] = breakpoints[i].getMarker(); } return markers; } @Override - protected void deleteMarkers( IMarker[] markers ) throws CoreException { + protected void deleteMarkers(IMarker[] markers) throws CoreException { } @Override - protected void listenToMarkerChanges( boolean listen ) { - if ( listen ) - DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener( this ); + protected void listenToMarkerChanges(boolean listen) { + if (listen) + DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(this); else - DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener( this ); + DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener(this); } @Override - protected boolean isAcceptable( IMarker marker ) { + protected boolean isAcceptable(IMarker marker) { String handle = marker.getAttribute(ICBreakpoint.SOURCE_HANDLE, null); if (handle != null) { - File file = new File( handle ); - return file.equals( getFile() ); + File file = new File(handle); + return file.equals(getFile()); } return false; } @@ -70,25 +70,25 @@ public class DebugMarkerAnnotationModel extends AbstractMarkerAnnotationModel im } @Override - public void breakpointsAdded( IBreakpoint[] breakpoints ) { - for ( int i = 0; i < breakpoints.length; ++i ) { - addMarkerAnnotation( breakpoints[i].getMarker() ); + public void breakpointsAdded(IBreakpoint[] breakpoints) { + for (int i = 0; i < breakpoints.length; ++i) { + addMarkerAnnotation(breakpoints[i].getMarker()); } fireModelChanged(); } @Override - public void breakpointsRemoved( IBreakpoint[] breakpoints, IMarkerDelta[] deltas ) { - for ( int i = 0; i < breakpoints.length; ++i ) { - removeMarkerAnnotation( breakpoints[i].getMarker() ); + public void breakpointsRemoved(IBreakpoint[] breakpoints, IMarkerDelta[] deltas) { + for (int i = 0; i < breakpoints.length; ++i) { + removeMarkerAnnotation(breakpoints[i].getMarker()); } fireModelChanged(); } @Override - public void breakpointsChanged( IBreakpoint[] breakpoints, IMarkerDelta[] deltas ) { - for ( int i = 0; i < breakpoints.length; ++i ) { - modifyMarkerAnnotation( breakpoints[i].getMarker() ); + public void breakpointsChanged(IBreakpoint[] breakpoints, IMarkerDelta[] deltas) { + for (int i = 0; i < breakpoints.length; ++i) { + modifyMarkerAnnotation(breakpoints[i].getMarker()); } fireModelChanged(); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/DebugMarkerAnnotationModelFactory.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/DebugMarkerAnnotationModelFactory.java index f3bf65bcc71..bf44654223e 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/DebugMarkerAnnotationModelFactory.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/DebugMarkerAnnotationModelFactory.java @@ -11,7 +11,7 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui; +package org.eclipse.cdt.debug.internal.ui; import java.io.File; import org.eclipse.core.filebuffers.FileBuffers; @@ -26,14 +26,14 @@ public class DebugMarkerAnnotationModelFactory extends ResourceMarkerAnnotationM * @see org.eclipse.ui.texteditor.ResourceMarkerAnnotationModelFactory#createAnnotationModel(org.eclipse.core.runtime.IPath) */ @Override - public IAnnotationModel createAnnotationModel( IPath location ) { - IFile file = FileBuffers.getWorkspaceFileAtLocation( location ); - if ( file != null ) { - return super.createAnnotationModel( location ); + public IAnnotationModel createAnnotationModel(IPath location) { + IFile file = FileBuffers.getWorkspaceFileAtLocation(location); + if (file != null) { + return super.createAnnotationModel(location); } - File osFile = new File( location.toOSString() ); - if ( osFile.exists() ) { - return new DebugMarkerAnnotationModel( osFile ); + File osFile = new File(location.toOSString()); + if (osFile.exists()) { + return new DebugMarkerAnnotationModel(osFile); } return null; } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/DetailsViewerConfiguration.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/DetailsViewerConfiguration.java index d5f6a540107..504a723d208 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/DetailsViewerConfiguration.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/DetailsViewerConfiguration.java @@ -10,13 +10,13 @@ * * Contributors: * QNX Software Systems - Initial API and implementation - ***********************************************************************/ -package org.eclipse.cdt.debug.internal.ui; + ***********************************************************************/ +package org.eclipse.cdt.debug.internal.ui; import org.eclipse.jface.text.source.SourceViewerConfiguration; - + /** - * The source viewer configuration used in the Details pane of the variables, + * The source viewer configuration used in the Details pane of the variables, * registers and expressions views. */ public class DetailsViewerConfiguration extends SourceViewerConfiguration { diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ErrorStatusHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ErrorStatusHandler.java index cdcb0d25cc2..d77fa7860d3 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ErrorStatusHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ErrorStatusHandler.java @@ -30,26 +30,25 @@ public class ErrorStatusHandler implements IStatusHandler { * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object) */ @Override - public Object handleStatus( final IStatus status, Object source ) throws CoreException { - if ( status != null && source != null ) { + public Object handleStatus(final IStatus status, Object source) throws CoreException { + if (status != null && source != null) { String title = ""; //$NON-NLS-1$ - if (source instanceof IDebugElement) { - IDebugTarget target = ((IDebugElement)source).getDebugTarget(); + if (source instanceof IDebugElement) { + IDebugTarget target = ((IDebugElement) source).getDebugTarget(); title = target.getName(); - } - else { - // Source is sometimes an action delegate instance. Can't gather + } else { + // Source is sometimes an action delegate instance. Can't gather // anything useful from it. Use a generic title title = CDebugUIMessages.getString("ErrorStatusHandler.1"); //$NON-NLS-1$ } final String title_f = title; - CDebugUIPlugin.getStandardDisplay().asyncExec( new Runnable() { + CDebugUIPlugin.getStandardDisplay().asyncExec(new Runnable() { @Override public void run() { - ErrorDialog.openError( CDebugUIPlugin.getActiveWorkbenchShell(), title_f, null, status ); + ErrorDialog.openError(CDebugUIPlugin.getActiveWorkbenchShell(), title_f, null, status); } - } ); + }); } return null; } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/HTMLPrinter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/HTMLPrinter.java index 1c89ba59e70..eb85db4bb6f 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/HTMLPrinter.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/HTMLPrinter.java @@ -13,7 +13,6 @@ *******************************************************************************/ package org.eclipse.cdt.debug.internal.ui; - import java.io.IOException; import java.io.Reader; @@ -24,55 +23,54 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; - /** * Provides a set of convenience methods for creating HTML pages. */ public class HTMLPrinter { - + private HTMLPrinter() { } - + private static String replace(String text, char c, String s) { - - int previous= 0; - int current= text.indexOf(c, previous); - + + int previous = 0; + int current = text.indexOf(c, previous); + if (current == -1) return text; - - StringBuffer buffer= new StringBuffer(); + + StringBuffer buffer = new StringBuffer(); while (current > -1) { buffer.append(text.substring(previous, current)); buffer.append(s); - previous= current + 1; - current= text.indexOf(c, previous); + 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, '<', "<"); //$NON-NLS-1$ + content = replace(content, '<', "<"); //$NON-NLS-1$ return replace(content, '>', ">"); //$NON-NLS-1$ } - + public static String read(Reader rd) { - - StringBuffer buffer= new StringBuffer(); - char[] readBuffer= new char[2048]; - + + StringBuffer buffer = new StringBuffer(); + char[] readBuffer = new char[2048]; + try { - int n= rd.read(readBuffer); + int n = rd.read(readBuffer); while (n > 0) { buffer.append(readBuffer, 0, n); - n= rd.read(readBuffer); + n = rd.read(readBuffer); } return buffer.toString(); } catch (IOException x) { } - + return null; } @@ -80,14 +78,14 @@ public class HTMLPrinter { if (bgRGB == null) insertPageProlog(buffer, position); else { - StringBuffer pageProlog= new StringBuffer(60); + StringBuffer pageProlog = new StringBuffer(60); pageProlog.append("<html><body text=\"#000000\" bgcolor=\""); //$NON-NLS-1$ appendColor(pageProlog, bgRGB); pageProlog.append("\"><font size=-1>"); //$NON-NLS-1$ - buffer.insert(position, pageProlog.toString()); + buffer.insert(position, pageProlog.toString()); } } - + private static void appendColor(StringBuffer buffer, RGB rgb) { buffer.append('#'); buffer.append(Integer.toHexString(rgb.red)); @@ -96,35 +94,35 @@ public class HTMLPrinter { } public static void insertPageProlog(StringBuffer buffer, int position) { - RGB bgColor= null; - IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + RGB bgColor = null; + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window != null) { - Display display= window.getShell().getDisplay(); + Display display = window.getShell().getDisplay(); if (display != null && !display.isDisposed()) - bgColor= display.getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB(); + bgColor = display.getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB(); } if (bgColor == null) - bgColor= new RGB(255,255, 225); // RGB value of info bg color on WindowsXP - + bgColor = new RGB(255, 255, 225); // RGB value of info bg color on WindowsXP + insertPageProlog(buffer, position, bgColor); } - + public static void addPageProlog(StringBuffer buffer) { insertPageProlog(buffer, buffer.length()); } - + public static void addPageEpilog(StringBuffer buffer) { buffer.append("</font></body></html>"); //$NON-NLS-1$ } - + public static void startBulletList(StringBuffer buffer) { buffer.append("<ul>"); //$NON-NLS-1$ } - + public static void endBulletList(StringBuffer buffer) { buffer.append("</ul>"); //$NON-NLS-1$ } - + public static void addBullet(StringBuffer buffer, String bullet) { if (bullet != null) { buffer.append("<li>"); //$NON-NLS-1$ @@ -132,7 +130,7 @@ public class HTMLPrinter { buffer.append("</li>"); //$NON-NLS-1$ } } - + public static void addSmallHeader(StringBuffer buffer, String header) { if (header != null) { buffer.append("<h5>"); //$NON-NLS-1$ @@ -140,14 +138,14 @@ public class HTMLPrinter { buffer.append("</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(StringBuffer buffer, Reader paragraphReader) { if (paragraphReader != null) addParagraph(buffer, read(paragraphReader)); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ICDebugHelpContextIds.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ICDebugHelpContextIds.java index 0920c99ebfd..8684e61e041 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ICDebugHelpContextIds.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ICDebugHelpContextIds.java @@ -23,7 +23,7 @@ import org.eclipse.cdt.debug.ui.CDebugUIPlugin; * This interface contains constants only; it is not intended to be implemented * or extended. * </p> - * + * * @since Jul 23, 2002 */ public interface ICDebugHelpContextIds { @@ -31,7 +31,7 @@ public interface ICDebugHelpContextIds { * C/C++ Debug UI plug-in identifier (value <code>"org.eclipse.cdt.debug.ui"</code>). */ public static final String PLUGIN_ID = CDebugUIPlugin.getUniqueIdentifier(); - + public static final String PREFIX = PLUGIN_ID + "."; //$NON-NLS-1$ // Actions @@ -43,7 +43,8 @@ public interface ICDebugHelpContextIds { public static final String MEMORY_SAVE_ACTION = PREFIX + "memory_save_action_context"; //$NON-NLS-1$ public static final String MEMORY_SHOW_ASCII_ACTION = PREFIX + "memory_show_ascii_action_context"; //$NON-NLS-1$ public static final String REFRESH_SHARED_LIBRARIES_ACTION = PREFIX + "refresh_shared_libraries_action_context"; //$NON-NLS-1$ - public static final String AUTO_REFRESH_SHARED_LIBRARIES_ACTION = PREFIX + "auto_refresh_shared_libraries_action_context"; //$NON-NLS-1$ + public static final String AUTO_REFRESH_SHARED_LIBRARIES_ACTION = PREFIX + + "auto_refresh_shared_libraries_action_context"; //$NON-NLS-1$ public static final String LOAD_SYMBOLS_FOR_ALL = PREFIX + "load_symbols_for_all_action_context"; //$NON-NLS-1$ public static final String REFRESH_REGISTERS_ACTION = PREFIX + "refresh_registers_action_context"; //$NON-NLS-1$ public static final String AUTO_REFRESH_REGISTERS_ACTION = PREFIX + "auto_refresh_registers_action_context"; //$NON-NLS-1$ @@ -51,19 +52,20 @@ public interface ICDebugHelpContextIds { public static final String ENABLE_DISABLE_BREAKPOINT_ACTION = PREFIX + "enable_disable_breakpoint_action_context"; //$NON-NLS-1$ public static final String BREAKPOINT_PROPERTIES_ACTION = PREFIX + "breakpoint_properties_action_context"; //$NON-NLS-1$ public static final String SHOW_DETAIL_PANE_ACTION = PREFIX + "show_detail_pane_action_context"; //$NON-NLS-1$ - public static final String CONFIGURE_COLUMNS_ACTION = PREFIX + "configure_columns_context"; //$NON-NLS-1$; - public static final String SHOW_COLUMNS_ACTION = PREFIX + "show_columns_context"; //$NON-NLS-1$; - public static final String MODULE_DETAIL_PANE_SELECT_ALL_ACTION = PREFIX + "module_detail_pane_select_all_action_context"; //$NON-NLS-1$ - public static final String MODULE_DETAIL_PANE_COPY_ACTION = PREFIX + "detail_pane_copy_action_context"; //$NON-NLS-1$ + public static final String CONFIGURE_COLUMNS_ACTION = PREFIX + "configure_columns_context"; //$NON-NLS-1$; + public static final String SHOW_COLUMNS_ACTION = PREFIX + "show_columns_context"; //$NON-NLS-1$; + public static final String MODULE_DETAIL_PANE_SELECT_ALL_ACTION = PREFIX + + "module_detail_pane_select_all_action_context"; //$NON-NLS-1$ + public static final String MODULE_DETAIL_PANE_COPY_ACTION = PREFIX + "detail_pane_copy_action_context"; //$NON-NLS-1$ // Views & Editors - /** + /** * The memory view is part of the platform, the context id is assigned there. */ public static final String MEMORY_VIEW = PREFIX + "MemoryView_context"; //$NON-NLS-1$ public static final String SHARED_LIBRARIES_VIEW = PREFIX + "shared_libraries_view_context"; //$NON-NLS-1$ public static final String MODULES_VIEW = PREFIX + "modules_view_context"; //$NON-NLS-1$ - public static final String MODULES_DETAIL_PANE = PREFIX + "modules_detail_pane"; //$NON-NLS-1$ + public static final String MODULES_DETAIL_PANE = PREFIX + "modules_detail_pane"; //$NON-NLS-1$ public static final String SIGNALS_VIEW = PREFIX + "signals_view_context"; //$NON-NLS-1$ public static final String DISASSEMBLY_VIEW = PREFIX + "disassembly_view_context"; //$NON-NLS-1$ public static final String SOURCE_NOT_FOUND = PREFIX + "source_not_found"; //$NON-NLS-1$ @@ -81,8 +83,9 @@ public interface ICDebugHelpContextIds { public static final String ADD_SOURCE_CONTAINER_DIALOG = PREFIX + "add_source_container_dialog"; //$NON-NLS-1$ public static final String ADD_DIRECTORY_CONTAINER_DIALOG = PREFIX + "add_directory_container_dialog"; //$NON-NLS-1$ public static final String REGISTER_GROUP = PREFIX + "register_group_dialog"; //$NON-NLS-1$ - public static final String CONFIGURE_COLUMNS_DIALOG = PREFIX + "configure_columns_dialog_context"; //$NON-NLS-1$; - public static final String COMPILATION_DIRECTORY_SOURCE_CONTAINER_DIALOG = PREFIX + "compilation_directory_source_container_dialog_context"; //$NON-NLS-1$;; + public static final String CONFIGURE_COLUMNS_DIALOG = PREFIX + "configure_columns_dialog_context"; //$NON-NLS-1$; + public static final String COMPILATION_DIRECTORY_SOURCE_CONTAINER_DIALOG = PREFIX + + "compilation_directory_source_container_dialog_context"; //$NON-NLS-1$;; public static final String ADD_TARGET_PROJECT_CONTAINER_DIALOG = PREFIX + "target_project_source_container_dialog";//$NON-NLS-1$ // Wizards diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/IInternalCDebugUIConstants.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/IInternalCDebugUIConstants.java index a7ddeeddec4..95f435d105d 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/IInternalCDebugUIConstants.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/IInternalCDebugUIConstants.java @@ -22,26 +22,27 @@ public interface IInternalCDebugUIConstants { * C/C++ Debug UI plug-in identifier (value <code>"org.eclipse.cdt.debug.ui"</code>). */ public static final String PLUGIN_ID = CDebugUIPlugin.getUniqueIdentifier(); - + public static final String PREFIX = PLUGIN_ID + "."; //$NON-NLS-1$ - /** - * Specifies the conditions under which the disassembly editor will be activated - */ - public static final String PREF_OPEN_DISASSEMBLY_MODE = PREFIX + "openDisassemblyMode"; //$NON-NLS-1$ + /** + * Specifies the conditions under which the disassembly editor will be activated + */ + public static final String PREF_OPEN_DISASSEMBLY_MODE = PREFIX + "openDisassemblyMode"; //$NON-NLS-1$ - /** + /** * The name of the font to use for disassembly view. This font is managed via * the workbench font preference page. - */ - public static final String DISASSEMBLY_FONT = PREFIX + "disassemblyFont"; //$NON-NLS-1$ + */ + public static final String DISASSEMBLY_FONT = PREFIX + "disassemblyFont"; //$NON-NLS-1$ // Current stack frame instruction pointer public static final String DISASM_INSTRUCTION_POINTER = PREFIX + "disassemblyInstructionPointer"; //$NON-NLS-1$ // marker types for instruction pointer annotations - top stack frame, and secondary public static final String DISASM_INSTRUCTION_POINTER_CURRENT = PREFIX + "disassemblyInstructionPointer.current"; //$NON-NLS-1$ - public static final String DISASM_INSTRUCTION_POINTER_SECONDARY = PREFIX + "disassemblyInstructionPointer.secondary"; //$NON-NLS-1$ + public static final String DISASM_INSTRUCTION_POINTER_SECONDARY = PREFIX + + "disassemblyInstructionPointer.secondary"; //$NON-NLS-1$ // annotation types for instruction pointers public static final String ANN_DISASM_INSTR_POINTER_CURRENT = PREFIX + "currentDisassemblyIP"; //$NON-NLS-1$ @@ -59,8 +60,8 @@ public interface IInternalCDebugUIConstants { /** * The name of the font to use for detail panes. This font is managed via * the workbench font preference page. - */ - public static final String DETAIL_PANE_FONT = PREFIX + "ModulesDetailPaneFont"; //$NON-NLS-1$ + */ + public static final String DETAIL_PANE_FONT = PREFIX + "ModulesDetailPaneFont"; //$NON-NLS-1$ /** * Status code indicating an unexpected internal error. @@ -69,10 +70,10 @@ public interface IInternalCDebugUIConstants { // new disassembly - public static final String DISASM_DISPLAY_MODE_INSTRUCTIONS = "instructions"; //$NON-NLS-1$ - public static final String DISASM_DISPLAY_MODE_SOURCE = "source"; //$NON-NLS-1$ + public static final String DISASM_DISPLAY_MODE_INSTRUCTIONS = "instructions"; //$NON-NLS-1$ + public static final String DISASM_DISPLAY_MODE_SOURCE = "source"; //$NON-NLS-1$ - // wizard images - public static final String IMG_ADD_COMP_DIR_WIZ = "IMG_ADD_SRC_DIRECTORY"; //$NON-NLS-1$ - public static final String IMG_EDIT_COMP_DIR_WIZ = "IMG_EDIT_SRC_DIRECTORY"; //$NON-NLS-1$ + // wizard images + public static final String IMG_ADD_COMP_DIR_WIZ = "IMG_ADD_SRC_DIRECTORY"; //$NON-NLS-1$ + public static final String IMG_EDIT_COMP_DIR_WIZ = "IMG_EDIT_SRC_DIRECTORY"; //$NON-NLS-1$ } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/InfoStatusHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/InfoStatusHandler.java index 7ed17052f05..1e9887b9d72 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/InfoStatusHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/InfoStatusHandler.java @@ -29,17 +29,17 @@ public class InfoStatusHandler implements IStatusHandler { * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object) */ @Override - public Object handleStatus( IStatus status, Object source ) throws CoreException { - if ( status != null && source != null && source instanceof IDebugTarget ) { - final String title = ((IDebugTarget)source).getName(); + public Object handleStatus(IStatus status, Object source) throws CoreException { + if (status != null && source != null && source instanceof IDebugTarget) { + final String title = ((IDebugTarget) source).getName(); final String message = status.getMessage(); - CDebugUIPlugin.getStandardDisplay().asyncExec( new Runnable() { + CDebugUIPlugin.getStandardDisplay().asyncExec(new Runnable() { @Override public void run() { - MessageDialog.openInformation( CDebugUIPlugin.getActiveWorkbenchShell(), title, message ); + MessageDialog.openInformation(CDebugUIPlugin.getActiveWorkbenchShell(), title, message); } - } ); + }); } return null; } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/OverlayImageCache.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/OverlayImageCache.java index 3ff5ceecb5b..1f1ccf3c457 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/OverlayImageCache.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/OverlayImageCache.java @@ -20,7 +20,7 @@ import org.eclipse.swt.graphics.Image; /** * Maintains a cache of overlay images. - * + * * @since May 30, 2003 */ public class OverlayImageCache { @@ -29,7 +29,7 @@ public class OverlayImageCache { /** * Returns and caches an image corresponding to the specified image * descriptor. - * + * * @param imageDecsriptor * the image descriptor * @return the image diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/OverlayImageDescriptor.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/OverlayImageDescriptor.java index 29e33835f1d..eea96a2276a 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/OverlayImageDescriptor.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/OverlayImageDescriptor.java @@ -41,14 +41,14 @@ public class OverlayImageDescriptor extends CompositeImageDescriptor { // the size private Point fSize; - public OverlayImageDescriptor( Image base, ImageDescriptor[] overlays ) { - this( base, overlays, new Point( DEFAULT_WIDTH, DEFAULT_HEIGHT ) ); + public OverlayImageDescriptor(Image base, ImageDescriptor[] overlays) { + this(base, overlays, new Point(DEFAULT_WIDTH, DEFAULT_HEIGHT)); } - public OverlayImageDescriptor( Image base, ImageDescriptor[] overlays, Point size ) { - setBase( base ); - setOverlays( overlays ); - setSize( size ); + public OverlayImageDescriptor(Image base, ImageDescriptor[] overlays, Point size) { + setBase(base); + setOverlays(overlays); + setSize(size); } /** @@ -57,44 +57,44 @@ public class OverlayImageDescriptor extends CompositeImageDescriptor { protected void drawOverlays(ImageDescriptor[] overlays) { Point size = getSize(); - for ( int i = 0; i < overlays.length; i++ ) { + for (int i = 0; i < overlays.length; i++) { ImageDescriptor overlay = overlays[i]; - if ( overlay == null ) + if (overlay == null) continue; ImageData overlayData = overlay.getImageData(); //Use the missing descriptor if it is not there. - if ( overlayData == null ) + if (overlayData == null) overlayData = ImageDescriptor.getMissingImageDescriptor().getImageData(); - switch( i ) { - case TOP_LEFT: - drawImage( overlayData, 0, 0 ); - break; - case TOP_RIGHT: - drawImage( overlayData, size.x - overlayData.width, 0 ); - break; - case BOTTOM_LEFT: - drawImage( overlayData, 0, size.y - overlayData.height ); - break; - case BOTTOM_RIGHT: - drawImage( overlayData, size.x - overlayData.width, size.y - overlayData.height ); - break; + switch (i) { + case TOP_LEFT: + drawImage(overlayData, 0, 0); + break; + case TOP_RIGHT: + drawImage(overlayData, size.x - overlayData.width, 0); + break; + case BOTTOM_LEFT: + drawImage(overlayData, 0, size.y - overlayData.height); + break; + case BOTTOM_RIGHT: + drawImage(overlayData, size.x - overlayData.width, size.y - overlayData.height); + break; } } } @Override - public boolean equals( Object o ) { - if ( !(o instanceof OverlayImageDescriptor) ) + public boolean equals(Object o) { + if (!(o instanceof OverlayImageDescriptor)) return false; - OverlayImageDescriptor other = (OverlayImageDescriptor)o; - return getBase().equals( other.getBase() ) && Arrays.equals( getOverlays(), other.getOverlays() ); + OverlayImageDescriptor other = (OverlayImageDescriptor) o; + return getBase().equals(other.getBase()) && Arrays.equals(getOverlays(), other.getOverlays()); } @Override public int hashCode() { int code = getBase().hashCode(); for (int i = 0; i < getOverlays().length; i++) { - if ( getOverlays()[i] != null ) + if (getOverlays()[i] != null) code ^= getOverlays()[i].hashCode(); } return code; @@ -102,19 +102,19 @@ public class OverlayImageDescriptor extends CompositeImageDescriptor { /* * (non-Javadoc) - * + * * @see org.eclipse.jface.resource.CompositeImageDescriptor#drawCompositeImage(int, * int) */ @Override - protected void drawCompositeImage( int width, int height ) { - drawImage( getBase().getImageData(), 0, 0 ); - drawOverlays( getOverlays() ); + protected void drawCompositeImage(int width, int height) { + drawImage(getBase().getImageData(), 0, 0); + drawOverlays(getOverlays()); } /* * (non-Javadoc) - * + * * @see org.eclipse.jface.resource.CompositeImageDescriptor#getSize() */ @Override @@ -126,7 +126,7 @@ public class OverlayImageDescriptor extends CompositeImageDescriptor { return this.fBase; } - private void setBase( Image base ) { + private void setBase(Image base) { this.fBase = base; } @@ -134,11 +134,11 @@ public class OverlayImageDescriptor extends CompositeImageDescriptor { return this.fOverlays; } - private void setOverlays( ImageDescriptor[] overlays ) { + private void setOverlays(ImageDescriptor[] overlays) { this.fOverlays = overlays; } - private void setSize( Point size ) { + private void setSize(Point size) { this.fSize = size; } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/QuestionStatusHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/QuestionStatusHandler.java index 822d93dada8..19d5466ea6d 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/QuestionStatusHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/QuestionStatusHandler.java @@ -29,19 +29,19 @@ public class QuestionStatusHandler implements IStatusHandler { * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object) */ @Override - public Object handleStatus( IStatus status, Object source ) throws CoreException { + public Object handleStatus(IStatus status, Object source) throws CoreException { final boolean result[] = new boolean[1]; - if ( status != null && source != null && source instanceof IDebugTarget ) { - final String title = ((IDebugTarget)source).getName(); + if (status != null && source != null && source instanceof IDebugTarget) { + final String title = ((IDebugTarget) source).getName(); final String message = status.getMessage(); - CDebugUIPlugin.getStandardDisplay().syncExec( new Runnable() { + CDebugUIPlugin.getStandardDisplay().syncExec(new Runnable() { @Override public void run() { - result[0] = MessageDialog.openQuestion( CDebugUIPlugin.getActiveWorkbenchShell(), title, message ); + result[0] = MessageDialog.openQuestion(CDebugUIPlugin.getActiveWorkbenchShell(), title, message); } - } ); + }); } - return Boolean.valueOf( result[0] ); + return Boolean.valueOf(result[0]); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/SWTUtil.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/SWTUtil.java index 92ee69e38ee..7a32c1ff41c 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/SWTUtil.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/SWTUtil.java @@ -42,7 +42,7 @@ public class SWTUtil { public static Display getStandardDisplay() { Display display; display = Display.getCurrent(); - if ( display == null ) + if (display == null) display = Display.getDefault(); return display; } @@ -50,54 +50,54 @@ public class SWTUtil { /** * 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(); + 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 ) { - PixelConverter converter = new PixelConverter( button ); - int widthHint = converter.convertHorizontalDLUsToPixels( IDialogConstants.BUTTON_WIDTH ); - return Math.max( widthHint, button.computeSize( SWT.DEFAULT, SWT.DEFAULT, true ).x ); + public static int getButtonWidthHint(Button button) { + 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. */ -// public static int getButtonHeigthHint( Button button ) { -// PixelConverter converter = new PixelConverter( button ); -// return converter.convertVerticalDLUsToPixels( IDialogConstants.BUTTON_HEIGHT ); -// } + // public static int getButtonHeigthHint( Button button ) { + // PixelConverter converter = new PixelConverter( button ); + // return converter.convertVerticalDLUsToPixels( IDialogConstants.BUTTON_HEIGHT ); + // } /** * Sets width and height hint 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 the button for which to set the dimension hint */ - public static void setButtonDimensionHint( Button button ) { - Assert.isNotNull( button ); + public static void setButtonDimensionHint(Button button) { + Assert.isNotNull(button); Object gd = button.getLayoutData(); - if ( gd instanceof GridData ) { - ((GridData)gd).widthHint = getButtonWidthHint( button ); - ((GridData)gd).horizontalAlignment = GridData.FILL; + if (gd instanceof GridData) { + ((GridData) gd).widthHint = getButtonWidthHint(button); + ((GridData) gd).horizontalAlignment = GridData.FILL; } } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/SingleCharReader.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/SingleCharReader.java index d9dc2b9dc43..7b0a2e09c88 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/SingleCharReader.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/SingleCharReader.java @@ -17,7 +17,7 @@ import java.io.IOException; import java.io.Reader; public abstract class SingleCharReader extends Reader { - + /** * @see Reader#read() */ @@ -29,33 +29,33 @@ public abstract class SingleCharReader extends Reader { */ @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(); + int end = off + len; + for (int i = off; i < end; i++) { + int ch = read(); if (ch == -1) { return (i == off) ? -1 : i - off; } - cbuf[i]= (char)ch; + cbuf[i] = (char) ch; } return len; - } - + } + /** * @see Reader#ready() - */ - @Override + */ + @Override public boolean ready() throws IOException { return true; } - + /** * Gets the content as a String */ public String getString() throws IOException { - StringBuilder buf= new StringBuilder(); + StringBuilder buf = new StringBuilder(); int ch; - while ((ch= read()) != -1) { - buf.append((char)ch); + while ((ch = read()) != -1) { + buf.append((char) ch); } return buf.toString(); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/SubstitutionTextReader.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/SubstitutionTextReader.java index 3bdf8b21a1e..73437235a29 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/SubstitutionTextReader.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/SubstitutionTextReader.java @@ -18,13 +18,13 @@ 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 + * 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$ - + + 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; @@ -32,67 +32,66 @@ public abstract class SubstitutionTextReader extends SingleCharReader { /** * Tells whether white space characters are skipped. */ - private boolean fSkipWhiteSpace= true; - + private boolean fSkipWhiteSpace = true; + private boolean fReadFromBuffer; private StringBuilder fBuffer; private int fIndex; - protected SubstitutionTextReader(Reader reader) { - fReader= reader; - fBuffer= new StringBuilder(); - fIndex= 0; - fReadFromBuffer= false; - fCharAfterWhiteSpace= -1; - fWasWhiteSpace= true; + fReader = reader; + fBuffer = new StringBuilder(); + fIndex = 0; + fReadFromBuffer = false; + fCharAfterWhiteSpace = -1; + fWasWhiteSpace = true; } - + /** - * Implement to compute the substitution for the given character and + * 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); + fReadFromBuffer = (fBuffer.length() > 0); if (fReadFromBuffer) { - char ch= fBuffer.charAt(fIndex++); + char ch = fBuffer.charAt(fIndex++); if (fIndex >= fBuffer.length()) { fBuffer.setLength(0); - fIndex= 0; + fIndex = 0; } return ch; } - int ch= fCharAfterWhiteSpace; + int ch = fCharAfterWhiteSpace; if (ch == -1) { - ch= fReader.read(); + ch = fReader.read(); } - if (fSkipWhiteSpace && Character.isWhitespace((char)ch)) { + if (fSkipWhiteSpace && Character.isWhitespace((char) ch)) { do { - ch= fReader.read(); - } while (Character.isWhitespace((char)ch)); + ch = fReader.read(); + } while (Character.isWhitespace((char) ch)); if (ch != -1) { - fCharAfterWhiteSpace= ch; + fCharAfterWhiteSpace = ch; return ' '; } } else { - fCharAfterWhiteSpace= -1; + fCharAfterWhiteSpace = -1; } return ch; } - + /** * @see Reader#read() */ @@ -100,52 +99,52 @@ public abstract class SubstitutionTextReader extends SingleCharReader { public int read() throws IOException { int c; do { - - c= nextChar(); + + c = nextChar(); while (!fReadFromBuffer) { - String s= computeSubstitution(c); + String s = computeSubstitution(c); if (s == null) break; if (s.length() > 0) fBuffer.insert(0, s); - c= nextChar(); + c = nextChar(); } - + } while (fSkipWhiteSpace && fWasWhiteSpace && (c == ' ')); - fWasWhiteSpace= (c == ' ' || c == '\r' || c == '\n'); + fWasWhiteSpace = (c == ' ' || c == '\r' || c == '\n'); return c; } - + /** * @see Reader#ready() - */ - @Override + */ + @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; + fWasWhiteSpace = true; + fCharAfterWhiteSpace = -1; fBuffer.setLength(0); - fIndex= 0; + fIndex = 0; } protected final void setSkipWhitespace(boolean state) { - fSkipWhiteSpace= state; + fSkipWhiteSpace = state; } protected final boolean isSkippingWhitespace() { diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractDebugActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractDebugActionDelegate.java index 69a55dc86d9..a699f3b3208 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractDebugActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractDebugActionDelegate.java @@ -13,7 +13,6 @@ *******************************************************************************/ package org.eclipse.cdt.debug.internal.ui.actions; - import java.util.Iterator; import org.eclipse.cdt.debug.ui.CDebugUIPlugin; @@ -41,8 +40,9 @@ import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; -public abstract class AbstractDebugActionDelegate implements IWorkbenchWindowActionDelegate, IViewActionDelegate, IActionDelegate2, ISelectionListener, INullSelectionListener { - +public abstract class AbstractDebugActionDelegate implements IWorkbenchWindowActionDelegate, IViewActionDelegate, + IActionDelegate2, ISelectionListener, INullSelectionListener { + /** * The underlying action for this delegate */ @@ -52,52 +52,52 @@ public abstract class AbstractDebugActionDelegate implements IWorkbenchWindowAct * if not installed in a view. */ private IViewPart fViewPart; - + /** * Cache of the most recent seletion */ private IStructuredSelection fSelection = StructuredSelection.EMPTY; - + /** * Whether this delegate has been initialized */ private boolean fInitialized = false; - + /** * The window associated with this action delegate * May be <code>null</code> */ protected IWorkbenchWindow fWindow; - + /** * Background job for this action, or <code>null</code> if none. */ private DebugRequestJob fBackgroundJob = null; - + class DebugRequestJob extends Job { - - private Object[] fElements = null; - - /** - * Constructs a new job to perform a debug request (for example, step) - * in the background. - * - * @param name job name - */ - public DebugRequestJob(String name) { - super(name); - setPriority(Job.INTERACTIVE); - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) - */ - @Override + + private Object[] fElements = null; + + /** + * Constructs a new job to perform a debug request (for example, step) + * in the background. + * + * @param name job name + */ + public DebugRequestJob(String name) { + super(name); + setPriority(Job.INTERACTIVE); + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override protected IStatus run(IProgressMonitor monitor) { - MultiStatus status= - new MultiStatus(CDebugUIPlugin.getUniqueIdentifier(), DebugException.REQUEST_FAILED, getStatusMessage(), null); - for (int i = 0; i < fElements.length; i++) { - Object element= fElements[i]; + MultiStatus status = new MultiStatus(CDebugUIPlugin.getUniqueIdentifier(), DebugException.REQUEST_FAILED, + getStatusMessage(), null); + for (int i = 0; i < fElements.length; i++) { + Object element = fElements[i]; try { doAction(element); } catch (DebugException e) { @@ -105,19 +105,19 @@ public abstract class AbstractDebugActionDelegate implements IWorkbenchWindowAct } } return status; - } - - /** - * Sets the selection to operate on. - * - * @param elements - */ - public void setTargets(Object[] elements) { - fElements = elements; - } - + } + + /** + * Sets the selection to operate on. + * + * @param elements + */ + public void setTargets(Object[] elements) { + fElements = elements; + } + } - + /** * It's crucial that delegate actions have a zero-arg constructor so that * they can be reflected into existence when referenced in an action set @@ -125,24 +125,24 @@ public abstract class AbstractDebugActionDelegate implements IWorkbenchWindowAct */ public AbstractDebugActionDelegate() { } - + /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() */ @Override - public void dispose(){ + public void dispose() { if (getWindow() != null) { getWindow().getSelectionService().removeSelectionListener(IDebugUIConstants.ID_DEBUG_VIEW, this); } fBackgroundJob = null; - fSelection= null; + fSelection = null; } /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) */ @Override - public void init(IWorkbenchWindow window){ + public void init(IWorkbenchWindow window) { // listen to selection changes in the debug view setWindow(window); window.getSelectionService().addSelectionListener(IDebugUIConstants.ID_DEBUG_VIEW, this); @@ -152,8 +152,8 @@ public abstract class AbstractDebugActionDelegate implements IWorkbenchWindowAct * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ @Override - public void run(IAction action){ - if (action.isEnabled()) { + public void run(IAction action) { + if (action.isEnabled()) { IStructuredSelection selection = getSelection(); // disable the action so it cannot be run again until an event or selection change // updates the enablement @@ -163,30 +163,30 @@ public abstract class AbstractDebugActionDelegate implements IWorkbenchWindowAct } else { runInForeground(selection); } - } + } } - + /** * Runs this action in a background job. */ private void runInBackground(IAction action, IStructuredSelection selection) { - if (fBackgroundJob == null) { + if (fBackgroundJob == null) { fBackgroundJob = new DebugRequestJob(action.getText()); - } - fBackgroundJob.setTargets(selection.toArray()); + } + fBackgroundJob.setTargets(selection.toArray()); fBackgroundJob.schedule(); } - + /** * Runs this action in the UI thread. */ private void runInForeground(final IStructuredSelection selection) { - final MultiStatus status= - new MultiStatus(CDebugUIPlugin.getUniqueIdentifier(), DebugException.REQUEST_FAILED, getStatusMessage(), null); + final MultiStatus status = new MultiStatus(CDebugUIPlugin.getUniqueIdentifier(), DebugException.REQUEST_FAILED, + getStatusMessage(), null); BusyIndicator.showWhile(Display.getCurrent(), () -> { - Iterator<?> selectionIter = selection.iterator(); + Iterator<?> selectionIter = selection.iterator(); while (selectionIter.hasNext()) { - Object element= selectionIter.next(); + Object element = selectionIter.next(); try { doAction(element); } catch (DebugException e) { @@ -199,7 +199,7 @@ public abstract class AbstractDebugActionDelegate implements IWorkbenchWindowAct private void reportErrors(final MultiStatus ms) { if (!ms.isOK()) { - IWorkbenchWindow window= CDebugUIPlugin.getActiveWorkbenchWindow(); + IWorkbenchWindow window = CDebugUIPlugin.getActiveWorkbenchWindow(); if (window != null) { ErrorDialog.openError(window.getShell(), getErrorDialogTitle(), getErrorDialogMessage(), ms); } else { @@ -218,7 +218,7 @@ public abstract class AbstractDebugActionDelegate implements IWorkbenchWindowAct } /** - * AbstractDebugActionDelegates come in 2 flavors: IViewActionDelegate, + * AbstractDebugActionDelegates come in 2 flavors: IViewActionDelegate, * IWorkbenchWindowActionDelegate delegates. * </p> * <ul> @@ -232,22 +232,22 @@ public abstract class AbstractDebugActionDelegate implements IWorkbenchWindowAct * IWorkbenchWindowActionDelegate's listen to selection changes * in the debug view only. * </p> - * + * * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) */ @Override public void selectionChanged(IAction action, ISelection s) { - boolean wasInitialized= initialize(action, s); + boolean wasInitialized = initialize(action, s); if (!wasInitialized) { if (getView() != null) { update(action, s); } } } - + protected void update(IAction action, ISelection s) { if (s instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection)s; + IStructuredSelection ss = (IStructuredSelection) s; action.setEnabled(getEnableStateForSelection(ss)); setSelection(ss); } else { @@ -255,7 +255,7 @@ public abstract class AbstractDebugActionDelegate implements IWorkbenchWindowAct setSelection(StructuredSelection.EMPTY); } } - + /** * Performs the specific action on this element. */ @@ -265,25 +265,27 @@ public abstract class AbstractDebugActionDelegate implements IWorkbenchWindowAct * Returns the String to use as an error dialog title for * a failed action. Default is to return null. */ - protected String getErrorDialogTitle(){ + protected String getErrorDialogTitle() { return null; } + /** * Returns the String to use as an error dialog message for * a failed action. This message appears as the "Message:" in * the error dialog for this action. * Default is to return null. */ - protected String getErrorDialogMessage(){ + protected String getErrorDialogMessage() { return null; } + /** * Returns the String to use as a status message for * a failed action. This message appears as the "Reason:" * in the error dialog for this action. * Default is to return the empty String. */ - protected String getStatusMessage(){ + protected String getStatusMessage() { return ""; //$NON-NLS-1$ } @@ -294,11 +296,11 @@ public abstract class AbstractDebugActionDelegate implements IWorkbenchWindowAct public void init(IViewPart view) { fViewPart = view; } - + /** * Returns this action's view part, or <code>null</code> * if not installed in a view. - * + * * @return view part or <code>null</code> */ protected IViewPart getView() { @@ -308,9 +310,9 @@ public abstract class AbstractDebugActionDelegate implements IWorkbenchWindowAct /** * Initialize this delegate, updating this delegate's * presentation. - * As well, all of the flavors of AbstractDebugActionDelegates need to + * As well, all of the flavors of AbstractDebugActionDelegates need to * have the initial enabled state set with a call to update(IAction, ISelection). - * + * * @param action the presentation for this action * @return whether the action was initialized */ @@ -319,11 +321,11 @@ public abstract class AbstractDebugActionDelegate implements IWorkbenchWindowAct setAction(action); if (getView() == null) { //update on the selection in the debug view - IWorkbenchWindow window= getWindow(); + IWorkbenchWindow window = getWindow(); if (window != null && window.getShell() != null && !window.getShell().isDisposed()) { - IWorkbenchPage page= window.getActivePage(); + IWorkbenchPage page = window.getActivePage(); if (page != null) { - selection= page.getSelection(IDebugUIConstants.ID_DEBUG_VIEW); + selection = page.getSelection(IDebugUIConstants.ID_DEBUG_VIEW); } } } @@ -336,21 +338,21 @@ public abstract class AbstractDebugActionDelegate implements IWorkbenchWindowAct /** * Returns the most recent selection - * + * * @return structured selection - */ + */ protected IStructuredSelection getSelection() { return fSelection; } - + /** * Sets the most recent selection - * + * * @parm selection structured selection - */ + */ private void setSelection(IStructuredSelection selection) { fSelection = selection; - } + } /* (non-Javadoc) * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) @@ -359,7 +361,7 @@ public abstract class AbstractDebugActionDelegate implements IWorkbenchWindowAct public void selectionChanged(IWorkbenchPart part, ISelection selection) { update(getAction(), selection); } - + protected void setAction(IAction action) { fAction = action; } @@ -367,11 +369,11 @@ public abstract class AbstractDebugActionDelegate implements IWorkbenchWindowAct protected IAction getAction() { return fAction; } - + protected void setView(IViewPart viewPart) { fViewPart = viewPart; } - + protected boolean isInitialized() { return fInitialized; } @@ -387,7 +389,7 @@ public abstract class AbstractDebugActionDelegate implements IWorkbenchWindowAct protected void setWindow(IWorkbenchWindow window) { fWindow = window; } - + /** * Return whether the action should be enabled or not based on the given selection. */ @@ -395,14 +397,14 @@ public abstract class AbstractDebugActionDelegate implements IWorkbenchWindowAct if (selection.size() == 0) { return false; } - Iterator<?> itr= selection.iterator(); + Iterator<?> itr = selection.iterator(); while (itr.hasNext()) { - Object element= itr.next(); + Object element = itr.next(); if (!isEnabledFor(element)) { return false; } } - return true; + return true; } protected boolean isEnabledFor(Object element) { diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractEditorActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractEditorActionDelegate.java index 68eecfe1082..019733bcd1c 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractEditorActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractEditorActionDelegate.java @@ -31,18 +31,13 @@ import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.actions.ActionDelegate; /** - * + * * Enter type comment. - * + * * @since Sep 19, 2002 */ -public abstract class AbstractEditorActionDelegate extends ActionDelegate - implements IWorkbenchWindowActionDelegate, - IEditorActionDelegate, - IPartListener, - ISelectionListener, - INullSelectionListener -{ +public abstract class AbstractEditorActionDelegate extends ActionDelegate implements IWorkbenchWindowActionDelegate, + IEditorActionDelegate, IPartListener, ISelectionListener, INullSelectionListener { private IAction fAction; private IWorkbenchWindow fWorkbenchWindow; private IWorkbenchPart fTargetPart; @@ -51,21 +46,18 @@ public abstract class AbstractEditorActionDelegate extends ActionDelegate /** * Constructor for AbstractEditorActionDelegate. */ - public AbstractEditorActionDelegate() - { + public AbstractEditorActionDelegate() { } /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() */ @Override - public void dispose() - { + public void dispose() { IWorkbenchWindow win = getWorkbenchWindow(); - if ( win != null ) - { - win.getPartService().removePartListener( this ); - win.getSelectionService().removeSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this ); + if (win != null) { + win.getPartService().removePartListener(this); + win.getSelectionService().removeSelectionListener(IDebugUIConstants.ID_DEBUG_VIEW, this); } } @@ -73,16 +65,14 @@ public abstract class AbstractEditorActionDelegate extends ActionDelegate * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(IWorkbenchWindow) */ @Override - public void init( IWorkbenchWindow window ) - { - setWorkbenchWindow( window ); + public void init(IWorkbenchWindow window) { + setWorkbenchWindow(window); IWorkbenchPage page = window.getActivePage(); - if ( page != null ) - { - setTargetPart( page.getActivePart() ); + if (page != null) { + setTargetPart(page.getActivePart()); } - window.getPartService().addPartListener( this ); - window.getSelectionService().addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this ); + window.getPartService().addPartListener(this); + window.getSelectionService().addSelectionListener(IDebugUIConstants.ID_DEBUG_VIEW, this); initializeDebugTarget(); update(); } @@ -91,19 +81,16 @@ public abstract class AbstractEditorActionDelegate extends ActionDelegate * @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(IAction, IEditorPart) */ @Override - public void setActiveEditor( IAction action, IEditorPart targetEditor ) - { - setAction( action ); - if ( getWorkbenchWindow() == null ) - { + public void setActiveEditor(IAction action, IEditorPart targetEditor) { + setAction(action); + if (getWorkbenchWindow() == null) { IWorkbenchWindow window = CDebugUIPlugin.getActiveWorkbenchWindow(); - setWorkbenchWindow( window ); - if ( window != null ) - { - window.getSelectionService().addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this ); + setWorkbenchWindow(window); + if (window != null) { + window.getSelectionService().addSelectionListener(IDebugUIConstants.ID_DEBUG_VIEW, this); } } - setTargetPart( targetEditor ); + setTargetPart(targetEditor); initializeDebugTarget(); update(); } @@ -112,28 +99,24 @@ public abstract class AbstractEditorActionDelegate extends ActionDelegate * @see org.eclipse.ui.IPartListener#partActivated(IWorkbenchPart) */ @Override - public void partActivated( IWorkbenchPart part ) - { - setTargetPart( part ); + public void partActivated(IWorkbenchPart part) { + setTargetPart(part); } /* (non-Javadoc) * @see org.eclipse.ui.IPartListener#partBroughtToTop(IWorkbenchPart) */ @Override - public void partBroughtToTop( IWorkbenchPart part ) - { + public void partBroughtToTop(IWorkbenchPart part) { } /* (non-Javadoc) * @see org.eclipse.ui.IPartListener#partClosed(IWorkbenchPart) */ @Override - public void partClosed( IWorkbenchPart part ) - { - if ( part == getTargetPart() ) - { - setTargetPart( null ); + public void partClosed(IWorkbenchPart part) { + if (part == getTargetPart()) { + setTargetPart(null); } } @@ -141,97 +124,81 @@ public abstract class AbstractEditorActionDelegate extends ActionDelegate * @see org.eclipse.ui.IPartListener#partDeactivated(IWorkbenchPart) */ @Override - public void partDeactivated(IWorkbenchPart part) - { + public void partDeactivated(IWorkbenchPart part) { } /* (non-Javadoc) * @see org.eclipse.ui.IPartListener#partOpened(IWorkbenchPart) */ @Override - public void partOpened( IWorkbenchPart part ) - { + public void partOpened(IWorkbenchPart part) { } @Override - public abstract void selectionChanged( IWorkbenchPart part, ISelection selection ); + public abstract void selectionChanged(IWorkbenchPart part, ISelection selection); /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#run(IAction) */ @Override - public abstract void run( IAction action ); + public abstract void run(IAction action); /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection) */ @Override - public void selectionChanged(IAction action, ISelection selection) - { - setAction( action ); + public void selectionChanged(IAction action, ISelection selection) { + setAction(action); update(); } - protected IWorkbenchPart getTargetPart() - { + protected IWorkbenchPart getTargetPart() { return fTargetPart; } - protected void setTargetPart( IWorkbenchPart part ) - { + protected void setTargetPart(IWorkbenchPart part) { fTargetPart = part; } - protected ISelection getTargetSelection() - { + protected ISelection getTargetSelection() { IWorkbenchPart part = getTargetPart(); - if ( part != null ) - { + if (part != null) { ISelectionProvider provider = part.getSite().getSelectionProvider(); - if ( provider != null ) - { + if (provider != null) { return provider.getSelection(); } } return null; } - - protected void setDebugTarget( IDebugTarget target ) - { + + protected void setDebugTarget(IDebugTarget target) { fDebugTarget = target; } - - protected IDebugTarget getDebugTarget() - { + + protected IDebugTarget getDebugTarget() { return fDebugTarget; } - protected IAction getAction() - { + protected IAction getAction() { return fAction; } - protected void setAction( IAction action ) - { + protected void setAction(IAction action) { fAction = action; } - protected IWorkbenchWindow getWorkbenchWindow() - { + protected IWorkbenchWindow getWorkbenchWindow() { return fWorkbenchWindow; } - protected void setWorkbenchWindow( IWorkbenchWindow workbenchWindow ) - { + protected void setWorkbenchWindow(IWorkbenchWindow workbenchWindow) { fWorkbenchWindow = workbenchWindow; } - protected void update() - { + protected void update() { IAction action = getAction(); - if ( action != null ) - { - action.setEnabled( getDebugTarget() != null && getTargetPart() != null ); + if (action != null) { + action.setEnabled(getDebugTarget() != null && getTargetPart() != null); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractListenerActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractListenerActionDelegate.java index 4dfb76615ef..d190e863371 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractListenerActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractListenerActionDelegate.java @@ -12,7 +12,7 @@ * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.debug.internal.ui.actions; - + import org.eclipse.debug.core.DebugEvent; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.IDebugEventSetListener; @@ -23,7 +23,8 @@ import org.eclipse.ui.IActionDelegate2; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbenchWindow; -public abstract class AbstractListenerActionDelegate extends AbstractDebugActionDelegate implements IDebugEventSetListener, IActionDelegate2 { +public abstract class AbstractListenerActionDelegate extends AbstractDebugActionDelegate + implements IDebugEventSetListener, IActionDelegate2 { /** * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() @@ -34,7 +35,7 @@ public abstract class AbstractListenerActionDelegate extends AbstractDebugAction super.dispose(); DebugPlugin.getDefault().removeDebugEventListener(this); } - + /** * @see IDebugEventSetListener#handleDebugEvents(DebugEvent[]) */ @@ -43,11 +44,11 @@ public abstract class AbstractListenerActionDelegate extends AbstractDebugAction if (getWindow() == null || getAction() == null) { return; } - Shell shell= getWindow().getShell(); + Shell shell = getWindow().getShell(); if (shell == null || shell.isDisposed()) { return; } - Runnable r= new Runnable() { + Runnable r = new Runnable() { @Override public void run() { for (int i = 0; i < events.length; i++) { @@ -57,37 +58,37 @@ public abstract class AbstractListenerActionDelegate extends AbstractDebugAction } } }; - + shell.getDisplay().asyncExec(r); } - + /** * Default implementation to update on specific debug events. * Subclasses should override to handle events differently. */ protected void doHandleDebugEvent(DebugEvent event) { switch (event.getKind()) { - case DebugEvent.TERMINATE : + case DebugEvent.TERMINATE: + update(getAction(), getSelection()); + break; + case DebugEvent.RESUME: + if (!event.isEvaluation() || !((event.getDetail() & DebugEvent.EVALUATION_IMPLICIT) != 0)) { update(getAction(), getSelection()); - break; - case DebugEvent.RESUME : - if (!event.isEvaluation() || !((event.getDetail() & DebugEvent.EVALUATION_IMPLICIT) != 0)) { - update(getAction(), getSelection()); - } - break; - case DebugEvent.SUSPEND : - // Update on suspend events (even for evaluations), in case the user changed - // the selection during an implicit evaluation. - update(getAction(), getSelection()); - break; + } + break; + case DebugEvent.SUSPEND: + // Update on suspend events (even for evaluations), in case the user changed + // the selection during an implicit evaluation. + update(getAction(), getSelection()); + break; } - } + } /** * @see IWorkbenchWindowActionDelegate#init(IWorkbenchWindow) */ @Override - public void init(IWorkbenchWindow window){ + public void init(IWorkbenchWindow window) { super.init(window); DebugPlugin.getDefault().addDebugEventListener(this); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractViewActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractViewActionDelegate.java index 5e2aa8856cc..8c6fc6851e8 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractViewActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractViewActionDelegate.java @@ -40,10 +40,11 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.actions.ActionDelegate; /** - * The superclass for action delegates of views different than the Debug view and + * The superclass for action delegates of views different than the Debug view and * driven by the selection in the Debug view. */ -public abstract class AbstractViewActionDelegate extends ActionDelegate implements IViewActionDelegate, ISelectionListener, INullSelectionListener, IDebugEventSetListener { +public abstract class AbstractViewActionDelegate extends ActionDelegate + implements IViewActionDelegate, ISelectionListener, INullSelectionListener, IDebugEventSetListener { private IAction fAction; @@ -55,16 +56,16 @@ public abstract class AbstractViewActionDelegate extends ActionDelegate implemen * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart) */ @Override - public void init( IViewPart view ) { - setView( view ); - DebugPlugin.getDefault().addDebugEventListener( this ); + public void init(IViewPart view) { + setView(view); + DebugPlugin.getDefault().addDebugEventListener(this); IWorkbenchWindow window = getWindow(); - if ( window != null ) { - window.getSelectionService().addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this ); + if (window != null) { + window.getSelectionService().addSelectionListener(IDebugUIConstants.ID_DEBUG_VIEW, this); } IAdaptable context = DebugUITools.getDebugContext(); - IStructuredSelection ss = ( context != null ) ? new StructuredSelection( context ) : StructuredSelection.EMPTY; - selectionChanged( (IWorkbenchPart)null, ss ); + IStructuredSelection ss = (context != null) ? new StructuredSelection(context) : StructuredSelection.EMPTY; + selectionChanged((IWorkbenchPart) null, ss); } /* (non-Javadoc) @@ -73,10 +74,10 @@ public abstract class AbstractViewActionDelegate extends ActionDelegate implemen @Override public void dispose() { IWorkbenchWindow window = getWindow(); - if ( window != null ) { - window.getSelectionService().removeSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this ); + if (window != null) { + window.getSelectionService().removeSelectionListener(IDebugUIConstants.ID_DEBUG_VIEW, this); } - DebugPlugin.getDefault().removeDebugEventListener( this ); + DebugPlugin.getDefault().removeDebugEventListener(this); super.dispose(); } @@ -84,60 +85,58 @@ public abstract class AbstractViewActionDelegate extends ActionDelegate implemen * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction) */ @Override - public void init( IAction action ) { - setAction( action ); - action.setEnabled( false ); - super.init( action ); + public void init(IAction action) { + setAction(action); + action.setEnabled(false); + super.init(action); } protected IDebugView getView() { return fView; } - private void setView( IViewPart view ) { - fView = (view instanceof IDebugView) ? (IDebugView)view : null; + private void setView(IViewPart view) { + fView = (view instanceof IDebugView) ? (IDebugView) view : null; } /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ @Override - public void run( IAction action ) { - final MultiStatus ms = new MultiStatus( CDebugUIPlugin.getUniqueIdentifier(), DebugException.REQUEST_FAILED, "", null ); //$NON-NLS-1$ - BusyIndicator.showWhile( Display.getCurrent(), new Runnable() { + public void run(IAction action) { + final MultiStatus ms = new MultiStatus(CDebugUIPlugin.getUniqueIdentifier(), DebugException.REQUEST_FAILED, "", //$NON-NLS-1$ + null); + BusyIndicator.showWhile(Display.getCurrent(), new Runnable() { @Override public void run() { try { doAction(); - } - catch( DebugException e ) { - ms.merge( e.getStatus() ); + } catch (DebugException e) { + ms.merge(e.getStatus()); } } - } ); - if ( !ms.isOK() ) { + }); + if (!ms.isOK()) { IWorkbenchWindow window = CDebugUIPlugin.getActiveWorkbenchWindow(); - if ( window != null ) { - CDebugUIPlugin.errorDialog( getErrorDialogMessage(), ms.getChildren()[0] ); - } - else { - CDebugUIPlugin.log( ms ); + if (window != null) { + CDebugUIPlugin.errorDialog(getErrorDialogMessage(), ms.getChildren()[0]); + } else { + CDebugUIPlugin.log(ms); } } } - protected IAction getAction() { return fAction; } - private void setAction( IAction action ) { + private void setAction(IAction action) { fAction = action; } private IWorkbenchWindow getWindow() { - if ( getView() != null ) { + if (getView() != null) { return getView().getViewSite().getWorkbenchWindow(); } return null; @@ -147,8 +146,8 @@ public abstract class AbstractViewActionDelegate extends ActionDelegate implemen * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) */ @Override - public void selectionChanged( IWorkbenchPart part, ISelection selection ) { - setSelection( selection ); + public void selectionChanged(IWorkbenchPart part, ISelection selection) { + setSelection(selection); update(); } @@ -156,42 +155,43 @@ public abstract class AbstractViewActionDelegate extends ActionDelegate implemen return fSelection; } - protected void setSelection( ISelection selection ) { - fSelection = (selection instanceof IStructuredSelection) ? (IStructuredSelection)selection : StructuredSelection.EMPTY; + protected void setSelection(ISelection selection) { + fSelection = (selection instanceof IStructuredSelection) ? (IStructuredSelection) selection + : StructuredSelection.EMPTY; } /* (non-Javadoc) * @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[]) */ @Override - public void handleDebugEvents( final DebugEvent[] events ) { - if ( getWindow() == null || getAction() == null ) { + public void handleDebugEvents(final DebugEvent[] events) { + if (getWindow() == null || getAction() == null) { return; } Shell shell = getWindow().getShell(); - if ( shell == null || shell.isDisposed() ) { + if (shell == null || shell.isDisposed()) { return; } Runnable r = new Runnable() { @Override public void run() { - for( int i = 0; i < events.length; i++ ) { - if ( events[i].getSource() != null ) { - doHandleDebugEvent( events[i] ); + for (int i = 0; i < events.length; i++) { + if (events[i].getSource() != null) { + doHandleDebugEvent(events[i]); } } } }; - shell.getDisplay().asyncExec( r ); + shell.getDisplay().asyncExec(r); } /* (non-Javadoc) * @see org.eclipse.ui.actions.ActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) */ @Override - public void selectionChanged( IAction action, ISelection selection ) { - setSelection( selection ); + public void selectionChanged(IAction action, ISelection selection) { + setSelection(selection); update(); } @@ -203,5 +203,5 @@ public abstract class AbstractViewActionDelegate extends ActionDelegate implemen protected abstract void update(); - protected abstract void doHandleDebugEvent( DebugEvent event ); + protected abstract void doHandleDebugEvent(DebugEvent event); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.java index 0f619a1a0f4..10fe14d820c 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.java @@ -20,16 +20,15 @@ public class ActionMessages { private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.actions.ActionMessages"; //$NON-NLS-1$ - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); private ActionMessages() { } - public static String getString( String key ) { + public static String getString(String key) { try { - return RESOURCE_BUNDLE.getString( key ); - } - catch( MissingResourceException e ) { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { return '!' + key + '!'; } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddExpressionEditorActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddExpressionEditorActionDelegate.java index e7984192361..62bad677210 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddExpressionEditorActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddExpressionEditorActionDelegate.java @@ -11,7 +11,7 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.actions; +package org.eclipse.cdt.debug.internal.ui.actions; import org.eclipse.cdt.debug.ui.CDebugUIPlugin; import org.eclipse.core.runtime.IAdaptable; @@ -33,7 +33,6 @@ import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PartInitException; import org.eclipse.ui.actions.ActionDelegate; - /** * The "Add Expression" action contribution to editors. @@ -41,73 +40,73 @@ import org.eclipse.ui.actions.ActionDelegate; public class AddExpressionEditorActionDelegate extends ActionDelegate implements IEditorActionDelegate { private IEditorPart fEditorPart; - + /* (non-Javadoc) * @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction, org.eclipse.ui.IEditorPart) */ @Override - public void setActiveEditor( IAction action, IEditorPart targetEditor ) { - setEditorPart( targetEditor ); + public void setActiveEditor(IAction action, IEditorPart targetEditor) { + setEditorPart(targetEditor); } private IEditorPart getEditorPart() { return fEditorPart; } - private void setEditorPart( IEditorPart editorPart ) { + private void setEditorPart(IEditorPart editorPart) { fEditorPart = editorPart; } @Override - public void run( IAction action ) { + public void run(IAction action) { String text = getSelectedText(); - ExpressionDialog dlg = new ExpressionDialog( getShell(), text ); - if ( dlg.open() != Window.OK ) + ExpressionDialog dlg = new ExpressionDialog(getShell(), text); + if (dlg.open() != Window.OK) return; - createExpression( dlg.getExpression() ); + createExpression(dlg.getExpression()); activateExpressionView(); } private String getSelectedText() { ISelection selection = getTargetSelection(); - if ( selection != null && selection instanceof ITextSelection ) { - return ((ITextSelection)selection).getText().replaceAll("(\\r\\n|\\n|\\t| )+", " ").trim(); //$NON-NLS-1$ //$NON-NLS-2$; + if (selection != null && selection instanceof ITextSelection) { + return ((ITextSelection) selection).getText().replaceAll("(\\r\\n|\\n|\\t| )+", " ").trim(); //$NON-NLS-1$ //$NON-NLS-2$; } return ""; //$NON-NLS-1$ } protected ISelection getTargetSelection() { IWorkbenchPart part = getEditorPart(); - if ( part != null ) { + if (part != null) { ISelectionProvider provider = part.getSite().getSelectionProvider(); - if ( provider != null ) { + if (provider != null) { return provider.getSelection(); } } return null; } - private void createExpression( String text ) { - IWatchExpression watchExpression= DebugPlugin.getDefault().getExpressionManager().newWatchExpression( text ); - DebugPlugin.getDefault().getExpressionManager().addExpression( watchExpression ); + private void createExpression(String text) { + IWatchExpression watchExpression = DebugPlugin.getDefault().getExpressionManager().newWatchExpression(text); + DebugPlugin.getDefault().getExpressionManager().addExpression(watchExpression); IAdaptable context = DebugUITools.getDebugContext(); - if ( context instanceof IDebugElement ) - watchExpression.setExpressionContext( (IDebugElement)context ); + if (context instanceof IDebugElement) + watchExpression.setExpressionContext((IDebugElement) context); } protected Shell getShell() { - return ( getEditorPart() != null ) ? getEditorPart().getSite().getShell() : CDebugUIPlugin.getActiveWorkbenchShell(); + return (getEditorPart() != null) ? getEditorPart().getSite().getShell() + : CDebugUIPlugin.getActiveWorkbenchShell(); } private void activateExpressionView() { IWorkbenchWindow window = CDebugUIPlugin.getActiveWorkbenchWindow(); - if ( window != null ) { + if (window != null) { IWorkbenchPage page = window.getActivePage(); - if ( page != null ) { + if (page != null) { try { - page.showView( IDebugUIConstants.ID_EXPRESSION_VIEW ); - } - catch( PartInitException e ) { + page.showView(IDebugUIConstants.ID_EXPRESSION_VIEW); + } catch (PartInitException e) { } } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointOnVariableActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointOnVariableActionDelegate.java index f02aeb3472c..7be886e7dde 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointOnVariableActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointOnVariableActionDelegate.java @@ -7,19 +7,20 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.debug.internal.ui.actions; /** - * This class was moved to a public package and this implementation is left here + * This class was moved to a public package and this implementation is left here * for backward compatibility for clients that used this internal class. - * + * * @deprecated Use the {@link org.eclipse.cdt.debug.ui.breakpoints.AddWatchpointOnVariableActionDelegate} * class instead. */ -public class AddWatchpointOnVariableActionDelegate extends org.eclipse.cdt.debug.ui.breakpoints.AddWatchpointOnVariableActionDelegate{ - +public class AddWatchpointOnVariableActionDelegate + extends org.eclipse.cdt.debug.ui.breakpoints.AddWatchpointOnVariableActionDelegate { + } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CastToArrayActionHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CastToArrayActionHandler.java index de8c2269fe8..8aace289b5f 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CastToArrayActionHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CastToArrayActionHandler.java @@ -10,7 +10,7 @@ * * Contributors: * QNX Software Systems - Initial API and implementation - * Nokia - adapt to new command framework + * Nokia - adapt to new command framework *******************************************************************************/ package org.eclipse.cdt.debug.internal.ui.actions; @@ -75,8 +75,8 @@ public class CastToArrayActionHandler extends AbstractHandler { private Text fLengthText; - public CastToArrayDialog( Shell parentShell, String initialType, int initialStart, int initialLength ) { - super( parentShell ); + public CastToArrayDialog(Shell parentShell, String initialType, int initialStart, int initialLength) { + super(parentShell); fType = (initialType == null) ? "" : initialType; //$NON-NLS-1$ fFirstIndex = initialStart; fLength = initialLength; @@ -96,33 +96,33 @@ public class CastToArrayActionHandler extends AbstractHandler { /* * (non-Javadoc) - * + * * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) */ @Override - protected void configureShell( Shell newShell ) { - super.configureShell( newShell ); - newShell.setText( ActionMessages.getString( "CastToArrayActionDelegate.0" ) ); //$NON-NLS-1$ - newShell.setImage( CDebugImages.get( CDebugImages.IMG_LCL_DISPLAY_AS_ARRAY ) ); + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText(ActionMessages.getString("CastToArrayActionDelegate.0")); //$NON-NLS-1$ + newShell.setImage(CDebugImages.get(CDebugImages.IMG_LCL_DISPLAY_AS_ARRAY)); } /* * (non-Javadoc) - * + * * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) */ @Override - protected void createButtonsForButtonBar( Composite parent ) { + protected void createButtonsForButtonBar(Composite parent) { // create OK and Cancel buttons by default - fOkButton = createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true ); - createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false ); + fOkButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); + createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); //do this here because setting the text will set enablement on the ok button /* * fTypeText.setFocus(); if ( fType != null ) { fTypeText.setText( fType ); fTypeText.selectAll(); fFirstIndexText.setText( String.valueOf( * fFirstIndex ) ); fLengthText.setText( String.valueOf( fLength ) ); } */ - fFirstIndexText.setText( String.valueOf( fFirstIndex ) ); - fLengthText.setText( String.valueOf( fLength ) ); + fFirstIndexText.setText(String.valueOf(fFirstIndex)); + fLengthText.setText(String.valueOf(fLength)); } protected Label getErrorMessageLabel() { @@ -131,110 +131,106 @@ public class CastToArrayActionHandler extends AbstractHandler { /* * (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 ); - createDialogFields( composite ); - fErrorMessageLabel = new Label( composite, SWT.NONE ); - fErrorMessageLabel.setLayoutData( new GridData( GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL ) ); - fErrorMessageLabel.setFont( parent.getFont() ); + protected Control createDialogArea(Composite parent) { + Composite composite = (Composite) super.createDialogArea(parent); + createDialogFields(composite); + fErrorMessageLabel = new Label(composite, SWT.NONE); + fErrorMessageLabel.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); + fErrorMessageLabel.setFont(parent.getFont()); return composite; } - private void createDialogFields( Composite parent ) { - Composite composite = ControlFactory.createComposite( parent, 4 ); - ((GridData)composite.getLayoutData()).widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH ); - ((GridLayout)composite.getLayout()).makeColumnsEqualWidth = true; - Label label = ControlFactory.createLabel( composite, ActionMessages.getString( "CastToArrayActionDelegate.1" ) ); //$NON-NLS-1$ - ((GridData)label.getLayoutData()).horizontalSpan = 3; - fFirstIndexText = ControlFactory.createTextField( composite ); - fFirstIndexText.addModifyListener( new ModifyListener() { + private void createDialogFields(Composite parent) { + Composite composite = ControlFactory.createComposite(parent, 4); + ((GridData) composite.getLayoutData()).widthHint = convertHorizontalDLUsToPixels( + IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); + ((GridLayout) composite.getLayout()).makeColumnsEqualWidth = true; + Label label = ControlFactory.createLabel(composite, + ActionMessages.getString("CastToArrayActionDelegate.1")); //$NON-NLS-1$ + ((GridData) label.getLayoutData()).horizontalSpan = 3; + fFirstIndexText = ControlFactory.createTextField(composite); + fFirstIndexText.addModifyListener(new ModifyListener() { @Override - public void modifyText( ModifyEvent e ) { + public void modifyText(ModifyEvent e) { validateInput(); } - } ); - label = ControlFactory.createLabel( composite, ActionMessages.getString( "CastToArrayActionDelegate.2" ) ); //$NON-NLS-1$ - ((GridData)label.getLayoutData()).horizontalSpan = 3; - fLengthText = ControlFactory.createTextField( composite ); - fLengthText.addModifyListener( new ModifyListener() { + }); + label = ControlFactory.createLabel(composite, ActionMessages.getString("CastToArrayActionDelegate.2")); //$NON-NLS-1$ + ((GridData) label.getLayoutData()).horizontalSpan = 3; + fLengthText = ControlFactory.createTextField(composite); + fLengthText.addModifyListener(new ModifyListener() { @Override - public void modifyText( ModifyEvent e ) { + public void modifyText(ModifyEvent e) { validateInput(); } - } ); + }); } protected void validateInput() { boolean enabled = true; String message = ""; //$NON-NLS-1$ String firstIndex = fFirstIndexText.getText().trim(); - if ( firstIndex.length() == 0 ) { - message = ActionMessages.getString( "CastToArrayActionDelegate.3" ); //$NON-NLS-1$ + if (firstIndex.length() == 0) { + message = ActionMessages.getString("CastToArrayActionDelegate.3"); //$NON-NLS-1$ enabled = false; - } - else { + } else { try { - Integer.parseInt( firstIndex ); - } - catch( NumberFormatException e ) { - message = ActionMessages.getString( "CastToArrayActionDelegate.4" ); //$NON-NLS-1$ + Integer.parseInt(firstIndex); + } catch (NumberFormatException e) { + message = ActionMessages.getString("CastToArrayActionDelegate.4"); //$NON-NLS-1$ enabled = false; } - if ( enabled ) { + if (enabled) { String lengthText = fLengthText.getText().trim(); - if ( lengthText.length() == 0 ) { - message = ActionMessages.getString( "CastToArrayActionDelegate.5" ); //$NON-NLS-1$ + if (lengthText.length() == 0) { + message = ActionMessages.getString("CastToArrayActionDelegate.5"); //$NON-NLS-1$ enabled = false; - } - else { + } else { int length = -1; try { - length = Integer.parseInt( lengthText ); - } - catch( NumberFormatException e ) { - message = ActionMessages.getString( "CastToArrayActionDelegate.6" ); //$NON-NLS-1$ + length = Integer.parseInt(lengthText); + } catch (NumberFormatException e) { + message = ActionMessages.getString("CastToArrayActionDelegate.6"); //$NON-NLS-1$ enabled = false; } - if ( enabled && length < 1 ) { - message = ActionMessages.getString( "CastToArrayActionDelegate.7" ); //$NON-NLS-1$ + if (enabled && length < 1) { + message = ActionMessages.getString("CastToArrayActionDelegate.7"); //$NON-NLS-1$ enabled = false; } } } } - fOkButton.setEnabled( enabled ); - getErrorMessageLabel().setText( message ); + fOkButton.setEnabled(enabled); + getErrorMessageLabel().setText(message); } /* * (non-Javadoc) - * + * * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int) */ @Override - protected void buttonPressed( int buttonId ) { - if ( buttonId == IDialogConstants.OK_ID ) { + protected void buttonPressed(int buttonId) { + if (buttonId == IDialogConstants.OK_ID) { String firstIndex = fFirstIndexText.getText().trim(); String lengthText = fLengthText.getText().trim(); try { - fFirstIndex = Integer.parseInt( firstIndex ); - fLength = Integer.parseInt( lengthText ); - } - catch( NumberFormatException e ) { + fFirstIndex = Integer.parseInt(firstIndex); + fLength = Integer.parseInt(lengthText); + } catch (NumberFormatException e) { fFirstIndex = 0; fLength = 0; } - } - else { + } else { fType = null; } - super.buttonPressed( buttonId ); + super.buttonPressed(buttonId); } } @@ -250,33 +246,31 @@ public class CastToArrayActionHandler extends AbstractHandler { @Override public Object execute(ExecutionEvent event) throws ExecutionException { - fTargetPart = HandlerUtil.getActivePartChecked(event); - if ( getCastToArray() == null || getCastToArray().length == 0 ) + fTargetPart = HandlerUtil.getActivePartChecked(event); + if (getCastToArray() == null || getCastToArray().length == 0) return null; - - BusyIndicator.showWhile( Display.getCurrent(), new Runnable() { + + BusyIndicator.showWhile(Display.getCurrent(), new Runnable() { @Override public void run() { try { - doAction( getCastToArray() ); - setStatus( null ); - } - catch( DebugException e ) { - setStatus( e.getStatus() ); + doAction(getCastToArray()); + setStatus(null); + } catch (DebugException e) { + setStatus(e.getStatus()); } } - } ); - if ( getStatus() != null && !getStatus().isOK() ) { + }); + if (getStatus() != null && !getStatus().isOK()) { IWorkbenchWindow window = CDebugUIPlugin.getActiveWorkbenchWindow(); - if ( window != null ) { - CDebugUIPlugin.errorDialog( ActionMessages.getString( "CastToArrayActionDelegate.8" ), getStatus() ); //$NON-NLS-1$ - } - else { - CDebugUIPlugin.log( getStatus() ); + if (window != null) { + CDebugUIPlugin.errorDialog(ActionMessages.getString("CastToArrayActionDelegate.8"), getStatus()); //$NON-NLS-1$ + } else { + CDebugUIPlugin.log(getStatus()); } } - + return null; } @@ -286,31 +280,31 @@ public class CastToArrayActionHandler extends AbstractHandler { setBaseEnabled(castableItems.length > 0); setCastToArray(castableItems); } - + private ICastToArray[] getCastToArray(Object evaluationContext) { List<ICastToArray> castableItems = new ArrayList<ICastToArray>(); - if (evaluationContext instanceof IEvaluationContext) { - Object s = ((IEvaluationContext) evaluationContext).getVariable(ISources.ACTIVE_MENU_SELECTION_NAME); - if (s instanceof IStructuredSelection) { - Iterator<?> iter = ((IStructuredSelection)s).iterator(); - while(iter.hasNext()) { - Object element = DebugPlugin.getAdapter(iter.next(), ICastToArray.class); - if (element instanceof ICastToArray) { - if (((ICastToArray)element).canCastToArray()) { - castableItems.add((ICastToArray)element); - } + if (evaluationContext instanceof IEvaluationContext) { + Object s = ((IEvaluationContext) evaluationContext).getVariable(ISources.ACTIVE_MENU_SELECTION_NAME); + if (s instanceof IStructuredSelection) { + Iterator<?> iter = ((IStructuredSelection) s).iterator(); + while (iter.hasNext()) { + Object element = DebugPlugin.getAdapter(iter.next(), ICastToArray.class); + if (element instanceof ICastToArray) { + if (((ICastToArray) element).canCastToArray()) { + castableItems.add((ICastToArray) element); + } } } } } - return castableItems.toArray(new ICastToArray[castableItems.size()]); + return castableItems.toArray(new ICastToArray[castableItems.size()]); } protected ICastToArray[] getCastToArray() { return fCastableItems; } - protected void setCastToArray( ICastToArray[] castableItems ) { + protected void setCastToArray(ICastToArray[] castableItems) { fCastableItems = castableItems; } @@ -318,25 +312,25 @@ public class CastToArrayActionHandler extends AbstractHandler { return fStatus; } - public void setStatus( IStatus status ) { + public void setStatus(IStatus status) { fStatus = status; } - protected void doAction( ICastToArray[] castableItems ) throws DebugException { + protected void doAction(ICastToArray[] castableItems) throws DebugException { String currentType = castableItems[0].getCurrentType().trim(); - CastToArrayDialog dialog = new CastToArrayDialog( CDebugUIPlugin.getActiveWorkbenchShell(), currentType, 0, 1 ); - if ( dialog.open() == Window.OK ) { + CastToArrayDialog dialog = new CastToArrayDialog(CDebugUIPlugin.getActiveWorkbenchShell(), currentType, 0, 1); + if (dialog.open() == Window.OK) { int firstIndex = dialog.getFirstIndex(); int lastIndex = dialog.getLength(); - for ( ICastToArray castableItem : castableItems ) { - castableItem.castToArray( firstIndex, lastIndex ); + for (ICastToArray castableItem : castableItems) { + castableItem.castToArray(firstIndex, lastIndex); } - if ( getSelectionProvider() != null ) - getSelectionProvider().setSelection( new StructuredSelection( castableItems ) ); + if (getSelectionProvider() != null) + getSelectionProvider().setSelection(new StructuredSelection(castableItems)); } } private ISelectionProvider getSelectionProvider() { - return (fTargetPart instanceof IDebugView) ? ((IDebugView)fTargetPart).getViewer() : null; + return (fTargetPart instanceof IDebugView) ? ((IDebugView) fTargetPart).getViewer() : null; } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CastToTypeActionHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CastToTypeActionHandler.java index c6ee071bc2d..58d73a9f46a 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CastToTypeActionHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CastToTypeActionHandler.java @@ -10,7 +10,7 @@ * * Contributors: * QNX Software Systems - Initial API and implementation - * Nokia - adapt to new command framework + * Nokia - adapt to new command framework *******************************************************************************/ package org.eclipse.cdt.debug.internal.ui.actions; @@ -54,9 +54,9 @@ public class CastToTypeActionHandler extends AbstractHandler { } @Override - public String isValid( String newText ) { - if ( newText.trim().length() == 0 ) { - return ActionMessages.getString( "CastToTypeActionDelegate.0" ); //$NON-NLS-1$ + public String isValid(String newText) { + if (newText.trim().length() == 0) { + return ActionMessages.getString("CastToTypeActionDelegate.0"); //$NON-NLS-1$ } return null; } @@ -64,22 +64,21 @@ public class CastToTypeActionHandler extends AbstractHandler { protected class CastToTypeDialog extends InputDialog { - public CastToTypeDialog( Shell parentShell, String initialValue ) { - super( parentShell, ActionMessages.getString( "CastToTypeActionDelegate.1" ), //$NON-NLS-1$ - ActionMessages.getString( "CastToTypeActionDelegate.2" ), //$NON-NLS-1$ - initialValue, - new CastToTypeInputValidator() ); + public CastToTypeDialog(Shell parentShell, String initialValue) { + super(parentShell, ActionMessages.getString("CastToTypeActionDelegate.1"), //$NON-NLS-1$ + ActionMessages.getString("CastToTypeActionDelegate.2"), //$NON-NLS-1$ + initialValue, new CastToTypeInputValidator()); } /* * (non-Javadoc) - * + * * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) */ @Override - protected void configureShell( Shell shell ) { - super.configureShell( shell ); - shell.setImage( CDebugImages.get( CDebugImages.IMG_LCL_CAST_TO_TYPE ) ); + protected void configureShell(Shell shell) { + super.configureShell(shell); + shell.setImage(CDebugImages.get(CDebugImages.IMG_LCL_CAST_TO_TYPE)); } } @@ -95,68 +94,66 @@ public class CastToTypeActionHandler extends AbstractHandler { @Override public Object execute(ExecutionEvent event) throws ExecutionException { - fTargetPart = HandlerUtil.getActivePartChecked(event); - - if ( getCastToType() == null || getCastToType().length == 0 ) + fTargetPart = HandlerUtil.getActivePartChecked(event); + + if (getCastToType() == null || getCastToType().length == 0) return null; - - BusyIndicator.showWhile( Display.getCurrent(), new Runnable() { + + BusyIndicator.showWhile(Display.getCurrent(), new Runnable() { @Override public void run() { try { - doAction( getCastToType() ); - setStatus( null ); - } - catch( DebugException e ) { - setStatus( e.getStatus() ); + doAction(getCastToType()); + setStatus(null); + } catch (DebugException e) { + setStatus(e.getStatus()); } } - } ); - if ( getStatus() != null && !getStatus().isOK() ) { + }); + if (getStatus() != null && !getStatus().isOK()) { IWorkbenchWindow window = CDebugUIPlugin.getActiveWorkbenchWindow(); - if ( window != null ) { - CDebugUIPlugin.errorDialog( ActionMessages.getString( "CastToTypeActionDelegate.3" ), getStatus() ); //$NON-NLS-1$ - } - else { - CDebugUIPlugin.log( getStatus() ); + if (window != null) { + CDebugUIPlugin.errorDialog(ActionMessages.getString("CastToTypeActionDelegate.3"), getStatus()); //$NON-NLS-1$ + } else { + CDebugUIPlugin.log(getStatus()); } } - + return null; } - + @Override public void setEnabled(Object evaluationContext) { ICastToType[] castableItems = getCastToType(evaluationContext); setBaseEnabled(castableItems.length > 0); setCastToType(castableItems); } - + private ICastToType[] getCastToType(Object evaluationContext) { - List<ICastToType> castableItems = new ArrayList<ICastToType>(); - if (evaluationContext instanceof IEvaluationContext) { - Object s = ((IEvaluationContext) evaluationContext).getVariable(ISources.ACTIVE_MENU_SELECTION_NAME); - if (s instanceof IStructuredSelection) { - Iterator<?> iter = ((IStructuredSelection)s).iterator(); - while(iter.hasNext()) { - Object element = DebugPlugin.getAdapter(iter.next(), ICastToType.class); - if (element instanceof ICastToType) { - if (((ICastToType)element).canCast()) { - castableItems.add((ICastToType)element); - } - } - } - } - } - return castableItems.toArray(new ICastToType[castableItems.size()]); + List<ICastToType> castableItems = new ArrayList<ICastToType>(); + if (evaluationContext instanceof IEvaluationContext) { + Object s = ((IEvaluationContext) evaluationContext).getVariable(ISources.ACTIVE_MENU_SELECTION_NAME); + if (s instanceof IStructuredSelection) { + Iterator<?> iter = ((IStructuredSelection) s).iterator(); + while (iter.hasNext()) { + Object element = DebugPlugin.getAdapter(iter.next(), ICastToType.class); + if (element instanceof ICastToType) { + if (((ICastToType) element).canCast()) { + castableItems.add((ICastToType) element); + } + } + } + } + } + return castableItems.toArray(new ICastToType[castableItems.size()]); } protected ICastToType[] getCastToType() { return fCastableItems; } - protected void setCastToType( ICastToType[] castableItems ) { + protected void setCastToType(ICastToType[] castableItems) { fCastableItems = castableItems; } @@ -164,24 +161,24 @@ public class CastToTypeActionHandler extends AbstractHandler { return fStatus; } - public void setStatus( IStatus status ) { + public void setStatus(IStatus status) { fStatus = status; } - protected void doAction( ICastToType[] castableItems ) throws DebugException { + protected void doAction(ICastToType[] castableItems) throws DebugException { String currentType = castableItems[0].getCurrentType().trim(); - CastToTypeDialog dialog = new CastToTypeDialog( CDebugUIPlugin.getActiveWorkbenchShell(), currentType ); - if ( dialog.open() == Window.OK ) { + CastToTypeDialog dialog = new CastToTypeDialog(CDebugUIPlugin.getActiveWorkbenchShell(), currentType); + if (dialog.open() == Window.OK) { String newType = dialog.getValue().trim(); - for ( ICastToType castableItem : castableItems ) { - castableItem.cast( newType ); + for (ICastToType castableItem : castableItems) { + castableItem.cast(newType); } - if ( getSelectionProvider() != null ) - getSelectionProvider().setSelection( new StructuredSelection( castableItems ) ); + if (getSelectionProvider() != null) + getSelectionProvider().setSelection(new StructuredSelection(castableItems)); } } private ISelectionProvider getSelectionProvider() { - return (fTargetPart instanceof IDebugView) ? ((IDebugView)fTargetPart).getViewer() : null; + return (fTargetPart instanceof IDebugView) ? ((IDebugView) fTargetPart).getViewer() : null; } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CollapseAllModulesAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CollapseAllModulesAction.java index 851e2f1a009..881ca26c891 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CollapseAllModulesAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CollapseAllModulesAction.java @@ -11,7 +11,7 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.actions; +package org.eclipse.cdt.debug.internal.ui.actions; import org.eclipse.core.runtime.Assert; import org.eclipse.debug.ui.IDebugView; @@ -21,7 +21,7 @@ import org.eclipse.jface.viewers.Viewer; import org.eclipse.ui.IViewActionDelegate; import org.eclipse.ui.IViewPart; import org.eclipse.ui.actions.ActionDelegate; - + /** * The delegate for the "Collapse All" action of the Modules view. */ @@ -33,21 +33,21 @@ public class CollapseAllModulesAction extends ActionDelegate implements IViewAct * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart) */ @Override - public void init( IViewPart view ) { - Assert.isLegal( view instanceof IDebugView ); - fView = (IDebugView)view; + public void init(IViewPart view) { + Assert.isLegal(view instanceof IDebugView); + fView = (IDebugView) view; } /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ @Override - public void run( IAction action ) { + public void run(IAction action) { Viewer viewer = getView().getViewer(); - if ( viewer instanceof TreeViewer ) { - viewer.getControl().setRedraw( false ); - ((TreeViewer)viewer).collapseAll(); - viewer.getControl().setRedraw( true ); + if (viewer instanceof TreeViewer) { + viewer.getControl().setRedraw(false); + ((TreeViewer) viewer).collapseAll(); + viewer.getControl().setRedraw(true); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ConfigureColumnsAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ConfigureColumnsAction.java index fdb0865ab42..8cc5758f907 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ConfigureColumnsAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ConfigureColumnsAction.java @@ -36,114 +36,114 @@ import org.eclipse.ui.texteditor.IUpdate; /** * Configures visible columns in an asynch tree viewer/ - * + * * @since 5.0 */ public class ConfigureColumnsAction extends Action implements IUpdate { - private TreeModelViewer fViewer; + private TreeModelViewer fViewer; - class ColumnContentProvider implements IStructuredContentProvider { + class ColumnContentProvider implements IStructuredContentProvider { - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) - */ - @Override - public Object[] getElements( Object inputElement ) { - return ((IColumnPresentation)inputElement).getAvailableColumns(); - } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) + */ + @Override + public Object[] getElements(Object inputElement) { + return ((IColumnPresentation) inputElement).getAvailableColumns(); + } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IContentProvider#dispose() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IContentProvider#dispose() + */ + @Override public void 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 ) { - } - } - - class ColumnLabelProvider extends LabelProvider { - - private Map<ImageDescriptor, Image> fImages = new HashMap<>(); - - @Override - public Image getImage( Object element ) { - ImageDescriptor imageDescriptor = fViewer.getColumnPresentation().getImageDescriptor( (String)element ); - if ( imageDescriptor != null ) { - Image image = fImages.get( imageDescriptor ); - if ( image == null ) { - image = imageDescriptor.createImage(); - fImages.put( imageDescriptor, image ); - } - return image; - } - return null; - } - - @Override - public String getText( Object element ) { - return fViewer.getColumnPresentation().getHeader( (String)element ); - } - - @Override + } + + /* (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) { + } + } + + class ColumnLabelProvider extends LabelProvider { + + private Map<ImageDescriptor, Image> fImages = new HashMap<>(); + + @Override + public Image getImage(Object element) { + ImageDescriptor imageDescriptor = fViewer.getColumnPresentation().getImageDescriptor((String) element); + if (imageDescriptor != null) { + Image image = fImages.get(imageDescriptor); + if (image == null) { + image = imageDescriptor.createImage(); + fImages.put(imageDescriptor, image); + } + return image; + } + return null; + } + + @Override + public String getText(Object element) { + return fViewer.getColumnPresentation().getHeader((String) element); + } + + @Override public void dispose() { - super.dispose(); - Iterator<Image> iterator = fImages.values().iterator(); - while( iterator.hasNext() ) { - Image image = iterator.next(); - image.dispose(); - } - fImages.clear(); - } - } - - public ConfigureColumnsAction( TreeModelViewer viewer ) { - setText( "Select &Columns..." ); - setId( CDebugUIPlugin.getUniqueIdentifier() + ".ConfigureColumnsAction" ); //$NON-NLS-1$ - PlatformUI.getWorkbench().getHelpSystem().setHelp( this, ICDebugHelpContextIds.CONFIGURE_COLUMNS_ACTION ); - fViewer = viewer; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.texteditor.IUpdate#update() - */ - @Override + super.dispose(); + Iterator<Image> iterator = fImages.values().iterator(); + while (iterator.hasNext()) { + Image image = iterator.next(); + image.dispose(); + } + fImages.clear(); + } + } + + public ConfigureColumnsAction(TreeModelViewer viewer) { + setText("Select &Columns..."); + setId(CDebugUIPlugin.getUniqueIdentifier() + ".ConfigureColumnsAction"); //$NON-NLS-1$ + PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICDebugHelpContextIds.CONFIGURE_COLUMNS_ACTION); + fViewer = viewer; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.texteditor.IUpdate#update() + */ + @Override public void update() { - setEnabled( fViewer.isShowColumns() ); - } + setEnabled(fViewer.isShowColumns()); + } - /* (non-Javadoc) - * @see org.eclipse.jface.action.Action#run() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.jface.action.Action#run() + */ + @Override public void run() { - ListSelectionDialog dialog = new ListSelectionDialog( fViewer.getControl().getShell(), fViewer.getColumnPresentation(), new ColumnContentProvider(), - new ColumnLabelProvider(), "Select the &columns to display:" ); - PlatformUI.getWorkbench().getHelpSystem().setHelp( this, ICDebugHelpContextIds.CONFIGURE_COLUMNS_DIALOG ); - String[] visibleColumns = fViewer.getVisibleColumns(); - List<String> initialSelection = new ArrayList<>( visibleColumns.length ); - for( int i = 0; i < visibleColumns.length; i++ ) { - initialSelection.add( visibleColumns[i] ); - } - dialog.setTitle( "Select Columns" ); - dialog.setInitialElementSelections( initialSelection ); - if ( dialog.open() == Window.OK ) { - Object[] result = dialog.getResult(); - if ( result.length == 0 ) { - fViewer.setShowColumns( false ); - } - else { - String[] ids = new String[result.length]; - System.arraycopy( result, 0, ids, 0, result.length ); - fViewer.resetColumnSizes( ids ); - fViewer.setVisibleColumns( ids ); - } - } - } + ListSelectionDialog dialog = new ListSelectionDialog(fViewer.getControl().getShell(), + fViewer.getColumnPresentation(), new ColumnContentProvider(), new ColumnLabelProvider(), + "Select the &columns to display:"); + PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICDebugHelpContextIds.CONFIGURE_COLUMNS_DIALOG); + String[] visibleColumns = fViewer.getVisibleColumns(); + List<String> initialSelection = new ArrayList<>(visibleColumns.length); + for (int i = 0; i < visibleColumns.length; i++) { + initialSelection.add(visibleColumns[i]); + } + dialog.setTitle("Select Columns"); + dialog.setInitialElementSelections(initialSelection); + if (dialog.open() == Window.OK) { + Object[] result = dialog.getResult(); + if (result.length == 0) { + fViewer.setShowColumns(false); + } else { + String[] ids = new String[result.length]; + System.arraycopy(result, 0, ids, 0, result.length); + fViewer.resetColumnSizes(ids); + fViewer.setVisibleColumns(ids); + } + } + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ExpressionDialog.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ExpressionDialog.java index f550e517b5f..12264d90c54 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ExpressionDialog.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ExpressionDialog.java @@ -43,87 +43,87 @@ public class ExpressionDialog extends Dialog { /** * Constructor for ExpressionDialog. - * + * * @param parentShell */ - public ExpressionDialog( Shell parentShell, String expression ) { - super( parentShell ); + public ExpressionDialog(Shell parentShell, String expression) { + super(parentShell); setShellStyle(getShellStyle() | SWT.RESIZE); - if ( expression != null ) + if (expression != null) fExpression = expression; } @Override - protected void configureShell( Shell shell ) { - super.configureShell( shell ); - shell.setText( ActionMessages.getString( "ExpressionDialog.0" ) ); //$NON-NLS-1$ - shell.setImage( DebugUITools.getImage( IDebugUIConstants.IMG_OBJS_EXPRESSION ) ); + protected void configureShell(Shell shell) { + super.configureShell(shell); + shell.setText(ActionMessages.getString("ExpressionDialog.0")); //$NON-NLS-1$ + shell.setImage(DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_EXPRESSION)); } @Override - protected Control createContents( Composite parent ) { - Control control = super.createContents( parent ); + protected Control createContents(Composite parent) { + Control control = super.createContents(parent); setOkButtonState(); return control; } @Override - protected Control createDialogArea( Composite parent ) { - Composite composite = new Composite( parent, SWT.NONE ); - composite.setLayout( new GridLayout() ); - ((GridLayout)composite.getLayout()).marginWidth = 10; - composite.setLayoutData( new GridData( GridData.FILL_BOTH ) ); - createDataWidgets( composite ); + protected Control createDialogArea(Composite parent) { + Composite composite = new Composite(parent, SWT.NONE); + composite.setLayout(new GridLayout()); + ((GridLayout) composite.getLayout()).marginWidth = 10; + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + createDataWidgets(composite); initializeDataWidgets(); return composite; } @Override - protected void createButtonsForButtonBar( Composite parent ) { - fBtnOk = createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true ); - createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false ); + protected void createButtonsForButtonBar(Composite parent) { + fBtnOk = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); + createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); } - private void createDataWidgets( Composite parent ) { - fTextExpression = createExpressionText( parent ); + private void createDataWidgets(Composite parent) { + fTextExpression = createExpressionText(parent); } private void initializeDataWidgets() { - fTextExpression.setText( fExpression ); - fTextExpression.setSelection( fExpression.length() ); + fTextExpression.setText(fExpression); + fTextExpression.setSelection(fExpression.length()); fTextExpression.selectAll(); setOkButtonState(); } - private Text createExpressionText( Composite parent ) { - Label label = new Label( parent, SWT.RIGHT ); - label.setText( ActionMessages.getString( "ExpressionDialog.1" ) ); //$NON-NLS-1$ - final Text text = new Text( parent, SWT.BORDER ); - GridData gridData = new GridData( GridData.FILL_HORIZONTAL ); + private Text createExpressionText(Composite parent) { + Label label = new Label(parent, SWT.RIGHT); + label.setText(ActionMessages.getString("ExpressionDialog.1")); //$NON-NLS-1$ + final Text text = new Text(parent, SWT.BORDER); + GridData gridData = new GridData(GridData.FILL_HORIZONTAL); gridData.widthHint = 300; - text.setLayoutData( gridData ); - addModifyListener( text ); + text.setLayoutData(gridData); + addModifyListener(text); return text; } protected void setOkButtonState() { - if ( fBtnOk == null ) + if (fBtnOk == null) return; - fBtnOk.setEnabled( fTextExpression.getText().trim().length() > 0 ); + fBtnOk.setEnabled(fTextExpression.getText().trim().length() > 0); } private void storeData() { fExpression = fTextExpression.getText().trim(); } - private void addModifyListener( Text text ) { - text.addModifyListener( new ModifyListener() { + private void addModifyListener(Text text) { + text.addModifyListener(new ModifyListener() { @Override - public void modifyText( ModifyEvent e ) { + public void modifyText(ModifyEvent e) { setOkButtonState(); } - } ); + }); } public String getExpression() { @@ -132,7 +132,7 @@ public class ExpressionDialog extends Dialog { /* * (non-Javadoc) - * + * * @see org.eclipse.jface.dialogs.Dialog#okPressed() */ @Override diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/IMoveToLineTarget.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/IMoveToLineTarget.java index 711f7f283ed..d625abe5864 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/IMoveToLineTarget.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/IMoveToLineTarget.java @@ -11,36 +11,36 @@ * Contributors: * Freescale Semiconductor - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.actions; +package org.eclipse.cdt.debug.internal.ui.actions; import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.model.ISuspendResume; import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.IWorkbenchPart; - + /** * An adapter for a "move to line" operation. */ public interface IMoveToLineTarget { /** - * Perform a move to line operation on the given element that is + * Perform a move to line operation on the given element that is * currently selected and suspended in the Debug view. - * + * * @param part the part on which the action has been invoked * @param selection the selection on which the action has been invoked * @param target suspended element to perform the "resume at line" action on - * @throws CoreException if unable to perform the action + * @throws CoreException if unable to perform the action */ - public void moveToLine( IWorkbenchPart part, ISelection selection, ISuspendResume target ) throws CoreException; + public void moveToLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) throws CoreException; /** * Returns whether a move to line operation can be performed on the given * element that is currently selected and suspended in the Debug view. - * + * * @param part the part on which the action has been invoked * @param selection the selection on which the action has been invoked * @param target suspended element to perform the "resume at line" action on - * @throws CoreException if unable to perform the action + * @throws CoreException if unable to perform the action */ - public boolean canMoveToLine( IWorkbenchPart part, ISelection selection, ISuspendResume target ); + public boolean canMoveToLine(IWorkbenchPart part, ISelection selection, ISuspendResume target); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/IResumeAtLineTarget.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/IResumeAtLineTarget.java index aad9192595c..fb1d82f173f 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/IResumeAtLineTarget.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/IResumeAtLineTarget.java @@ -11,36 +11,36 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.actions; +package org.eclipse.cdt.debug.internal.ui.actions; import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.model.ISuspendResume; import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.IWorkbenchPart; - + /** * An adapter for a "resume at line" operation. */ public interface IResumeAtLineTarget { /** - * Perform a resume at line operation on the given element that is + * Perform a resume at line operation on the given element that is * currently selected and suspended in the Debug view. - * + * * @param part the part on which the action has been invoked * @param selection the selection on which the action has been invoked * @param target suspended element to perform the "resume at line" action on - * @throws CoreException if unable to perform the action + * @throws CoreException if unable to perform the action */ - public void resumeAtLine( IWorkbenchPart part, ISelection selection, ISuspendResume target ) throws CoreException; + public void resumeAtLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) throws CoreException; /** * Returns whether a resume at line operation can be performed on the given * element that is currently selected and suspended in the Debug view. - * + * * @param part the part on which the action has been invoked * @param selection the selection on which the action has been invoked * @param target suspended element to perform the "resume at line" action on - * @throws CoreException if unable to perform the action + * @throws CoreException if unable to perform the action */ - public boolean canResumeAtLine( IWorkbenchPart part, ISelection selection, ISuspendResume target ); + public boolean canResumeAtLine(IWorkbenchPart part, ISelection selection, ISuspendResume target); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/LoadModuleSymbolsActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/LoadModuleSymbolsActionDelegate.java index d8c95e57dbe..7e261e574ec 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/LoadModuleSymbolsActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/LoadModuleSymbolsActionDelegate.java @@ -40,14 +40,14 @@ public class LoadModuleSymbolsActionDelegate extends ActionDelegate implements I * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart) */ @Override - public void setActivePart( IAction action, IWorkbenchPart targetPart ) { + public void setActivePart(IAction action, IWorkbenchPart targetPart) { } protected ICModule getModule() { return fModule; } - private void setModule( ICModule module ) { + private void setModule(ICModule module) { fModule = module; } @@ -55,26 +55,24 @@ public class LoadModuleSymbolsActionDelegate extends ActionDelegate implements I * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ @Override - public void run( IAction action ) { - final ICModule module = getModule(); - if ( module != null ) { - - DebugPlugin.getDefault().asyncExec( - new Runnable() { - @Override - public void run() { - try { - doAction( module ); - } - catch( DebugException e ) { - failed( e ); - } - } - } ); + public void run(IAction action) { + final ICModule module = getModule(); + if (module != null) { + + DebugPlugin.getDefault().asyncExec(new Runnable() { + @Override + public void run() { + try { + doAction(module); + } catch (DebugException e) { + failed(e); + } + } + }); } } - protected void doAction( ICModule module ) throws DebugException { + protected void doAction(ICModule module) throws DebugException { module.loadSymbols(); } @@ -82,31 +80,34 @@ public class LoadModuleSymbolsActionDelegate extends ActionDelegate implements I * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) */ @Override - public void selectionChanged( IAction action, ISelection selection ) { - if ( selection instanceof IStructuredSelection ) { - if ( ((IStructuredSelection)selection).size() == 1 ) { - Object element = ((IStructuredSelection)selection).getFirstElement(); - if ( element instanceof ICModule ) { - boolean enabled = enablesFor( (ICModule)element ); - action.setEnabled( enabled ); - if ( enabled ) { - setModule( (ICModule)element ); + public void selectionChanged(IAction action, ISelection selection) { + if (selection instanceof IStructuredSelection) { + if (((IStructuredSelection) selection).size() == 1) { + Object element = ((IStructuredSelection) selection).getFirstElement(); + if (element instanceof ICModule) { + boolean enabled = enablesFor((ICModule) element); + action.setEnabled(enabled); + if (enabled) { + setModule((ICModule) element); return; } } } } - action.setEnabled( false ); - setModule( null ); + action.setEnabled(false); + setModule(null); } - private boolean enablesFor( ICModule module ) { - return ( module != null && module.canLoadSymbols() ); + private boolean enablesFor(ICModule module) { + return (module != null && module.canLoadSymbols()); } - protected void failed( Throwable e ) { - MultiStatus ms = new MultiStatus( CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, ActionMessages.getString( "LoadModuleSymbolsActionDelegate.0" ), null ); //$NON-NLS-1$ - ms.add( new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, e.getMessage(), null ) ); - CDebugUtils.error( ms, getModule() ); + protected void failed(Throwable e) { + MultiStatus ms = new MultiStatus(CDIDebugModel.getPluginIdentifier(), + ICDebugInternalConstants.STATUS_CODE_ERROR, + ActionMessages.getString("LoadModuleSymbolsActionDelegate.0"), null); //$NON-NLS-1$ + ms.add(new Status(IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), + ICDebugInternalConstants.STATUS_CODE_ERROR, e.getMessage(), null)); + CDebugUtils.error(ms, getModule()); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ModulesPropertiesActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ModulesPropertiesActionDelegate.java index d5fc38a6978..1332a234ecc 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ModulesPropertiesActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ModulesPropertiesActionDelegate.java @@ -11,7 +11,7 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.actions; +package org.eclipse.cdt.debug.internal.ui.actions; import org.eclipse.cdt.debug.core.model.ICModule; import org.eclipse.jface.action.IAction; @@ -34,8 +34,8 @@ public class ModulesPropertiesActionDelegate extends ActionDelegate implements I private IWorkbenchPart fTargetPart; - /** - * Constructor for ModulesPropertiesActionDelegate. + /** + * Constructor for ModulesPropertiesActionDelegate. */ public ModulesPropertiesActionDelegate() { super(); @@ -45,7 +45,7 @@ public class ModulesPropertiesActionDelegate extends ActionDelegate implements I return fModule; } - private void setModule( ICModule module ) { + private void setModule(ICModule module) { fModule = module; } @@ -53,7 +53,7 @@ public class ModulesPropertiesActionDelegate extends ActionDelegate implements I * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart) */ @Override - public void setActivePart( IAction action, IWorkbenchPart targetPart ) { + public void setActivePart(IAction action, IWorkbenchPart targetPart) { fTargetPart = targetPart; } @@ -61,26 +61,27 @@ public class ModulesPropertiesActionDelegate extends ActionDelegate implements I * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ @Override - public void run( IAction action ) { - PropertyDialogAction propertyAction = new PropertyDialogAction( getActivePart().getSite(), new ISelectionProvider() { + public void run(IAction action) { + PropertyDialogAction propertyAction = new PropertyDialogAction(getActivePart().getSite(), + new ISelectionProvider() { - @Override - public void addSelectionChangedListener( ISelectionChangedListener listener ) { - } + @Override + public void addSelectionChangedListener(ISelectionChangedListener listener) { + } - @Override - public ISelection getSelection() { - return new StructuredSelection( getModule() ); - } + @Override + public ISelection getSelection() { + return new StructuredSelection(getModule()); + } - @Override - public void removeSelectionChangedListener( ISelectionChangedListener listener ) { - } + @Override + public void removeSelectionChangedListener(ISelectionChangedListener listener) { + } - @Override - public void setSelection( ISelection selection ) { - } - } ); + @Override + public void setSelection(ISelection selection) { + } + }); propertyAction.run(); } @@ -88,17 +89,17 @@ public class ModulesPropertiesActionDelegate extends ActionDelegate implements I * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) */ @Override - public void selectionChanged( IAction action, ISelection selection ) { - if ( selection instanceof IStructuredSelection ) { - Object element = ((IStructuredSelection)selection).getFirstElement(); - if ( element instanceof ICModule ) { - action.setEnabled( true ); - setModule( (ICModule)element ); + public void selectionChanged(IAction action, ISelection selection) { + if (selection instanceof IStructuredSelection) { + Object element = ((IStructuredSelection) selection).getFirstElement(); + if (element instanceof ICModule) { + action.setEnabled(true); + setModule((ICModule) element); return; } } - action.setEnabled( false ); - setModule( null ); + action.setEnabled(false); + setModule(null); } protected IWorkbenchPart getActivePart() { diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/MoveToLineActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/MoveToLineActionDelegate.java index e00359fbd2f..ee1f41b6568 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/MoveToLineActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/MoveToLineActionDelegate.java @@ -12,7 +12,7 @@ * Freescale Semiconductor - Initial API and implementation * Ericsson - Updated to latest platform code *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.actions; +package org.eclipse.cdt.debug.internal.ui.actions; import org.eclipse.cdt.debug.ui.CDebugUIPlugin; import org.eclipse.core.runtime.CoreException; @@ -39,20 +39,20 @@ import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPartSite; import org.eclipse.ui.IWorkbenchWindow; - + /** * A move to line action that can be contributed to a an editor. The action * will perform the "move to line" operation for editors that provide * an appropriate <code>IMoveToLineTarget</code> adapter. */ public class MoveToLineActionDelegate implements IEditorActionDelegate, IActionDelegate2, IViewActionDelegate { - + private IWorkbenchPart fActivePart = null; private IMoveToLineTarget fPartTarget = null; private IAction fAction = null; private DebugContextListener fContextListener = new DebugContextListener(); private ISuspendResume fTargetElement = null; - + class DebugContextListener implements IDebugContextListener { protected void contextActivated(ISelection selection) { @@ -60,8 +60,8 @@ public class MoveToLineActionDelegate implements IEditorActionDelegate, IActionD if (selection instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection) selection; if (ss.size() == 1) { - fTargetElement = (ISuspendResume) - DebugPlugin.getAdapter(ss.getFirstElement(), ISuspendResume.class); + fTargetElement = (ISuspendResume) DebugPlugin.getAdapter(ss.getFirstElement(), + ISuspendResume.class); } } update(); @@ -71,19 +71,21 @@ public class MoveToLineActionDelegate implements IEditorActionDelegate, IActionD public void debugContextChanged(DebugContextEvent event) { contextActivated(event.getContext()); } - - } - + + } + /*(non-Javadoc) * @see org.eclipse.ui.IActionDelegate2#dispose() */ @Override public void dispose() { - DebugUITools.getDebugContextManager().getContextService(fActivePart.getSite().getWorkbenchWindow()).removeDebugContextListener(fContextListener); + DebugUITools.getDebugContextManager().getContextService(fActivePart.getSite().getWorkbenchWindow()) + .removeDebugContextListener(fContextListener); fActivePart = null; fPartTarget = null; - + } + /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ @@ -91,12 +93,16 @@ public class MoveToLineActionDelegate implements IEditorActionDelegate, IActionD public void run(IAction action) { if (fPartTarget != null && fTargetElement != null) { try { - fPartTarget.moveToLine(fActivePart, fActivePart.getSite().getSelectionProvider().getSelection(), fTargetElement); + fPartTarget.moveToLine(fActivePart, fActivePart.getSite().getSelectionProvider().getSelection(), + fTargetElement); } catch (CoreException e) { - ErrorDialog.openError( fActivePart.getSite().getWorkbenchWindow().getShell(), ActionMessages.getString( "MoveToLineActionDelegate.1" ), ActionMessages.getString( "MoveToLineActionDelegate.2" ), e.getStatus() ); //$NON-NLS-1$ //$NON-NLS-2$ + ErrorDialog.openError(fActivePart.getSite().getWorkbenchWindow().getShell(), + ActionMessages.getString("MoveToLineActionDelegate.1"), //$NON-NLS-1$ + ActionMessages.getString("MoveToLineActionDelegate.2"), e.getStatus()); //$NON-NLS-1$ } } } + /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) */ @@ -105,7 +111,7 @@ public class MoveToLineActionDelegate implements IEditorActionDelegate, IActionD this.fAction = action; update(); } - + /* (non-Javadoc) * @see org.eclipse.ui.texteditor.IUpdate#update() */ @@ -120,26 +126,28 @@ public class MoveToLineActionDelegate implements IEditorActionDelegate, IActionD if (fPartTarget != null && fTargetElement != null) { IWorkbenchPartSite site = fActivePart.getSite(); if (site != null) { - ISelectionProvider selectionProvider = site.getSelectionProvider(); - if (selectionProvider != null) { - ISelection selection = selectionProvider.getSelection(); - enabled = fTargetElement.isSuspended() && fPartTarget.canMoveToLine(fActivePart, selection, fTargetElement); - } + ISelectionProvider selectionProvider = site.getSelectionProvider(); + if (selectionProvider != null) { + ISelection selection = selectionProvider.getSelection(); + enabled = fTargetElement.isSuspended() + && fPartTarget.canMoveToLine(fActivePart, selection, fTargetElement); + } } } - fAction.setEnabled(enabled); + fAction.setEnabled(enabled); } }; CDebugUIPlugin.getStandardDisplay().asyncExec(r); } - + /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction) */ @Override public void init(IAction action) { - this.fAction = action; + this.fAction = action; } + /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event) */ @@ -147,15 +155,16 @@ public class MoveToLineActionDelegate implements IEditorActionDelegate, IActionD public void runWithEvent(IAction action, Event event) { run(action); } + /* (non-Javadoc) * @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction, org.eclipse.ui.IEditorPart) */ @Override public void setActiveEditor(IAction action, IEditorPart targetEditor) { init(action); - bindTo(targetEditor); + bindTo(targetEditor); } - + /* (non-Javadoc) * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart) */ @@ -163,16 +172,17 @@ public class MoveToLineActionDelegate implements IEditorActionDelegate, IActionD public void init(IViewPart view) { bindTo(view); } - + /** * Binds this action to operate on the given part's IMoveToLineTarget adapter. - * + * * @param part */ private void bindTo(IWorkbenchPart part) { IDebugContextManager manager = DebugUITools.getDebugContextManager(); if (fActivePart != null && !fActivePart.equals(part)) { - manager.getContextService(fActivePart.getSite().getWorkbenchWindow()).removeDebugContextListener(fContextListener); + manager.getContextService(fActivePart.getSite().getWorkbenchWindow()) + .removeDebugContextListener(fContextListener); } fPartTarget = null; fActivePart = part; @@ -180,17 +190,18 @@ public class MoveToLineActionDelegate implements IEditorActionDelegate, IActionD IWorkbenchWindow workbenchWindow = part.getSite().getWorkbenchWindow(); IDebugContextService service = manager.getContextService(workbenchWindow); service.addDebugContextListener(fContextListener); - fPartTarget = part.getAdapter(IMoveToLineTarget.class); + fPartTarget = part.getAdapter(IMoveToLineTarget.class); if (fPartTarget == null) { IAdapterManager adapterManager = Platform.getAdapterManager(); // TODO: we could restrict loading to cases when the debugging context is on if (adapterManager.hasAdapter(part, IMoveToLineTarget.class.getName())) { - fPartTarget = (IMoveToLineTarget) adapterManager.loadAdapter(part, IMoveToLineTarget.class.getName()); + fPartTarget = (IMoveToLineTarget) adapterManager.loadAdapter(part, + IMoveToLineTarget.class.getName()); } } ISelection activeContext = service.getActiveContext(); fContextListener.contextActivated(activeContext); } - update(); + update(); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/MoveToLineAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/MoveToLineAdapter.java index 94ad7e07958..bf91273f9ad 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/MoveToLineAdapter.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/MoveToLineAdapter.java @@ -48,103 +48,101 @@ public class MoveToLineAdapter implements IMoveToLineTarget { * @see org.eclipse.cdt.debug.internal.ui.actions.IMoveToLineTarget#moveToLine(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection, org.eclipse.debug.core.model.ISuspendResume) */ @Override - public void moveToLine( IWorkbenchPart part, ISelection selection, ISuspendResume target ) throws CoreException { + public void moveToLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) throws CoreException { String errorMessage = null; - if ( part instanceof ITextEditor ) { - ITextEditor textEditor = (ITextEditor)part; + if (part instanceof ITextEditor) { + ITextEditor textEditor = (ITextEditor) part; IEditorInput input = textEditor.getEditorInput(); - if ( input == null ) { - errorMessage = ActionMessages.getString( "MoveToLineAdapter.0" ); //$NON-NLS-1$ - } - else { - IDocument document = textEditor.getDocumentProvider().getDocument( input ); - if ( document == null ) { - errorMessage = ActionMessages.getString( "MoveToLineAdapter.1" ); //$NON-NLS-1$ - } - else { - final String fileName = getFileName( input ); - ITextSelection textSelection = (ITextSelection)selection; + if (input == null) { + errorMessage = ActionMessages.getString("MoveToLineAdapter.0"); //$NON-NLS-1$ + } else { + IDocument document = textEditor.getDocumentProvider().getDocument(input); + if (document == null) { + errorMessage = ActionMessages.getString("MoveToLineAdapter.1"); //$NON-NLS-1$ + } else { + final String fileName = getFileName(input); + ITextSelection textSelection = (ITextSelection) selection; final int lineNumber = textSelection.getStartLine() + 1; - if ( target instanceof IAdaptable ) { - final IPath path = new Path( fileName ); - final IMoveToLine moveToLine = ((IAdaptable)target).getAdapter( IMoveToLine.class ); - if ( moveToLine != null && moveToLine.canMoveToLine( path.toPortableString(), lineNumber ) ) { + if (target instanceof IAdaptable) { + final IPath path = new Path(fileName); + final IMoveToLine moveToLine = ((IAdaptable) target).getAdapter(IMoveToLine.class); + if (moveToLine != null && moveToLine.canMoveToLine(path.toPortableString(), lineNumber)) { Runnable r = new Runnable() { @Override public void run() { try { - moveToLine.moveToLine(path.toPortableString(), lineNumber ); - } - catch( DebugException e ) { - failed( e ); + moveToLine.moveToLine(path.toPortableString(), lineNumber); + } catch (DebugException e) { + failed(e); } } }; - runInBackground( r ); + runInBackground(r); } } return; } } + } else { + errorMessage = ActionMessages.getString("MoveToLineAdapter.3"); //$NON-NLS-1$ } - else { - errorMessage = ActionMessages.getString( "MoveToLineAdapter.3" ); //$NON-NLS-1$ - } - throw new CoreException( new Status( IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), IInternalCDebugUIConstants.INTERNAL_ERROR, errorMessage, null ) ); + throw new CoreException(new Status(IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), + IInternalCDebugUIConstants.INTERNAL_ERROR, errorMessage, null)); } /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.actions.IMoveToLineTarget#canMoveToLine(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection, org.eclipse.debug.core.model.ISuspendResume) */ @Override - public boolean canMoveToLine( IWorkbenchPart part, ISelection selection, ISuspendResume target ) { - if ( target instanceof IAdaptable ) { - if ( part instanceof IEditorPart ) { - IMoveToLine moveToLine = ((IAdaptable)target).getAdapter( IMoveToLine.class ); - if ( moveToLine == null) + public boolean canMoveToLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) { + if (target instanceof IAdaptable) { + if (part instanceof IEditorPart) { + IMoveToLine moveToLine = ((IAdaptable) target).getAdapter(IMoveToLine.class); + if (moveToLine == null) return false; - IEditorPart editorPart = (IEditorPart)part; + IEditorPart editorPart = (IEditorPart) part; IEditorInput input = editorPart.getEditorInput(); - if ( input == null ) { + if (input == null) { return false; } - if ( !(editorPart instanceof ITextEditor) ) { + if (!(editorPart instanceof ITextEditor)) { return false; } - ITextEditor textEditor = (ITextEditor)editorPart; - IDocument document = textEditor.getDocumentProvider().getDocument( input ); - if ( document == null ) { + ITextEditor textEditor = (ITextEditor) editorPart; + IDocument document = textEditor.getDocumentProvider().getDocument(input); + if (document == null) { return false; } String fileName = null; try { - fileName = getFileName( input ); - } - catch( CoreException e ) { + fileName = getFileName(input); + } catch (CoreException e) { } if (fileName == null) { return false; } - final IPath path = new Path( fileName ); - ITextSelection textSelection = (ITextSelection)selection; + final IPath path = new Path(fileName); + ITextSelection textSelection = (ITextSelection) selection; int lineNumber = textSelection.getStartLine() + 1; - return moveToLine.canMoveToLine(path.toPortableString(), lineNumber ); + return moveToLine.canMoveToLine(path.toPortableString(), lineNumber); } } return false; } - private String getFileName( IEditorInput input ) throws CoreException { - return CDebugUIUtils.getEditorFilePath(input); + private String getFileName(IEditorInput input) throws CoreException { + return CDebugUIUtils.getEditorFilePath(input); } - private void runInBackground( Runnable r ) { - DebugPlugin.getDefault().asyncExec( r ); + private void runInBackground(Runnable r) { + DebugPlugin.getDefault().asyncExec(r); } - protected void failed( Throwable e ) { - MultiStatus ms = new MultiStatus( CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, ActionMessages.getString( "MoveToLineAdapter.4" ), null ); //$NON-NLS-1$ - ms.add( new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, e.getMessage(), e ) ); - CDebugUtils.error( ms, this ); + protected void failed(Throwable e) { + MultiStatus ms = new MultiStatus(CDIDebugModel.getPluginIdentifier(), + ICDebugInternalConstants.STATUS_CODE_ERROR, ActionMessages.getString("MoveToLineAdapter.4"), null); //$NON-NLS-1$ + ms.add(new Status(IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), + ICDebugInternalConstants.STATUS_CODE_ERROR, e.getMessage(), e)); + CDebugUtils.error(ms, this); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/OpenNewViewAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/OpenNewViewAction.java index 74b1d96cd4d..563791b7a48 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/OpenNewViewAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/OpenNewViewAction.java @@ -36,7 +36,7 @@ public class OpenNewViewAction extends Action { public OpenNewViewAction() { } - + @Override public String getText() { return ActionMessages.getString("OpenNewViewActionText"); //$NON-NLS-1$ @@ -69,8 +69,9 @@ public class OpenNewViewAction extends Action { @Override public void run() { - if (fView == null) return; - + if (fView == null) + return; + IViewSite site = fView.getViewSite(); String viewId = site.getId(); IWorkbenchWindow ww = fView.getViewSite().getWorkbenchWindow(); @@ -92,13 +93,13 @@ public class OpenNewViewAction extends Action { try { ww.getActivePage().showView(viewId, secondaryId != null ? PinCloneUtils.encodeClonedPartSecondaryId(secondaryId.toString()) : null, - IWorkbenchPage.VIEW_ACTIVATE); + IWorkbenchPage.VIEW_ACTIVATE); } catch (PartInitException e) { CDebugUIPlugin.log(e); } } } - + /** Sets the view, that this action will open a new instance of */ public void init(IViewPart view) { fView = view; diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/OpenNewViewActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/OpenNewViewActionDelegate.java index 3107be8aa71..0cf7fe8be90 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/OpenNewViewActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/OpenNewViewActionDelegate.java @@ -24,7 +24,7 @@ import org.eclipse.ui.IViewPart; */ public class OpenNewViewActionDelegate implements IViewActionDelegate { private OpenNewViewAction fOpenNewViewAction = new OpenNewViewAction(); - + /* * (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/PinDebugContextActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/PinDebugContextActionDelegate.java index ee97ac186c3..2e8f6c72d61 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/PinDebugContextActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/PinDebugContextActionDelegate.java @@ -45,7 +45,7 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.WorkbenchPart; /** - * Pin the selected debug context for the view. + * Pin the selected debug context for the view. */ public class PinDebugContextActionDelegate implements IViewActionDelegate, IActionDelegate2, IDebugContextListener { private IViewPart fPart; @@ -54,10 +54,10 @@ public class PinDebugContextActionDelegate implements IViewActionDelegate, IActi private IAction fAction; private IPartListener2 fPartListener; private DebugContextPinProvider fProvider; - + public PinDebugContextActionDelegate() { } - + /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event) */ @@ -65,7 +65,7 @@ public class PinDebugContextActionDelegate implements IViewActionDelegate, IActi public void runWithEvent(IAction action, Event event) { run(action); } - + /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ @@ -77,13 +77,13 @@ public class PinDebugContextActionDelegate implements IViewActionDelegate, IActi fLastKnownDescription = ((WorkbenchPart) fPart).getContentDescription(); fPinnedContextLabel = getPinContextLabel(fProvider); PinCloneUtils.setPartContentDescription(fPart, fPinnedContextLabel); - updatePinContextColor(fProvider); + updatePinContextColor(fProvider); } } else { fProvider = null; DebugEventFilterService.getInstance().removeDebugEventFilter(fPart); updatePinContextColor(fProvider); - PinCloneUtils.setPartContentDescription(fPart, fLastKnownDescription); + PinCloneUtils.setPartContentDescription(fPart, fLastKnownDescription); } } @@ -101,7 +101,7 @@ public class PinDebugContextActionDelegate implements IViewActionDelegate, IActi public void init(IAction action) { fAction = action; } - + /* (non-Javadoc) * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart) */ @@ -110,12 +110,13 @@ public class PinDebugContextActionDelegate implements IViewActionDelegate, IActi fPart = view; if (fAction != null && !fAction.isChecked()) { - IDebugContextService service = DebugUITools.getDebugContextManager().getContextService(fPart.getViewSite().getWorkbenchWindow()); - boolean pinnable = PinCloneUtils.isPinnable(fPart, service.getActiveContext()); + IDebugContextService service = DebugUITools.getDebugContextManager() + .getContextService(fPart.getViewSite().getWorkbenchWindow()); + boolean pinnable = PinCloneUtils.isPinnable(fPart, service.getActiveContext()); fAction.setEnabled(pinnable); } - - fPart.addPropertyListener(new IPropertyListener() { + + fPart.addPropertyListener(new IPropertyListener() { @Override public void propertyChanged(Object source, int propId) { if (IWorkbenchPartConstants.PROP_CONTENT_DESCRIPTION == propId) { @@ -125,7 +126,7 @@ public class PinDebugContextActionDelegate implements IViewActionDelegate, IActi if (!fPinnedContextLabel.equals(desc)) { fLastKnownDescription = desc; } - + // if action is checked, than set it back to the pinned context label. if (fAction != null && fAction.isChecked()) { PinCloneUtils.setPartContentDescription(fPart, fPinnedContextLabel); @@ -134,16 +135,18 @@ public class PinDebugContextActionDelegate implements IViewActionDelegate, IActi PinCloneUtils.setPartTitle(fPart); } } - }); - + }); + DebugUITools.addPartDebugContextListener(fPart.getSite(), this); - + // Platform AbstractDebugView saves action check state, // in our case, we don't want this behavior. // Listens to part close and set the check state off. - fPartListener = new IPartListener2() { + fPartListener = new IPartListener2() { @Override - public void partBroughtToTop(IWorkbenchPartReference partRef) {} + public void partBroughtToTop(IWorkbenchPartReference partRef) { + } + @Override public void partClosed(IWorkbenchPartReference partRef) { IWorkbenchPart part = partRef.getPart(false); @@ -151,22 +154,34 @@ public class PinDebugContextActionDelegate implements IViewActionDelegate, IActi unpinPart(); } } + @Override - public void partDeactivated(IWorkbenchPartReference partRef) {} + public void partDeactivated(IWorkbenchPartReference partRef) { + } + @Override - public void partOpened(IWorkbenchPartReference partRef) {} + public void partOpened(IWorkbenchPartReference partRef) { + } + @Override - public void partHidden(IWorkbenchPartReference partRef) {} + public void partHidden(IWorkbenchPartReference partRef) { + } + @Override - public void partVisible(IWorkbenchPartReference partRef) {} + public void partVisible(IWorkbenchPartReference partRef) { + } + @Override - public void partInputChanged(IWorkbenchPartReference partRef) {} + public void partInputChanged(IWorkbenchPartReference partRef) { + } + @Override - public void partActivated(IWorkbenchPartReference partRef) {} + public void partActivated(IWorkbenchPartReference partRef) { + } }; - fPart.getSite().getWorkbenchWindow().getPartService().addPartListener(fPartListener); + fPart.getSite().getWorkbenchWindow().getPartService().addPartListener(fPartListener); } - + /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate2#dispose() */ @@ -176,23 +191,23 @@ public class PinDebugContextActionDelegate implements IViewActionDelegate, IActi fPart.getSite().getWorkbenchWindow().getPartService().removePartListener(fPartListener); unpinPart(); } - + protected void unpinPart() { if (fAction.isChecked()) { DebugEventFilterService.getInstance().removeDebugEventFilter(fPart); fAction.setChecked(false); } } - + protected ISelection getActiveDebugContext() { - IDebugContextService contextService = - DebugUITools.getDebugContextManager().getContextService(fPart.getSite().getWorkbenchWindow()); - return contextService.getActiveContext(); + IDebugContextService contextService = DebugUITools.getDebugContextManager() + .getContextService(fPart.getSite().getWorkbenchWindow()); + return contextService.getActiveContext(); } - + private String getPinContextLabel(DebugContextPinProvider provider) { String description = ""; //$NON-NLS-1$ - + if (provider != null) { Set<String> labels = new HashSet<String>(); for (IPinElementHandle handle : provider.getPinHandles()) { @@ -200,7 +215,7 @@ public class PinDebugContextActionDelegate implements IViewActionDelegate, IActi if (tmp != null && tmp.trim().length() != 0) labels.add(tmp); } - + for (String label : labels) { if (label != null) { if (description.length() > 0) { @@ -213,19 +228,20 @@ public class PinDebugContextActionDelegate implements IViewActionDelegate, IActi } return description; } - + private String getLabel(IPinElementHandle handle) { String label = ""; //$NON-NLS-1$ if (handle != null) label = handle.getLabel(); - + return label; } private boolean useMultiPinImage(Set<IPinElementHandle> handles) { - if (handles.size() <= 1) return false; - + if (handles.size() <= 1) + return false; + int overlayColor = IPinElementColorDescriptor.UNDEFINED; ImageDescriptor imageDesc = null; for (IPinElementHandle handle : handles) { @@ -235,27 +251,27 @@ public class PinDebugContextActionDelegate implements IViewActionDelegate, IActi if (imageDesc != null && !imageDesc.equals(descImageDesc)) return true; imageDesc = descImageDesc; - + int descOverlayColor = colorDesc.getOverlayColor(); if (overlayColor != IPinElementColorDescriptor.UNDEFINED && descOverlayColor != overlayColor) return true; overlayColor = descOverlayColor; } } - + return false; } - + private void updatePinContextColor(DebugContextPinProvider provider) { ImageDescriptor imageDesc = null; if (provider != null) { Set<IPinElementHandle> handles = provider.getPinHandles(); - - // if handles have different toolbar icon descriptor or different pin color, than use a + + // if handles have different toolbar icon descriptor or different pin color, than use a // multi-pin toolbar icon if (useMultiPinImage(handles)) - imageDesc = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_VIEW_PIN_ACTION_MULTI); - + imageDesc = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_VIEW_PIN_ACTION_MULTI); + if (imageDesc == null) { Iterator<IPinElementHandle> itr = handles.iterator(); if (itr.hasNext()) { @@ -263,10 +279,10 @@ public class PinDebugContextActionDelegate implements IViewActionDelegate, IActi IPinElementColorDescriptor desc = handle.getPinElementColorDescriptor(); if (desc != null) imageDesc = desc.getToolbarIconDescriptor(); - + if (imageDesc == null && desc != null) { int overlayColor = desc.getOverlayColor() % IPinElementColorDescriptor.DEFAULT_COLOR_COUNT; - + switch (overlayColor) { case IPinProvider.IPinElementColorDescriptor.GREEN: imageDesc = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_VIEW_PIN_ACTION_G); @@ -282,12 +298,12 @@ public class PinDebugContextActionDelegate implements IViewActionDelegate, IActi } } } - + if (imageDesc == null) imageDesc = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_VIEW_PIN_ACTION); fAction.setImageDescriptor(imageDesc); - } - + } + /* (non-Javadoc) * @see org.eclipse.debug.ui.contexts.IDebugContextListener#debugContextChanged(org.eclipse.debug.ui.contexts.DebugContextEvent) */ @@ -295,8 +311,8 @@ public class PinDebugContextActionDelegate implements IViewActionDelegate, IActi public void debugContextChanged(DebugContextEvent event) { if (fAction != null && !fAction.isChecked()) { final boolean pinnable = PinCloneUtils.isPinnable(fPart, event.getContext()); - if (pinnable != fAction.isEnabled()) { - PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { + if (pinnable != fAction.isEnabled()) { + PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { @Override public void run() { fAction.setEnabled(pinnable); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RegisterGroupDialog.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RegisterGroupDialog.java index 0fe90ee76cb..31e8a8b2818 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RegisterGroupDialog.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RegisterGroupDialog.java @@ -11,7 +11,7 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.actions; +package org.eclipse.cdt.debug.internal.ui.actions; import java.util.Arrays; import java.util.List; @@ -41,7 +41,7 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; import com.ibm.icu.text.MessageFormat; - + /** * This dialog is used to add/edit user-defined register groups. */ @@ -50,20 +50,20 @@ public class RegisterGroupDialog extends TitleAreaDialog { public class RegisterLabelProvider extends LabelProvider { @Override - public Image getImage( Object element ) { - if ( element instanceof IRegisterDescriptor ) { - return CDebugImages.get( CDebugImages.IMG_OBJS_REGISTER ); + public Image getImage(Object element) { + if (element instanceof IRegisterDescriptor) { + return CDebugImages.get(CDebugImages.IMG_OBJS_REGISTER); } - return super.getImage( element ); + return super.getImage(element); } @Override - public String getText( Object element ) { - if ( element instanceof IRegisterDescriptor ) { - IRegisterDescriptor rd = (IRegisterDescriptor)element; - return MessageFormat.format( "{0} - {1}", new Object[] { rd.getName(), rd.getGroupName() } ); //$NON-NLS-1$ + public String getText(Object element) { + if (element instanceof IRegisterDescriptor) { + IRegisterDescriptor rd = (IRegisterDescriptor) element; + return MessageFormat.format("{0} - {1}", new Object[] { rd.getName(), rd.getGroupName() }); //$NON-NLS-1$ } - return super.getText( element ); + return super.getText(element); } } @@ -72,82 +72,84 @@ public class RegisterGroupDialog extends TitleAreaDialog { private String fName; private IRegisterDescriptor[] fDescriptors; - public RegisterGroupDialog( Shell parentShell, IRegisterDescriptor[] allRegisters ) { - this( parentShell, ActionMessages.getString( "RegisterGroupDialog.0" ), allRegisters, new IRegisterDescriptor[0] ); //$NON-NLS-1$ + public RegisterGroupDialog(Shell parentShell, IRegisterDescriptor[] allRegisters) { + this(parentShell, ActionMessages.getString("RegisterGroupDialog.0"), allRegisters, new IRegisterDescriptor[0]); //$NON-NLS-1$ } - public RegisterGroupDialog( Shell parentShell, String groupName, IRegisterDescriptor[] allRegisters, IRegisterDescriptor[] groupRegisters ) { - super( parentShell ); + public RegisterGroupDialog(Shell parentShell, String groupName, IRegisterDescriptor[] allRegisters, + IRegisterDescriptor[] groupRegisters) { + super(parentShell); fName = groupName; fDescriptors = groupRegisters; - String[] buttonLabels = new String[] { ActionMessages.getString( "RegisterGroupDialog.1" ), ActionMessages.getString( "RegisterGroupDialog.2" ) }; //$NON-NLS-1$ //$NON-NLS-2$ - fNameField = new StringDialogField(); - fNameField.setLabelText( ActionMessages.getString( "RegisterGroupDialog.3" ) ); //$NON-NLS-1$ - fNameField.setTextWithoutUpdate( groupName ); - fNameField.setDialogFieldListener( new IDialogFieldListener() { + String[] buttonLabels = new String[] { ActionMessages.getString("RegisterGroupDialog.1"), //$NON-NLS-1$ + ActionMessages.getString("RegisterGroupDialog.2") }; //$NON-NLS-1$ + fNameField = new StringDialogField(); + fNameField.setLabelText(ActionMessages.getString("RegisterGroupDialog.3")); //$NON-NLS-1$ + fNameField.setTextWithoutUpdate(groupName); + fNameField.setDialogFieldListener(new IDialogFieldListener() { @Override - public void dialogFieldChanged( DialogField field ) { + public void dialogFieldChanged(DialogField field) { update(); } - } ); - fListField = new CheckedListDialogField( new IListAdapter() { - + }); + fListField = new CheckedListDialogField(new IListAdapter() { + @Override - public void customButtonPressed( DialogField field, int index ) { + public void customButtonPressed(DialogField field, int index) { // TODO Auto-generated method stub - + } @Override - public void selectionChanged( DialogField field ) { + public void selectionChanged(DialogField field) { // TODO Auto-generated method stub - + } - }, buttonLabels, new RegisterLabelProvider() ); - fListField.setLabelText( ActionMessages.getString( "RegisterGroupDialog.4" ) ); //$NON-NLS-1$ - fListField.setCheckAllButtonIndex( 0 ); - fListField.setUncheckAllButtonIndex( 1 ); - fListField.setElements( Arrays.asList( allRegisters ) ); - fListField.setCheckedElements( Arrays.asList( groupRegisters ) ); + }, buttonLabels, new RegisterLabelProvider()); + fListField.setLabelText(ActionMessages.getString("RegisterGroupDialog.4")); //$NON-NLS-1$ + fListField.setCheckAllButtonIndex(0); + fListField.setUncheckAllButtonIndex(1); + fListField.setElements(Arrays.asList(allRegisters)); + fListField.setCheckedElements(Arrays.asList(groupRegisters)); } /* (non-Javadoc) * @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite) */ @Override - protected Control createDialogArea( Composite parent ) { - getShell().setText( ActionMessages.getString( "RegisterGroupDialog.5" ) ); //$NON-NLS-1$ - setTitle( ActionMessages.getString( "RegisterGroupDialog.6" ) ); //$NON-NLS-1$ - // setTitleImage( CDebugImages.get( CDebugImages.IMG_WIZBAN_REGISTER_GROUP ) ); - PlatformUI.getWorkbench().getHelpSystem().setHelp( getShell(), ICDebugHelpContextIds.REGISTER_GROUP ); - Composite composite = new Composite( parent, SWT.NONE ); + protected Control createDialogArea(Composite parent) { + getShell().setText(ActionMessages.getString("RegisterGroupDialog.5")); //$NON-NLS-1$ + setTitle(ActionMessages.getString("RegisterGroupDialog.6")); //$NON-NLS-1$ + // setTitleImage( CDebugImages.get( CDebugImages.IMG_WIZBAN_REGISTER_GROUP ) ); + PlatformUI.getWorkbench().getHelpSystem().setHelp(getShell(), ICDebugHelpContextIds.REGISTER_GROUP); + Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); - layout.numColumns = Math.max( fNameField.getNumberOfControls(), fListField.getNumberOfControls() ); - layout.marginHeight = convertVerticalDLUsToPixels( IDialogConstants.VERTICAL_MARGIN ); - layout.marginWidth = convertHorizontalDLUsToPixels( IDialogConstants.HORIZONTAL_MARGIN ); - composite.setLayout( layout ); - composite.setLayoutData( new GridData( GridData.FILL_BOTH ) ); - Dialog.applyDialogFont( composite ); - PixelConverter converter = new PixelConverter( composite ); - new Separator().doFillIntoGrid( composite, layout.numColumns, converter.convertHeightInCharsToPixels( 1 ) ); - fNameField.doFillIntoGrid( composite, layout.numColumns ); - fNameField.getTextControl( null ).selectAll(); - new Separator().doFillIntoGrid( composite, layout.numColumns, converter.convertHeightInCharsToPixels( 1 ) ); - fListField.doFillIntoGrid( composite, layout.numColumns + 1 ); - LayoutUtil.setHorizontalSpan( fListField.getLabelControl( null ), layout.numColumns ); - LayoutUtil.setHeigthHint( fListField.getListControl( null ), convertWidthInCharsToPixels( 30 ) ); - LayoutUtil.setHorizontalGrabbing( fListField.getListControl( null ) ); - setMessage( null ); + layout.numColumns = Math.max(fNameField.getNumberOfControls(), fListField.getNumberOfControls()); + layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); + layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); + composite.setLayout(layout); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + Dialog.applyDialogFont(composite); + PixelConverter converter = new PixelConverter(composite); + new Separator().doFillIntoGrid(composite, layout.numColumns, converter.convertHeightInCharsToPixels(1)); + fNameField.doFillIntoGrid(composite, layout.numColumns); + fNameField.getTextControl(null).selectAll(); + new Separator().doFillIntoGrid(composite, layout.numColumns, converter.convertHeightInCharsToPixels(1)); + fListField.doFillIntoGrid(composite, layout.numColumns + 1); + LayoutUtil.setHorizontalSpan(fListField.getLabelControl(null), layout.numColumns); + LayoutUtil.setHeigthHint(fListField.getListControl(null), convertWidthInCharsToPixels(30)); + LayoutUtil.setHorizontalGrabbing(fListField.getListControl(null)); + setMessage(null); return composite; } protected void update() { - setErrorMessage( null ); + setErrorMessage(null); String name = fNameField.getText().trim(); - if ( name.length() == 0 ) { - setErrorMessage( ActionMessages.getString( "RegisterGroupDialog.7" ) ); //$NON-NLS-1$ + if (name.length() == 0) { + setErrorMessage(ActionMessages.getString("RegisterGroupDialog.7")); //$NON-NLS-1$ } - getButton( IDialogConstants.OK_ID ).setEnabled( name.length() > 0 ); + getButton(IDialogConstants.OK_ID).setEnabled(name.length() > 0); } @Override @@ -155,7 +157,7 @@ public class RegisterGroupDialog extends TitleAreaDialog { super.okPressed(); fName = fNameField.getText().trim(); List<IRegisterDescriptor> elements = fListField.getCheckedElements(); - fDescriptors = elements.toArray( new IRegisterDescriptor[elements.size()] ); + fDescriptors = elements.toArray(new IRegisterDescriptor[elements.size()]); } public String getName() { diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RestoreDefaultTypeActionHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RestoreDefaultTypeActionHandler.java index a4105922748..bd8d30be00d 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RestoreDefaultTypeActionHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RestoreDefaultTypeActionHandler.java @@ -46,38 +46,36 @@ public class RestoreDefaultTypeActionHandler extends AbstractHandler { return fCastableItems; } - protected void setCastToType( ICastToType[] castableItems ) { + protected void setCastToType(ICastToType[] castableItems) { fCastableItems = castableItems; } @Override public Object execute(ExecutionEvent event) throws ExecutionException { - if ( getCastToType() == null || getCastToType().length == 0 ) + if (getCastToType() == null || getCastToType().length == 0) return null; - - BusyIndicator.showWhile( Display.getCurrent(), new Runnable() { + + BusyIndicator.showWhile(Display.getCurrent(), new Runnable() { @Override public void run() { try { - doAction( getCastToType() ); - setStatus( null ); - } - catch( DebugException e ) { - setStatus( e.getStatus() ); + doAction(getCastToType()); + setStatus(null); + } catch (DebugException e) { + setStatus(e.getStatus()); } } - } ); - if ( getStatus() != null && !getStatus().isOK() ) { + }); + if (getStatus() != null && !getStatus().isOK()) { IWorkbenchWindow window = CDebugUIPlugin.getActiveWorkbenchWindow(); - if ( window != null ) { - CDebugUIPlugin.errorDialog( ActionMessages.getString( "RestoreDefaultTypeActionDelegate.0" ), getStatus() ); //$NON-NLS-1$ - } - else { - CDebugUIPlugin.log( getStatus() ); + if (window != null) { + CDebugUIPlugin.errorDialog(ActionMessages.getString("RestoreDefaultTypeActionDelegate.0"), getStatus()); //$NON-NLS-1$ + } else { + CDebugUIPlugin.log(getStatus()); } } - + return null; } @@ -87,36 +85,36 @@ public class RestoreDefaultTypeActionHandler extends AbstractHandler { setBaseEnabled(castableItems.length > 0); setCastToType(castableItems); } - + private ICastToType[] getCastToType(Object evaluationContext) { List<ICastToType> castableItems = new ArrayList<ICastToType>(); - if (evaluationContext instanceof IEvaluationContext) { - Object s = ((IEvaluationContext) evaluationContext).getVariable(ISources.ACTIVE_MENU_SELECTION_NAME); - if (s instanceof IStructuredSelection) { - Iterator<?> iter = ((IStructuredSelection)s).iterator(); - while( iter.hasNext() ) { - Object element = DebugPlugin.getAdapter(iter.next(), ICastToType.class); - if (element instanceof ICastToType) { - if (((ICastToType)element).isCasted()) { - castableItems.add((ICastToType)element); - } - } - } - } - } - return castableItems.toArray(new ICastToType[castableItems.size()]); + if (evaluationContext instanceof IEvaluationContext) { + Object s = ((IEvaluationContext) evaluationContext).getVariable(ISources.ACTIVE_MENU_SELECTION_NAME); + if (s instanceof IStructuredSelection) { + Iterator<?> iter = ((IStructuredSelection) s).iterator(); + while (iter.hasNext()) { + Object element = DebugPlugin.getAdapter(iter.next(), ICastToType.class); + if (element instanceof ICastToType) { + if (((ICastToType) element).isCasted()) { + castableItems.add((ICastToType) element); + } + } + } + } + } + return castableItems.toArray(new ICastToType[castableItems.size()]); } - + public IStatus getStatus() { return fStatus; } - public void setStatus( IStatus status ) { + public void setStatus(IStatus status) { fStatus = status; } - protected void doAction( ICastToType[] castableItems ) throws DebugException { - for ( ICastToType castableItem : castableItems ) { + protected void doAction(ICastToType[] castableItems) throws DebugException { + for (ICastToType castableItem : castableItems) { castableItem.restoreOriginal(); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ResumeAtLineActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ResumeAtLineActionDelegate.java index 10e6fdf3138..53412ea9c2a 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ResumeAtLineActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ResumeAtLineActionDelegate.java @@ -12,7 +12,7 @@ * QNX Software Systems - Initial API and implementation * Ericsson - Updated to latest platform code *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.actions; +package org.eclipse.cdt.debug.internal.ui.actions; import org.eclipse.cdt.debug.ui.CDebugUIPlugin; import org.eclipse.core.runtime.CoreException; @@ -39,20 +39,20 @@ import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPartSite; import org.eclipse.ui.IWorkbenchWindow; - + /** * A resume at line action that can be contributed to a an editor. The action * will perform the "resume at line" operation for editors that provide * an appropriate <code>IResumeAtLineTarget</code> adapter. */ public class ResumeAtLineActionDelegate implements IEditorActionDelegate, IActionDelegate2, IViewActionDelegate { - + private IWorkbenchPart fActivePart = null; private IResumeAtLineTarget fPartTarget = null; private IAction fAction = null; private DebugContextListener fContextListener = new DebugContextListener(); private ISuspendResume fTargetElement = null; - + class DebugContextListener implements IDebugContextListener { protected void contextActivated(ISelection selection) { @@ -60,8 +60,8 @@ public class ResumeAtLineActionDelegate implements IEditorActionDelegate, IActio if (selection instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection) selection; if (ss.size() == 1) { - fTargetElement = (ISuspendResume) - DebugPlugin.getAdapter(ss.getFirstElement(), ISuspendResume.class); + fTargetElement = (ISuspendResume) DebugPlugin.getAdapter(ss.getFirstElement(), + ISuspendResume.class); } } update(); @@ -71,19 +71,21 @@ public class ResumeAtLineActionDelegate implements IEditorActionDelegate, IActio public void debugContextChanged(DebugContextEvent event) { contextActivated(event.getContext()); } - - } - + + } + /*(non-Javadoc) * @see org.eclipse.ui.IActionDelegate2#dispose() */ @Override public void dispose() { - DebugUITools.getDebugContextManager().getContextService(fActivePart.getSite().getWorkbenchWindow()).removeDebugContextListener(fContextListener); + DebugUITools.getDebugContextManager().getContextService(fActivePart.getSite().getWorkbenchWindow()) + .removeDebugContextListener(fContextListener); fActivePart = null; fPartTarget = null; - + } + /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ @@ -91,12 +93,16 @@ public class ResumeAtLineActionDelegate implements IEditorActionDelegate, IActio public void run(IAction action) { if (fPartTarget != null && fTargetElement != null) { try { - fPartTarget.resumeAtLine(fActivePart, fActivePart.getSite().getSelectionProvider().getSelection(), fTargetElement); + fPartTarget.resumeAtLine(fActivePart, fActivePart.getSite().getSelectionProvider().getSelection(), + fTargetElement); } catch (CoreException e) { - ErrorDialog.openError( fActivePart.getSite().getWorkbenchWindow().getShell(), ActionMessages.getString( "ResumeAtLineActionDelegate.1" ), ActionMessages.getString( "ResumeAtLineActionDelegate.2" ), e.getStatus() ); //$NON-NLS-1$ //$NON-NLS-2$ + ErrorDialog.openError(fActivePart.getSite().getWorkbenchWindow().getShell(), + ActionMessages.getString("ResumeAtLineActionDelegate.1"), //$NON-NLS-1$ + ActionMessages.getString("ResumeAtLineActionDelegate.2"), e.getStatus()); //$NON-NLS-1$ } } } + /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) */ @@ -105,7 +111,7 @@ public class ResumeAtLineActionDelegate implements IEditorActionDelegate, IActio this.fAction = action; update(); } - + /* (non-Javadoc) * @see org.eclipse.ui.texteditor.IUpdate#update() */ @@ -120,26 +126,28 @@ public class ResumeAtLineActionDelegate implements IEditorActionDelegate, IActio if (fPartTarget != null && fTargetElement != null) { IWorkbenchPartSite site = fActivePart.getSite(); if (site != null) { - ISelectionProvider selectionProvider = site.getSelectionProvider(); - if (selectionProvider != null) { - ISelection selection = selectionProvider.getSelection(); - enabled = fTargetElement.isSuspended() && fPartTarget.canResumeAtLine(fActivePart, selection, fTargetElement); - } + ISelectionProvider selectionProvider = site.getSelectionProvider(); + if (selectionProvider != null) { + ISelection selection = selectionProvider.getSelection(); + enabled = fTargetElement.isSuspended() + && fPartTarget.canResumeAtLine(fActivePart, selection, fTargetElement); + } } } - fAction.setEnabled(enabled); + fAction.setEnabled(enabled); } }; CDebugUIPlugin.getStandardDisplay().asyncExec(r); } - + /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction) */ @Override public void init(IAction action) { - this.fAction = action; + this.fAction = action; } + /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event) */ @@ -147,15 +155,16 @@ public class ResumeAtLineActionDelegate implements IEditorActionDelegate, IActio public void runWithEvent(IAction action, Event event) { run(action); } + /* (non-Javadoc) * @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction, org.eclipse.ui.IEditorPart) */ @Override public void setActiveEditor(IAction action, IEditorPart targetEditor) { init(action); - bindTo(targetEditor); + bindTo(targetEditor); } - + /* (non-Javadoc) * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart) */ @@ -163,16 +172,17 @@ public class ResumeAtLineActionDelegate implements IEditorActionDelegate, IActio public void init(IViewPart view) { bindTo(view); } - + /** * Binds this action to operate on the given part's IResumeAtLineTarget adapter. - * + * * @param part */ private void bindTo(IWorkbenchPart part) { IDebugContextManager manager = DebugUITools.getDebugContextManager(); if (fActivePart != null && !fActivePart.equals(part)) { - manager.getContextService(fActivePart.getSite().getWorkbenchWindow()).removeDebugContextListener(fContextListener); + manager.getContextService(fActivePart.getSite().getWorkbenchWindow()) + .removeDebugContextListener(fContextListener); } fPartTarget = null; fActivePart = part; @@ -180,17 +190,18 @@ public class ResumeAtLineActionDelegate implements IEditorActionDelegate, IActio IWorkbenchWindow workbenchWindow = part.getSite().getWorkbenchWindow(); IDebugContextService service = manager.getContextService(workbenchWindow); service.addDebugContextListener(fContextListener); - fPartTarget = part.getAdapter(IResumeAtLineTarget.class); + fPartTarget = part.getAdapter(IResumeAtLineTarget.class); if (fPartTarget == null) { IAdapterManager adapterManager = Platform.getAdapterManager(); // TODO: we could restrict loading to cases when the debugging context is on if (adapterManager.hasAdapter(part, IResumeAtLineTarget.class.getName())) { - fPartTarget = (IResumeAtLineTarget) adapterManager.loadAdapter(part, IResumeAtLineTarget.class.getName()); + fPartTarget = (IResumeAtLineTarget) adapterManager.loadAdapter(part, + IResumeAtLineTarget.class.getName()); } } ISelection activeContext = service.getActiveContext(); fContextListener.contextActivated(activeContext); } - update(); + update(); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ResumeAtLineAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ResumeAtLineAdapter.java index 27aa290bee3..2d3623a72b0 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ResumeAtLineAdapter.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ResumeAtLineAdapter.java @@ -12,7 +12,7 @@ * QNX Software Systems - Initial API and implementation * Freescale - https://bugs.eclipse.org/bugs/show_bug.cgi?id=186929 *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.actions; +package org.eclipse.cdt.debug.internal.ui.actions; import org.eclipse.cdt.debug.core.CDIDebugModel; import org.eclipse.cdt.debug.core.CDebugUtils; @@ -38,7 +38,7 @@ import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.texteditor.ITextEditor; - + /** * Resume at line target adapter for the CDI and DSF-GDB debuggers */ @@ -48,104 +48,102 @@ public class ResumeAtLineAdapter implements IResumeAtLineTarget { * @see org.eclipse.cdt.debug.internal.ui.actions.IResumeAtLineTarget#resumeAtLine(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection, org.eclipse.debug.core.model.ISuspendResume) */ @Override - public void resumeAtLine( IWorkbenchPart part, ISelection selection, ISuspendResume target ) throws CoreException { + public void resumeAtLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) throws CoreException { String errorMessage = null; - if ( part instanceof ITextEditor ) { - ITextEditor textEditor = (ITextEditor)part; + if (part instanceof ITextEditor) { + ITextEditor textEditor = (ITextEditor) part; IEditorInput input = textEditor.getEditorInput(); - if ( input == null ) { - errorMessage = ActionMessages.getString( "ResumeAtLineAdapter.0" ); //$NON-NLS-1$ - } - else { - IDocument document = textEditor.getDocumentProvider().getDocument( input ); - if ( document == null ) { - errorMessage = ActionMessages.getString( "ResumeAtLineAdapter.1" ); //$NON-NLS-1$ - } - else { - final String fileName = getFileName( input ); // actually, absolute path, not just file name + if (input == null) { + errorMessage = ActionMessages.getString("ResumeAtLineAdapter.0"); //$NON-NLS-1$ + } else { + IDocument document = textEditor.getDocumentProvider().getDocument(input); + if (document == null) { + errorMessage = ActionMessages.getString("ResumeAtLineAdapter.1"); //$NON-NLS-1$ + } else { + final String fileName = getFileName(input); // actually, absolute path, not just file name final IPath path = new Path(fileName); - ITextSelection textSelection = (ITextSelection)selection; + ITextSelection textSelection = (ITextSelection) selection; final int lineNumber = textSelection.getStartLine() + 1; - if ( target instanceof IAdaptable ) { - final IResumeAtLine resumeAtLine = ((IAdaptable)target).getAdapter( IResumeAtLine.class ); - if ( resumeAtLine != null && resumeAtLine.canResumeAtLine( path.toPortableString(), lineNumber ) ) { + if (target instanceof IAdaptable) { + final IResumeAtLine resumeAtLine = ((IAdaptable) target).getAdapter(IResumeAtLine.class); + if (resumeAtLine != null && resumeAtLine.canResumeAtLine(path.toPortableString(), lineNumber)) { Runnable r = new Runnable() { @Override public void run() { try { - resumeAtLine.resumeAtLine( path.toPortableString(), lineNumber ); + resumeAtLine.resumeAtLine(path.toPortableString(), lineNumber); + } catch (DebugException e) { + failed(e); } - catch( DebugException e ) { - failed( e ); - } } }; - runInBackground( r ); + runInBackground(r); } } return; } } + } else { + errorMessage = ActionMessages.getString("ResumeAtLineAdapter.3"); //$NON-NLS-1$ } - else { - errorMessage = ActionMessages.getString( "ResumeAtLineAdapter.3" ); //$NON-NLS-1$ - } - throw new CoreException( new Status( IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), IInternalCDebugUIConstants.INTERNAL_ERROR, errorMessage, null ) ); + throw new CoreException(new Status(IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), + IInternalCDebugUIConstants.INTERNAL_ERROR, errorMessage, null)); } /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.actions.IResumeAtLineTarget#canResumeAtLine(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection, org.eclipse.debug.core.model.ISuspendResume) */ @Override - public boolean canResumeAtLine( IWorkbenchPart part, ISelection selection, ISuspendResume target ) { - if ( target instanceof IAdaptable ) { - if ( part instanceof IEditorPart ) { - IResumeAtLine resumeAtLine = ((IAdaptable)target).getAdapter( IResumeAtLine.class ); - if ( resumeAtLine == null) + public boolean canResumeAtLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) { + if (target instanceof IAdaptable) { + if (part instanceof IEditorPart) { + IResumeAtLine resumeAtLine = ((IAdaptable) target).getAdapter(IResumeAtLine.class); + if (resumeAtLine == null) return false; - IEditorPart editorPart = (IEditorPart)part; + IEditorPart editorPart = (IEditorPart) part; IEditorInput input = editorPart.getEditorInput(); - if ( input == null ) { + if (input == null) { return false; } - if ( !(editorPart instanceof ITextEditor) ) { + if (!(editorPart instanceof ITextEditor)) { return false; } - ITextEditor textEditor = (ITextEditor)editorPart; - IDocument document = textEditor.getDocumentProvider().getDocument( input ); - if ( document == null ) { + ITextEditor textEditor = (ITextEditor) editorPart; + IDocument document = textEditor.getDocumentProvider().getDocument(input); + if (document == null) { return false; } String fileName = null; // actually, absolute path, not just file name try { - fileName = getFileName( input ); - } - catch( CoreException e ) { + fileName = getFileName(input); + } catch (CoreException e) { } if (fileName == null) { return false; } - final IPath path = new Path( fileName ); - ITextSelection textSelection = (ITextSelection)selection; + final IPath path = new Path(fileName); + ITextSelection textSelection = (ITextSelection) selection; int lineNumber = textSelection.getStartLine() + 1; - return resumeAtLine.canResumeAtLine( path.toPortableString(), lineNumber ); + return resumeAtLine.canResumeAtLine(path.toPortableString(), lineNumber); } } return false; } - private String getFileName( IEditorInput input ) throws CoreException { + private String getFileName(IEditorInput input) throws CoreException { return CDebugUIUtils.getEditorFilePath(input); } - private void runInBackground( Runnable r ) { - DebugPlugin.getDefault().asyncExec( r ); + private void runInBackground(Runnable r) { + DebugPlugin.getDefault().asyncExec(r); } - protected void failed( Throwable e ) { - MultiStatus ms = new MultiStatus( CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, ActionMessages.getString( "ResumeAtLineAdapter.4" ), null ); //$NON-NLS-1$ - ms.add( new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, e.getMessage(), e ) ); - CDebugUtils.error( ms, this ); + protected void failed(Throwable e) { + MultiStatus ms = new MultiStatus(CDIDebugModel.getPluginIdentifier(), + ICDebugInternalConstants.STATUS_CODE_ERROR, ActionMessages.getString("ResumeAtLineAdapter.4"), null); //$NON-NLS-1$ + ms.add(new Status(IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), + ICDebugInternalConstants.STATUS_CODE_ERROR, e.getMessage(), e)); + CDebugUtils.error(ms, this); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargetAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargetAction.java index bed08129eb6..ad4b481f25b 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargetAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargetAction.java @@ -9,7 +9,7 @@ * SPDX-License-Identifier: EPL-2.0 * * Contributors: - * IBM Corporation - initial API and implementation + * IBM Corporation - initial API and implementation * Anton Leherbauer (Wind River Systems) - bug 183291 * Ericsson - Updated to the latest platform version of this file *******************************************************************************/ @@ -41,13 +41,13 @@ import org.eclipse.ui.IWorkbenchWindowActionDelegate; * Global retargettable debug action. */ public abstract class RetargetAction implements IWorkbenchWindowActionDelegate, IPartListener, IActionDelegate2 { - + protected IWorkbenchWindow fWindow = null; private IWorkbenchPart fActivePart = null; private Object fTargetAdapter = null; private IAction fAction = null; - private static final ISelection EMPTY_SELECTION = new EmptySelection(); - + private static final ISelection EMPTY_SELECTION = new EmptySelection(); + static class EmptySelection implements ISelection { /* (non-Javadoc) @@ -57,13 +57,13 @@ public abstract class RetargetAction implements IWorkbenchWindowActionDelegate, public boolean isEmpty() { return true; } - + } - + /** * Returns the current selection in the active part, possibly * and empty selection, but never <code>null</code>. - * + * * @return the selection in the active part, possibly empty */ protected ISelection getTargetSelection() { @@ -75,11 +75,11 @@ public abstract class RetargetAction implements IWorkbenchWindowActionDelegate, } return EMPTY_SELECTION; } - + protected IWorkbenchPart getActivePart() { - return fActivePart; + return fActivePart; } - + /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() */ @@ -88,8 +88,9 @@ public abstract class RetargetAction implements IWorkbenchWindowActionDelegate, fWindow.getPartService().removePartListener(this); fActivePart = null; fTargetAdapter = null; - + } + /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) */ @@ -103,6 +104,7 @@ public abstract class RetargetAction implements IWorkbenchWindowActionDelegate, partActivated(part); } } + /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ @@ -115,32 +117,35 @@ public abstract class RetargetAction implements IWorkbenchWindowActionDelegate, } else { String message = getOperationUnavailableMessage(); IStatus status = new Status(IStatus.INFO, DebugUIPlugin.getUniqueIdentifier(), message); - DebugUIPlugin.errorDialog(DebugUIPlugin.getShell(), DebugUIPlugin.removeAccelerators(action.getText()), message, status); + DebugUIPlugin.errorDialog(DebugUIPlugin.getShell(), + DebugUIPlugin.removeAccelerators(action.getText()), message, status); } } catch (CoreException e) { - ErrorDialog.openError(fWindow.getShell(), ActionMessages.getString("RetargetAction.0"), ActionMessages.getString("RetargetAction.1"), e.getStatus()); //$NON-NLS-1$ //$NON-NLS-2$ + ErrorDialog.openError(fWindow.getShell(), ActionMessages.getString("RetargetAction.0"), //$NON-NLS-1$ + ActionMessages.getString("RetargetAction.1"), e.getStatus()); //$NON-NLS-1$ } } } - + /** * Returns a message to display when we find that the operation is not enabled * when invoked in an editor (we check enabled state before running in this case, * rather than updating on each selection change - see bug 180441). - * + * * @return information message when unavailable */ protected abstract String getOperationUnavailableMessage(); - + /** * Performs the specific breakpoint toggling. - * - * @param selection selection in the active part + * + * @param selection selection in the active part * @param part active part * @throws CoreException if an exception occurs */ - protected abstract void performAction(Object target, ISelection selection, IWorkbenchPart part) throws CoreException; - + protected abstract void performAction(Object target, ISelection selection, IWorkbenchPart part) + throws CoreException; + /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) */ @@ -162,7 +167,7 @@ public abstract class RetargetAction implements IWorkbenchWindowActionDelegate, } action.setEnabled(enabled); } - + /* (non-Javadoc) * @see org.eclipse.ui.IPartListener#partActivated(org.eclipse.ui.IWorkbenchPart) */ @@ -171,7 +176,7 @@ public abstract class RetargetAction implements IWorkbenchWindowActionDelegate, fActivePart = part; IResource resource = part.getAdapter(IResource.class); if (resource == null && part instanceof IEditorPart) { - resource = ((IEditorPart)part).getEditorInput().getAdapter(IResource.class); + resource = ((IEditorPart) part).getEditorInput().getAdapter(IResource.class); } if (resource != null) { fTargetAdapter = getAdapter(resource); @@ -183,31 +188,32 @@ public abstract class RetargetAction implements IWorkbenchWindowActionDelegate, fAction.setEnabled(fTargetAdapter != null); } } - + protected Object getAdapter(IAdaptable adaptable) { - Object adapter = adaptable.getAdapter(getAdapterClass()); + Object adapter = adaptable.getAdapter(getAdapterClass()); if (adapter == null) { IAdapterManager adapterManager = Platform.getAdapterManager(); - if (adapterManager.hasAdapter(adaptable, getAdapterClass().getName())) { - adapter = adapterManager.loadAdapter(adaptable, getAdapterClass().getName()); + if (adapterManager.hasAdapter(adaptable, getAdapterClass().getName())) { + adapter = adapterManager.loadAdapter(adaptable, getAdapterClass().getName()); } } return adapter; } - + /** * Returns the type of adapter (target) this action works on. - * + * * @return the type of adapter this action works on */ protected abstract Class<?> getAdapterClass(); - + /* (non-Javadoc) * @see org.eclipse.ui.IPartListener#partBroughtToTop(org.eclipse.ui.IWorkbenchPart) */ @Override - public void partBroughtToTop(IWorkbenchPart part) { + public void partBroughtToTop(IWorkbenchPart part) { } + /* (non-Javadoc) * @see org.eclipse.ui.IPartListener#partClosed(org.eclipse.ui.IWorkbenchPart) */ @@ -215,11 +221,11 @@ public abstract class RetargetAction implements IWorkbenchWindowActionDelegate, public void partClosed(IWorkbenchPart part) { clearPart(part); } - + /** * Clears reference to active part and adapter when a relevant part * is closed or no longer active. - * + * * @param part workbench part that has been closed or no longer active */ protected void clearPart(IWorkbenchPart part) { @@ -228,6 +234,7 @@ public abstract class RetargetAction implements IWorkbenchWindowActionDelegate, fTargetAdapter = null; } } + /* (non-Javadoc) * @see org.eclipse.ui.IPartListener#partDeactivated(org.eclipse.ui.IWorkbenchPart) */ @@ -235,37 +242,38 @@ public abstract class RetargetAction implements IWorkbenchWindowActionDelegate, public void partDeactivated(IWorkbenchPart part) { clearPart(part); } + /* (non-Javadoc) * @see org.eclipse.ui.IPartListener#partOpened(org.eclipse.ui.IWorkbenchPart) */ @Override - public void partOpened(IWorkbenchPart part) { + public void partOpened(IWorkbenchPart part) { } /** * Returns whether the target adapter is enabled - * + * * @return whether target adapter is enabled */ protected boolean isTargetEnabled() { if (fTargetAdapter != null) { - if (fActivePart != null) { - return canPerformAction(fTargetAdapter, getTargetSelection(), fActivePart); - } + if (fActivePart != null) { + return canPerformAction(fTargetAdapter, getTargetSelection(), fActivePart); + } } return false; } - + /** * Returns whether the specific operation is supported. - * - * @param target the target adapter + * + * @param target the target adapter * @param selection the selection to verify the operation on * @param part the part the operation has been requested on * @return whether the operation can be performed */ protected abstract boolean canPerformAction(Object target, ISelection selection, IWorkbenchPart part); - + /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction) */ @@ -284,7 +292,7 @@ public abstract class RetargetAction implements IWorkbenchWindowActionDelegate, /** * Returns the proxy to this action delegate or <code>null</code> - * + * * @return action proxy or <code>null</code> */ protected IAction getAction() { @@ -293,7 +301,7 @@ public abstract class RetargetAction implements IWorkbenchWindowActionDelegate, /** * Returns whether there is currently a target adapter for this action. - * + * * @return whether the action has a target adapter. */ protected boolean hasTargetAdapter() { diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargetMoveToLineAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargetMoveToLineAction.java index 6a774ed9b7c..17bdb93f801 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargetMoveToLineAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargetMoveToLineAction.java @@ -31,10 +31,10 @@ import org.eclipse.ui.IWorkbenchWindow; * Global retargettable move to line action. */ public class RetargetMoveToLineAction extends RetargetAction { - + private DebugContextListener fContextListener = new DebugContextListener(); private ISuspendResume fTargetElement = null; - + class DebugContextListener implements IDebugContextListener { protected void contextActivated(ISelection selection) { @@ -42,8 +42,8 @@ public class RetargetMoveToLineAction extends RetargetAction { if (selection instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection) selection; if (ss.size() == 1) { - fTargetElement = (ISuspendResume) - DebugPlugin.getAdapter(ss.getFirstElement(), ISuspendResume.class); + fTargetElement = (ISuspendResume) DebugPlugin.getAdapter(ss.getFirstElement(), + ISuspendResume.class); } } IAction action = getAction(); @@ -57,7 +57,7 @@ public class RetargetMoveToLineAction extends RetargetAction { contextActivated(event.getContext()); } } - + /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() */ @@ -66,6 +66,7 @@ public class RetargetMoveToLineAction extends RetargetAction { DebugUITools.getDebugContextManager().getContextService(fWindow).removeDebugContextListener(fContextListener); super.dispose(); } + /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) */ @@ -77,36 +78,36 @@ public class RetargetMoveToLineAction extends RetargetAction { ISelection activeContext = service.getActiveContext(); fContextListener.contextActivated(activeContext); } - + /* (non-Javadoc) * @see org.eclipse.debug.internal.ui.actions.RetargetAction#canPerformAction(java.lang.Object, org.eclipse.jface.viewers.ISelection, org.eclipse.ui.IWorkbenchPart) */ @Override - protected boolean canPerformAction(Object target, ISelection selection, IWorkbenchPart part) { - return fTargetElement != null && - ((IMoveToLineTarget)target).canMoveToLine(part, selection, fTargetElement); + protected boolean canPerformAction(Object target, ISelection selection, IWorkbenchPart part) { + return fTargetElement != null && ((IMoveToLineTarget) target).canMoveToLine(part, selection, fTargetElement); } - + @Override protected Class<?> getAdapterClass() { return IMoveToLineTarget.class; } + /* (non-Javadoc) * @see org.eclipse.debug.internal.ui.actions.RetargetAction#performAction(java.lang.Object, org.eclipse.jface.viewers.ISelection, org.eclipse.ui.IWorkbenchPart) */ @Override protected void performAction(Object target, ISelection selection, IWorkbenchPart part) throws CoreException { - ((IMoveToLineTarget)target).moveToLine(part, selection, fTargetElement); + ((IMoveToLineTarget) target).moveToLine(part, selection, fTargetElement); } - + /* (non-Javadoc) * @see org.eclipse.debug.internal.ui.actions.RetargetAction#getOperationUnavailableMessage() */ @Override protected String getOperationUnavailableMessage() { return ActionMessages.getString("RetargetMoveToLineAction.0"); //$NON-NLS-1$ - } - + } + /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) */ diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargetResumeAtLineAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargetResumeAtLineAction.java index 3168e7e3a1d..7b07f768a8a 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargetResumeAtLineAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargetResumeAtLineAction.java @@ -12,7 +12,7 @@ * QNX Software Systems - Initial API and implementation * Ericsson - Updated with the latest platform changes of RetargetAction (302273) *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.actions; +package org.eclipse.cdt.debug.internal.ui.actions; import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.DebugPlugin; @@ -26,15 +26,15 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchWindow; - + /** * Global retargettable resume at line action. */ public class RetargetResumeAtLineAction extends RetargetAction { - + private DebugContextListener fContextListener = new DebugContextListener(); private ISuspendResume fTargetElement = null; - + class DebugContextListener implements IDebugContextListener { protected void contextActivated(ISelection selection) { @@ -42,8 +42,8 @@ public class RetargetResumeAtLineAction extends RetargetAction { if (selection instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection) selection; if (ss.size() == 1) { - fTargetElement = (ISuspendResume) - DebugPlugin.getAdapter(ss.getFirstElement(), ISuspendResume.class); + fTargetElement = (ISuspendResume) DebugPlugin.getAdapter(ss.getFirstElement(), + ISuspendResume.class); } } IAction action = getAction(); @@ -57,7 +57,7 @@ public class RetargetResumeAtLineAction extends RetargetAction { contextActivated(event.getContext()); } } - + /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() */ @@ -66,6 +66,7 @@ public class RetargetResumeAtLineAction extends RetargetAction { DebugUITools.getDebugContextManager().getContextService(fWindow).removeDebugContextListener(fContextListener); super.dispose(); } + /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) */ @@ -77,36 +78,37 @@ public class RetargetResumeAtLineAction extends RetargetAction { ISelection activeContext = service.getActiveContext(); fContextListener.contextActivated(activeContext); } - + /* (non-Javadoc) * @see org.eclipse.debug.internal.ui.actions.RetargetAction#canPerformAction(java.lang.Object, org.eclipse.jface.viewers.ISelection, org.eclipse.ui.IWorkbenchPart) */ @Override - protected boolean canPerformAction(Object target, ISelection selection, IWorkbenchPart part) { - return fTargetElement != null && - ((IResumeAtLineTarget)target).canResumeAtLine(part, selection, fTargetElement); + protected boolean canPerformAction(Object target, ISelection selection, IWorkbenchPart part) { + return fTargetElement != null + && ((IResumeAtLineTarget) target).canResumeAtLine(part, selection, fTargetElement); } - + @Override protected Class<?> getAdapterClass() { return IResumeAtLineTarget.class; } + /* (non-Javadoc) * @see org.eclipse.debug.internal.ui.actions.RetargetAction#performAction(java.lang.Object, org.eclipse.jface.viewers.ISelection, org.eclipse.ui.IWorkbenchPart) */ @Override protected void performAction(Object target, ISelection selection, IWorkbenchPart part) throws CoreException { - ((IResumeAtLineTarget)target).resumeAtLine(part, selection, fTargetElement); + ((IResumeAtLineTarget) target).resumeAtLine(part, selection, fTargetElement); } - + /* (non-Javadoc) * @see org.eclipse.debug.internal.ui.actions.RetargetAction#getOperationUnavailableMessage() */ @Override protected String getOperationUnavailableMessage() { return ActionMessages.getString("RetargetResumeAtLineAction.0"); //$NON-NLS-1$ - } - + } + /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) */ diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargettableActionAdapterFactory.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargettableActionAdapterFactory.java index 39abff33651..7c6447bf082 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargettableActionAdapterFactory.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargettableActionAdapterFactory.java @@ -20,34 +20,32 @@ import org.eclipse.debug.ui.actions.IRunToLineTarget; /** * Creates adapters for retargettable actions in debug platform. - * Contributed via <code>org.eclipse.core.runtime.adapters</code> - * extension point. + * Contributed via <code>org.eclipse.core.runtime.adapters</code> + * extension point. */ public class RetargettableActionAdapterFactory implements IAdapterFactory { @SuppressWarnings("unchecked") @Override - public <T> T getAdapter( Object adaptableObject, Class<T> adapterType ) { - if ( adapterType == IRunToLineTarget.class ) { + public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) { + if (adapterType == IRunToLineTarget.class) { return (T) new RunToLineAdapter(); - } - if ( adapterType == IResumeAtLineTarget.class ) { + } + if (adapterType == IResumeAtLineTarget.class) { return (T) new ResumeAtLineAdapter(); } - if ( adapterType == IMoveToLineTarget.class ) { + if (adapterType == IMoveToLineTarget.class) { return (T) new MoveToLineAdapter(); - } - if ( adapterType == IResumeWithoutSignalHandler.class ) { + } + if (adapterType == IResumeWithoutSignalHandler.class) { return (T) new ResumeWithoutSignalCommand(); - } + } return null; } @Override public Class<?>[] getAdapterList() { - return new Class[]{ IRunToLineTarget.class, - IResumeAtLineTarget.class, - IMoveToLineTarget.class, - IResumeWithoutSignalHandler.class }; + return new Class[] { IRunToLineTarget.class, IResumeAtLineTarget.class, IMoveToLineTarget.class, + IResumeWithoutSignalHandler.class }; } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RunToLineAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RunToLineAdapter.java index 26029edd227..b7d5e1208d1 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RunToLineAdapter.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RunToLineAdapter.java @@ -51,105 +51,105 @@ public class RunToLineAdapter implements IRunToLineTarget { * @see org.eclipse.debug.ui.actions.IRunToLineTarget#runToLine(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection, org.eclipse.debug.core.model.ISuspendResume) */ @Override - public void runToLine( IWorkbenchPart part, ISelection selection, ISuspendResume target ) throws CoreException { + public void runToLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) throws CoreException { String errorMessage = null; - if ( part instanceof ITextEditor ) { - ITextEditor textEditor = (ITextEditor)part; + if (part instanceof ITextEditor) { + ITextEditor textEditor = (ITextEditor) part; IEditorInput input = textEditor.getEditorInput(); - if ( input == null ) { - errorMessage = ActionMessages.getString( "RunToLineAdapter.Empty_editor_1" ); //$NON-NLS-1$ - } - else { - IDocument document = textEditor.getDocumentProvider().getDocument( input ); - if ( document == null ) { - errorMessage = ActionMessages.getString( "RunToLineAdapter.Missing_document_1" ); //$NON-NLS-1$ - } - else { - final String fileName = getFileName( input ); // actually, absolute path, not just file name - final IPath path = new Path( fileName ); - ITextSelection textSelection = (ITextSelection)selection; + if (input == null) { + errorMessage = ActionMessages.getString("RunToLineAdapter.Empty_editor_1"); //$NON-NLS-1$ + } else { + IDocument document = textEditor.getDocumentProvider().getDocument(input); + if (document == null) { + errorMessage = ActionMessages.getString("RunToLineAdapter.Missing_document_1"); //$NON-NLS-1$ + } else { + final String fileName = getFileName(input); // actually, absolute path, not just file name + final IPath path = new Path(fileName); + ITextSelection textSelection = (ITextSelection) selection; final int lineNumber = textSelection.getStartLine() + 1; - if ( target instanceof IAdaptable ) { - final IRunToLine runToLine = ((IAdaptable)target).getAdapter( IRunToLine.class ); - if ( runToLine != null && runToLine.canRunToLine( path.toPortableString(), lineNumber ) ) { + if (target instanceof IAdaptable) { + final IRunToLine runToLine = ((IAdaptable) target).getAdapter(IRunToLine.class); + if (runToLine != null && runToLine.canRunToLine(path.toPortableString(), lineNumber)) { Runnable r = new Runnable() { - + @Override public void run() { try { - runToLine.runToLine( path.toPortableString(), lineNumber, DebugUITools.getPreferenceStore().getBoolean( IDebugUIConstants.PREF_SKIP_BREAKPOINTS_DURING_RUN_TO_LINE ) ); + runToLine.runToLine(path.toPortableString(), lineNumber, + DebugUITools.getPreferenceStore().getBoolean( + IDebugUIConstants.PREF_SKIP_BREAKPOINTS_DURING_RUN_TO_LINE)); + } catch (DebugException e) { + failed(e); } - catch( DebugException e ) { - failed( e ); - } } }; - runInBackground( r ); + runInBackground(r); } } return; } } + } else { + errorMessage = ActionMessages.getString("RunToLineAdapter.Operation_is_not_supported_1"); //$NON-NLS-1$ } - else { - errorMessage = ActionMessages.getString( "RunToLineAdapter.Operation_is_not_supported_1" ); //$NON-NLS-1$ - } - throw new CoreException( new Status( IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), IInternalCDebugUIConstants.INTERNAL_ERROR, errorMessage, null ) ); + throw new CoreException(new Status(IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), + IInternalCDebugUIConstants.INTERNAL_ERROR, errorMessage, null)); } /* (non-Javadoc) * @see org.eclipse.debug.ui.actions.IRunToLineTarget#canRunToLine(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection, org.eclipse.debug.core.model.ISuspendResume) */ @Override - public boolean canRunToLine( IWorkbenchPart part, ISelection selection, ISuspendResume target ) { - if ( target instanceof IAdaptable ) { - if ( part instanceof IEditorPart ) { - IRunToLine runToLine = ((IAdaptable)target).getAdapter( IRunToLine.class ); - if ( runToLine == null ) + public boolean canRunToLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) { + if (target instanceof IAdaptable) { + if (part instanceof IEditorPart) { + IRunToLine runToLine = ((IAdaptable) target).getAdapter(IRunToLine.class); + if (runToLine == null) return false; - IEditorPart editorPart = (IEditorPart)part; + IEditorPart editorPart = (IEditorPart) part; IEditorInput input = editorPart.getEditorInput(); - if ( input == null ) { + if (input == null) { return false; } - if ( !(editorPart instanceof ITextEditor) ) { + if (!(editorPart instanceof ITextEditor)) { return false; } - ITextEditor textEditor = (ITextEditor)editorPart; - IDocument document = textEditor.getDocumentProvider().getDocument( input ); - if ( document == null ) { + ITextEditor textEditor = (ITextEditor) editorPart; + IDocument document = textEditor.getDocumentProvider().getDocument(input); + if (document == null) { return false; } String fileName = null; // actually, absolute path, not just file name try { - fileName = getFileName( input ); - } - catch( CoreException e ) { + fileName = getFileName(input); + } catch (CoreException e) { } if (fileName == null) { return false; } - final IPath path = new Path( fileName ); - - ITextSelection textSelection = (ITextSelection)selection; + final IPath path = new Path(fileName); + + ITextSelection textSelection = (ITextSelection) selection; int lineNumber = textSelection.getStartLine() + 1; - return runToLine.canRunToLine( path.toPortableString(), lineNumber ); + return runToLine.canRunToLine(path.toPortableString(), lineNumber); } } return false; } - private String getFileName( IEditorInput input ) throws CoreException { + private String getFileName(IEditorInput input) throws CoreException { return CDebugUIUtils.getEditorFilePath(input); } - private void runInBackground( Runnable r ) { - DebugPlugin.getDefault().asyncExec( r ); + private void runInBackground(Runnable r) { + DebugPlugin.getDefault().asyncExec(r); } - protected void failed( Throwable e ) { - MultiStatus ms = new MultiStatus( CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, ActionMessages.getString( "RunToLineAdapter.0" ), null ); //$NON-NLS-1$ - ms.add( new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, e.getMessage(), e ) ); - CDebugUtils.error( ms, this ); + protected void failed(Throwable e) { + MultiStatus ms = new MultiStatus(CDIDebugModel.getPluginIdentifier(), + ICDebugInternalConstants.STATUS_CODE_ERROR, ActionMessages.getString("RunToLineAdapter.0"), null); //$NON-NLS-1$ + ms.add(new Status(IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), + ICDebugInternalConstants.STATUS_CODE_ERROR, e.getMessage(), e)); + CDebugUtils.error(ms, this); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ShowFullPathsAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ShowFullPathsAction.java index a1de249c981..77069c5c06a 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ShowFullPathsAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ShowFullPathsAction.java @@ -53,7 +53,7 @@ public class ShowFullPathsAction extends ViewFilterAction { * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) */ @Override - public boolean select( Viewer viewer, Object parentElement, Object element ) { + public boolean select(Viewer viewer, Object parentElement, Object element) { return true; } @@ -61,67 +61,67 @@ public class ShowFullPathsAction extends ViewFilterAction { * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ @Override - public void run( IAction action ) { + public void run(IAction action) { final StructuredViewer viewer = getStructuredViewer(); - IDebugView view = getView().getAdapter( IDebugView.class ); + IDebugView view = getView().getAdapter(IDebugView.class); if (view != null) { - IDebugModelPresentation pres = view.getPresentation( CDIDebugModel.getPluginIdentifier() ); - if ( pres != null ) { - pres.setAttribute( CDebugModelPresentation.DISPLAY_FULL_PATHS, Boolean.valueOf( getValue() ) ); - BusyIndicator.showWhile( viewer.getControl().getDisplay(), - new Runnable() { - @Override - public void run() { - String key = getView().getSite().getId() + "." + getPreferenceKey(); //$NON-NLS-1$ - getPreferenceStore().setValue( key, getValue() ); - CDebugUIPlugin.getDefault().savePluginPreferences(); + IDebugModelPresentation pres = view.getPresentation(CDIDebugModel.getPluginIdentifier()); + if (pres != null) { + pres.setAttribute(CDebugModelPresentation.DISPLAY_FULL_PATHS, Boolean.valueOf(getValue())); + BusyIndicator.showWhile(viewer.getControl().getDisplay(), new Runnable() { + @Override + public void run() { + String key = getView().getSite().getId() + "." + getPreferenceKey(); //$NON-NLS-1$ + getPreferenceStore().setValue(key, getValue()); + CDebugUIPlugin.getDefault().savePluginPreferences(); - // Refresh the viewer after we've set the preference because - // DSF-based debuggers trigger off this preference. - viewer.refresh(); - } - } ); + // Refresh the viewer after we've set the preference because + // DSF-based debuggers trigger off this preference. + viewer.refresh(); + } + }); } - } + } } - + /* * Some debugger integrations don`t use debugTargets (e.g., DSF), so we * verify if the launch has the proper attribute instead. * If we don`t find any launches that allow us to enable the action, we should - * call our parent class to keep any previous debugger integration properly - * working with this feature. - */ - /** @since 7.0 */ + * call our parent class to keep any previous debugger integration properly + * working with this feature. + */ + /** @since 7.0 */ @Override public void selectionChanged(IAction action, ISelection selection) { IDebugView view = getView().getAdapter(IDebugView.class); - + // Debug view if (view instanceof LaunchView) { ILaunchManager launchmgr = DebugPlugin.getDefault().getLaunchManager(); ILaunch[] launches = launchmgr.getLaunches(); for (ILaunch launch : launches) { - if (launch.getAttribute(getPreferenceKey()) != null && - launch.isTerminated() == false) { + if (launch.getAttribute(getPreferenceKey()) != null && launch.isTerminated() == false) { setEnabled(true); return; } } } - + // Breakpoints view else if (view instanceof BreakpointsView) { IBreakpointManager bkptmgr = DebugPlugin.getDefault().getBreakpointManager(); IBreakpoint[] bkpts = bkptmgr.getBreakpoints(); for (IBreakpoint bkpt : bkpts) { try { - Object attr = bkpt.getMarker().getAttribute(ICDebugInternalConstants.ATTR_CAPABLE_OF_SHOW_FULL_PATHS); + Object attr = bkpt.getMarker() + .getAttribute(ICDebugInternalConstants.ATTR_CAPABLE_OF_SHOW_FULL_PATHS); if (attr != null) { setEnabled(true); return; } - } catch (Exception e) {/* ignore */} + } catch (Exception e) { + /* ignore */} } } super.selectionChanged(action, selection); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/SignalActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/SignalActionDelegate.java index 2589a383f4b..3c88bec24a8 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/SignalActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/SignalActionDelegate.java @@ -36,41 +36,40 @@ public class SignalActionDelegate extends ActionDelegate implements IObjectActio /* * (non-Javadoc) - * + * * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) */ @Override - public void setActivePart( IAction action, IWorkbenchPart targetPart ) { + public void setActivePart(IAction action, IWorkbenchPart targetPart) { } /* * (non-Javadoc) - * + * * @see org.eclipse.ui.IActionDelegate#run(IAction) */ @Override - public void run( IAction action ) { - if ( getSignal() != null ) { - final MultiStatus ms = new MultiStatus( CDebugUIPlugin.getUniqueIdentifier(), DebugException.REQUEST_FAILED, ActionMessages.getString( "SignalActionDelegate.0" ), null ); //$NON-NLS-1$ - BusyIndicator.showWhile( Display.getCurrent(), new Runnable() { + public void run(IAction action) { + if (getSignal() != null) { + final MultiStatus ms = new MultiStatus(CDebugUIPlugin.getUniqueIdentifier(), DebugException.REQUEST_FAILED, + ActionMessages.getString("SignalActionDelegate.0"), null); //$NON-NLS-1$ + BusyIndicator.showWhile(Display.getCurrent(), new Runnable() { @Override public void run() { try { - doAction( getSignal() ); - } - catch( DebugException e ) { - ms.merge( e.getStatus() ); + doAction(getSignal()); + } catch (DebugException e) { + ms.merge(e.getStatus()); } } - } ); - if ( !ms.isOK() ) { + }); + if (!ms.isOK()) { IWorkbenchWindow window = CDebugUIPlugin.getActiveWorkbenchWindow(); - if ( window != null ) { - CDebugUIPlugin.errorDialog( ActionMessages.getString( "SignalActionDelegate.1" ), ms ); //$NON-NLS-1$ - } - else { - CDebugUIPlugin.log( ms ); + if (window != null) { + CDebugUIPlugin.errorDialog(ActionMessages.getString("SignalActionDelegate.1"), ms); //$NON-NLS-1$ + } else { + CDebugUIPlugin.log(ms); } } } @@ -78,35 +77,35 @@ public class SignalActionDelegate extends ActionDelegate implements IObjectActio /* * (non-Javadoc) - * + * * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection) */ @Override - public void selectionChanged( IAction action, ISelection selection ) { - if ( selection instanceof IStructuredSelection ) { - Object element = ((IStructuredSelection)selection).getFirstElement(); - if ( element instanceof ICSignal ) { - boolean enabled = enablesFor( (ICSignal)element ); - action.setEnabled( enabled ); - if ( enabled ) { - setSignal( (ICSignal)element ); + public void selectionChanged(IAction action, ISelection selection) { + if (selection instanceof IStructuredSelection) { + Object element = ((IStructuredSelection) selection).getFirstElement(); + if (element instanceof ICSignal) { + boolean enabled = enablesFor((ICSignal) element); + action.setEnabled(enabled); + if (enabled) { + setSignal((ICSignal) element); return; } } } - action.setEnabled( false ); - setSignal( null ); + action.setEnabled(false); + setSignal(null); } - protected void doAction( ICSignal signal ) throws DebugException { + protected void doAction(ICSignal signal) throws DebugException { signal.signal(); } - private boolean enablesFor( ICSignal signal ) { + private boolean enablesFor(ICSignal signal) { return (signal != null && signal.getDebugTarget().isSuspended()); } - private void setSignal( ICSignal signal ) { + private void setSignal(ICSignal signal) { fSignal = signal; } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/SignalPropertiesActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/SignalPropertiesActionDelegate.java index 3102463d2d8..b8e1ca058b1 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/SignalPropertiesActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/SignalPropertiesActionDelegate.java @@ -36,7 +36,7 @@ public class SignalPropertiesActionDelegate extends ActionDelegate implements IO /** * Constructor for SignalPropertiesActionDelegate. - * + * */ public SignalPropertiesActionDelegate() { super(); @@ -47,7 +47,7 @@ public class SignalPropertiesActionDelegate extends ActionDelegate implements IO * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart) */ @Override - public void setActivePart( IAction action, IWorkbenchPart targetPart ) { + public void setActivePart(IAction action, IWorkbenchPart targetPart) { fTargetPart = targetPart; } @@ -55,24 +55,24 @@ public class SignalPropertiesActionDelegate extends ActionDelegate implements IO * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) */ @Override - public void selectionChanged( IAction action, ISelection selection ) { - if ( selection instanceof IStructuredSelection ) { - Object element = ((IStructuredSelection)selection).getFirstElement(); - if ( element instanceof ICSignal ) { - action.setEnabled( true ); - setSignal( (ICSignal)element ); + public void selectionChanged(IAction action, ISelection selection) { + if (selection instanceof IStructuredSelection) { + Object element = ((IStructuredSelection) selection).getFirstElement(); + if (element instanceof ICSignal) { + action.setEnabled(true); + setSignal((ICSignal) element); return; } } - action.setEnabled( false ); - setSignal( null ); + action.setEnabled(false); + setSignal(null); } protected ICSignal getSignal() { return this.fSignal; } - private void setSignal( ICSignal signal ) { + private void setSignal(ICSignal signal) { this.fSignal = signal; } @@ -80,26 +80,27 @@ public class SignalPropertiesActionDelegate extends ActionDelegate implements IO * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ @Override - public void run( IAction action ) { - PropertyDialogAction propertyAction = new PropertyDialogAction( getActivePart().getSite(), new ISelectionProvider() { + public void run(IAction action) { + PropertyDialogAction propertyAction = new PropertyDialogAction(getActivePart().getSite(), + new ISelectionProvider() { - @Override - public void addSelectionChangedListener( ISelectionChangedListener listener ) { - } + @Override + public void addSelectionChangedListener(ISelectionChangedListener listener) { + } - @Override - public ISelection getSelection() { - return new StructuredSelection( getSignal() ); - } + @Override + public ISelection getSelection() { + return new StructuredSelection(getSignal()); + } - @Override - public void removeSelectionChangedListener( ISelectionChangedListener listener ) { - } + @Override + public void removeSelectionChangedListener(ISelectionChangedListener listener) { + } - @Override - public void setSelection( ISelection selection ) { - } - } ); + @Override + public void setSelection(ISelection selection) { + } + }); propertyAction.run(); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleInstructionStepModeActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleInstructionStepModeActionDelegate.java index 53f99b33f30..2598d93f247 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleInstructionStepModeActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleInstructionStepModeActionDelegate.java @@ -39,12 +39,11 @@ import org.eclipse.ui.actions.ActionDelegate; /** * Turns instruction step mode on/off for selected target. */ -public class ToggleInstructionStepModeActionDelegate extends ActionDelegate - implements IViewActionDelegate, IWorkbenchWindowActionDelegate, IPropertyChangeListener, IDebugContextListener -{ +public class ToggleInstructionStepModeActionDelegate extends ActionDelegate + implements IViewActionDelegate, IWorkbenchWindowActionDelegate, IPropertyChangeListener, IDebugContextListener { private ISteppingModeTarget fTarget = null; - + private IAction fAction = null; private IWorkbenchWindow fWindow = null; @@ -53,13 +52,13 @@ public class ToggleInstructionStepModeActionDelegate extends ActionDelegate * @see org.eclipse.core.runtime.Preferences.IPropertyChangeListener#propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent) */ @Override - public void propertyChange( PropertyChangeEvent event ) { + public void propertyChange(PropertyChangeEvent event) { IAction action = getAction(); - if ( action != null ) { - if ( event.getNewValue() instanceof Boolean ) { - boolean value = ((Boolean)event.getNewValue()).booleanValue(); - if ( value != action.isChecked() ) - action.setChecked( value ); + if (action != null) { + if (event.getNewValue() instanceof Boolean) { + boolean value = ((Boolean) event.getNewValue()).booleanValue(); + if (value != action.isChecked()) + action.setChecked(value); } } } @@ -68,101 +67,99 @@ public class ToggleInstructionStepModeActionDelegate extends ActionDelegate * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart) */ @Override - public void init( IViewPart view ) { + public void init(IViewPart view) { fWindow = view.getSite().getWorkbenchWindow(); DebugUITools.getDebugContextManager().getContextService(fWindow).addDebugContextListener(this); } @Override public void init(IWorkbenchWindow window) { - fWindow = window; - DebugUITools.getDebugContextManager().getContextService(fWindow).addDebugContextListener(this); + fWindow = window; + DebugUITools.getDebugContextManager().getContextService(fWindow).addDebugContextListener(this); } - + /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate2#dispose() */ @Override public void dispose() { - DebugUITools.getDebugContextManager().getContextService(fWindow).removeDebugContextListener(this); - ISteppingModeTarget target = getTarget(); - if ( target != null && target instanceof ITargetProperties ) { - ((ITargetProperties)target).removePropertyChangeListener( this ); - } - setTarget( null ); - setAction( null ); - } + DebugUITools.getDebugContextManager().getContextService(fWindow).removeDebugContextListener(this); + ISteppingModeTarget target = getTarget(); + if (target != null && target instanceof ITargetProperties) { + ((ITargetProperties) target).removePropertyChangeListener(this); + } + setTarget(null); + setAction(null); + } /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction) */ @Override - public void init( IAction action ) { - setAction( action ); - action.setChecked( false ); - action.setEnabled( false ); + public void init(IAction action) { + setAction(action); + action.setChecked(false); + action.setEnabled(false); } /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ @Override - public void run( IAction action ) { + public void run(IAction action) { boolean enabled = getAction().isChecked(); - ISteppingModeTarget target = getTarget(); - if ( target != null ) { - target.enableInstructionStepping( enabled ); - } + ISteppingModeTarget target = getTarget(); + if (target != null) { + target.enableInstructionStepping(enabled); + } } /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event) */ @Override - public void runWithEvent( IAction action, Event event ) { - run( action ); + public void runWithEvent(IAction action, Event event) { + run(action); } @Override public void debugContextChanged(DebugContextEvent event) { - if (fAction == null) return; - - ISelection selection = event.getContext(); - ISteppingModeTarget newTarget = null; - if ( selection instanceof IStructuredSelection ) { - newTarget = getTargetFromSelection( ((IStructuredSelection)selection).getFirstElement() ); - } - ISteppingModeTarget oldTarget = getTarget(); - if ( oldTarget != null && !oldTarget.equals( newTarget ) ) { - if ( oldTarget instanceof ITargetProperties ) { - ((ITargetProperties)oldTarget).removePropertyChangeListener( this ); - } - setTarget( null ); - fAction.setChecked( false ); - } - if ( newTarget != null && !isTerminated( newTarget ) ) { - setTarget( newTarget ); - if ( newTarget instanceof ITargetProperties ) { - ((ITargetProperties)newTarget).addPropertyChangeListener( this ); - } - fAction.setChecked( newTarget.isInstructionSteppingEnabled() ); - } - fAction.setEnabled( - newTarget != null - && newTarget.supportsInstructionStepping() - && !isTerminated( newTarget ) ); + if (fAction == null) + return; + + ISelection selection = event.getContext(); + ISteppingModeTarget newTarget = null; + if (selection instanceof IStructuredSelection) { + newTarget = getTargetFromSelection(((IStructuredSelection) selection).getFirstElement()); + } + ISteppingModeTarget oldTarget = getTarget(); + if (oldTarget != null && !oldTarget.equals(newTarget)) { + if (oldTarget instanceof ITargetProperties) { + ((ITargetProperties) oldTarget).removePropertyChangeListener(this); + } + setTarget(null); + fAction.setChecked(false); + } + if (newTarget != null && !isTerminated(newTarget)) { + setTarget(newTarget); + if (newTarget instanceof ITargetProperties) { + ((ITargetProperties) newTarget).addPropertyChangeListener(this); + } + fAction.setChecked(newTarget.isInstructionSteppingEnabled()); + } + fAction.setEnabled(newTarget != null && newTarget.supportsInstructionStepping() && !isTerminated(newTarget)); + } + + private boolean isTerminated(ISteppingModeTarget target) { + return ((target instanceof ITerminate && ((ITerminate) target).isTerminated()) + || (target instanceof IDisconnect && ((IDisconnect) target).isDisconnected())); } - private boolean isTerminated( ISteppingModeTarget target ) { - return ( (target instanceof ITerminate && ((ITerminate)target).isTerminated()) - || (target instanceof IDisconnect && ((IDisconnect)target).isDisconnected()) ); - } - private ISteppingModeTarget getTarget() { return this.fTarget; } - private void setTarget( ISteppingModeTarget target ) { + private void setTarget(ISteppingModeTarget target) { this.fTarget = target; } @@ -170,26 +167,24 @@ public class ToggleInstructionStepModeActionDelegate extends ActionDelegate return this.fAction; } - private void setAction( IAction action ) { + private void setAction(IAction action) { this.fAction = action; } - private ISteppingModeTarget getTargetFromSelection( Object element ) { - ISteppingModeTarget target= null; - if ( element instanceof IDebugElement ) { - IDebugTarget debugTarget = ((IDebugElement)element).getDebugTarget(); + private ISteppingModeTarget getTargetFromSelection(Object element) { + ISteppingModeTarget target = null; + if (element instanceof IDebugElement) { + IDebugTarget debugTarget = ((IDebugElement) element).getDebugTarget(); if (debugTarget instanceof ISteppingModeTarget) { - target= (ISteppingModeTarget) debugTarget; + target = (ISteppingModeTarget) debugTarget; } } if (target == null) { if (element instanceof IAdaptable) { - target= ((IAdaptable)element).getAdapter(ISteppingModeTarget.class); + target = ((IAdaptable) element).getAdapter(ISteppingModeTarget.class); } } return target; } - - - + } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ViewFilterAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ViewFilterAction.java index d5064ba402a..c751ca87daa 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ViewFilterAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ViewFilterAction.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -40,7 +40,7 @@ import org.eclipse.ui.IViewPart; * the view has no CDT content. */ public abstract class ViewFilterAction extends ViewerFilter implements IViewActionDelegate, IActionDelegate2 { - + private IViewPart fView; private IAction fAction; @@ -110,17 +110,17 @@ public abstract class ViewFilterAction extends ViewerFilter implements IViewActi * practical generic way to test that so we have to use view specific tests. * Currently, we support the Debug and Breakpoints view. Support for other * views should be added as needed. - * + * * Note that because we do this test on a view selection change, there can * be some edge cases where we'll be enabled even though there is no CDT * content. Closing those gaps would not be easy, and thus not worth the * effort as no harm is done by an unintentional enablement. - * + * * For the Debug view case, we check debugTargets in the base method to * be backwards compatible as this was the criteria from the start. - * A specific action can specialize this method but should call super.selectionChanged - * to maintain backwards compatibility. - * + * A specific action can specialize this method but should call super.selectionChanged + * to maintain backwards compatibility. + * * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, * org.eclipse.jface.viewers.ISelection) */ @@ -128,7 +128,7 @@ public abstract class ViewFilterAction extends ViewerFilter implements IViewActi public void selectionChanged(IAction action, ISelection selection) { boolean enable = false; IDebugView view = getView().getAdapter(IDebugView.class); - + // Debug view if (view instanceof LaunchView) { ILaunchManager launchmgr = DebugPlugin.getDefault().getLaunchManager(); @@ -161,11 +161,11 @@ public abstract class ViewFilterAction extends ViewerFilter implements IViewActi protected IPreferenceStore getPreferenceStore() { return CDebugUIPlugin.getDefault().getPreferenceStore(); } - + /** * Returns the value of this filters preference (on/off) for the given * view. - * + * * @param part * @return boolean */ @@ -173,41 +173,41 @@ public abstract class ViewFilterAction extends ViewerFilter implements IViewActi String key = part.getSite().getId() + "." + getPreferenceKey(); //$NON-NLS-1$ return getPreferenceStore().getBoolean(key); } - + /** * Returns the key for this action's preference - * + * * @return String */ - protected abstract String getPreferenceKey(); + protected abstract String getPreferenceKey(); protected IViewPart getView() { return fView; } - + protected StructuredViewer getStructuredViewer() { IDebugView view = getView().getAdapter(IDebugView.class); if (view != null) { Viewer viewer = view.getViewer(); if (viewer instanceof StructuredViewer) { - return (StructuredViewer)viewer; + return (StructuredViewer) viewer; } - } + } return null; } - + /** * Returns whether this action is selected/checked. - * + * * @return whether this action is selected/checked */ protected boolean getValue() { return fAction.isChecked(); } - + /** * Sets whether the action should be enabled or not. - * + * * @since 7.0 */ protected void setEnabled(boolean enabled) { diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AbstractBreakpointRulerAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AbstractBreakpointRulerAction.java index 8f43b6ed267..05a909a3790 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AbstractBreakpointRulerAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AbstractBreakpointRulerAction.java @@ -26,18 +26,18 @@ import org.eclipse.ui.texteditor.IUpdate; /** * Abstract base implementation of the breakpoint ruler actions. - * - * @see {@link RulerBreakpointAction} + * + * @see {@link RulerBreakpointAction} */ public abstract class AbstractBreakpointRulerAction extends Action implements IUpdate { - + private final IWorkbenchPart fTargetPart; private final IVerticalRulerInfo fRulerInfo; - + /** * Constructs an action to work on breakpoints in the specified * part with the specified vertical ruler information. - * + * * @param part a text editor or DisassemblyView * @param info vertical ruler information */ @@ -50,29 +50,29 @@ public abstract class AbstractBreakpointRulerAction extends Action implements IU /** * Returns the breakpoint at the last line of mouse activity in the ruler * or <code>null</code> if none. - * + * * @return breakpoint associated with activity in the ruler or <code>null</code> */ protected IBreakpoint getBreakpoint() { - IWorkbenchPart targetPart = getTargetPart(); - if (targetPart instanceof ITextEditor) { - return CDebugUIUtils.getBreakpointFromEditor((ITextEditor)targetPart, getVerticalRulerInfo()); - } - return null; + IWorkbenchPart targetPart = getTargetPart(); + if (targetPart instanceof ITextEditor) { + return CDebugUIUtils.getBreakpointFromEditor((ITextEditor) targetPart, getVerticalRulerInfo()); + } + return null; } - + /** * Returns the workbench part this action was created for. - * + * * @return workbench part, a text editor or a DisassemblyView */ protected IWorkbenchPart getTargetPart() { return fTargetPart; } - + /** * Returns the vertical ruler information this action was created for. - * + * * @return vertical ruler information */ protected IVerticalRulerInfo getVerticalRulerInfo() { diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddEventBreakpointActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddEventBreakpointActionDelegate.java index 8d9fbee37c0..a5a736d1c2f 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddEventBreakpointActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddEventBreakpointActionDelegate.java @@ -1,6 +1,6 @@ /******************************************************************************* * Copyright (c) 2008, 2012 QNX Software Systems and others. - * + * * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -35,7 +35,8 @@ import org.eclipse.ui.actions.ActionDelegate; /** * A delegate for the "Add Event Breakpoint" action. */ -public class AddEventBreakpointActionDelegate extends ActionDelegate implements IViewActionDelegate, IObjectActionDelegate { +public class AddEventBreakpointActionDelegate extends ActionDelegate + implements IViewActionDelegate, IObjectActionDelegate { private IViewPart fView; private IWorkbenchPart fPart; @@ -60,7 +61,7 @@ public class AddEventBreakpointActionDelegate extends ActionDelegate implements @Override public void selectionChanged(IAction action, ISelection selection) { - fSelection = selection; + fSelection = selection; } /* (non-Javadoc) @@ -68,18 +69,19 @@ public class AddEventBreakpointActionDelegate extends ActionDelegate implements */ @Override public void run(IAction action) { - IToggleBreakpointsTarget toggleTarget = DebugUITools.getToggleBreakpointsTargetManager().getToggleBreakpointsTarget(fPart, fSelection); - IToggleBreakpointsTargetCExtension cToggleTarget = null; - if (toggleTarget instanceof IToggleBreakpointsTargetCExtension) { - cToggleTarget = (IToggleBreakpointsTargetCExtension)toggleTarget; - } else { - cToggleTarget = fDefaultToggleTarget; - } - try { - cToggleTarget.createEventBreakpointsInteractive(fPart, fSelection); - } catch (CoreException e) { - CDebugUIPlugin.errorDialog( ActionMessages.getString("AddEventBreakpointActionDelegate.2"), e ); //$NON-NLS-1$ - } + IToggleBreakpointsTarget toggleTarget = DebugUITools.getToggleBreakpointsTargetManager() + .getToggleBreakpointsTarget(fPart, fSelection); + IToggleBreakpointsTargetCExtension cToggleTarget = null; + if (toggleTarget instanceof IToggleBreakpointsTargetCExtension) { + cToggleTarget = (IToggleBreakpointsTargetCExtension) toggleTarget; + } else { + cToggleTarget = fDefaultToggleTarget; + } + try { + cToggleTarget.createEventBreakpointsInteractive(fPart, fSelection); + } catch (CoreException e) { + CDebugUIPlugin.errorDialog(ActionMessages.getString("AddEventBreakpointActionDelegate.2"), e); //$NON-NLS-1$ + } } protected void addEventBreakpoint(String id, String arg) { @@ -98,7 +100,7 @@ public class AddEventBreakpointActionDelegate extends ActionDelegate implements @Override public void setActivePart(IAction action, IWorkbenchPart targetPart) { - fPart = targetPart; + fPart = targetPart; } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddFunctionBreakpointActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddFunctionBreakpointActionDelegate.java index 615bcfad2bb..fb3e41b9e8b 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddFunctionBreakpointActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddFunctionBreakpointActionDelegate.java @@ -12,7 +12,7 @@ * QNX Software Systems - Initial API and implementation * Freescale Semiconductor - Address watchpoints, https://bugs.eclipse.org/bugs/show_bug.cgi?id=118299 *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.actions.breakpoints; +package org.eclipse.cdt.debug.internal.ui.actions.breakpoints; import org.eclipse.cdt.debug.internal.ui.actions.ActionMessages; import org.eclipse.cdt.debug.ui.CDebugUIPlugin; @@ -25,7 +25,7 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.IViewActionDelegate; import org.eclipse.ui.IViewPart; import org.eclipse.ui.actions.ActionDelegate; - + /** * A delegate for the "Add Function Breakpoint" action. */ @@ -34,13 +34,13 @@ public class AddFunctionBreakpointActionDelegate extends ActionDelegate implemen private IViewPart fView; private ISelection fSelection; private ToggleBreakpointAdapter fDefaultToggleTarget = new ToggleBreakpointAdapter(); - + /* (non-Javadoc) * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart) */ @Override - public void init( IViewPart view ) { - setView( view ); + public void init(IViewPart view) { + setView(view); } private void setView(IViewPart view) { @@ -50,29 +50,30 @@ public class AddFunctionBreakpointActionDelegate extends ActionDelegate implemen protected IViewPart getView() { return fView; } - + @Override public void selectionChanged(IAction action, ISelection selection) { - fSelection = selection; + fSelection = selection; } - + /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ @Override - public void run( IAction action ) { - IToggleBreakpointsTarget toggleTarget = DebugUITools.getToggleBreakpointsTargetManager().getToggleBreakpointsTarget(fView, fSelection); - IToggleBreakpointsTargetCExtension cToggleTarget = null; - if (toggleTarget instanceof IToggleBreakpointsTargetCExtension) { - cToggleTarget = (IToggleBreakpointsTargetCExtension)toggleTarget; - } else { - cToggleTarget = fDefaultToggleTarget; - } - - try { - cToggleTarget.createFunctionBreakpointInteractive(fView, fSelection); - } catch (CoreException e) { - CDebugUIPlugin.errorDialog( ActionMessages.getString( "AddFunctionBreakpointActionDelegate.0" ), e ); //$NON-NLS-1$ - } + public void run(IAction action) { + IToggleBreakpointsTarget toggleTarget = DebugUITools.getToggleBreakpointsTargetManager() + .getToggleBreakpointsTarget(fView, fSelection); + IToggleBreakpointsTargetCExtension cToggleTarget = null; + if (toggleTarget instanceof IToggleBreakpointsTargetCExtension) { + cToggleTarget = (IToggleBreakpointsTargetCExtension) toggleTarget; + } else { + cToggleTarget = fDefaultToggleTarget; + } + + try { + cToggleTarget.createFunctionBreakpointInteractive(fView, fSelection); + } catch (CoreException e) { + CDebugUIPlugin.errorDialog(ActionMessages.getString("AddFunctionBreakpointActionDelegate.0"), e); //$NON-NLS-1$ + } } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddLineBreakpointActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddLineBreakpointActionDelegate.java index cb5201df200..5bc8645dfd7 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddLineBreakpointActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddLineBreakpointActionDelegate.java @@ -42,8 +42,8 @@ public class AddLineBreakpointActionDelegate extends ActionDelegate implements I * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart) */ @Override - public void init( IViewPart view ) { - setView( view ); + public void init(IViewPart view) { + setView(view); } private void setView(IViewPart view) { @@ -56,26 +56,27 @@ public class AddLineBreakpointActionDelegate extends ActionDelegate implements I @Override public void selectionChanged(IAction action, ISelection selection) { - fSelection = selection; + fSelection = selection; } /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ @Override - public void run( IAction action ) { - IToggleBreakpointsTarget toggleTarget = DebugUITools.getToggleBreakpointsTargetManager().getToggleBreakpointsTarget(fView, fSelection); - IToggleBreakpointsTargetCExtension cToggleTarget = null; - if (toggleTarget instanceof IToggleBreakpointsTargetCExtension) { - cToggleTarget = (IToggleBreakpointsTargetCExtension)toggleTarget; - } else { - cToggleTarget = fDefaultToggleTarget; - } + public void run(IAction action) { + IToggleBreakpointsTarget toggleTarget = DebugUITools.getToggleBreakpointsTargetManager() + .getToggleBreakpointsTarget(fView, fSelection); + IToggleBreakpointsTargetCExtension cToggleTarget = null; + if (toggleTarget instanceof IToggleBreakpointsTargetCExtension) { + cToggleTarget = (IToggleBreakpointsTargetCExtension) toggleTarget; + } else { + cToggleTarget = fDefaultToggleTarget; + } - try { - cToggleTarget.createLineBreakpointsInteractive(fView, fSelection); - } catch (CoreException e) { - CDebugUIPlugin.errorDialog( ActionMessages.getString( "AddLineBreakpointActionDelegate.0" ), e ); //$NON-NLS-1$ - } + try { + cToggleTarget.createLineBreakpointsInteractive(fView, fSelection); + } catch (CoreException e) { + CDebugUIPlugin.errorDialog(ActionMessages.getString("AddLineBreakpointActionDelegate.0"), e); //$NON-NLS-1$ + } } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CAddBreakpointInteractiveRulerAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CAddBreakpointInteractiveRulerAction.java index ee9e05d2c5d..ecef41f3ec2 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CAddBreakpointInteractiveRulerAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CAddBreakpointInteractiveRulerAction.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation * Wind River Systems - added support for IToggleBreakpointsTargetFactory @@ -41,30 +41,30 @@ import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.ui.texteditor.IUpdate; /** - * Action to interactively create a breakpoint from the vertical ruler of a - * workbench part containing a document. The part must provide an + * Action to interactively create a breakpoint from the vertical ruler of a + * workbench part containing a document. The part must provide an * <code>IToggleBreakpointsTargetExtension2</code> adapter. * <p> - * Clients may instantiate this class. + * Clients may instantiate this class. * </p> * @since 7.2 * @see org.eclipse.debug.ui.actions.RulerToggleBreakpointActionDelegate */ public class CAddBreakpointInteractiveRulerAction extends Action implements IUpdate { - + private IWorkbenchPart fPart; private IDocument fDocument; private IVerticalRulerInfo fRulerInfo; private IToggleBreakpointsTargetManagerListener fListener = new IToggleBreakpointsTargetManagerListener() { - public void preferredTargetsChanged() { - update(); - } + public void preferredTargetsChanged() { + update(); + } }; /** * Constructs a new action to toggle a breakpoint in the given * part containing the given document and ruler. - * + * * @param part the part in which to toggle the breakpoint - provides * an <code>IToggleBreakpointsTarget</code> adapter * @param document the document breakpoints are being set in or @@ -74,61 +74,61 @@ public class CAddBreakpointInteractiveRulerAction extends Action implements IUpd */ public CAddBreakpointInteractiveRulerAction(IWorkbenchPart part, IDocument document, IVerticalRulerInfo rulerInfo) { super(ActionMessages.getString("CAddBreakpointInteractiveRulerAction_label") + "\t" + //$NON-NLS-1$ //$NON-NLS-2$ - CDebugUIUtils.formatKeyBindingString(SWT.MOD1, ActionMessages.getString("CRulerToggleBreakpointAction_accelerator")) ); //$NON-NLS-1$ + CDebugUIUtils.formatKeyBindingString(SWT.MOD1, + ActionMessages.getString("CRulerToggleBreakpointAction_accelerator"))); //$NON-NLS-1$ fPart = part; fDocument = document; fRulerInfo = rulerInfo; DebugUITools.getToggleBreakpointsTargetManager().addChangedListener(fListener); } - + /* * (non-Javadoc) * @see org.eclipse.jface.action.IAction#run() */ public void run() { - IDocument document= getDocument(); + IDocument document = getDocument(); if (document == null) { return; } int line = fRulerInfo.getLineOfLastMouseButtonActivity(); - + // Test if line is valid if (line == -1) return; try { ITextSelection selection = getTextSelection(document, line); - IToggleBreakpointsTarget toggleTarget = - DebugUITools.getToggleBreakpointsTargetManager().getToggleBreakpointsTarget(fPart, selection); + IToggleBreakpointsTarget toggleTarget = DebugUITools.getToggleBreakpointsTargetManager() + .getToggleBreakpointsTarget(fPart, selection); if (toggleTarget instanceof IToggleBreakpointsTargetCExtension) { - IToggleBreakpointsTargetCExtension extension = (IToggleBreakpointsTargetCExtension) toggleTarget; - if (extension.canCreateLineBreakpointsInteractive(fPart, selection)) { - extension.createLineBreakpointsInteractive(fPart, selection); - } - } + IToggleBreakpointsTargetCExtension extension = (IToggleBreakpointsTargetCExtension) toggleTarget; + if (extension.canCreateLineBreakpointsInteractive(fPart, selection)) { + extension.createLineBreakpointsInteractive(fPart, selection); + } + } } catch (BadLocationException e) { reportException(e); } catch (CoreException e) { reportException(e); } } - + /** * Report an error to the user. - * + * * @param e underlying exception */ private void reportException(Exception e) { - IStatus status= new Status(IStatus.ERROR, CDebugUIPlugin.PLUGIN_ID, "Error creating breakpoint: ", e); //$NON-NLS-1$ - ErrorDialog.openError( - fPart.getSite().getShell(), - ActionMessages.getString("CAddBreakpointInteractiveRulerAction_error_title"), //$NON-NLS-1$ - ActionMessages.getString("CAddBreakpointInteractiveRulerAction_error_message"), //$NON-NLS-1$ - status); - CDebugUIPlugin.log(status); // + IStatus status = new Status(IStatus.ERROR, CDebugUIPlugin.PLUGIN_ID, "Error creating breakpoint: ", e); //$NON-NLS-1$ + ErrorDialog.openError(fPart.getSite().getShell(), + ActionMessages.getString("CAddBreakpointInteractiveRulerAction_error_title"), //$NON-NLS-1$ + ActionMessages.getString("CAddBreakpointInteractiveRulerAction_error_message"), //$NON-NLS-1$ + status); + CDebugUIPlugin.log(status); // } - + /** * Disposes this action. Clients must call this method when * this action is no longer needed. @@ -137,60 +137,60 @@ public class CAddBreakpointInteractiveRulerAction extends Action implements IUpd fDocument = null; fPart = null; fRulerInfo = null; - DebugUITools.getToggleBreakpointsTargetManager().removeChangedListener(fListener); + DebugUITools.getToggleBreakpointsTargetManager().removeChangedListener(fListener); } /** * Returns the document on which this action operates. - * + * * @return the document or <code>null</code> if none */ private IDocument getDocument() { if (fDocument != null) return fDocument; - + if (fPart instanceof ITextEditor) { - ITextEditor editor= (ITextEditor)fPart; + ITextEditor editor = (ITextEditor) fPart; IDocumentProvider provider = editor.getDocumentProvider(); if (provider != null) return provider.getDocument(editor.getEditorInput()); } - + IDocument doc = fPart.getAdapter(IDocument.class); if (doc != null) { return doc; } - + return null; } - + /* (non-Javadoc) * @see org.eclipse.ui.texteditor.IUpdate#update() */ public void update() { - IDocument document= getDocument(); + IDocument document = getDocument(); if (document != null) { - int line = fRulerInfo.getLineOfLastMouseButtonActivity(); - if (line > -1) { - try { - ITextSelection selection = getTextSelection(document, line); - - IToggleBreakpointsTarget adapter = - DebugUITools.getToggleBreakpointsTargetManager().getToggleBreakpointsTarget(fPart, selection); - if (adapter == null) { - setEnabled(false); - return; - } - if (adapter instanceof IToggleBreakpointsTargetCExtension) { - IToggleBreakpointsTargetCExtension extension = (IToggleBreakpointsTargetCExtension) adapter; - if (extension.canCreateLineBreakpointsInteractive(fPart, selection)) { - setEnabled(true); - return; - } - } - } catch (BadLocationException e) { - reportException(e); - } + int line = fRulerInfo.getLineOfLastMouseButtonActivity(); + if (line > -1) { + try { + ITextSelection selection = getTextSelection(document, line); + + IToggleBreakpointsTarget adapter = DebugUITools.getToggleBreakpointsTargetManager() + .getToggleBreakpointsTarget(fPart, selection); + if (adapter == null) { + setEnabled(false); + return; + } + if (adapter instanceof IToggleBreakpointsTargetCExtension) { + IToggleBreakpointsTargetCExtension extension = (IToggleBreakpointsTargetCExtension) adapter; + if (extension.canCreateLineBreakpointsInteractive(fPart, selection)) { + setEnabled(true); + return; + } + } + } catch (BadLocationException e) { + reportException(e); + } } } setEnabled(false); @@ -198,9 +198,9 @@ public class CAddBreakpointInteractiveRulerAction extends Action implements IUpd /** * Determines the text selection for the breakpoint action. If clicking on the ruler inside - * the highlighted text, return the text selection for the highlighted text. Otherwise, + * the highlighted text, return the text selection for the highlighted text. Otherwise, * return a text selection representing the start of the line. - * + * * @param document The IDocument backing the Editor. * @param line The line clicked on in the ruler. * @return An ITextSelection as described. @@ -210,13 +210,12 @@ public class CAddBreakpointInteractiveRulerAction extends Action implements IUpd IRegion region = document.getLineInformation(line); ITextSelection textSelection = new TextSelection(document, region.getOffset(), 0); ISelectionProvider provider = fPart.getSite().getSelectionProvider(); - if (provider != null){ + if (provider != null) { ISelection selection = provider.getSelection(); - if (selection instanceof ITextSelection - && ((ITextSelection) selection).getStartLine() <= line + if (selection instanceof ITextSelection && ((ITextSelection) selection).getStartLine() <= line && ((ITextSelection) selection).getEndLine() >= line) { textSelection = (ITextSelection) selection; - } + } } return textSelection; } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CAddBreakpointInteractiveRulerActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CAddBreakpointInteractiveRulerActionDelegate.java index f4a253949d3..e835f79017e 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CAddBreakpointInteractiveRulerActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CAddBreakpointInteractiveRulerActionDelegate.java @@ -22,8 +22,8 @@ import org.eclipse.ui.texteditor.AbstractRulerActionDelegate; import org.eclipse.ui.texteditor.ITextEditor; /** - * Creates a breakpoint interactively, that is with user input as well as context - * information gathered from editor location. This action delegate can be + * Creates a breakpoint interactively, that is with user input as well as context + * information gathered from editor location. This action delegate can be * contributed to an editor with the <code>editorActions</code> extension point. * This action is a factory that creates another action that performs the * actual breakpoint toggling. The created action acts on the editor's @@ -47,15 +47,16 @@ import org.eclipse.ui.texteditor.ITextEditor; * </pre> * </p> * <p> - * Clients may refer to this class as an action delegate in plug-in XML. + * Clients may refer to this class as an action delegate in plug-in XML. * </p> * @see IToggleBreakpointsTargetCExtension * @since 7.2 * @noextend This class is not intended to be sub-classed by clients. * @noinstantiate This class is not intended to be instantiated by clients. */ -public class CAddBreakpointInteractiveRulerActionDelegate extends AbstractRulerActionDelegate implements IActionDelegate2 { - +public class CAddBreakpointInteractiveRulerActionDelegate extends AbstractRulerActionDelegate + implements IActionDelegate2 { + private IEditorPart fEditor = null; private CAddBreakpointInteractiveRulerAction fDelegate = null; diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CAddDynamicPrintfInteractiveRulerAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CAddDynamicPrintfInteractiveRulerAction.java index c7a56d39a77..792997a6a75 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CAddDynamicPrintfInteractiveRulerAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CAddDynamicPrintfInteractiveRulerAction.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation * Wind River Systems - added support for IToggleBreakpointsTargetFactory @@ -43,85 +43,85 @@ import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.ui.texteditor.IUpdate; /** - * Action to interactively create a dynamic printf from the vertical ruler of a - * workbench part containing a document. The part must provide an + * Action to interactively create a dynamic printf from the vertical ruler of a + * workbench part containing a document. The part must provide an * <code>IToggleBreakpointsTargetExtension2</code> adapter. * <p> - * Clients may instantiate this class. + * Clients may instantiate this class. * </p> * @since 7.4 * @see org.eclipse.debug.ui.actions.RulerToggleBreakpointActionDelegate */ public class CAddDynamicPrintfInteractiveRulerAction extends Action implements IUpdate { - + private IWorkbenchPart fPart; private IDocument fDocument; private IVerticalRulerInfo fRulerInfo; private IToggleBreakpointsTargetCExtension fDynamicPrintfBreakpointsTarget; - + /** * Constructs a new action to toggle a dynamic printf in the given * part containing the given document and ruler. - * + * * @param part the part in which to toggle the dynamic printf - provides * an <code>IToggleBreakpointsTarget</code> adapter * @param document the document breakpoints are being set in or * <code>null</code> when the document should be derived from the given part * @param rulerInfo specifies location the user has double-clicked */ - public CAddDynamicPrintfInteractiveRulerAction(IWorkbenchPart part, IDocument document, IVerticalRulerInfo rulerInfo) { - super(ActionMessages.getString("CAddDynamicPrintfInteractiveRulerAction_label")); //$NON-NLS-1$ + public CAddDynamicPrintfInteractiveRulerAction(IWorkbenchPart part, IDocument document, + IVerticalRulerInfo rulerInfo) { + super(ActionMessages.getString("CAddDynamicPrintfInteractiveRulerAction_label")); //$NON-NLS-1$ fPart = part; fDocument = document; fRulerInfo = rulerInfo; } - + /* * (non-Javadoc) * @see org.eclipse.jface.action.IAction#run() */ public void run() { - IDocument document= getDocument(); + IDocument document = getDocument(); if (document == null) { return; } int line = fRulerInfo.getLineOfLastMouseButtonActivity(); - + // Test if line is valid if (line == -1) return; - try { + try { if (fDynamicPrintfBreakpointsTarget != null) { ITextSelection selection = getTextSelection(document, line); if (fDynamicPrintfBreakpointsTarget.canCreateLineBreakpointsInteractive(fPart, selection)) { fDynamicPrintfBreakpointsTarget.createLineBreakpointsInteractive(fPart, selection); } - } + } } catch (BadLocationException e) { reportException(e); } catch (CoreException e) { reportException(e); } } - + /** * Report an error to the user. - * + * * @param e underlying exception */ private void reportException(Exception e) { - IStatus status= new Status(IStatus.ERROR, CDebugUIPlugin.PLUGIN_ID, "Error creating dynamic printf: ", e); //$NON-NLS-1$ - ErrorDialog.openError( - fPart.getSite().getShell(), - ActionMessages.getString("CAddBreakpointInteractiveRulerAction_error_title"), //$NON-NLS-1$ - ActionMessages.getString("CAddDynamicPrintfInteractiveRulerAction_error_message"), //$NON-NLS-1$ - status); - CDebugUIPlugin.log(status); + IStatus status = new Status(IStatus.ERROR, CDebugUIPlugin.PLUGIN_ID, "Error creating dynamic printf: ", e); //$NON-NLS-1$ + ErrorDialog.openError(fPart.getSite().getShell(), + ActionMessages.getString("CAddBreakpointInteractiveRulerAction_error_title"), //$NON-NLS-1$ + ActionMessages.getString("CAddDynamicPrintfInteractiveRulerAction_error_message"), //$NON-NLS-1$ + status); + CDebugUIPlugin.log(status); } - + /** * Disposes this action. Clients must call this method when * this action is no longer needed. @@ -134,54 +134,54 @@ public class CAddDynamicPrintfInteractiveRulerAction extends Action implements I /** * Returns the document on which this action operates. - * + * * @return the document or <code>null</code> if none */ private IDocument getDocument() { if (fDocument != null) return fDocument; - + if (fPart instanceof ITextEditor) { - ITextEditor editor= (ITextEditor)fPart; + ITextEditor editor = (ITextEditor) fPart; IDocumentProvider provider = editor.getDocumentProvider(); if (provider != null) return provider.getDocument(editor.getEditorInput()); } - + IDocument doc = fPart.getAdapter(IDocument.class); if (doc != null) { return doc; } - + return null; } - + /* (non-Javadoc) * @see org.eclipse.ui.texteditor.IUpdate#update() */ public void update() { - IDocument document= getDocument(); + IDocument document = getDocument(); if (document != null) { - int line = fRulerInfo.getLineOfLastMouseButtonActivity(); - if (line > -1) { - try { - ITextSelection selection = getTextSelection(document, line); - + int line = fRulerInfo.getLineOfLastMouseButtonActivity(); + if (line > -1) { + try { + ITextSelection selection = getTextSelection(document, line); + if (fDynamicPrintfBreakpointsTarget == null) { fDynamicPrintfBreakpointsTarget = fetchDynamicPrintfBreakpointsTarget(selection); } - if (fDynamicPrintfBreakpointsTarget == null) { - setEnabled(false); - return; - } - if (fDynamicPrintfBreakpointsTarget.canCreateLineBreakpointsInteractive(fPart, selection)) { - setEnabled(true); - return; - } - } catch (BadLocationException e) { - reportException(e); - } + if (fDynamicPrintfBreakpointsTarget == null) { + setEnabled(false); + return; + } + if (fDynamicPrintfBreakpointsTarget.canCreateLineBreakpointsInteractive(fPart, selection)) { + setEnabled(true); + return; + } + } catch (BadLocationException e) { + reportException(e); + } } } setEnabled(false); @@ -189,9 +189,9 @@ public class CAddDynamicPrintfInteractiveRulerAction extends Action implements I /** * Determines the text selection for the breakpoint action. If clicking on the ruler inside - * the highlighted text, return the text selection for the highlighted text. Otherwise, + * the highlighted text, return the text selection for the highlighted text. Otherwise, * return a text selection representing the start of the line. - * + * * @param document The IDocument backing the Editor. * @param line The line clicked on in the ruler. * @return An ITextSelection as described. @@ -201,38 +201,40 @@ public class CAddDynamicPrintfInteractiveRulerAction extends Action implements I IRegion region = document.getLineInformation(line); ITextSelection textSelection = new TextSelection(document, region.getOffset(), 0); ISelectionProvider provider = fPart.getSite().getSelectionProvider(); - if (provider != null){ + if (provider != null) { ISelection selection = provider.getSelection(); - if (selection instanceof ITextSelection - && ((ITextSelection) selection).getStartLine() <= line + if (selection instanceof ITextSelection && ((ITextSelection) selection).getStartLine() <= line && ((ITextSelection) selection).getEndLine() >= line) { textSelection = (ITextSelection) selection; - } + } } return textSelection; } private IToggleBreakpointsTargetCExtension fetchDynamicPrintfBreakpointsTarget(ITextSelection selection) { - if (fDynamicPrintfBreakpointsTarget == null){ - IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint(IDebugUIConstants.PLUGIN_ID, IDebugUIConstants.EXTENSION_POINT_TOGGLE_BREAKPOINTS_TARGET_FACTORIES); + if (fDynamicPrintfBreakpointsTarget == null) { + IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint(IDebugUIConstants.PLUGIN_ID, + IDebugUIConstants.EXTENSION_POINT_TOGGLE_BREAKPOINTS_TARGET_FACTORIES); IConfigurationElement[] elements = ep.getConfigurationElements(); - for (int i= 0; i < elements.length; i++) { - String id = elements[i].getAttribute("id"); //$NON-NLS-1$ + for (int i = 0; i < elements.length; i++) { + String id = elements[i].getAttribute("id"); //$NON-NLS-1$ if (id != null && id.equals("org.eclipse.cdt.debug.ui.ToggleCDynamicPrintfTargetFactory")) { //$NON-NLS-1$ - try{ + try { Object obj = elements[i].createExecutableExtension("class"); //$NON-NLS-1$ - if(obj instanceof IToggleBreakpointsTargetFactory) { - IToggleBreakpointsTarget target = ((IToggleBreakpointsTargetFactory)obj).createToggleTarget(ToggleCDynamicPrintfTargetFactory.TOGGLE_C_DYNAMICPRINTF_TARGET_ID); + if (obj instanceof IToggleBreakpointsTargetFactory) { + IToggleBreakpointsTarget target = ((IToggleBreakpointsTargetFactory) obj) + .createToggleTarget( + ToggleCDynamicPrintfTargetFactory.TOGGLE_C_DYNAMICPRINTF_TARGET_ID); if (target instanceof IToggleBreakpointsTargetCExtension) { - fDynamicPrintfBreakpointsTarget = (IToggleBreakpointsTargetCExtension)target; + fDynamicPrintfBreakpointsTarget = (IToggleBreakpointsTargetCExtension) target; } - } - } catch (CoreException e){ + } + } catch (CoreException e) { } break; } } } return fDynamicPrintfBreakpointsTarget; - } + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CAddDynamicPrintfInteractiveRulerActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CAddDynamicPrintfInteractiveRulerActionDelegate.java index ffb709c8f7c..1922f8398d3 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CAddDynamicPrintfInteractiveRulerActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CAddDynamicPrintfInteractiveRulerActionDelegate.java @@ -23,8 +23,8 @@ import org.eclipse.ui.texteditor.AbstractRulerActionDelegate; import org.eclipse.ui.texteditor.ITextEditor; /** - * Creates a Dynamic Printf interactively, that is with user input as well as context - * information gathered from editor location. This action delegate can be + * Creates a Dynamic Printf interactively, that is with user input as well as context + * information gathered from editor location. This action delegate can be * contributed to an editor with the <code>editorActions</code> extension point. * This action is as a factory that creates another action that performs the * actual breakpoint toggling. The created action acts on the editor's @@ -48,15 +48,16 @@ import org.eclipse.ui.texteditor.ITextEditor; * </pre> * </p> * <p> - * Clients may refer to this class as an action delegate in plug-in XML. + * Clients may refer to this class as an action delegate in plug-in XML. * </p> * @see IToggleBreakpointsTargetCExtension * @since 7.4 * @noextend This class is not intended to be sub-classed by clients. * @noinstantiate This class is not intended to be instantiated by clients. */ -public class CAddDynamicPrintfInteractiveRulerActionDelegate extends AbstractRulerActionDelegate implements IActionDelegate2 { - +public class CAddDynamicPrintfInteractiveRulerActionDelegate extends AbstractRulerActionDelegate + implements IActionDelegate2 { + private IEditorPart fEditor = null; private CAddDynamicPrintfInteractiveRulerAction fDelegate = null; diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CBreakpointPropertiesHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CBreakpointPropertiesHandler.java index 1fc8b054fdb..2f89442e4cb 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CBreakpointPropertiesHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CBreakpointPropertiesHandler.java @@ -40,31 +40,31 @@ public class CBreakpointPropertiesHandler extends AbstractHandler { @Override public Object execute(ExecutionEvent event) throws ExecutionException { - IWorkbenchPart part = HandlerUtil.getActivePartChecked(event); - final ICBreakpoint bp = getBreakpoint(event.getApplicationContext()); - - if (part != null && bp != null) { - CDebugUIUtils.editBreakpointProperties(part, bp); - } - - return null; + IWorkbenchPart part = HandlerUtil.getActivePartChecked(event); + final ICBreakpoint bp = getBreakpoint(event.getApplicationContext()); + + if (part != null && bp != null) { + CDebugUIUtils.editBreakpointProperties(part, bp); + } + + return null; } - + @Override public void setEnabled(Object evaluationContext) { - setBaseEnabled( getBreakpoint(evaluationContext) != null ); + setBaseEnabled(getBreakpoint(evaluationContext) != null); } - + private ICBreakpoint getBreakpoint(Object evaluationContext) { - if (evaluationContext instanceof IEvaluationContext) { - Object s = ((IEvaluationContext) evaluationContext).getVariable(ISources.ACTIVE_MENU_SELECTION_NAME); - if (s instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection)s; - if (ss.size() == 1) { - return (ICBreakpoint)DebugPlugin.getAdapter(ss.getFirstElement(), ICBreakpoint.class); - } - } - } - return null; + if (evaluationContext instanceof IEvaluationContext) { + Object s = ((IEvaluationContext) evaluationContext).getVariable(ISources.ACTIVE_MENU_SELECTION_NAME); + if (s instanceof IStructuredSelection) { + IStructuredSelection ss = (IStructuredSelection) s; + if (ss.size() == 1) { + return (ICBreakpoint) DebugPlugin.getAdapter(ss.getFirstElement(), ICBreakpoint.class); + } + } + } + return null; } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CBreakpointPropertiesRulerAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CBreakpointPropertiesRulerAction.java index 067a025123f..50f919fc982 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CBreakpointPropertiesRulerAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CBreakpointPropertiesRulerAction.java @@ -33,22 +33,24 @@ import org.eclipse.swt.SWT; import org.eclipse.ui.IWorkbenchPart; /** - * Opens a custom properties dialog to configure the attibutes of a C/C++ breakpoint + * Opens a custom properties dialog to configure the attibutes of a C/C++ breakpoint * from the ruler popup menu. */ public class CBreakpointPropertiesRulerAction extends AbstractBreakpointRulerAction { - private ICBreakpoint fBreakpoint; + private ICBreakpoint fBreakpoint; /** * Creates the action to modify the breakpoint properties. */ - public CBreakpointPropertiesRulerAction( IWorkbenchPart part, IVerticalRulerInfo info ) { - super( part, info ); - setText( ActionMessages.getString( "CBreakpointPropertiesRulerAction.Breakpoint_Properties" ) + "\t" + //$NON-NLS-1$ //$NON-NLS-2$ - CDebugUIUtils.formatKeyBindingString(SWT.MOD1, ActionMessages.getString("CRulerToggleBreakpointAction_accelerator")) ); //$NON-NLS-1$ - part.getSite().getWorkbenchWindow().getWorkbench().getHelpSystem().setHelp( this, ICDebugHelpContextIds.BREAKPOINT_PROPERTIES_ACTION ); - setId( IInternalCDebugUIConstants.ACTION_BREAKPOINT_PROPERTIES ); + public CBreakpointPropertiesRulerAction(IWorkbenchPart part, IVerticalRulerInfo info) { + super(part, info); + setText(ActionMessages.getString("CBreakpointPropertiesRulerAction.Breakpoint_Properties") + "\t" + //$NON-NLS-1$ //$NON-NLS-2$ + CDebugUIUtils.formatKeyBindingString(SWT.MOD1, + ActionMessages.getString("CRulerToggleBreakpointAction_accelerator"))); //$NON-NLS-1$ + part.getSite().getWorkbenchWindow().getWorkbench().getHelpSystem().setHelp(this, + ICDebugHelpContextIds.BREAKPOINT_PROPERTIES_ACTION); + setId(IInternalCDebugUIConstants.ACTION_BREAKPOINT_PROPERTIES); } /* (non-Javadoc) @@ -56,33 +58,49 @@ public class CBreakpointPropertiesRulerAction extends AbstractBreakpointRulerAct */ @Override public void run() { - if ( fBreakpoint != null ) { - final ISelection debugContext = DebugUITools.getDebugContextForPart(getTargetPart()); - CBreakpointPropertyDialogAction propertiesAction = new CBreakpointPropertyDialogAction( - getTargetPart().getSite(), - new ISelectionProvider() { - @Override - public ISelection getSelection() { - return new StructuredSelection( fBreakpoint ); - } - @Override public void addSelectionChangedListener( ISelectionChangedListener listener ) {} - @Override public void removeSelectionChangedListener( ISelectionChangedListener listener ) {} - @Override public void setSelection( ISelection selection ) {} - }, - new IDebugContextProvider() { - @Override - public ISelection getActiveContext() { - return debugContext; - } - @Override public void addDebugContextListener(IDebugContextListener listener) {} - @Override public void removeDebugContextListener(IDebugContextListener listener) {} - @Override public IWorkbenchPart getPart() { return null; } - - } - ); - propertiesAction.run(); - propertiesAction.dispose(); - } + if (fBreakpoint != null) { + final ISelection debugContext = DebugUITools.getDebugContextForPart(getTargetPart()); + CBreakpointPropertyDialogAction propertiesAction = new CBreakpointPropertyDialogAction( + getTargetPart().getSite(), new ISelectionProvider() { + @Override + public ISelection getSelection() { + return new StructuredSelection(fBreakpoint); + } + + @Override + public void addSelectionChangedListener(ISelectionChangedListener listener) { + } + + @Override + public void removeSelectionChangedListener(ISelectionChangedListener listener) { + } + + @Override + public void setSelection(ISelection selection) { + } + }, new IDebugContextProvider() { + @Override + public ISelection getActiveContext() { + return debugContext; + } + + @Override + public void addDebugContextListener(IDebugContextListener listener) { + } + + @Override + public void removeDebugContextListener(IDebugContextListener listener) { + } + + @Override + public IWorkbenchPart getPart() { + return null; + } + + }); + propertiesAction.run(); + propertiesAction.dispose(); + } } /* (non-Javadoc) @@ -90,13 +108,13 @@ public class CBreakpointPropertiesRulerAction extends AbstractBreakpointRulerAct */ @Override public void update() { - IBreakpoint breakpoint= getBreakpoint(); - - if (breakpoint instanceof ICBreakpoint) { - fBreakpoint = (ICBreakpoint)breakpoint; - } else { - fBreakpoint = null; - } - setEnabled( fBreakpoint != null ); + IBreakpoint breakpoint = getBreakpoint(); + + if (breakpoint instanceof ICBreakpoint) { + fBreakpoint = (ICBreakpoint) breakpoint; + } else { + fBreakpoint = null; + } + setEnabled(fBreakpoint != null); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CBreakpointPropertiesRulerActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CBreakpointPropertiesRulerActionDelegate.java index 25db11bd8c8..a2ae50e113f 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CBreakpointPropertiesRulerActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CBreakpointPropertiesRulerActionDelegate.java @@ -24,7 +24,7 @@ public class CBreakpointPropertiesRulerActionDelegate extends AbstractRulerActio * @see org.eclipse.ui.texteditor.AbstractRulerActionDelegate#createAction(org.eclipse.ui.texteditor.ITextEditor, org.eclipse.jface.text.source.IVerticalRulerInfo) */ @Override - protected IAction createAction( ITextEditor editor, IVerticalRulerInfo rulerInfo ) { - return new CBreakpointPropertiesRulerAction( editor, rulerInfo ); + protected IAction createAction(ITextEditor editor, IVerticalRulerInfo rulerInfo) { + return new CBreakpointPropertiesRulerAction(editor, rulerInfo); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CRulerEnableDisableBreakpointActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CRulerEnableDisableBreakpointActionDelegate.java index f0ac08470c4..70bd16deb25 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CRulerEnableDisableBreakpointActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CRulerEnableDisableBreakpointActionDelegate.java @@ -19,10 +19,10 @@ import org.eclipse.ui.texteditor.AbstractRulerActionDelegate; import org.eclipse.ui.texteditor.ITextEditor; /** - * This is a copy of the RulerEnableDisableBreakpointActionDelegate in platform. + * This is a copy of the RulerEnableDisableBreakpointActionDelegate in platform. * It updates the toggle action to include an accelertor text in its label. * See bug 374153. - * + * * @see org.eclipse.debug.ui.actions.RulerEnableDisableBreakpointActionDelegate */ public class CRulerEnableDisableBreakpointActionDelegate extends AbstractRulerActionDelegate { diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CRulerToggleBreakpointActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CRulerToggleBreakpointActionDelegate.java index 8658e5bf2d8..395f258b009 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CRulerToggleBreakpointActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CRulerToggleBreakpointActionDelegate.java @@ -24,14 +24,14 @@ import org.eclipse.ui.texteditor.AbstractRulerActionDelegate; import org.eclipse.ui.texteditor.ITextEditor; /** - * This is a copy of the RulerToggleBreakpointActionDelegate in platform. + * This is a copy of the RulerToggleBreakpointActionDelegate in platform. * It updates the toggle action to include an accelertor text in its label. * See bug 374153. - * + * * @see org.eclipse.debug.ui.actions.RulerToggleBreakpointActionDelegate */ public class CRulerToggleBreakpointActionDelegate extends AbstractRulerActionDelegate implements IActionDelegate2 { - + private IEditorPart fEditor = null; private ToggleBreakpointAction fDelegate = null; @@ -40,8 +40,8 @@ public class CRulerToggleBreakpointActionDelegate extends AbstractRulerActionDel */ protected IAction createAction(ITextEditor editor, IVerticalRulerInfo rulerInfo) { fDelegate = new ToggleBreakpointAction(editor, null, rulerInfo); - fDelegate.setText( ActionMessages.getString("CRulerToggleBreakpointActionDelegate_label") ); //$NON-NLS-1$ - + fDelegate.setText(ActionMessages.getString("CRulerToggleBreakpointActionDelegate_label")); //$NON-NLS-1$ + return fDelegate; } @@ -80,7 +80,7 @@ public class CRulerToggleBreakpointActionDelegate extends AbstractRulerActionDel * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event) */ public void runWithEvent(IAction action, Event event) { - if(fDelegate != null) { + if (fDelegate != null) { fDelegate.runWithEvent(event); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CToggleBreakpointObjectActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CToggleBreakpointObjectActionDelegate.java index bde87748cea..5544037c830 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CToggleBreakpointObjectActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CToggleBreakpointObjectActionDelegate.java @@ -32,59 +32,60 @@ import org.eclipse.ui.IWorkbenchPart; * will perform a toggle breakpoint operation for a selected object. * <p> * This class is based on {@link org.eclipse.debug.internal.ui.actions.breakpoints.ToggleBreakpointObjectActionDelegate } - * class. In addition to the copied functionality, it adds the handling of + * class. In addition to the copied functionality, it adds the handling of * action-triggering event. * </p> - * + * * @since 7.2 */ public abstract class CToggleBreakpointObjectActionDelegate implements IObjectActionDelegate, IActionDelegate2 { - + private IWorkbenchPart fPart; private IStructuredSelection fSelection; - + public void setActivePart(IAction action, IWorkbenchPart targetPart) { fPart = targetPart; } public void run(IAction action) { - runWithEvent(action, null); + runWithEvent(action, null); } public void runWithEvent(IAction action, Event event) { - IToggleBreakpointsTarget target = - DebugUITools.getToggleBreakpointsTargetManager().getToggleBreakpointsTarget(fPart, fSelection); - if (target != null) { - try { - performAction(target, fPart, fSelection, event); - } catch (CoreException e) { - DebugPlugin.log(e); - } - } - } + IToggleBreakpointsTarget target = DebugUITools.getToggleBreakpointsTargetManager() + .getToggleBreakpointsTarget(fPart, fSelection); + if (target != null) { + try { + performAction(target, fPart, fSelection, event); + } catch (CoreException e) { + DebugPlugin.log(e); + } + } + } /** * Performs the operation specific to this action. - * + * * @param target adapter to toggle breakpoints * @param part the active part * @param selection the selection in the active part * @param event that triggered this action * @exception CoreException if an exception occurs */ - protected abstract void performAction(IToggleBreakpointsTarget target, IWorkbenchPart part, ISelection selection, Event event) - throws CoreException; - + protected abstract void performAction(IToggleBreakpointsTarget target, IWorkbenchPart part, ISelection selection, + Event event) throws CoreException; + /** * Returns whether the specific operation is supported. - * + * * @param target the target adapter * @param selection the selection to verify the operation on * @param part the part the operation has been requested on * @return whether the operation can be performed */ - protected abstract boolean canPerformAction(IToggleBreakpointsTarget target, IWorkbenchPart part, ISelection selection); - + protected abstract boolean canPerformAction(IToggleBreakpointsTarget target, IWorkbenchPart part, + ISelection selection); + public void selectionChanged(IAction action, ISelection selection) { boolean enabled = false; if (selection instanceof IStructuredSelection) { @@ -93,9 +94,9 @@ public abstract class CToggleBreakpointObjectActionDelegate implements IObjectAc // selectionChagned() can sometimes be called before setActivePart(). // Guard here against that possibility. if (fPart != null) { - IToggleBreakpointsTarget target = - DebugUITools.getToggleBreakpointsTargetManager().getToggleBreakpointsTarget(fPart, fSelection); - enabled = target != null && canPerformAction(target, fPart, fSelection); + IToggleBreakpointsTarget target = DebugUITools.getToggleBreakpointsTargetManager() + .getToggleBreakpointsTarget(fPart, fSelection); + enabled = target != null && canPerformAction(target, fPart, fSelection); } } action.setEnabled(enabled); @@ -103,7 +104,7 @@ public abstract class CToggleBreakpointObjectActionDelegate implements IObjectAc public void init(IAction action) { } - + public void dispose() { fSelection = null; fPart = null; diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CToggleMethodBreakpointActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CToggleMethodBreakpointActionDelegate.java index 28f5fa0b4fb..f85556d6f1c 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CToggleMethodBreakpointActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CToggleMethodBreakpointActionDelegate.java @@ -28,31 +28,27 @@ import org.eclipse.ui.IWorkbenchPart; * that provide an <code>IToggleBreakpointsTarget</code> adapter. * <p> * This class is based on {@link org.eclipse.debug.ui.actions.ToggleMethodBreakpointActionDelegate } - * class. In addition to the copied functionality, it adds the handling of + * class. In addition to the copied functionality, it adds the handling of * action-triggering event. * </p> - * + * * @since 7.2 */ public class CToggleMethodBreakpointActionDelegate extends CToggleBreakpointObjectActionDelegate { - protected void performAction(IToggleBreakpointsTarget target, IWorkbenchPart part, ISelection selection, Event event) - throws CoreException - { - if ((event.stateMask & SWT.MOD1) != 0 && - target instanceof IToggleBreakpointsTargetCExtension && - ((IToggleBreakpointsTargetCExtension)target).canCreateFunctionBreakpointInteractive(part, selection)) - { - ((IToggleBreakpointsTargetCExtension)target).createFunctionBreakpointInteractive(part, selection); - } - else { - target.toggleMethodBreakpoints(part, selection); - } + protected void performAction(IToggleBreakpointsTarget target, IWorkbenchPart part, ISelection selection, + Event event) throws CoreException { + if ((event.stateMask & SWT.MOD1) != 0 && target instanceof IToggleBreakpointsTargetCExtension + && ((IToggleBreakpointsTargetCExtension) target).canCreateFunctionBreakpointInteractive(part, + selection)) { + ((IToggleBreakpointsTargetCExtension) target).createFunctionBreakpointInteractive(part, selection); + } else { + target.toggleMethodBreakpoints(part, selection); + } } @Override - protected boolean canPerformAction(IToggleBreakpointsTarget target, - IWorkbenchPart part, ISelection selection) { + protected boolean canPerformAction(IToggleBreakpointsTarget target, IWorkbenchPart part, ISelection selection) { return target.canToggleMethodBreakpoints(part, selection); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CToggleWatchpointActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CToggleWatchpointActionDelegate.java index 8ac0e52d858..b4556a18afd 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CToggleWatchpointActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CToggleWatchpointActionDelegate.java @@ -28,31 +28,26 @@ import org.eclipse.ui.IWorkbenchPart; * that provide an <code>IToggleBreakpointsTarget</code> adapter. * <p> * This class is based on {@link org.eclipse.debug.ui.actions.ToggleWatchpointActionDelegate } - * class. In addition to the copied functionality, it adds the handling of + * class. In addition to the copied functionality, it adds the handling of * action-triggering event. * </p> - * + * * @since 7.5 */ public class CToggleWatchpointActionDelegate extends CToggleBreakpointObjectActionDelegate { - protected void performAction(IToggleBreakpointsTarget target, IWorkbenchPart part, ISelection selection, Event event) - throws CoreException - { - if ((event.stateMask & SWT.MOD1) != 0 && - target instanceof IToggleBreakpointsTargetCExtension && - ((IToggleBreakpointsTargetCExtension)target).canCreateWatchpointsInteractive(part, selection)) - { - ((IToggleBreakpointsTargetCExtension)target).createWatchpointsInteractive(part, selection); - } - else { - target.toggleWatchpoints(part, selection); - } + protected void performAction(IToggleBreakpointsTarget target, IWorkbenchPart part, ISelection selection, + Event event) throws CoreException { + if ((event.stateMask & SWT.MOD1) != 0 && target instanceof IToggleBreakpointsTargetCExtension + && ((IToggleBreakpointsTargetCExtension) target).canCreateWatchpointsInteractive(part, selection)) { + ((IToggleBreakpointsTargetCExtension) target).createWatchpointsInteractive(part, selection); + } else { + target.toggleWatchpoints(part, selection); + } } @Override - protected boolean canPerformAction(IToggleBreakpointsTarget target, - IWorkbenchPart part, ISelection selection) { + protected boolean canPerformAction(IToggleBreakpointsTarget target, IWorkbenchPart part, ISelection selection) { return target.canToggleWatchpoints(part, selection); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/EnableDisableBreakpointRulerAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/EnableDisableBreakpointRulerAction.java index 941a8a40902..2b8676556d6 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/EnableDisableBreakpointRulerAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/EnableDisableBreakpointRulerAction.java @@ -33,12 +33,14 @@ public class EnableDisableBreakpointRulerAction extends AbstractBreakpointRulerA /** * Creates the action to enable/disable breakpoints */ - public EnableDisableBreakpointRulerAction( IWorkbenchPart part, IVerticalRulerInfo info ) { - super( part, info ); - setText( ActionMessages.getString( "EnableDisableBreakpointRulerAction.Enable_Breakpoint_1" ) + "\t" + //$NON-NLS-1$ //$NON-NLS-2$ - CDebugUIUtils.formatKeyBindingString(SWT.MOD2, ActionMessages.getString("CRulerToggleBreakpointAction_accelerator")) ); //$NON-NLS-1$ - part.getSite().getWorkbenchWindow().getWorkbench().getHelpSystem().setHelp( this, ICDebugHelpContextIds.ENABLE_DISABLE_BREAKPOINT_ACTION ); - setId( IInternalCDebugUIConstants.ACTION_ENABLE_DISABLE_BREAKPOINT ); + public EnableDisableBreakpointRulerAction(IWorkbenchPart part, IVerticalRulerInfo info) { + super(part, info); + setText(ActionMessages.getString("EnableDisableBreakpointRulerAction.Enable_Breakpoint_1") + "\t" + //$NON-NLS-1$ //$NON-NLS-2$ + CDebugUIUtils.formatKeyBindingString(SWT.MOD2, + ActionMessages.getString("CRulerToggleBreakpointAction_accelerator"))); //$NON-NLS-1$ + part.getSite().getWorkbenchWindow().getWorkbench().getHelpSystem().setHelp(this, + ICDebugHelpContextIds.ENABLE_DISABLE_BREAKPOINT_ACTION); + setId(IInternalCDebugUIConstants.ACTION_ENABLE_DISABLE_BREAKPOINT); } /* (non-Javadoc) @@ -46,14 +48,15 @@ public class EnableDisableBreakpointRulerAction extends AbstractBreakpointRulerA */ @Override public void run() { - if ( fBreakpoint != null ) { + if (fBreakpoint != null) { try { - fBreakpoint.setEnabled( !fBreakpoint.isEnabled() ); - } - catch( CoreException e ) { - ErrorDialog.openError( getTargetPart().getSite().getShell(), ActionMessages.getString( "EnableDisableBreakpointRulerAction.Enabling_disabling_breakpoints_1" ), //$NON-NLS-1$ - ActionMessages.getString( "EnableDisableBreakpointRulerAction.Exceptions_occurred_enabling_or_disabling_breakpoint_1" ), //$NON-NLS-1$ - e.getStatus() ); + fBreakpoint.setEnabled(!fBreakpoint.isEnabled()); + } catch (CoreException e) { + ErrorDialog.openError(getTargetPart().getSite().getShell(), + ActionMessages.getString("EnableDisableBreakpointRulerAction.Enabling_disabling_breakpoints_1"), //$NON-NLS-1$ + ActionMessages.getString( + "EnableDisableBreakpointRulerAction.Exceptions_occurred_enabling_or_disabling_breakpoint_1"), //$NON-NLS-1$ + e.getStatus()); } } } @@ -64,19 +67,20 @@ public class EnableDisableBreakpointRulerAction extends AbstractBreakpointRulerA @Override public void update() { fBreakpoint = getBreakpoint(); - setEnabled( fBreakpoint != null ); - if ( isEnabled() ) { + setEnabled(fBreakpoint != null); + if (isEnabled()) { try { if (getBreakpoint().isEnabled()) { - setText( ActionMessages.getString("EnableDisableBreakpointRulerAction.Disable_Breakpoint_1") + "\t" + //$NON-NLS-1$ //$NON-NLS-2$ - CDebugUIUtils.formatKeyBindingString(SWT.MOD2, ActionMessages.getString("CRulerToggleBreakpointAction_accelerator")) ); //$NON-NLS-1$ + setText(ActionMessages.getString("EnableDisableBreakpointRulerAction.Disable_Breakpoint_1") + "\t" + //$NON-NLS-1$ //$NON-NLS-2$ + CDebugUIUtils.formatKeyBindingString(SWT.MOD2, + ActionMessages.getString("CRulerToggleBreakpointAction_accelerator"))); //$NON-NLS-1$ } else { - setText( ActionMessages.getString("EnableDisableBreakpointRulerAction.Enable_Breakpoint_1") + "\t" + //$NON-NLS-1$ //$NON-NLS-2$ - CDebugUIUtils.formatKeyBindingString(SWT.MOD2, ActionMessages.getString("CRulerToggleBreakpointAction_accelerator")) ); //$NON-NLS-1$ + setText(ActionMessages.getString("EnableDisableBreakpointRulerAction.Enable_Breakpoint_1") + "\t" + //$NON-NLS-1$ //$NON-NLS-2$ + CDebugUIUtils.formatKeyBindingString(SWT.MOD2, + ActionMessages.getString("CRulerToggleBreakpointAction_accelerator"))); //$NON-NLS-1$ } - } - catch( CoreException e ) { - DebugPlugin.log( e ); + } catch (CoreException e) { + DebugPlugin.log(e); } } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/Messages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/Messages.java index f8b457c697e..67a5697430a 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/Messages.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/Messages.java @@ -13,14 +13,13 @@ *******************************************************************************/ package org.eclipse.cdt.debug.internal.ui.actions.breakpoints; - import org.eclipse.osgi.util.NLS; public class Messages extends NLS { public static String Default_LineDynamicPrintf_String; public static String Default_FunctionDynamicPrintf_String; - + static { NLS.initializeMessages(Messages.class.getName(), Messages.class); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleBreakpointAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleBreakpointAdapter.java index 39169cba42f..69d37bfd66f 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleBreakpointAdapter.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleBreakpointAdapter.java @@ -33,80 +33,79 @@ import org.eclipse.ui.IWorkbenchPart; /** * Toggles a line breakpoint in a C/C++ editor. - * + * * @since 7.2 */ public class ToggleBreakpointAdapter extends AbstractToggleBreakpointAdapter { @Override - protected ICLineBreakpoint findLineBreakpoint( String sourceHandle, IResource resource, int lineNumber ) throws CoreException { - return CDIDebugModel.lineBreakpointExists( sourceHandle, resource, lineNumber ); + protected ICLineBreakpoint findLineBreakpoint(String sourceHandle, IResource resource, int lineNumber) + throws CoreException { + return CDIDebugModel.lineBreakpointExists(sourceHandle, resource, lineNumber); } @Override - protected void createLineBreakpoint(boolean interactive, IWorkbenchPart part, String sourceHandle, - IResource resource, int lineNumber) throws CoreException - { - if (interactive) { - ICLineBreakpoint lineBp = CDIDebugModel.createBlankLineBreakpoint(); - Map<String, Object> attributes = new HashMap<String, Object>(); - CDIDebugModel.setLineBreakpointAttributes( - attributes, sourceHandle, getBreakpointType(), lineNumber, true, 0, "" ); //$NON-NLS-1$ - openBreakpointPropertiesDialog(lineBp, part, resource, attributes); - } else { - CDIDebugModel.createLineBreakpoint( sourceHandle, resource, getBreakpointType(), lineNumber, true, 0, "", true );//$NON-NLS-1$ - } + protected void createLineBreakpoint(boolean interactive, IWorkbenchPart part, String sourceHandle, + IResource resource, int lineNumber) throws CoreException { + if (interactive) { + ICLineBreakpoint lineBp = CDIDebugModel.createBlankLineBreakpoint(); + Map<String, Object> attributes = new HashMap<String, Object>(); + CDIDebugModel.setLineBreakpointAttributes(attributes, sourceHandle, getBreakpointType(), lineNumber, true, + 0, ""); //$NON-NLS-1$ + openBreakpointPropertiesDialog(lineBp, part, resource, attributes); + } else { + CDIDebugModel.createLineBreakpoint(sourceHandle, resource, getBreakpointType(), lineNumber, true, 0, "", //$NON-NLS-1$ + true); + } } @Override - protected ICFunctionBreakpoint findFunctionBreakpoint(String sourceHandle, IResource resource, String functionName) - throws CoreException - { - return CDIDebugModel.functionBreakpointExists( sourceHandle, resource, functionName ); + protected ICFunctionBreakpoint findFunctionBreakpoint(String sourceHandle, IResource resource, String functionName) + throws CoreException { + return CDIDebugModel.functionBreakpointExists(sourceHandle, resource, functionName); } @Override - protected void createFunctionBreakpoint(boolean interactive, IWorkbenchPart part, String sourceHandle, - IResource resource, String functionName, int charStart, int charEnd, int lineNumber ) throws CoreException - { - if (interactive) { - ICFunctionBreakpoint bp = CDIDebugModel.createBlankFunctionBreakpoint(); - Map<String, Object> attributes = new HashMap<String, Object>(); - CDIDebugModel.setFunctionBreakpointAttributes( attributes, sourceHandle, getBreakpointType(), functionName, - charStart, charEnd, lineNumber, true, 0, "" ); //$NON-NLS-1$ - openBreakpointPropertiesDialog(bp, part, resource, attributes); - } else { - CDIDebugModel.createFunctionBreakpoint(sourceHandle, resource, getBreakpointType(), functionName, charStart, - charEnd, lineNumber, true, 0, "", true); //$NON-NLS-1$ - } + protected void createFunctionBreakpoint(boolean interactive, IWorkbenchPart part, String sourceHandle, + IResource resource, String functionName, int charStart, int charEnd, int lineNumber) throws CoreException { + if (interactive) { + ICFunctionBreakpoint bp = CDIDebugModel.createBlankFunctionBreakpoint(); + Map<String, Object> attributes = new HashMap<String, Object>(); + CDIDebugModel.setFunctionBreakpointAttributes(attributes, sourceHandle, getBreakpointType(), functionName, + charStart, charEnd, lineNumber, true, 0, ""); //$NON-NLS-1$ + openBreakpointPropertiesDialog(bp, part, resource, attributes); + } else { + CDIDebugModel.createFunctionBreakpoint(sourceHandle, resource, getBreakpointType(), functionName, charStart, + charEnd, lineNumber, true, 0, "", true); //$NON-NLS-1$ + } } @Override - protected ICWatchpoint findWatchpoint( String sourceHandle, IResource resource, String expression ) throws CoreException { - return CDIDebugModel.watchpointExists( sourceHandle, resource, expression ); + protected ICWatchpoint findWatchpoint(String sourceHandle, IResource resource, String expression) + throws CoreException { + return CDIDebugModel.watchpointExists(sourceHandle, resource, expression); } @Override - protected void createWatchpoint( boolean interactive, IWorkbenchPart part, String sourceHandle, IResource resource, - int charStart, int charEnd, int lineNumber, String expression, String memorySpace, String range) throws CoreException - { - ICWatchpoint bp = CDIDebugModel.createBlankWatchpoint(); - Map<String, Object> attributes = new HashMap<String, Object>(); - CDIDebugModel.setWatchPointAttributes(attributes, sourceHandle, resource, true, false, - expression, memorySpace, new BigInteger(range), true, 0, ""); //$NON-NLS-1$ - openBreakpointPropertiesDialog(bp, part, resource, attributes); + protected void createWatchpoint(boolean interactive, IWorkbenchPart part, String sourceHandle, IResource resource, + int charStart, int charEnd, int lineNumber, String expression, String memorySpace, String range) + throws CoreException { + ICWatchpoint bp = CDIDebugModel.createBlankWatchpoint(); + Map<String, Object> attributes = new HashMap<String, Object>(); + CDIDebugModel.setWatchPointAttributes(attributes, sourceHandle, resource, true, false, expression, memorySpace, + new BigInteger(range), true, 0, ""); //$NON-NLS-1$ + openBreakpointPropertiesDialog(bp, part, resource, attributes); } @Override - protected void createEventBreakpoint( boolean interactive, IWorkbenchPart part, IResource resource, String type, - String arg ) throws CoreException - { - ICEventBreakpoint bp = CDIDebugModel.createBlankEventBreakpoint(); - Map<String, Object> attributes = new HashMap<String, Object>(); - CDIDebugModel.setEventBreakpointAttributes(attributes,type, arg); - openBreakpointPropertiesDialog(bp, part, resource, attributes); + protected void createEventBreakpoint(boolean interactive, IWorkbenchPart part, IResource resource, String type, + String arg) throws CoreException { + ICEventBreakpoint bp = CDIDebugModel.createBlankEventBreakpoint(); + Map<String, Object> attributes = new HashMap<String, Object>(); + CDIDebugModel.setEventBreakpointAttributes(attributes, type, arg); + openBreakpointPropertiesDialog(bp, part, resource, attributes); } - + protected int getBreakpointType() { return ICBreakpointType.REGULAR; } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleCBreakpointsTargetFactory.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleCBreakpointsTargetFactory.java index 0a77ffaa0cc..60031da3b28 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleCBreakpointsTargetFactory.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleCBreakpointsTargetFactory.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation *******************************************************************************/ @@ -32,75 +32,74 @@ import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.ui.IWorkbenchPart; /** - * + * */ public class ToggleCBreakpointsTargetFactory implements IToggleBreakpointsTargetFactory { - - public static String TOGGLE_C_BREAKPOINT_TARGET_ID = CDebugUIPlugin.getUniqueIdentifier() + ".toggleCBreakpointTarget"; //$NON-NLS-1$ - - private static Set<String> TOGGLE_TARGET_IDS = new HashSet<String>(1); - static { - TOGGLE_TARGET_IDS.add(TOGGLE_C_BREAKPOINT_TARGET_ID); - } - - private ToggleBreakpointAdapter fCToggleBreakpointTarget = new ToggleBreakpointAdapter(); - - @Override + + public static String TOGGLE_C_BREAKPOINT_TARGET_ID = CDebugUIPlugin.getUniqueIdentifier() + + ".toggleCBreakpointTarget"; //$NON-NLS-1$ + + private static Set<String> TOGGLE_TARGET_IDS = new HashSet<String>(1); + static { + TOGGLE_TARGET_IDS.add(TOGGLE_C_BREAKPOINT_TARGET_ID); + } + + private ToggleBreakpointAdapter fCToggleBreakpointTarget = new ToggleBreakpointAdapter(); + + @Override public IToggleBreakpointsTarget createToggleTarget(String targetID) { - if (TOGGLE_C_BREAKPOINT_TARGET_ID.equals(targetID)) { - return fCToggleBreakpointTarget; - } - return null; - } - - @Override + if (TOGGLE_C_BREAKPOINT_TARGET_ID.equals(targetID)) { + return fCToggleBreakpointTarget; + } + return null; + } + + @Override public String getDefaultToggleTarget(IWorkbenchPart part, ISelection selection) { - // Return the debug context as a default if the currently selected context - // is a CDT element. Otherwise return null. - Object element = getDebugContext(part).getFirstElement(); - if (element instanceof IAdaptable) { - IDebugModelProvider modelProvider = - ((IAdaptable)element).getAdapter(IDebugModelProvider.class); - if (modelProvider != null) { - String[] models = modelProvider.getModelIdentifiers(); - for (String model : models) { - if (CDIDebugModel.getPluginIdentifier().equals(model) || - ICBreakpoint.C_BREAKPOINTS_DEBUG_MODEL_ID.equals(model)) - { - return TOGGLE_C_BREAKPOINT_TARGET_ID; - } - } - } else if (element instanceof IDebugElement) { - if (CDIDebugModel.getPluginIdentifier().equals(((IDebugElement)element).getModelIdentifier()) ) { - return TOGGLE_C_BREAKPOINT_TARGET_ID; - } - } - } - return null; - } - - @Override + // Return the debug context as a default if the currently selected context + // is a CDT element. Otherwise return null. + Object element = getDebugContext(part).getFirstElement(); + if (element instanceof IAdaptable) { + IDebugModelProvider modelProvider = ((IAdaptable) element).getAdapter(IDebugModelProvider.class); + if (modelProvider != null) { + String[] models = modelProvider.getModelIdentifiers(); + for (String model : models) { + if (CDIDebugModel.getPluginIdentifier().equals(model) + || ICBreakpoint.C_BREAKPOINTS_DEBUG_MODEL_ID.equals(model)) { + return TOGGLE_C_BREAKPOINT_TARGET_ID; + } + } + } else if (element instanceof IDebugElement) { + if (CDIDebugModel.getPluginIdentifier().equals(((IDebugElement) element).getModelIdentifier())) { + return TOGGLE_C_BREAKPOINT_TARGET_ID; + } + } + } + return null; + } + + @Override public String getToggleTargetDescription(String targetID) { - return ActionMessages.getString("ToggleCBreakpointsTargetFactory.CBreakpointDescription"); //$NON-NLS-1$ - } - - @Override + return ActionMessages.getString("ToggleCBreakpointsTargetFactory.CBreakpointDescription"); //$NON-NLS-1$ + } + + @Override public String getToggleTargetName(String targetID) { - return ActionMessages.getString("ToggleCBreakpointsTargetFactory.CBreakpointName"); //$NON-NLS-1$ - } - - @Override - public Set<String> getToggleTargets(IWorkbenchPart part, ISelection selection) { - return TOGGLE_TARGET_IDS; - } - - private IStructuredSelection getDebugContext(IWorkbenchPart part) { - ISelection selection = DebugUITools.getDebugContextManager(). - getContextService(part.getSite().getWorkbenchWindow()).getActiveContext(); - if (selection instanceof IStructuredSelection) { - return (IStructuredSelection)selection; - } - return StructuredSelection.EMPTY; - } + return ActionMessages.getString("ToggleCBreakpointsTargetFactory.CBreakpointName"); //$NON-NLS-1$ + } + + @Override + public Set<String> getToggleTargets(IWorkbenchPart part, ISelection selection) { + return TOGGLE_TARGET_IDS; + } + + private IStructuredSelection getDebugContext(IWorkbenchPart part) { + ISelection selection = DebugUITools.getDebugContextManager() + .getContextService(part.getSite().getWorkbenchWindow()).getActiveContext(); + if (selection instanceof IStructuredSelection) { + return (IStructuredSelection) selection; + } + return StructuredSelection.EMPTY; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleCDynamicPrintfTargetFactory.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleCDynamicPrintfTargetFactory.java index 817aa601f05..a16c6ea334d 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleCDynamicPrintfTargetFactory.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleCDynamicPrintfTargetFactory.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Marc Khouzam (Ericsson) - initial API and implementation *******************************************************************************/ @@ -25,51 +25,52 @@ import org.eclipse.ui.IWorkbenchPart; /** * Toggle Dynamic Printf target factory for the CEditor. - * + * * @since 7.5 */ public class ToggleCDynamicPrintfTargetFactory implements IToggleBreakpointsTargetFactory { - - public static String TOGGLE_C_DYNAMICPRINTF_TARGET_ID = CDebugUIPlugin.getUniqueIdentifier() + ".toggleCDynamicPrintfTarget"; //$NON-NLS-1$ - - private static Set<String> TOGGLE_TARGET_IDS = new HashSet<String>(1); - static { - TOGGLE_TARGET_IDS.add(TOGGLE_C_DYNAMICPRINTF_TARGET_ID); - } - - private ToggleDynamicPrintfAdapter fCToggleDynamicPrintfTarget = new ToggleDynamicPrintfAdapter(); - - @Override - public IToggleBreakpointsTarget createToggleTarget(String targetID) { - if (TOGGLE_C_DYNAMICPRINTF_TARGET_ID.equals(targetID)) { - return fCToggleDynamicPrintfTarget; - } - return null; - } - - @Override - public String getDefaultToggleTarget(IWorkbenchPart part, ISelection selection) { - return null; - } - - @Override - public String getToggleTargetDescription(String targetID) { - if (TOGGLE_C_DYNAMICPRINTF_TARGET_ID.equals(targetID)) { - return ActionMessages.getString("ToggleCBreakpointsTargetFactory.CDynamicPrintfDescription"); //$NON-NLS-1$ - } - return null; - } - - @Override - public String getToggleTargetName(String targetID) { - if (TOGGLE_C_DYNAMICPRINTF_TARGET_ID.equals(targetID)) { - return ActionMessages.getString("ToggleCBreakpointsTargetFactory.CDynamicPrintfName"); //$NON-NLS-1$ - } - return null; - } - - @Override - public Set<String> getToggleTargets(IWorkbenchPart part, ISelection selection) { - return TOGGLE_TARGET_IDS; - } + + public static String TOGGLE_C_DYNAMICPRINTF_TARGET_ID = CDebugUIPlugin.getUniqueIdentifier() + + ".toggleCDynamicPrintfTarget"; //$NON-NLS-1$ + + private static Set<String> TOGGLE_TARGET_IDS = new HashSet<String>(1); + static { + TOGGLE_TARGET_IDS.add(TOGGLE_C_DYNAMICPRINTF_TARGET_ID); + } + + private ToggleDynamicPrintfAdapter fCToggleDynamicPrintfTarget = new ToggleDynamicPrintfAdapter(); + + @Override + public IToggleBreakpointsTarget createToggleTarget(String targetID) { + if (TOGGLE_C_DYNAMICPRINTF_TARGET_ID.equals(targetID)) { + return fCToggleDynamicPrintfTarget; + } + return null; + } + + @Override + public String getDefaultToggleTarget(IWorkbenchPart part, ISelection selection) { + return null; + } + + @Override + public String getToggleTargetDescription(String targetID) { + if (TOGGLE_C_DYNAMICPRINTF_TARGET_ID.equals(targetID)) { + return ActionMessages.getString("ToggleCBreakpointsTargetFactory.CDynamicPrintfDescription"); //$NON-NLS-1$ + } + return null; + } + + @Override + public String getToggleTargetName(String targetID) { + if (TOGGLE_C_DYNAMICPRINTF_TARGET_ID.equals(targetID)) { + return ActionMessages.getString("ToggleCBreakpointsTargetFactory.CDynamicPrintfName"); //$NON-NLS-1$ + } + return null; + } + + @Override + public Set<String> getToggleTargets(IWorkbenchPart part, ISelection selection) { + return TOGGLE_TARGET_IDS; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleCTracepointsTargetFactory.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleCTracepointsTargetFactory.java index e236c074c41..23a99cf5d2c 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleCTracepointsTargetFactory.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleCTracepointsTargetFactory.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Ericsson - initial API and implementation *******************************************************************************/ @@ -26,51 +26,52 @@ import org.eclipse.ui.IWorkbenchPart; /** * Toggle tracepoints target factory for the CEditor. * We use a separate factory so that we can control it through an action set. - * + * * @since 6.1 */ public class ToggleCTracepointsTargetFactory implements IToggleBreakpointsTargetFactory { - - public static String TOGGLE_C_TRACEPOINT_TARGET_ID = CDebugUIPlugin.getUniqueIdentifier() + ".toggleCTracepointTarget"; //$NON-NLS-1$ - - private static Set<String> TOGGLE_TARGET_IDS = new HashSet<String>(1); - static { - TOGGLE_TARGET_IDS.add(TOGGLE_C_TRACEPOINT_TARGET_ID); - } - - private ToggleTracepointAdapter fCToggleTracepointTarget = new ToggleTracepointAdapter(); - - @Override + + public static String TOGGLE_C_TRACEPOINT_TARGET_ID = CDebugUIPlugin.getUniqueIdentifier() + + ".toggleCTracepointTarget"; //$NON-NLS-1$ + + private static Set<String> TOGGLE_TARGET_IDS = new HashSet<String>(1); + static { + TOGGLE_TARGET_IDS.add(TOGGLE_C_TRACEPOINT_TARGET_ID); + } + + private ToggleTracepointAdapter fCToggleTracepointTarget = new ToggleTracepointAdapter(); + + @Override public IToggleBreakpointsTarget createToggleTarget(String targetID) { - if (TOGGLE_C_TRACEPOINT_TARGET_ID.equals(targetID)) { - return fCToggleTracepointTarget; - } - return null; - } - - @Override + if (TOGGLE_C_TRACEPOINT_TARGET_ID.equals(targetID)) { + return fCToggleTracepointTarget; + } + return null; + } + + @Override public String getDefaultToggleTarget(IWorkbenchPart part, ISelection selection) { - return null; - } - - @Override + return null; + } + + @Override public String getToggleTargetDescription(String targetID) { - if (TOGGLE_C_TRACEPOINT_TARGET_ID.equals(targetID)) { - return ActionMessages.getString("ToggleCBreakpointsTargetFactory.CTracepointDescription"); //$NON-NLS-1$ - } - return null; - } - - @Override + if (TOGGLE_C_TRACEPOINT_TARGET_ID.equals(targetID)) { + return ActionMessages.getString("ToggleCBreakpointsTargetFactory.CTracepointDescription"); //$NON-NLS-1$ + } + return null; + } + + @Override public String getToggleTargetName(String targetID) { - if (TOGGLE_C_TRACEPOINT_TARGET_ID.equals(targetID)) { - return ActionMessages.getString("ToggleCBreakpointsTargetFactory.CTracepointName"); //$NON-NLS-1$ - } - return null; - } - - @Override - public Set<String> getToggleTargets(IWorkbenchPart part, ISelection selection) { - return TOGGLE_TARGET_IDS; - } + if (TOGGLE_C_TRACEPOINT_TARGET_ID.equals(targetID)) { + return ActionMessages.getString("ToggleCBreakpointsTargetFactory.CTracepointName"); //$NON-NLS-1$ + } + return null; + } + + @Override + public Set<String> getToggleTargets(IWorkbenchPart part, ISelection selection) { + return TOGGLE_TARGET_IDS; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleDynamicPrintfAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleDynamicPrintfAdapter.java index e46634ebf40..5e330dc74ce 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleDynamicPrintfAdapter.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleDynamicPrintfAdapter.java @@ -32,97 +32,101 @@ import org.eclipse.ui.IWorkbenchPart; /** * Toggles a dynamic printf in a C/C++ editor. - * + * * @since 7.5 */ public class ToggleDynamicPrintfAdapter extends AbstractToggleBreakpointAdapter { @Override - protected ICLineBreakpoint findLineBreakpoint( String sourceHandle, IResource resource, int lineNumber ) throws CoreException { - return CDIDebugModel.lineBreakpointExists( sourceHandle, resource, lineNumber ); + protected ICLineBreakpoint findLineBreakpoint(String sourceHandle, IResource resource, int lineNumber) + throws CoreException { + return CDIDebugModel.lineBreakpointExists(sourceHandle, resource, lineNumber); } - @Override - protected void createLineBreakpoint(boolean interactive, IWorkbenchPart part, String sourceHandle, - IResource resource, int lineNumber) throws CoreException - { - if (interactive) { - ICDynamicPrintf dprintf = (ICDynamicPrintf)CDIDebugModel.createBlankLineDynamicPrintf(); - Map<String, Object> attributes = new HashMap<String, Object>(); - CDIDebugModel.setLineBreakpointAttributes( - attributes, sourceHandle, getBreakpointType(), lineNumber, true, 0, "" ); //$NON-NLS-1$ - - // Although the user will be given the opportunity to provide the printf string - // in the properties dialog, we pre-fill it with the default string to be nice - attributes.put(ICDynamicPrintf.PRINTF_STRING, - NLS.bind(Messages.Default_LineDynamicPrintf_String, escapeBackslashes(sourceHandle), lineNumber)); - - openBreakpointPropertiesDialog(dprintf, part, resource, attributes); - } else { - // We provide a default printf string to make the dynamic printf useful automatically - String printfStr = NLS.bind(Messages.Default_LineDynamicPrintf_String, escapeBackslashes(sourceHandle), lineNumber); - - CDIDebugModel.createLineDynamicPrintf( - sourceHandle, resource, getBreakpointType(), lineNumber, true, 0, "", printfStr, true );//$NON-NLS-1$ - } - } + @Override + protected void createLineBreakpoint(boolean interactive, IWorkbenchPart part, String sourceHandle, + IResource resource, int lineNumber) throws CoreException { + if (interactive) { + ICDynamicPrintf dprintf = (ICDynamicPrintf) CDIDebugModel.createBlankLineDynamicPrintf(); + Map<String, Object> attributes = new HashMap<String, Object>(); + CDIDebugModel.setLineBreakpointAttributes(attributes, sourceHandle, getBreakpointType(), lineNumber, true, + 0, ""); //$NON-NLS-1$ + + // Although the user will be given the opportunity to provide the printf string + // in the properties dialog, we pre-fill it with the default string to be nice + attributes.put(ICDynamicPrintf.PRINTF_STRING, + NLS.bind(Messages.Default_LineDynamicPrintf_String, escapeBackslashes(sourceHandle), lineNumber)); + + openBreakpointPropertiesDialog(dprintf, part, resource, attributes); + } else { + // We provide a default printf string to make the dynamic printf useful automatically + String printfStr = NLS.bind(Messages.Default_LineDynamicPrintf_String, escapeBackslashes(sourceHandle), + lineNumber); + + CDIDebugModel.createLineDynamicPrintf(sourceHandle, resource, getBreakpointType(), lineNumber, true, 0, "", //$NON-NLS-1$ + printfStr, true); + } + } @Override - protected ICFunctionBreakpoint findFunctionBreakpoint( String sourceHandle, IResource resource, String functionName ) throws CoreException { - return CDIDebugModel.functionBreakpointExists( sourceHandle, resource, functionName ); + protected ICFunctionBreakpoint findFunctionBreakpoint(String sourceHandle, IResource resource, String functionName) + throws CoreException { + return CDIDebugModel.functionBreakpointExists(sourceHandle, resource, functionName); } - @Override - protected void createFunctionBreakpoint(boolean interactive, IWorkbenchPart part, String sourceHandle, - IResource resource, String functionName, int charStart, int charEnd, int lineNumber ) throws CoreException - { - if (interactive) { - ICDynamicPrintf dprintf = (ICDynamicPrintf)CDIDebugModel.createBlankFunctionDynamicPrintf(); - Map<String, Object> attributes = new HashMap<String, Object>(); - CDIDebugModel.setFunctionBreakpointAttributes( attributes, sourceHandle, getBreakpointType(), functionName, - charStart, charEnd, lineNumber, true, 0, "" ); //$NON-NLS-1$ - - // Although the user will be given the opportunity to provide the printf string - // in the properties dialog, we pre-fill it with the default string to be nice - dprintf.setPrintfString(NLS.bind(Messages.Default_FunctionDynamicPrintf_String, escapeBackslashes(sourceHandle), functionName)); - - openBreakpointPropertiesDialog(dprintf, part, resource, attributes); - } else { - // We provide a default printf string to make the dynamic printf useful automatically - String printfStr = NLS.bind(Messages.Default_FunctionDynamicPrintf_String, escapeBackslashes(sourceHandle), functionName); - - CDIDebugModel.createFunctionDynamicPrintf(sourceHandle, resource, getBreakpointType(), functionName, charStart, - charEnd, lineNumber, true, 0, "", printfStr, true); //$NON-NLS-1$ - } - } + @Override + protected void createFunctionBreakpoint(boolean interactive, IWorkbenchPart part, String sourceHandle, + IResource resource, String functionName, int charStart, int charEnd, int lineNumber) throws CoreException { + if (interactive) { + ICDynamicPrintf dprintf = (ICDynamicPrintf) CDIDebugModel.createBlankFunctionDynamicPrintf(); + Map<String, Object> attributes = new HashMap<String, Object>(); + CDIDebugModel.setFunctionBreakpointAttributes(attributes, sourceHandle, getBreakpointType(), functionName, + charStart, charEnd, lineNumber, true, 0, ""); //$NON-NLS-1$ + + // Although the user will be given the opportunity to provide the printf string + // in the properties dialog, we pre-fill it with the default string to be nice + dprintf.setPrintfString(NLS.bind(Messages.Default_FunctionDynamicPrintf_String, + escapeBackslashes(sourceHandle), functionName)); + + openBreakpointPropertiesDialog(dprintf, part, resource, attributes); + } else { + // We provide a default printf string to make the dynamic printf useful automatically + String printfStr = NLS.bind(Messages.Default_FunctionDynamicPrintf_String, escapeBackslashes(sourceHandle), + functionName); + + CDIDebugModel.createFunctionDynamicPrintf(sourceHandle, resource, getBreakpointType(), functionName, + charStart, charEnd, lineNumber, true, 0, "", printfStr, true); //$NON-NLS-1$ + } + } @Override - protected ICWatchpoint findWatchpoint( String sourceHandle, IResource resource, String expression ) throws CoreException { + protected ICWatchpoint findWatchpoint(String sourceHandle, IResource resource, String expression) + throws CoreException { return null; } @Override public boolean canToggleWatchpoints(IWorkbenchPart part, ISelection selection) { - return false; + return false; + } + + @Override + protected void createWatchpoint(boolean interactive, IWorkbenchPart part, String sourceHandle, IResource resource, + int charStart, int charEnd, int lineNumber, String expression, String memorySpace, String range) + throws CoreException { } - - @Override - protected void createWatchpoint( boolean interactive, IWorkbenchPart part, String sourceHandle, IResource resource, - int charStart, int charEnd, int lineNumber, String expression, String memorySpace, String range) throws CoreException - { - } - - @Override - public boolean canCreateEventBreakpointsInteractive(IWorkbenchPart part, ISelection selection) { - return false; - } - - @Override - protected void createEventBreakpoint(boolean interactive, IWorkbenchPart part, IResource resource, String type, - String arg) throws CoreException { - - } - + + @Override + public boolean canCreateEventBreakpointsInteractive(IWorkbenchPart part, ISelection selection) { + return false; + } + + @Override + protected void createEventBreakpoint(boolean interactive, IWorkbenchPart part, IResource resource, String type, + String arg) throws CoreException { + + } + protected int getBreakpointType() { return ICBreakpointType.REGULAR; } @@ -131,7 +135,7 @@ public class ToggleDynamicPrintfAdapter extends AbstractToggleBreakpointAdapter * Escape embedded backslashes for inclusion in C string. */ private static String escapeBackslashes(String str) { - return str.replaceAll(Pattern.quote("\\"), "\\\\\\\\"); //$NON-NLS-1$//$NON-NLS-2$ + return str.replaceAll(Pattern.quote("\\"), "\\\\\\\\"); //$NON-NLS-1$//$NON-NLS-2$ } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleTracepointAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleTracepointAdapter.java index 80da5a8bac9..350ec2f652c 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleTracepointAdapter.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleTracepointAdapter.java @@ -33,74 +33,74 @@ import org.eclipse.ui.IWorkbenchPart; public class ToggleTracepointAdapter extends AbstractToggleBreakpointAdapter { @Override - protected ICLineBreakpoint findLineBreakpoint( String sourceHandle, IResource resource, int lineNumber ) throws CoreException { - return CDIDebugModel.lineBreakpointExists( sourceHandle, resource, lineNumber ); + protected ICLineBreakpoint findLineBreakpoint(String sourceHandle, IResource resource, int lineNumber) + throws CoreException { + return CDIDebugModel.lineBreakpointExists(sourceHandle, resource, lineNumber); } - @Override - protected void createLineBreakpoint(boolean interactive, IWorkbenchPart part, String sourceHandle, - IResource resource, int lineNumber) throws CoreException - { - if (interactive) { - ICLineBreakpoint lineBp = CDIDebugModel.createBlankLineTracepoint(); - Map<String, Object> attributes = new HashMap<String, Object>(); - CDIDebugModel.setLineBreakpointAttributes( - attributes, sourceHandle, getBreakpointType(), lineNumber, true, 0, "" ); //$NON-NLS-1$ - openBreakpointPropertiesDialog(lineBp, part, resource, attributes); - } else { - CDIDebugModel.createLineTracepoint( sourceHandle, resource, getBreakpointType(), lineNumber, true, 0, "", true );//$NON-NLS-1$ - } - } + @Override + protected void createLineBreakpoint(boolean interactive, IWorkbenchPart part, String sourceHandle, + IResource resource, int lineNumber) throws CoreException { + if (interactive) { + ICLineBreakpoint lineBp = CDIDebugModel.createBlankLineTracepoint(); + Map<String, Object> attributes = new HashMap<String, Object>(); + CDIDebugModel.setLineBreakpointAttributes(attributes, sourceHandle, getBreakpointType(), lineNumber, true, + 0, ""); //$NON-NLS-1$ + openBreakpointPropertiesDialog(lineBp, part, resource, attributes); + } else { + CDIDebugModel.createLineTracepoint(sourceHandle, resource, getBreakpointType(), lineNumber, true, 0, "", //$NON-NLS-1$ + true); + } + } @Override - protected ICFunctionBreakpoint findFunctionBreakpoint( String sourceHandle, IResource resource, String functionName ) throws CoreException { - return CDIDebugModel.functionBreakpointExists( sourceHandle, resource, functionName ); + protected ICFunctionBreakpoint findFunctionBreakpoint(String sourceHandle, IResource resource, String functionName) + throws CoreException { + return CDIDebugModel.functionBreakpointExists(sourceHandle, resource, functionName); } - @Override - protected void createFunctionBreakpoint(boolean interactive, IWorkbenchPart part, String sourceHandle, - IResource resource, String functionName, int charStart, int charEnd, int lineNumber ) throws CoreException - { - if (interactive) { - ICFunctionBreakpoint bp = CDIDebugModel.createBlankFunctionTracepoint(); - Map<String, Object> attributes = new HashMap<String, Object>(); - CDIDebugModel.setFunctionBreakpointAttributes( attributes, sourceHandle, getBreakpointType(), functionName, - charStart, charEnd, lineNumber, true, 0, "" ); //$NON-NLS-1$ - openBreakpointPropertiesDialog(bp, part, resource, attributes); - } else { - CDIDebugModel.createFunctionTracepoint(sourceHandle, resource, getBreakpointType(), functionName, charStart, - charEnd, lineNumber, true, 0, "", true); //$NON-NLS-1$ - } - } + @Override + protected void createFunctionBreakpoint(boolean interactive, IWorkbenchPart part, String sourceHandle, + IResource resource, String functionName, int charStart, int charEnd, int lineNumber) throws CoreException { + if (interactive) { + ICFunctionBreakpoint bp = CDIDebugModel.createBlankFunctionTracepoint(); + Map<String, Object> attributes = new HashMap<String, Object>(); + CDIDebugModel.setFunctionBreakpointAttributes(attributes, sourceHandle, getBreakpointType(), functionName, + charStart, charEnd, lineNumber, true, 0, ""); //$NON-NLS-1$ + openBreakpointPropertiesDialog(bp, part, resource, attributes); + } else { + CDIDebugModel.createFunctionTracepoint(sourceHandle, resource, getBreakpointType(), functionName, charStart, + charEnd, lineNumber, true, 0, "", true); //$NON-NLS-1$ + } + } @Override - protected ICWatchpoint findWatchpoint( String sourceHandle, IResource resource, String expression ) throws CoreException { + protected ICWatchpoint findWatchpoint(String sourceHandle, IResource resource, String expression) + throws CoreException { return null; } @Override public boolean canToggleWatchpoints(IWorkbenchPart part, ISelection selection) { - return false; + return false; + } + + protected void createWatchpoint(boolean interactive, IWorkbenchPart part, String sourceHandle, IResource resource, + int charStart, int charEnd, int lineNumber, String expression, String memorySpace, String range) + throws CoreException { } - - protected void createWatchpoint( boolean interactive, IWorkbenchPart part, String sourceHandle, IResource resource, - int charStart, int charEnd, int lineNumber, String expression, String memorySpace, String range) throws CoreException - { - } - @Override - public boolean canCreateEventBreakpointsInteractive(IWorkbenchPart part, ISelection selection) { - return false; - } - - @Override - protected void createEventBreakpoint(boolean interactive, IWorkbenchPart part, IResource resource, String type, - String arg) throws CoreException { - - } - + @Override + public boolean canCreateEventBreakpointsInteractive(IWorkbenchPart part, ISelection selection) { + return false; + } + + @Override + protected void createEventBreakpoint(boolean interactive, IWorkbenchPart part, IResource resource, String type, + String arg) throws CoreException { + + } - protected int getBreakpointType() { return ICBreakpointType.REGULAR; } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/BreakpointComboFieldEditor.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/BreakpointComboFieldEditor.java index 3888099729f..d9b56901375 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/BreakpointComboFieldEditor.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/BreakpointComboFieldEditor.java @@ -21,14 +21,13 @@ import org.eclipse.swt.widgets.Composite; /** * Extends combo field editor to load combo values from {@extensionPoint org.eclipse.cdt.debug.ui.breakpointContribution} extension */ -public class BreakpointComboFieldEditor extends ComboFieldEditor implements - ICBreakpointsUIContributionUser { +public class BreakpointComboFieldEditor extends ComboFieldEditor implements ICBreakpointsUIContributionUser { private ICBreakpointsUIContribution fContribution; /** - * Create combo field editor that would load choice values from {@link ICBreakpointsUIContribution} - * @param name - property name, must be the same as breakpoint attribute + * Create combo field editor that would load choice values from {@link ICBreakpointsUIContribution} + * @param name - property name, must be the same as breakpoint attribute * @param labelText - text in front of field * @param parent */ @@ -36,8 +35,6 @@ public class BreakpointComboFieldEditor extends ComboFieldEditor implements super(name, labelText, new String[0][0], parent); } - - /* (non-Javadoc) * @see org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointsUIContributionUser#setContribution(org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointsUIContribution) */ @@ -46,8 +43,8 @@ public class BreakpointComboFieldEditor extends ComboFieldEditor implements fContribution = contribution; //load values from contribution String[] possibleValues = fContribution.getPossibleValues(); - String[][] entryNamesAndValues = new String[possibleValues.length][2]; - for (int i=0; i<possibleValues.length; ++i) { + String[][] entryNamesAndValues = new String[possibleValues.length][2]; + for (int i = 0; i < possibleValues.length; ++i) { entryNamesAndValues[i][0] = fContribution.getLabelForValue(possibleValues[i]); entryNamesAndValues[i][1] = possibleValues[i]; } @@ -61,7 +58,6 @@ public class BreakpointComboFieldEditor extends ComboFieldEditor implements public ICBreakpointsUIContribution getContribution() { return fContribution; } - /** * @see FieldEditor#doLoad() @@ -70,7 +66,6 @@ public class BreakpointComboFieldEditor extends ComboFieldEditor implements protected void doLoad() { updateComboForValue(storeToComboValue()); } - /** * @see FieldEditor#doStore() @@ -81,45 +76,44 @@ public class BreakpointComboFieldEditor extends ComboFieldEditor implements getPreferenceStore().setToDefault(getPreferenceName()); return; } - + comboValueToStore(fValue); } - /** - * load field value from preference store and return as combo widget value + * load field value from preference store and return as combo widget value * @return - "String" value of the attribute */ protected String storeToComboValue() { String value = getPreferenceStore().getString(getPreferenceName()); - if (fContribution!=null) { - if ("integer".equals (fContribution.getType())) { //$NON-NLS-1$ - value = Integer.toString( getPreferenceStore().getInt(getPreferenceName()) ); - } else if ("boolean".equals (fContribution.getType()) ) {//$NON-NLS-1$ - value = Boolean.toString( getPreferenceStore().getBoolean(getPreferenceName()) ); - } else if ("float".equals (fContribution.getType()) ) {//$NON-NLS-1$ - value = Float.toString( getPreferenceStore().getFloat(getPreferenceName()) ); - } else if ("double".equals (fContribution.getType()) ) {//$NON-NLS-1$ - value = Double.toString( getPreferenceStore().getDouble(getPreferenceName()) ); + if (fContribution != null) { + if ("integer".equals(fContribution.getType())) { //$NON-NLS-1$ + value = Integer.toString(getPreferenceStore().getInt(getPreferenceName())); + } else if ("boolean".equals(fContribution.getType())) {//$NON-NLS-1$ + value = Boolean.toString(getPreferenceStore().getBoolean(getPreferenceName())); + } else if ("float".equals(fContribution.getType())) {//$NON-NLS-1$ + value = Float.toString(getPreferenceStore().getFloat(getPreferenceName())); + } else if ("double".equals(fContribution.getType())) {//$NON-NLS-1$ + value = Double.toString(getPreferenceStore().getDouble(getPreferenceName())); } } return value; } /** - * Save to preference store the selected combo value + * Save to preference store the selected combo value * @param val - value to be stored. */ protected void comboValueToStore(String val) { - if (fContribution!=null) { - if ("integer".equals (fContribution.getType())) { //$NON-NLS-1$ - getPreferenceStore().setValue(getPreferenceName(), Integer.parseInt(val)) ; - } else if ("boolean".equals (fContribution.getType()) ) {//$NON-NLS-1$ - getPreferenceStore().setValue(getPreferenceName(), Boolean.parseBoolean(val)) ; - } else if ("float".equals (fContribution.getType()) ) {//$NON-NLS-1$ - getPreferenceStore().setValue(getPreferenceName(), Float.parseFloat(val)) ; - } else if ("double".equals (fContribution.getType()) ) {//$NON-NLS-1$ - getPreferenceStore().setValue(getPreferenceName(), Double.parseDouble(val)) ; + if (fContribution != null) { + if ("integer".equals(fContribution.getType())) { //$NON-NLS-1$ + getPreferenceStore().setValue(getPreferenceName(), Integer.parseInt(val)); + } else if ("boolean".equals(fContribution.getType())) {//$NON-NLS-1$ + getPreferenceStore().setValue(getPreferenceName(), Boolean.parseBoolean(val)); + } else if ("float".equals(fContribution.getType())) {//$NON-NLS-1$ + getPreferenceStore().setValue(getPreferenceName(), Float.parseFloat(val)); + } else if ("double".equals(fContribution.getType())) {//$NON-NLS-1$ + getPreferenceStore().setValue(getPreferenceName(), Double.parseDouble(val)); } else { // handle "String" attribute type getPreferenceStore().setValue(getPreferenceName(), val); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/BreakpointImageProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/BreakpointImageProvider.java index d5ad6696bc7..07498d8ed86 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/BreakpointImageProvider.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/BreakpointImageProvider.java @@ -23,7 +23,6 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.ui.texteditor.IAnnotationImageProvider; import org.eclipse.ui.texteditor.MarkerAnnotation; - /** * Provides breakpoint's image information. */ @@ -33,13 +32,13 @@ public class BreakpointImageProvider implements IAnnotationImageProvider { * @see org.eclipse.ui.texteditor.IAnnotationImageProvider#getManagedImage(org.eclipse.jface.text.source.Annotation) */ @Override - public Image getManagedImage( Annotation annotation ) { - if ( annotation instanceof MarkerAnnotation ) { - IMarker marker = ((MarkerAnnotation)annotation).getMarker(); - if ( marker != null && marker.exists() ) { - IBreakpoint breakpoint = DebugPlugin.getDefault().getBreakpointManager().getBreakpoint( marker ); - if ( breakpoint != null ) { - return DebugUIPlugin.getModelPresentation().getImage( breakpoint ); + public Image getManagedImage(Annotation annotation) { + if (annotation instanceof MarkerAnnotation) { + IMarker marker = ((MarkerAnnotation) annotation).getMarker(); + if (marker != null && marker.exists()) { + IBreakpoint breakpoint = DebugPlugin.getDefault().getBreakpointManager().getBreakpoint(marker); + if (breakpoint != null) { + return DebugUIPlugin.getModelPresentation().getImage(breakpoint); } } } @@ -50,7 +49,7 @@ public class BreakpointImageProvider implements IAnnotationImageProvider { * @see org.eclipse.ui.texteditor.IAnnotationImageProvider#getImageDescriptorId(org.eclipse.jface.text.source.Annotation) */ @Override - public String getImageDescriptorId( Annotation annotation ) { + public String getImageDescriptorId(Annotation annotation) { return null; } @@ -58,7 +57,7 @@ public class BreakpointImageProvider implements IAnnotationImageProvider { * @see org.eclipse.ui.texteditor.IAnnotationImageProvider#getImageDescriptor(java.lang.String) */ @Override - public ImageDescriptor getImageDescriptor( String imageDescritporId ) { + public ImageDescriptor getImageDescriptor(String imageDescritporId) { return null; } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/BreakpointsMessages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/BreakpointsMessages.java index 662cc6e5880..6219dbdc2ab 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/BreakpointsMessages.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/BreakpointsMessages.java @@ -20,16 +20,15 @@ public class BreakpointsMessages { private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.breakpoints.BreakpointsMessages"; //$NON-NLS-1$ - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); private BreakpointsMessages() { } - public static String getString( String key ) { + public static String getString(String key) { try { - return RESOURCE_BUNDLE.getString( key ); - } - catch( MissingResourceException e ) { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { return '!' + key + '!'; } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointContext.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointContext.java index 77450fd5382..6e7d6f0791f 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointContext.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointContext.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation * Ericsson - Added tracepoint support (284286) @@ -45,74 +45,89 @@ import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.model.IWorkbenchAdapter; /** - * Input for breakpoint properties dialog. It captures both the + * Input for breakpoint properties dialog. It captures both the * selected breakpoint object as well as the selected debug context. * This combined context can then be used by breakpoint property - * pages to access model and target specific breakpoint settings. + * pages to access model and target specific breakpoint settings. */ public class CBreakpointContext extends PlatformObject implements ICBreakpointContext { - // Register an adapter factory for the class when it is first loaded. - static { - Platform.getAdapterManager().registerAdapters(new CBreakpointContextAdapterFactory(), CBreakpointContext.class); - } - - /** - * Breakpoint object held by this context. - */ - private final ICBreakpoint fBreakpoint; - - /** - * The resource that the breakpoint is to be created for. - */ - private final IResource fResource; - - /** - * The active debug context held by this context. - */ - private final ISelection fDebugContext; - - /** - * Associated preference store. - */ - private final CBreakpointPreferenceStore fPreferenceStore; - - /** - * Creates a new breakpoint context with given breakpoint and debug - * context selection. - */ - public CBreakpointContext(ICBreakpoint breakpoint, ISelection debugContext) { - this (breakpoint, debugContext, null, null); - } - - public CBreakpointContext(ICBreakpoint breakpoint, ISelection debugContext, IResource resource, Map<String, Object> attributes) { - fBreakpoint = breakpoint; - fResource = resource; - fDebugContext = debugContext; - fPreferenceStore = new CBreakpointPreferenceStore(this, attributes); - } - - @Override - public ICBreakpoint getBreakpoint() { return fBreakpoint; } - - @Override - public IResource getResource() { return fResource; } - - @Override - public IPreferenceStore getPreferenceStore() { return fPreferenceStore; } - - /** - * Returns the debug context. - */ - public ISelection getDebugContext() { return fDebugContext; } - - /** - * (non-Javadoc) - * @see org.eclipse.debug.ui.contexts.IDebugContextProvider implementation - */ - public IWorkbenchPart getPart() { return null; } - public void addDebugContextListener(IDebugContextListener listener) {} - public void removeDebugContextListener(IDebugContextListener listener) {} + // Register an adapter factory for the class when it is first loaded. + static { + Platform.getAdapterManager().registerAdapters(new CBreakpointContextAdapterFactory(), CBreakpointContext.class); + } + + /** + * Breakpoint object held by this context. + */ + private final ICBreakpoint fBreakpoint; + + /** + * The resource that the breakpoint is to be created for. + */ + private final IResource fResource; + + /** + * The active debug context held by this context. + */ + private final ISelection fDebugContext; + + /** + * Associated preference store. + */ + private final CBreakpointPreferenceStore fPreferenceStore; + + /** + * Creates a new breakpoint context with given breakpoint and debug + * context selection. + */ + public CBreakpointContext(ICBreakpoint breakpoint, ISelection debugContext) { + this(breakpoint, debugContext, null, null); + } + + public CBreakpointContext(ICBreakpoint breakpoint, ISelection debugContext, IResource resource, + Map<String, Object> attributes) { + fBreakpoint = breakpoint; + fResource = resource; + fDebugContext = debugContext; + fPreferenceStore = new CBreakpointPreferenceStore(this, attributes); + } + + @Override + public ICBreakpoint getBreakpoint() { + return fBreakpoint; + } + + @Override + public IResource getResource() { + return fResource; + } + + @Override + public IPreferenceStore getPreferenceStore() { + return fPreferenceStore; + } + + /** + * Returns the debug context. + */ + public ISelection getDebugContext() { + return fDebugContext; + } + + /** + * (non-Javadoc) + * @see org.eclipse.debug.ui.contexts.IDebugContextProvider implementation + */ + public IWorkbenchPart getPart() { + return null; + } + + public void addDebugContextListener(IDebugContextListener listener) { + } + + public void removeDebugContextListener(IDebugContextListener listener) { + } public ISelection getActiveContext() { return fDebugContext; @@ -121,98 +136,104 @@ public class CBreakpointContext extends PlatformObject implements ICBreakpointCo /** * Action filter for the breakpoint context, which allows property - * pages to filter their activation based on the debug model ID of + * pages to filter their activation based on the debug model ID of * the active debug context. */ class CBreakpointContextActionFilter implements IActionFilter { - private static String[] EMPTY_IDENTIFIERS_ARRAY = new String[0]; - - @Override + private static String[] EMPTY_IDENTIFIERS_ARRAY = new String[0]; + + @Override public boolean testAttribute(Object target, String name, String value) { - if (target instanceof CBreakpointContext) { - if ("debugModelId".equals(name)) { //$NON-NLS-1$ - String[] targetModelIds = getDebugModelIds( (CBreakpointContext)target ); - for (int i = 0; i < targetModelIds.length; i++) { - if (targetModelIds[i].equals(value)) { - return true; - } - } - } - } - return false; - } - - private String[] getDebugModelIds(CBreakpointContext bpContext) { - ISelection debugContext = bpContext.getDebugContext(); - if (debugContext instanceof IStructuredSelection) { - Object debugElement = ((IStructuredSelection)debugContext).getFirstElement(); - if (debugElement instanceof IAdaptable) { - IDebugModelProvider debugModelProvider = - ((IAdaptable)debugElement).getAdapter(IDebugModelProvider.class); - if (debugModelProvider != null) { - return debugModelProvider.getModelIdentifiers(); - } else if (debugElement instanceof IDebugElement) { - return new String[] { ((IDebugElement)debugElement).getModelIdentifier() }; - } - } - } - return EMPTY_IDENTIFIERS_ARRAY; - } + if (target instanceof CBreakpointContext) { + if ("debugModelId".equals(name)) { //$NON-NLS-1$ + String[] targetModelIds = getDebugModelIds((CBreakpointContext) target); + for (int i = 0; i < targetModelIds.length; i++) { + if (targetModelIds[i].equals(value)) { + return true; + } + } + } + } + return false; + } + + private String[] getDebugModelIds(CBreakpointContext bpContext) { + ISelection debugContext = bpContext.getDebugContext(); + if (debugContext instanceof IStructuredSelection) { + Object debugElement = ((IStructuredSelection) debugContext).getFirstElement(); + if (debugElement instanceof IAdaptable) { + IDebugModelProvider debugModelProvider = ((IAdaptable) debugElement) + .getAdapter(IDebugModelProvider.class); + if (debugModelProvider != null) { + return debugModelProvider.getModelIdentifiers(); + } else if (debugElement instanceof IDebugElement) { + return new String[] { ((IDebugElement) debugElement).getModelIdentifier() }; + } + } + } + return EMPTY_IDENTIFIERS_ARRAY; + } } class CBreakpointContextWorkbenchAdapter implements IWorkbenchAdapter { - @Override - public String getLabel(Object o) { - if (o instanceof ICBreakpointContext) { - ICBreakpoint bp = ((ICBreakpointContext)o).getBreakpoint(); - return getBreakpointMainLabel(bp); - } - return ""; //$NON-NLS-1$ - } - - @Override - public Object[] getChildren(Object o) { return null; } - - @Override - public ImageDescriptor getImageDescriptor(Object object) { return null; } - - @Override - public Object getParent(Object o) { return null; } - - private String getBreakpointMainLabel(ICBreakpoint breakpoint) { - if (breakpoint instanceof ICFunctionBreakpoint) { - if (breakpoint instanceof ICTracepoint) { - return BreakpointsMessages.getString("TracepointPropertyPage.tracepointType_function_label"); //$NON-NLS-1$ - } else if (breakpoint instanceof ICDynamicPrintf) { - return BreakpointsMessages.getString("DPrintfPropertyPage.dprintfType_function_label"); //$NON-NLS-1$ - } else { - return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_function_label"); //$NON-NLS-1$ - } - } else if (breakpoint instanceof ICAddressBreakpoint) { - if (breakpoint instanceof ICTracepoint) { - return BreakpointsMessages.getString("TracepointPropertyPage.tracepointType_address_label"); //$NON-NLS-1$ - } else if (breakpoint instanceof ICDynamicPrintf) { - return BreakpointsMessages.getString("DPrintfPropertyPage.dprintfType_address_label"); //$NON-NLS-1$ - } else { - return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_address_label"); //$NON-NLS-1$ - } - } else if (breakpoint instanceof ICLineBreakpoint) { - if (breakpoint instanceof ICTracepoint) { - return BreakpointsMessages.getString("TracepointPropertyPage.tracepointType_line_label"); //$NON-NLS-1$ - } else if (breakpoint instanceof ICDynamicPrintf) { - return BreakpointsMessages.getString("DPrintfPropertyPage.dprintfType_line_label"); //$NON-NLS-1$ - } else { - return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_line_label"); //$NON-NLS-1$ - } - } else if (breakpoint instanceof ICEventBreakpoint) { - return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_event_label"); //$NON-NLS-1$ - } else if (breakpoint instanceof ICWatchpoint) { - return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_watchpoint_label"); //$NON-NLS-1$ - } - // default main label is the label of marker type for the breakpoint - return CDIDebugModel.calculateMarkerType(breakpoint); - } + @Override + public String getLabel(Object o) { + if (o instanceof ICBreakpointContext) { + ICBreakpoint bp = ((ICBreakpointContext) o).getBreakpoint(); + return getBreakpointMainLabel(bp); + } + return ""; //$NON-NLS-1$ + } + + @Override + public Object[] getChildren(Object o) { + return null; + } + + @Override + public ImageDescriptor getImageDescriptor(Object object) { + return null; + } + + @Override + public Object getParent(Object o) { + return null; + } + + private String getBreakpointMainLabel(ICBreakpoint breakpoint) { + if (breakpoint instanceof ICFunctionBreakpoint) { + if (breakpoint instanceof ICTracepoint) { + return BreakpointsMessages.getString("TracepointPropertyPage.tracepointType_function_label"); //$NON-NLS-1$ + } else if (breakpoint instanceof ICDynamicPrintf) { + return BreakpointsMessages.getString("DPrintfPropertyPage.dprintfType_function_label"); //$NON-NLS-1$ + } else { + return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_function_label"); //$NON-NLS-1$ + } + } else if (breakpoint instanceof ICAddressBreakpoint) { + if (breakpoint instanceof ICTracepoint) { + return BreakpointsMessages.getString("TracepointPropertyPage.tracepointType_address_label"); //$NON-NLS-1$ + } else if (breakpoint instanceof ICDynamicPrintf) { + return BreakpointsMessages.getString("DPrintfPropertyPage.dprintfType_address_label"); //$NON-NLS-1$ + } else { + return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_address_label"); //$NON-NLS-1$ + } + } else if (breakpoint instanceof ICLineBreakpoint) { + if (breakpoint instanceof ICTracepoint) { + return BreakpointsMessages.getString("TracepointPropertyPage.tracepointType_line_label"); //$NON-NLS-1$ + } else if (breakpoint instanceof ICDynamicPrintf) { + return BreakpointsMessages.getString("DPrintfPropertyPage.dprintfType_line_label"); //$NON-NLS-1$ + } else { + return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_line_label"); //$NON-NLS-1$ + } + } else if (breakpoint instanceof ICEventBreakpoint) { + return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_event_label"); //$NON-NLS-1$ + } else if (breakpoint instanceof ICWatchpoint) { + return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_watchpoint_label"); //$NON-NLS-1$ + } + // default main label is the label of marker type for the breakpoint + return CDIDebugModel.calculateMarkerType(breakpoint); + } } @@ -221,45 +242,42 @@ class CBreakpointContextWorkbenchAdapter implements IWorkbenchAdapter { * filter for the CBreakpointContext type. */ class CBreakpointContextAdapterFactory implements IAdapterFactory { - - private static final Class<?>[] fgAdapterList = new Class[] { - IBreakpoint.class, ICBreakpoint.class, ICTracepoint.class, ICDynamicPrintf.class, - IActionFilter.class, IPreferenceStore.class, IWorkbenchAdapter.class, - }; - - private static final IActionFilter fgActionFilter = new CBreakpointContextActionFilter(); - private static final IWorkbenchAdapter fgWorkbenchAdapter = new CBreakpointContextWorkbenchAdapter(); - - @SuppressWarnings("unchecked") + + private static final Class<?>[] fgAdapterList = new Class[] { IBreakpoint.class, ICBreakpoint.class, + ICTracepoint.class, ICDynamicPrintf.class, IActionFilter.class, IPreferenceStore.class, + IWorkbenchAdapter.class, }; + + private static final IActionFilter fgActionFilter = new CBreakpointContextActionFilter(); + private static final IWorkbenchAdapter fgWorkbenchAdapter = new CBreakpointContextWorkbenchAdapter(); + + @SuppressWarnings("unchecked") @Override public <T> T getAdapter(Object obj, Class<T> adapterType) { - // Note: only return the breakpoint object as an adapter if it has - // an associated marker. Otherwise the property pages will throw multiple - // exceptions. - if (adapterType.isInstance( ((CBreakpointContext)obj).getBreakpoint() ) && - ((CBreakpointContext)obj).getBreakpoint().getMarker() != null) - { - return (T) ((CBreakpointContext)obj).getBreakpoint(); - } - - if ( IPreferenceStore.class.equals(adapterType) ) { - return (T) ((CBreakpointContext)obj).getPreferenceStore(); - } - - if (IActionFilter.class.equals(adapterType)) { - return (T) fgActionFilter; - } - - if (IWorkbenchAdapter.class.equals(adapterType)) { - return (T) fgWorkbenchAdapter; - } - - return null; - } - - @Override + // Note: only return the breakpoint object as an adapter if it has + // an associated marker. Otherwise the property pages will throw multiple + // exceptions. + if (adapterType.isInstance(((CBreakpointContext) obj).getBreakpoint()) + && ((CBreakpointContext) obj).getBreakpoint().getMarker() != null) { + return (T) ((CBreakpointContext) obj).getBreakpoint(); + } + + if (IPreferenceStore.class.equals(adapterType)) { + return (T) ((CBreakpointContext) obj).getPreferenceStore(); + } + + if (IActionFilter.class.equals(adapterType)) { + return (T) fgActionFilter; + } + + if (IWorkbenchAdapter.class.equals(adapterType)) { + return (T) fgWorkbenchAdapter; + } + + return null; + } + + @Override public Class<?>[] getAdapterList() { - return fgAdapterList; - } + return fgAdapterList; + } } - diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPreferenceStore.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPreferenceStore.java index 4dc3cd816fd..9893a79e6eb 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPreferenceStore.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPreferenceStore.java @@ -52,178 +52,174 @@ import org.eclipse.jface.util.PropertyChangeEvent; /** * A preference store that presents the state of the properties of a C/C++ breakpoint, - * tracepoint or dynamic-printf. + * tracepoint or dynamic-printf. */ public class CBreakpointPreferenceStore implements IPersistentPreferenceStore { // This map is the current properties/values being maintained/manipulated - private HashMap<String, Object> fProperties = new HashMap<String, Object>(); - - // Original set of values. So we can see what has really changed on the save and - // perform appropriate change operations. We only really want to operate on changed - // values, to avoid generating churn. - private HashMap<String, Object> fOriginalValues = new HashMap<String, Object>(); - private boolean fIsDirty = false; - private boolean fIsCanceled = false; - private ListenerList<IPropertyChangeListener> fListeners; - private final CBreakpointContext fContext; - - public CBreakpointPreferenceStore() { - this (null, null); - } - - public CBreakpointPreferenceStore(CBreakpointContext context, Map<String, Object> attributes) { - fListeners = new ListenerList<>(org.eclipse.core.runtime.ListenerList.IDENTITY); - fContext = context; - - fOriginalValues.clear(); - fProperties.clear(); - if (context != null) { - IMarker marker = context.getBreakpoint().getMarker(); - if (marker != null) { - Map<String, Object> bpAttrs = Collections.emptyMap(); - try { - bpAttrs = marker.getAttributes(); - fOriginalValues.putAll(bpAttrs); - fProperties.putAll(bpAttrs); - } catch (CoreException e) { - DebugPlugin.log(e); - } - } - } - if (attributes != null) { - fProperties.putAll(attributes); - fIsDirty = true; - } - } - - public Map<String, Object> getAttributes() { - return fProperties; - } - - public void setCanceled(boolean canceled) { - fIsCanceled = canceled; - } - - public void save() throws IOException { - if (!fIsCanceled && fContext != null && fContext.getBreakpoint() != null) { - ICBreakpoint bp = fContext.getBreakpoint(); - if (bp.getMarker() != null && fIsDirty) { - saveToExistingMarker(bp, bp.getMarker()); - } else { - IResource resolved = getResource(fContext.getResource()); - if (resolved != null) { - saveToNewMarker(bp, resolved); - } else { - throw new IOException("Unable to create breakpoint: no resource specified."); //$NON-NLS-1$ - } - } - } - - } - - /** - * Get the resource to apply the marker against. This may not be the same - * resource the dialog was created for if the user has selected a different - * resource. - * <p> - * If the {@link ICBreakpoint#SOURCE_HANDLE} resolves to the same file on - * the filesystem as the preferred resource the preferred resource is used. - * - * @param preferred - * resource to use if it matches the SOURCE_HANDLE - * @return Resource to install marker on, or <code>null</code> for not - * available. - */ - private IResource getResource(IResource preferred) { - IResource resolved = null; - String source = getString(ICBreakpoint.SOURCE_HANDLE); - if (!"".equals(source)) { //$NON-NLS-1$ - IPath rawLocation = preferred.getRawLocation(); - if (rawLocation != null) { - File file = rawLocation.toFile(); - File sourceFile = new File(source); - if (file.getAbsoluteFile().equals(sourceFile.getAbsoluteFile())) { - resolved = preferred; - } - } - - if (resolved == null) { - IPath path = Path.fromOSString(source); - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - IFile file = root.getFileForLocation(path); - if (file == null) { - resolved = root; - } else { - resolved = file; - } - } - } - if (resolved == null) { - resolved = preferred; - } - return resolved; - } - - private void saveToExistingMarker(final ICBreakpoint breakpoint, final IMarker marker) throws IOException { - final List<String> changedProperties = new ArrayList<String>( 5 ); - Set<String> valueNames = fProperties.keySet(); - for ( String name : valueNames ) { - if ( fProperties.containsKey( name ) ) { - Object originalObject = fOriginalValues.get( name ); - Object currentObject = fProperties.get( name ); - if ( originalObject == null ) { - changedProperties.add( name ); + private HashMap<String, Object> fProperties = new HashMap<String, Object>(); + + // Original set of values. So we can see what has really changed on the save and + // perform appropriate change operations. We only really want to operate on changed + // values, to avoid generating churn. + private HashMap<String, Object> fOriginalValues = new HashMap<String, Object>(); + private boolean fIsDirty = false; + private boolean fIsCanceled = false; + private ListenerList<IPropertyChangeListener> fListeners; + private final CBreakpointContext fContext; + + public CBreakpointPreferenceStore() { + this(null, null); + } + + public CBreakpointPreferenceStore(CBreakpointContext context, Map<String, Object> attributes) { + fListeners = new ListenerList<>(org.eclipse.core.runtime.ListenerList.IDENTITY); + fContext = context; + + fOriginalValues.clear(); + fProperties.clear(); + if (context != null) { + IMarker marker = context.getBreakpoint().getMarker(); + if (marker != null) { + Map<String, Object> bpAttrs = Collections.emptyMap(); + try { + bpAttrs = marker.getAttributes(); + fOriginalValues.putAll(bpAttrs); + fProperties.putAll(bpAttrs); + } catch (CoreException e) { + DebugPlugin.log(e); } - else if ( ! originalObject.equals( currentObject ) ) { - changedProperties.add( name ); + } + } + if (attributes != null) { + fProperties.putAll(attributes); + fIsDirty = true; + } + } + + public Map<String, Object> getAttributes() { + return fProperties; + } + + public void setCanceled(boolean canceled) { + fIsCanceled = canceled; + } + + public void save() throws IOException { + if (!fIsCanceled && fContext != null && fContext.getBreakpoint() != null) { + ICBreakpoint bp = fContext.getBreakpoint(); + if (bp.getMarker() != null && fIsDirty) { + saveToExistingMarker(bp, bp.getMarker()); + } else { + IResource resolved = getResource(fContext.getResource()); + if (resolved != null) { + saveToNewMarker(bp, resolved); + } else { + throw new IOException("Unable to create breakpoint: no resource specified."); //$NON-NLS-1$ } } } - if ( ! changedProperties.isEmpty() ) { + + } + + /** + * Get the resource to apply the marker against. This may not be the same + * resource the dialog was created for if the user has selected a different + * resource. + * <p> + * If the {@link ICBreakpoint#SOURCE_HANDLE} resolves to the same file on + * the filesystem as the preferred resource the preferred resource is used. + * + * @param preferred + * resource to use if it matches the SOURCE_HANDLE + * @return Resource to install marker on, or <code>null</code> for not + * available. + */ + private IResource getResource(IResource preferred) { + IResource resolved = null; + String source = getString(ICBreakpoint.SOURCE_HANDLE); + if (!"".equals(source)) { //$NON-NLS-1$ + IPath rawLocation = preferred.getRawLocation(); + if (rawLocation != null) { + File file = rawLocation.toFile(); + File sourceFile = new File(source); + if (file.getAbsoluteFile().equals(sourceFile.getAbsoluteFile())) { + resolved = preferred; + } + } + + if (resolved == null) { + IPath path = Path.fromOSString(source); + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + IFile file = root.getFileForLocation(path); + if (file == null) { + resolved = root; + } else { + resolved = file; + } + } + } + if (resolved == null) { + resolved = preferred; + } + return resolved; + } + + private void saveToExistingMarker(final ICBreakpoint breakpoint, final IMarker marker) throws IOException { + final List<String> changedProperties = new ArrayList<String>(5); + Set<String> valueNames = fProperties.keySet(); + for (String name : valueNames) { + if (fProperties.containsKey(name)) { + Object originalObject = fOriginalValues.get(name); + Object currentObject = fProperties.get(name); + if (originalObject == null) { + changedProperties.add(name); + } else if (!originalObject.equals(currentObject)) { + changedProperties.add(name); + } + } + } + if (!changedProperties.isEmpty()) { IWorkspaceRunnable wr = new IWorkspaceRunnable() { - public void run( IProgressMonitor monitor ) throws CoreException { + public void run(IProgressMonitor monitor) throws CoreException { Iterator<String> changed = changedProperties.iterator(); - while( changed.hasNext() ) { + while (changed.hasNext()) { String property = changed.next(); - if ( property.equals( ICBreakpoint.ENABLED ) ) { - breakpoint.setEnabled( getBoolean( ICBreakpoint.ENABLED ) ); - } - else if ( property.equals( ICBreakpoint.IGNORE_COUNT ) ) { - breakpoint.setIgnoreCount( getInt( ICBreakpoint.IGNORE_COUNT ) ); - } - else if ( breakpoint instanceof ICTracepoint && property.equals( ICTracepoint.PASS_COUNT ) ) { - ((ICTracepoint)breakpoint).setPassCount( getInt( ICTracepoint.PASS_COUNT ) ); - } - else if ( breakpoint instanceof ICDynamicPrintf && property.equals( ICDynamicPrintf.PRINTF_STRING ) ) { - ((ICDynamicPrintf)breakpoint).setPrintfString( getString( ICDynamicPrintf.PRINTF_STRING ) ); - } - else if ( property.equals( ICBreakpoint.CONDITION ) ) { - breakpoint.setCondition( getString( ICBreakpoint.CONDITION ) ); - } - else if ( property.equals( IMarker.LINE_NUMBER ) ) { + if (property.equals(ICBreakpoint.ENABLED)) { + breakpoint.setEnabled(getBoolean(ICBreakpoint.ENABLED)); + } else if (property.equals(ICBreakpoint.IGNORE_COUNT)) { + breakpoint.setIgnoreCount(getInt(ICBreakpoint.IGNORE_COUNT)); + } else if (breakpoint instanceof ICTracepoint && property.equals(ICTracepoint.PASS_COUNT)) { + ((ICTracepoint) breakpoint).setPassCount(getInt(ICTracepoint.PASS_COUNT)); + } else if (breakpoint instanceof ICDynamicPrintf + && property.equals(ICDynamicPrintf.PRINTF_STRING)) { + ((ICDynamicPrintf) breakpoint).setPrintfString(getString(ICDynamicPrintf.PRINTF_STRING)); + } else if (property.equals(ICBreakpoint.CONDITION)) { + breakpoint.setCondition(getString(ICBreakpoint.CONDITION)); + } else if (property.equals(IMarker.LINE_NUMBER)) { if (breakpoint instanceof ICLineBreakpoint2) { // refresh message and line number // Note there are no API methods to set the line number of a Line Breakpoint, so we // replicate what is done in CDIDebugModel.setLineBreakpointAttributes() // to set the line number fields properly and then refresh the message if possible - ((ICLineBreakpoint2)breakpoint).setRequestedLine(getInt(IMarker.LINE_NUMBER)); + ((ICLineBreakpoint2) breakpoint).setRequestedLine(getInt(IMarker.LINE_NUMBER)); breakpoint.getMarker().setAttribute(IMarker.LINE_NUMBER, getInt(IMarker.LINE_NUMBER)); - ((ICBreakpoint2)breakpoint).refreshMessage(); + ((ICBreakpoint2) breakpoint).refreshMessage(); } else { // already workspace runnable, setting markers are safe breakpoint.getMarker().setAttribute(IMarker.LINE_NUMBER, getInt(IMarker.LINE_NUMBER)); - breakpoint.getMarker().setAttribute(ICLineBreakpoint2.REQUESTED_LINE, getInt(IMarker.LINE_NUMBER)); + breakpoint.getMarker().setAttribute(ICLineBreakpoint2.REQUESTED_LINE, + getInt(IMarker.LINE_NUMBER)); } } else { - // this allow set attributes contributed by other plugins + // this allow set attributes contributed by other plugins Object value = fProperties.get(property); - if ( value != null ) { + if (value != null) { marker.setAttribute(property, value); if (breakpoint instanceof ICBreakpoint2) { // To be safe, refresh the breakpoint message as the property // change might affect it. - ((ICBreakpoint2)breakpoint).refreshMessage(); + ((ICBreakpoint2) breakpoint).refreshMessage(); } } } @@ -231,166 +227,204 @@ public class CBreakpointPreferenceStore implements IPersistentPreferenceStore { } }; try { - ResourcesPlugin.getWorkspace().run( wr, null ); + ResourcesPlugin.getWorkspace().run(wr, null); + } catch (CoreException ce) { + throw new IOException("Cannot save properties to breakpoint.", ce); //$NON-NLS-1$ + } + } + } + + private void saveToNewMarker(final ICBreakpoint breakpoint, final IResource resource) throws IOException { + try { + // On initial creation of BP, make sure that requested values of breakpoint + // match the current values (i.e. make sure it starts as a not-relocated breakpoint) + // See CDIDebugModel.setLineBreakpointAttributes + if (fProperties.containsKey(ICLineBreakpoint2.REQUESTED_SOURCE_HANDLE)) { + fProperties.put(ICLineBreakpoint2.REQUESTED_SOURCE_HANDLE, fProperties.get(ICBreakpoint.SOURCE_HANDLE)); + } + if (fProperties.containsKey(ICLineBreakpoint2.REQUESTED_LINE)) { + fProperties.put(ICLineBreakpoint2.REQUESTED_LINE, fProperties.get(IMarker.LINE_NUMBER)); } - catch( CoreException ce ) { - throw new IOException("Cannot save properties to breakpoint.", ce); //$NON-NLS-1$ + if (fProperties.containsKey(ICLineBreakpoint2.REQUESTED_CHAR_START)) { + fProperties.put(ICLineBreakpoint2.REQUESTED_CHAR_START, fProperties.get(IMarker.CHAR_START)); } - } - } - - private void saveToNewMarker(final ICBreakpoint breakpoint, final IResource resource) throws IOException { - try { - // On initial creation of BP, make sure that requested values of breakpoint - // match the current values (i.e. make sure it starts as a not-relocated breakpoint) - // See CDIDebugModel.setLineBreakpointAttributes - if (fProperties.containsKey(ICLineBreakpoint2.REQUESTED_SOURCE_HANDLE)) { - fProperties.put(ICLineBreakpoint2.REQUESTED_SOURCE_HANDLE, fProperties.get(ICBreakpoint.SOURCE_HANDLE)); - } - if (fProperties.containsKey(ICLineBreakpoint2.REQUESTED_LINE)) { - fProperties.put(ICLineBreakpoint2.REQUESTED_LINE, fProperties.get(IMarker.LINE_NUMBER)); - } - if (fProperties.containsKey(ICLineBreakpoint2.REQUESTED_CHAR_START)) { - fProperties.put(ICLineBreakpoint2.REQUESTED_CHAR_START, fProperties.get(IMarker.CHAR_START)); - } - if (fProperties.containsKey(ICLineBreakpoint2.REQUESTED_CHAR_END)) { - fProperties.put(ICLineBreakpoint2.REQUESTED_CHAR_END, fProperties.get(IMarker.CHAR_END)); - } - - CDIDebugModel.createBreakpointMarker(breakpoint, resource, fProperties, true); - } - catch( CoreException ce ) { - throw new IOException("Cannot save properties to new breakpoint.", ce); //$NON-NLS-1$ - } - } - - /////////////////////////////////////////////////////////////////////// - // IPreferenceStore - - public boolean needsSaving() { - return fIsDirty && !fIsCanceled; - } - - public boolean contains(String name) { - return fProperties.containsKey(name); - } - - public void addPropertyChangeListener(IPropertyChangeListener listener) { - fListeners.add(listener); - } - - public void removePropertyChangeListener(IPropertyChangeListener listener) { - fListeners.remove(listener); - } - - public void firePropertyChangeEvent(String name, - Object oldValue, - Object newValue) - { - Object[] listeners = fListeners.getListeners(); - // Do we need to fire an event. - if (listeners.length > 0 && (oldValue == null || !oldValue.equals(newValue))) { - PropertyChangeEvent pe = new PropertyChangeEvent(this, name, oldValue, newValue); - for (int i = 0; i < listeners.length; ++i) { - IPropertyChangeListener l = (IPropertyChangeListener) listeners[i]; - l.propertyChange(pe); - } - } - } - - public boolean getBoolean(String name) { - boolean retVal = false; - Object o = fProperties.get(name); - if (o instanceof Boolean) { - retVal = ((Boolean)o).booleanValue(); - } - return retVal; - } - - public int getInt(String name) { - int retVal = 0; - Object o = fProperties.get(name); - if (o instanceof Integer) { - retVal = ((Integer)o).intValue(); - } - return retVal; - } - - public String getString(String name) { - String retVal = ""; //$NON-NLS-1$ - Object o = fProperties.get(name); - if (o instanceof String) { - retVal = (String)o; - } - return retVal; - } - - public double getDouble(String name) { return 0; } - public float getFloat(String name) { return 0; } - public long getLong(String name) { return 0; } - - public boolean isDefault(String name) { return false; } - - public boolean getDefaultBoolean(String name) { return false; } - public double getDefaultDouble(String name) { return 0; } - public float getDefaultFloat(String name) { return 0; } - public int getDefaultInt(String name) { return 0; } - public long getDefaultLong(String name) { return 0; } - public String getDefaultString(String name) { return null; } - - public void putValue(String name, String value) { - Object oldValue = fProperties.get(name); - if ( oldValue == null || !oldValue.equals(value) ) { - fProperties.put(name, value); - setDirty(true); - } - } - - public void setDefault(String name, double value) {} - public void setDefault(String name, float value) {} - public void setDefault(String name, int value) {} - public void setDefault(String name, long value) {} - public void setDefault(String name, String defaultObject) {} - public void setDefault(String name, boolean value) {} - public void setToDefault(String name) {} - - public void setValue(String name, boolean value) { - boolean oldValue = getBoolean(name); - if (oldValue != value) { - fProperties.put( name, Boolean.valueOf(value) ); - setDirty(true); - firePropertyChangeEvent(name, Boolean.valueOf(oldValue), Boolean.valueOf(value) ); - } - } - - public void setValue(String name, int value) { - int oldValue = getInt(name); - if (oldValue != value) { - fProperties.put( name, Integer.valueOf(value) ); - setDirty(true); - firePropertyChangeEvent(name, Integer.valueOf(oldValue), Integer.valueOf(value) ); - } - } - - public void setValue(String name, String value) { - Object oldValue = fProperties.get(name); - if ( (oldValue == null && value != null) || - (oldValue != null && !oldValue.equals(value)) ) - { - fProperties.put(name, value); - setDirty(true); - firePropertyChangeEvent(name, oldValue, value); - } - } - - public void setValue(String name, float value) {} - public void setValue(String name, double value) {} - public void setValue(String name, long value) {} - - // IPreferenceStore - /////////////////////////////////////////////////////////////////////// - - private void setDirty(boolean isDirty) { - fIsDirty = isDirty; - } + if (fProperties.containsKey(ICLineBreakpoint2.REQUESTED_CHAR_END)) { + fProperties.put(ICLineBreakpoint2.REQUESTED_CHAR_END, fProperties.get(IMarker.CHAR_END)); + } + + CDIDebugModel.createBreakpointMarker(breakpoint, resource, fProperties, true); + } catch (CoreException ce) { + throw new IOException("Cannot save properties to new breakpoint.", ce); //$NON-NLS-1$ + } + } + + /////////////////////////////////////////////////////////////////////// + // IPreferenceStore + + public boolean needsSaving() { + return fIsDirty && !fIsCanceled; + } + + public boolean contains(String name) { + return fProperties.containsKey(name); + } + + public void addPropertyChangeListener(IPropertyChangeListener listener) { + fListeners.add(listener); + } + + public void removePropertyChangeListener(IPropertyChangeListener listener) { + fListeners.remove(listener); + } + + public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) { + Object[] listeners = fListeners.getListeners(); + // Do we need to fire an event. + if (listeners.length > 0 && (oldValue == null || !oldValue.equals(newValue))) { + PropertyChangeEvent pe = new PropertyChangeEvent(this, name, oldValue, newValue); + for (int i = 0; i < listeners.length; ++i) { + IPropertyChangeListener l = (IPropertyChangeListener) listeners[i]; + l.propertyChange(pe); + } + } + } + + public boolean getBoolean(String name) { + boolean retVal = false; + Object o = fProperties.get(name); + if (o instanceof Boolean) { + retVal = ((Boolean) o).booleanValue(); + } + return retVal; + } + + public int getInt(String name) { + int retVal = 0; + Object o = fProperties.get(name); + if (o instanceof Integer) { + retVal = ((Integer) o).intValue(); + } + return retVal; + } + + public String getString(String name) { + String retVal = ""; //$NON-NLS-1$ + Object o = fProperties.get(name); + if (o instanceof String) { + retVal = (String) o; + } + return retVal; + } + + public double getDouble(String name) { + return 0; + } + + public float getFloat(String name) { + return 0; + } + + public long getLong(String name) { + return 0; + } + + public boolean isDefault(String name) { + return false; + } + + public boolean getDefaultBoolean(String name) { + return false; + } + + public double getDefaultDouble(String name) { + return 0; + } + + public float getDefaultFloat(String name) { + return 0; + } + + public int getDefaultInt(String name) { + return 0; + } + + public long getDefaultLong(String name) { + return 0; + } + + public String getDefaultString(String name) { + return null; + } + + public void putValue(String name, String value) { + Object oldValue = fProperties.get(name); + if (oldValue == null || !oldValue.equals(value)) { + fProperties.put(name, value); + setDirty(true); + } + } + + public void setDefault(String name, double value) { + } + + public void setDefault(String name, float value) { + } + + public void setDefault(String name, int value) { + } + + public void setDefault(String name, long value) { + } + + public void setDefault(String name, String defaultObject) { + } + + public void setDefault(String name, boolean value) { + } + + public void setToDefault(String name) { + } + + public void setValue(String name, boolean value) { + boolean oldValue = getBoolean(name); + if (oldValue != value) { + fProperties.put(name, Boolean.valueOf(value)); + setDirty(true); + firePropertyChangeEvent(name, Boolean.valueOf(oldValue), Boolean.valueOf(value)); + } + } + + public void setValue(String name, int value) { + int oldValue = getInt(name); + if (oldValue != value) { + fProperties.put(name, Integer.valueOf(value)); + setDirty(true); + firePropertyChangeEvent(name, Integer.valueOf(oldValue), Integer.valueOf(value)); + } + } + + public void setValue(String name, String value) { + Object oldValue = fProperties.get(name); + if ((oldValue == null && value != null) || (oldValue != null && !oldValue.equals(value))) { + fProperties.put(name, value); + setDirty(true); + firePropertyChangeEvent(name, oldValue, value); + } + } + + public void setValue(String name, float value) { + } + + public void setValue(String name, double value) { + } + + public void setValue(String name, long value) { + } + + // IPreferenceStore + /////////////////////////////////////////////////////////////////////// + + private void setDirty(boolean isDirty) { + fIsDirty = isDirty; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPropertyPage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPropertyPage.java index 932b4535ab0..8597628aecc 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPropertyPage.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPropertyPage.java @@ -91,12 +91,12 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement private Composite fEventBPComposite; private Composite fEventArgsComposite; private List<FieldEditor> fEventArgsFEs = null; - + class BreakpointIntegerFieldEditor extends IntegerFieldEditor { - public BreakpointIntegerFieldEditor( String name, String labelText, Composite parent ) { - super( name, labelText, parent ); - setErrorMessage( BreakpointsMessages.getString( "CBreakpointPropertyPage.0" ) ); //$NON-NLS-1$ + public BreakpointIntegerFieldEditor(String name, String labelText, Composite parent) { + super(name, labelText, parent); + setErrorMessage(BreakpointsMessages.getString("CBreakpointPropertyPage.0")); //$NON-NLS-1$ } /** @@ -105,7 +105,7 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement @Override protected boolean checkState() { Text control = getTextControl(); - if ( !control.isEnabled() ) { + if (!control.isEnabled()) { clearErrorMessage(); return true; } @@ -122,13 +122,13 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement /** * Only store if the text control is enabled - * + * * @see FieldEditor#doStore() */ @Override protected void doStore() { Text text = getTextControl(); - if ( text.isEnabled() ) { + if (text.isEnabled()) { super.doStore(); } } @@ -138,14 +138,13 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement */ @Override protected void clearErrorMessage() { - if ( getPage() != null ) { + if (getPage() != null) { String message = getPage().getErrorMessage(); - if ( message != null ) { - if ( getErrorMessage().equals( message ) ) { + if (message != null) { + if (getErrorMessage().equals(message)) { super.clearErrorMessage(); } - } - else { + } else { super.clearErrorMessage(); } } @@ -154,8 +153,8 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement class BreakpointStringFieldEditor extends StringFieldEditor { - public BreakpointStringFieldEditor( String name, String labelText, Composite parent ) { - super( name, labelText, parent ); + public BreakpointStringFieldEditor(String name, String labelText, Composite parent) { + super(name, labelText, parent); } @Override @@ -177,7 +176,7 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement @Override protected boolean checkState() { Text control = getTextControl(); - if ( !control.isEnabled() ) { + if (!control.isEnabled()) { clearErrorMessage(); return true; } @@ -187,14 +186,15 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement @Override protected void doStore() { Text text = getTextControl(); - if ( text.isEnabled() ) { + if (text.isEnabled()) { super.doStore(); } } + @Override - protected void doLoad() { + protected void doLoad() { String value = getPreferenceStore().getString(getPreferenceName()); - setStringValue(value); + setStringValue(value); } /** @@ -210,14 +210,13 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement */ @Override protected void clearErrorMessage() { - if ( getPage() != null ) { + if (getPage() != null) { String message = getPage().getErrorMessage(); - if ( message != null ) { - if ( getErrorMessage().equals( message ) ) { + if (message != null) { + if (getErrorMessage().equals(message)) { super.clearErrorMessage(); } - } - else { + } else { super.clearErrorMessage(); } } @@ -243,7 +242,8 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement super.doFillIntoGrid(parent, numColumns); composite = new Composite(parent, SWT.NONE); - composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(getNumberOfControls(), 1).align(SWT.END, SWT.FILL).create()); + composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(getNumberOfControls(), 1) + .align(SWT.END, SWT.FILL).create()); composite.setLayout(new FillLayout()); Button browseWorkspace = new Button(composite, SWT.PUSH); browseWorkspace.setText(BreakpointsMessages.getString("CBreakpointPropertyPage.workspace_button")); //$NON-NLS-1$ @@ -251,7 +251,8 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement browseWorkspace.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent evt) { - FilteredResourcesSelectionDialog dialog = new FilteredResourcesSelectionDialog(getShell(), false, ResourcesPlugin.getWorkspace().getRoot(), IResource.FILE); + FilteredResourcesSelectionDialog dialog = new FilteredResourcesSelectionDialog(getShell(), false, + ResourcesPlugin.getWorkspace().getRoot(), IResource.FILE); String text = getTextControl().getText(); IPath path = Path.fromOSString(text); String filename; @@ -277,7 +278,6 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement } }); - Button browseFileSystem = new Button(composite, SWT.PUSH); browseFileSystem.setText(BreakpointsMessages.getString("CBreakpointPropertyPage.file_system_button")); //$NON-NLS-1$ browseFileSystem.setFont(parent.getFont()); @@ -296,7 +296,7 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement @Override protected boolean doCheckState() { - // Check that the file name supplied is absolute and exists so that we can + // Check that the file name supplied is absolute and exists so that we can // associate it to an IResource later for creating a breakpoint marker. String stringValue = getStringValue(); if (stringValue == null) { @@ -309,226 +309,227 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement return super.doCheckState(); } - + } - class WatchpointRangeFieldEditor extends IntegerFieldEditor { - - private static final String DISABLED_VALUE = "0"; //$NON-NLS-1$ - private Button fCheckbox; - private boolean fWasSelected; - - public WatchpointRangeFieldEditor( String name, String labelText, Composite parent ) { - super( name, labelText, parent ); - } - - @Override - protected void doFillIntoGrid(Composite parent, int numColumns) { - getCheckboxControl(parent); - super.doFillIntoGrid(parent, numColumns); - } - - private Button getCheckboxControl(Composite parent) { - if (fCheckbox == null) { - Composite inner= new Composite(parent, SWT.NULL); - final GridLayout layout= new GridLayout(2, false); - layout.marginWidth = 0; - inner.setLayout(layout); - fCheckbox= new Button(inner, SWT.CHECK); - fCheckbox.setFont(parent.getFont()); - fCheckbox.setText(getLabelText()); - // create and hide label from base class - Label label = getLabelControl(inner); - label.setText(""); //$NON-NLS-1$ - label.setVisible(false); - fCheckbox.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - boolean isSelected = fCheckbox.getSelection(); - valueChanged(fWasSelected, isSelected); - fWasSelected = isSelected; - } - }); - } else { - checkParent(fCheckbox.getParent(), parent); - } - return fCheckbox; - } - - @Override - protected boolean checkState() { - if (fCheckbox != null && !fCheckbox.getSelection()) { - clearErrorMessage(); - return true; - } - return super.checkState(); - } - - @Override - public Label getLabelControl(Composite parent) { - final Label label= getLabelControl(); - if (label == null) { - return super.getLabelControl(parent); - } else { - checkParent(label.getParent(), parent); - } - return label; - } - - @Override - protected void doLoad() { - if (getTextControl() != null && fCheckbox != null && getLabelControl() != null) { - oldValue = getPreferenceStore().getString(getPreferenceName()); - boolean enabled = !DISABLED_VALUE.equals(oldValue); - getTextControl().setText(enabled ? oldValue : ""); //$NON-NLS-1$ - fCheckbox.setSelection(enabled); - fWasSelected = enabled; - getTextControl().setEnabled(enabled); - getLabelControl().setEnabled(enabled); - } - } - - @Override - protected void doStore() { - if (fCheckbox != null && !fCheckbox.getSelection()) { - getPreferenceStore().setValue(getPreferenceName(), DISABLED_VALUE); - } else { - Text text = getTextControl(); - if (text != null) { - getPreferenceStore().setValue(getPreferenceName(), text.getText().trim()); - } - } - } - - @Override - public int getIntValue() throws NumberFormatException { - if (fCheckbox != null && !fCheckbox.getSelection()) { - return 0; - } else { - return super.getIntValue(); - } - } - - protected void valueChanged(boolean oldValue, boolean newValue) { - if (oldValue != newValue) { - valueChanged(); - fireStateChanged(VALUE, oldValue, newValue); - getTextControl().setEnabled(newValue); - getLabelControl().setEnabled(newValue); - } - } - - } - - class WatchpointMemorySpaceFieldEditor extends ComboFieldEditor { - - private static final String DISABLED_VALUE = ""; //$NON-NLS-1$ - private Button fCheckbox; - private boolean fWasSelected; - - public WatchpointMemorySpaceFieldEditor( String name, String labelText, String[] memorySpaces, Composite parent ) { - super( name, labelText, makeArray2D(memorySpaces), parent ); - } - - @Override - protected void doFillIntoGrid(Composite parent, int numColumns) { - getCheckboxControl(parent); - super.doFillIntoGrid(parent, numColumns); - } - - private Button getCheckboxControl(Composite parent) { - if (fCheckbox == null) { - Composite inner= new Composite(parent, SWT.NULL); - final GridLayout layout= new GridLayout(2, false); - layout.marginWidth = 0; - inner.setLayout(layout); - fCheckbox= new Button(inner, SWT.CHECK); - fCheckbox.setFont(parent.getFont()); - fCheckbox.setText(getLabelText()); - // create and hide label from base class - Label label = getLabelControl(inner); - label.setText(""); //$NON-NLS-1$ - label.setVisible(false); - fCheckbox.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - boolean isSelected = fCheckbox.getSelection(); - valueChanged(fWasSelected, isSelected); - fWasSelected = isSelected; - } - }); - } else { - checkParent(fCheckbox.getParent(), parent); - } - return fCheckbox; - } - - @Override - public Label getLabelControl(Composite parent) { - final Label label= getLabelControl(); - if (label == null) { - return super.getLabelControl(parent); - } else { - checkParent(label.getParent(), parent); - } - return label; - } - - @Override - protected void doLoad() { - super.doLoad(); - if (fCheckbox != null && getLabelControl() != null) { - String value = getPreferenceStore().getString(getPreferenceName()); - boolean enabled = !DISABLED_VALUE.equals(value); - fCheckbox.setSelection(enabled); - fWasSelected = enabled; - getComboBoxControl().setEnabled(enabled); - getLabelControl().setEnabled(enabled); - } - } - - @Override - protected void doStore() { - if (fCheckbox != null && !fCheckbox.getSelection()) { - getPreferenceStore().setValue(getPreferenceName(), DISABLED_VALUE); - } else { - super.doStore(); - } - } - - protected void valueChanged(boolean oldValue, boolean newValue) { - if (oldValue != newValue) { - fireStateChanged(VALUE, oldValue, newValue); - getComboBoxControl().setEnabled(newValue); - getLabelControl().setEnabled(newValue); - } - } - - } - - private String[][] makeArray2D(String[] array) { - String[][] array2d = new String[array.length][]; - for (int i = 0; i < array.length; i++) { - array2d[i] = new String[2]; - array2d[i][0] = array2d[i][1] = array[i]; - } - return array2d; - } - - private String[][] joinToArray2D(String[] labels, String[] values) { - String[][] array2d = new String[labels.length][]; - for (int i = 0; i < labels.length; i++) { - array2d[i] = new String[2]; - array2d[i][0] = labels[i]; - array2d[i][1] = values[i]; - } - return array2d; - } + class WatchpointRangeFieldEditor extends IntegerFieldEditor { + + private static final String DISABLED_VALUE = "0"; //$NON-NLS-1$ + private Button fCheckbox; + private boolean fWasSelected; + + public WatchpointRangeFieldEditor(String name, String labelText, Composite parent) { + super(name, labelText, parent); + } + + @Override + protected void doFillIntoGrid(Composite parent, int numColumns) { + getCheckboxControl(parent); + super.doFillIntoGrid(parent, numColumns); + } + + private Button getCheckboxControl(Composite parent) { + if (fCheckbox == null) { + Composite inner = new Composite(parent, SWT.NULL); + final GridLayout layout = new GridLayout(2, false); + layout.marginWidth = 0; + inner.setLayout(layout); + fCheckbox = new Button(inner, SWT.CHECK); + fCheckbox.setFont(parent.getFont()); + fCheckbox.setText(getLabelText()); + // create and hide label from base class + Label label = getLabelControl(inner); + label.setText(""); //$NON-NLS-1$ + label.setVisible(false); + fCheckbox.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + boolean isSelected = fCheckbox.getSelection(); + valueChanged(fWasSelected, isSelected); + fWasSelected = isSelected; + } + }); + } else { + checkParent(fCheckbox.getParent(), parent); + } + return fCheckbox; + } + + @Override + protected boolean checkState() { + if (fCheckbox != null && !fCheckbox.getSelection()) { + clearErrorMessage(); + return true; + } + return super.checkState(); + } + + @Override + public Label getLabelControl(Composite parent) { + final Label label = getLabelControl(); + if (label == null) { + return super.getLabelControl(parent); + } else { + checkParent(label.getParent(), parent); + } + return label; + } + + @Override + protected void doLoad() { + if (getTextControl() != null && fCheckbox != null && getLabelControl() != null) { + oldValue = getPreferenceStore().getString(getPreferenceName()); + boolean enabled = !DISABLED_VALUE.equals(oldValue); + getTextControl().setText(enabled ? oldValue : ""); //$NON-NLS-1$ + fCheckbox.setSelection(enabled); + fWasSelected = enabled; + getTextControl().setEnabled(enabled); + getLabelControl().setEnabled(enabled); + } + } + + @Override + protected void doStore() { + if (fCheckbox != null && !fCheckbox.getSelection()) { + getPreferenceStore().setValue(getPreferenceName(), DISABLED_VALUE); + } else { + Text text = getTextControl(); + if (text != null) { + getPreferenceStore().setValue(getPreferenceName(), text.getText().trim()); + } + } + } + + @Override + public int getIntValue() throws NumberFormatException { + if (fCheckbox != null && !fCheckbox.getSelection()) { + return 0; + } else { + return super.getIntValue(); + } + } + + protected void valueChanged(boolean oldValue, boolean newValue) { + if (oldValue != newValue) { + valueChanged(); + fireStateChanged(VALUE, oldValue, newValue); + getTextControl().setEnabled(newValue); + getLabelControl().setEnabled(newValue); + } + } + + } + + class WatchpointMemorySpaceFieldEditor extends ComboFieldEditor { + + private static final String DISABLED_VALUE = ""; //$NON-NLS-1$ + private Button fCheckbox; + private boolean fWasSelected; + + public WatchpointMemorySpaceFieldEditor(String name, String labelText, String[] memorySpaces, + Composite parent) { + super(name, labelText, makeArray2D(memorySpaces), parent); + } + + @Override + protected void doFillIntoGrid(Composite parent, int numColumns) { + getCheckboxControl(parent); + super.doFillIntoGrid(parent, numColumns); + } + + private Button getCheckboxControl(Composite parent) { + if (fCheckbox == null) { + Composite inner = new Composite(parent, SWT.NULL); + final GridLayout layout = new GridLayout(2, false); + layout.marginWidth = 0; + inner.setLayout(layout); + fCheckbox = new Button(inner, SWT.CHECK); + fCheckbox.setFont(parent.getFont()); + fCheckbox.setText(getLabelText()); + // create and hide label from base class + Label label = getLabelControl(inner); + label.setText(""); //$NON-NLS-1$ + label.setVisible(false); + fCheckbox.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + boolean isSelected = fCheckbox.getSelection(); + valueChanged(fWasSelected, isSelected); + fWasSelected = isSelected; + } + }); + } else { + checkParent(fCheckbox.getParent(), parent); + } + return fCheckbox; + } + + @Override + public Label getLabelControl(Composite parent) { + final Label label = getLabelControl(); + if (label == null) { + return super.getLabelControl(parent); + } else { + checkParent(label.getParent(), parent); + } + return label; + } + + @Override + protected void doLoad() { + super.doLoad(); + if (fCheckbox != null && getLabelControl() != null) { + String value = getPreferenceStore().getString(getPreferenceName()); + boolean enabled = !DISABLED_VALUE.equals(value); + fCheckbox.setSelection(enabled); + fWasSelected = enabled; + getComboBoxControl().setEnabled(enabled); + getLabelControl().setEnabled(enabled); + } + } + + @Override + protected void doStore() { + if (fCheckbox != null && !fCheckbox.getSelection()) { + getPreferenceStore().setValue(getPreferenceName(), DISABLED_VALUE); + } else { + super.doStore(); + } + } + + protected void valueChanged(boolean oldValue, boolean newValue) { + if (oldValue != newValue) { + fireStateChanged(VALUE, oldValue, newValue); + getComboBoxControl().setEnabled(newValue); + getLabelControl().setEnabled(newValue); + } + } + + } + + private String[][] makeArray2D(String[] array) { + String[][] array2d = new String[array.length][]; + for (int i = 0; i < array.length; i++) { + array2d[i] = new String[2]; + array2d[i][0] = array2d[i][1] = array[i]; + } + return array2d; + } + + private String[][] joinToArray2D(String[] labels, String[] values) { + String[][] array2d = new String[labels.length][]; + for (int i = 0; i < labels.length; i++) { + array2d[i] = new String[2]; + array2d[i][0] = labels[i]; + array2d[i][1] = values[i]; + } + return array2d; + } class LabelFieldEditor extends ReadOnlyFieldEditor { private String fValue; - public LabelFieldEditor( Composite parent, String title, String value ) { + public LabelFieldEditor(Composite parent, String title, String value) { super(title, title, parent); fValue = value; } @@ -539,6 +540,7 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement textField.setText(fValue); } } + @Override protected void doLoadDefault() { // nothing @@ -555,19 +557,19 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement private BreakpointFileNameFieldEditor fFileEditor; private BreakpointIntegerFieldEditor fLineEditor; private BreakpointIntegerFieldEditor fIgnoreCount; - + private IAdaptable fElement; - /** + /** * Indicates if the page currently aims to create * a breakpoint that already exits. */ private boolean fDuplicateBreakpoint; /** - * The preference store used to interface between the breakpoint and the + * The preference store used to interface between the breakpoint and the * breakpoint preference page. This preference store is initialized only - * when the preference store cannot be retrieved from the preference + * when the preference store cannot be retrieved from the preference * dialog's element. * @see #getPreferenceStore() */ @@ -575,14 +577,14 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement /** * Constructor for CBreakpointPropertyPage. - * + * * @param breakpoint */ public CBreakpointPropertyPage() { - super( GRID ); + super(GRID); noDefaultAndApplyButton(); -// Control control = getControl(); -// fCBreakpointPreferenceStore = new CBreakpointPreferenceStore(); + // Control control = getControl(); + // fCBreakpointPreferenceStore = new CBreakpointPreferenceStore(); } @Override @@ -590,110 +592,109 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement ICBreakpoint breakpoint = getBreakpoint(); createMainLabel(breakpoint); createContributedFieldEditors(breakpoint, ICBreakpointsUIContribution.BREAKPOINT_LABELS); - createTypeSpecificLabelFieldEditors( breakpoint ); - createEnabledField( getFieldEditorParent() ); - createConditionEditor( getFieldEditorParent() ); - createIgnoreCountEditor( getFieldEditorParent() ); - createContributedFieldEditors(breakpoint, ICBreakpointsUIContribution.BREAKPOINT_EDITORS); + createTypeSpecificLabelFieldEditors(breakpoint); + createEnabledField(getFieldEditorParent()); + createConditionEditor(getFieldEditorParent()); + createIgnoreCountEditor(getFieldEditorParent()); + createContributedFieldEditors(breakpoint, ICBreakpointsUIContribution.BREAKPOINT_EDITORS); } private void createMainLabel(ICBreakpoint breakpoint) { - String label = getBreakpointMainLabel(breakpoint); - addField( createLabelEditor( - getFieldEditorParent(), - BreakpointsMessages.getString( "CBreakpointPropertyPage.breakpointType_label" ), //$NON-NLS-1$ - label) ); + String label = getBreakpointMainLabel(breakpoint); + addField(createLabelEditor(getFieldEditorParent(), + BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_label"), //$NON-NLS-1$ + label)); } /** * Method createTypeSpecificLabelFieldEditors. - * + * * @param breakpoint */ - private void createTypeSpecificLabelFieldEditors( ICBreakpoint breakpoint ) { + private void createTypeSpecificLabelFieldEditors(ICBreakpoint breakpoint) { - if ( breakpoint instanceof ICFunctionBreakpoint ) { - createFunctionEditor(getFieldEditorParent()); - } - else if ( breakpoint instanceof ICAddressBreakpoint ) { - String title = BreakpointsMessages.getString( "CBreakpointPropertyPage.address_label" ); //$NON-NLS-1$ - - String address = getPreferenceStore().getString(ICLineBreakpoint.ADDRESS); - if (address == null || address.trim().length() == 0) { - address = BreakpointsMessages.getString( "CBreakpointPropertyPage.address_valueNotAvailable_label" ); //$NON-NLS-1$ - } - addField( createLabelEditor( getFieldEditorParent(), title, address ) ); - } - else if ( breakpoint instanceof ICWatchpoint ) { + if (breakpoint instanceof ICFunctionBreakpoint) { + createFunctionEditor(getFieldEditorParent()); + } else if (breakpoint instanceof ICAddressBreakpoint) { + String title = BreakpointsMessages.getString("CBreakpointPropertyPage.address_label"); //$NON-NLS-1$ + + String address = getPreferenceStore().getString(ICLineBreakpoint.ADDRESS); + if (address == null || address.trim().length() == 0) { + address = BreakpointsMessages.getString("CBreakpointPropertyPage.address_valueNotAvailable_label"); //$NON-NLS-1$ + } + addField(createLabelEditor(getFieldEditorParent(), title, address)); + } else if (breakpoint instanceof ICWatchpoint) { IResource resource = getResource(); if (resource != null) { - IProject project = resource.getProject(); - if ( project != null ) { - addField( createLabelEditor( getFieldEditorParent(), BreakpointsMessages.getString( "CBreakpointPropertyPage.project_label" ), project.getName() ) ); //$NON-NLS-1$ - } - } + IProject project = resource.getProject(); + if (project != null) { + addField(createLabelEditor(getFieldEditorParent(), + BreakpointsMessages.getString("CBreakpointPropertyPage.project_label"), project.getName())); //$NON-NLS-1$ + } + } String filename = getPreferenceStore().getString(ICBreakpoint.SOURCE_HANDLE); if (filename != null && !filename.isEmpty()) { - addField( createLabelEditor( getFieldEditorParent(), BreakpointsMessages.getString( "CBreakpointPropertyPage.sourceHandle_label" ), filename ) ); //$NON-NLS-1$ + addField(createLabelEditor(getFieldEditorParent(), + BreakpointsMessages.getString("CBreakpointPropertyPage.sourceHandle_label"), filename)); //$NON-NLS-1$ } createWatchExpressionEditor(getFieldEditorParent()); - createWatchMemorySpaceEditor(getFieldEditorParent()); + createWatchMemorySpaceEditor(getFieldEditorParent()); createWatchRangeEditor(getFieldEditorParent()); createWatchTypeEditors(getFieldEditorParent()); - - } - else if ( breakpoint instanceof ILineBreakpoint ) { + + } else if (breakpoint instanceof ILineBreakpoint) { createFileLineNumberEditor(getFieldEditorParent()); - } - else if ( breakpoint instanceof CEventBreakpoint ) { - createEventBreakpointEditor( breakpoint, ICBreakpointsUIContribution.BREAKPOINT_LABELS); + } else if (breakpoint instanceof CEventBreakpoint) { + createEventBreakpointEditor(breakpoint, ICBreakpointsUIContribution.BREAKPOINT_LABELS); } } private String getBreakpointMainLabel(ICBreakpoint breakpoint) { - if (breakpoint instanceof ICWatchpoint && breakpoint.getMarker() != null) { - // For an existing breakpoint, calculate watchpoint label based - // on read/write type. - boolean isReadType = getPreferenceStore().getBoolean(ICWatchpoint.READ); - boolean isWriteType = getPreferenceStore().getBoolean(ICWatchpoint.WRITE); - if (isReadType && !isWriteType) { - return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_watchpoint_read_label"); //$NON-NLS-1$ - } else if (!isReadType && isWriteType) { - return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_watchpoint_label"); //$NON-NLS-1$ - } else { - return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_watchpoint_access_label"); //$NON-NLS-1$ - } - } - - IWorkbenchAdapter labelProvider = getElement().getAdapter(IWorkbenchAdapter.class); - if (labelProvider != null) { - return labelProvider.getLabel(getElement()); - } - // default main label is the label of marker type for the breakpoint - return CDIDebugModel.calculateMarkerType(breakpoint); + if (breakpoint instanceof ICWatchpoint && breakpoint.getMarker() != null) { + // For an existing breakpoint, calculate watchpoint label based + // on read/write type. + boolean isReadType = getPreferenceStore().getBoolean(ICWatchpoint.READ); + boolean isWriteType = getPreferenceStore().getBoolean(ICWatchpoint.WRITE); + if (isReadType && !isWriteType) { + return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_watchpoint_read_label"); //$NON-NLS-1$ + } else if (!isReadType && isWriteType) { + return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_watchpoint_label"); //$NON-NLS-1$ + } else { + return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_watchpoint_access_label"); //$NON-NLS-1$ + } + } + + IWorkbenchAdapter labelProvider = getElement().getAdapter(IWorkbenchAdapter.class); + if (labelProvider != null) { + return labelProvider.getLabel(getElement()); + } + // default main label is the label of marker type for the breakpoint + return CDIDebugModel.calculateMarkerType(breakpoint); } - - protected void createFunctionEditor( Composite parent ) { - - ICBreakpoint breakpoint = getBreakpoint(); - String title = BreakpointsMessages.getString("CBreakpointPropertyPage.function_label"); //$NON-NLS-1$ - if (breakpoint == null || breakpoint.getMarker() == null) { - BreakpointStringFieldEditor expressionEditor = new BreakpointStringFieldEditor( - ICLineBreakpoint.FUNCTION, title, parent); - expressionEditor.setErrorMessage(BreakpointsMessages.getString("CBreakpointPropertyPage.function_value_errorMessage")); //$NON-NLS-1$ - expressionEditor.setEmptyStringAllowed(false); - addField(expressionEditor); - } else { - String function = getPreferenceStore().getString(ICLineBreakpoint.FUNCTION); - if ( function == null ) { - function = BreakpointsMessages.getString( "CBreakpointPropertyPage.function_valueNotAvailable_label" ); //$NON-NLS-1$ - } - addField( createLabelEditor( getFieldEditorParent(), BreakpointsMessages.getString( "CBreakpointPropertyPage.function_label" ), function ) ); //$NON-NLS-1$ + + protected void createFunctionEditor(Composite parent) { + + ICBreakpoint breakpoint = getBreakpoint(); + String title = BreakpointsMessages.getString("CBreakpointPropertyPage.function_label"); //$NON-NLS-1$ + if (breakpoint == null || breakpoint.getMarker() == null) { + BreakpointStringFieldEditor expressionEditor = new BreakpointStringFieldEditor(ICLineBreakpoint.FUNCTION, + title, parent); + expressionEditor.setErrorMessage( + BreakpointsMessages.getString("CBreakpointPropertyPage.function_value_errorMessage")); //$NON-NLS-1$ + expressionEditor.setEmptyStringAllowed(false); + addField(expressionEditor); + } else { + String function = getPreferenceStore().getString(ICLineBreakpoint.FUNCTION); + if (function == null) { + function = BreakpointsMessages.getString("CBreakpointPropertyPage.function_valueNotAvailable_label"); //$NON-NLS-1$ + } + addField(createLabelEditor(getFieldEditorParent(), + BreakpointsMessages.getString("CBreakpointPropertyPage.function_label"), function)); //$NON-NLS-1$ } } - protected void createFileLineNumberEditor( Composite parent ) { - String title = BreakpointsMessages.getString( "CBreakpointPropertyPage.sourceHandle_label" ); //$NON-NLS-1$ + protected void createFileLineNumberEditor(Composite parent) { + String title = BreakpointsMessages.getString("CBreakpointPropertyPage.sourceHandle_label"); //$NON-NLS-1$ ICBreakpoint breakpoint = getBreakpoint(); boolean isNewBreakpoint = breakpoint == null || breakpoint.getMarker() == null; @@ -701,8 +702,7 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement boolean isFilenameEditable = fileName != null && fileName.isEmpty(); if (isNewBreakpoint && isFilenameEditable) { - fFileEditor = new BreakpointFileNameFieldEditor( - ICLineBreakpoint.SOURCE_HANDLE, title, parent); + fFileEditor = new BreakpointFileNameFieldEditor(ICLineBreakpoint.SOURCE_HANDLE, title, parent); fFileEditor.setErrorMessage(BreakpointsMessages.getString("CBreakpointPropertyPage.fileName_errorMessage")); //$NON-NLS-1$ fFileEditor.setEmptyStringAllowed(false); addField(fFileEditor); @@ -721,102 +721,100 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement createLineNumberEditor(parent); } } - - protected void createLineNumberEditor( Composite parent ) { - String title = BreakpointsMessages.getString( "CBreakpointPropertyPage.lineNumber_label" ); //$NON-NLS-1$ - fLineEditor = new BreakpointIntegerFieldEditor(IMarker.LINE_NUMBER ,title, parent); - fLineEditor.setValidRange(1, Integer.MAX_VALUE); - fLineEditor.setErrorMessage(BreakpointsMessages.getString("CBreakpointPropertyPage.lineNumber_errorMessage")); //$NON-NLS-1$ - addField(fLineEditor); + + protected void createLineNumberEditor(Composite parent) { + String title = BreakpointsMessages.getString("CBreakpointPropertyPage.lineNumber_label"); //$NON-NLS-1$ + fLineEditor = new BreakpointIntegerFieldEditor(IMarker.LINE_NUMBER, title, parent); + fLineEditor.setValidRange(1, Integer.MAX_VALUE); + fLineEditor.setErrorMessage(BreakpointsMessages.getString("CBreakpointPropertyPage.lineNumber_errorMessage")); //$NON-NLS-1$ + addField(fLineEditor); + } + + protected void createWatchExpressionEditor(Composite parent) { + ICBreakpoint breakpoint = getBreakpoint(); + if (breakpoint == null || breakpoint.getMarker() == null) { + BreakpointStringFieldEditor expressionEditor = new BreakpointStringFieldEditor(ICWatchpoint.EXPRESSION, + BreakpointsMessages.getString("CBreakpointPropertyPage.watchpoint_expression_label"), //$NON-NLS-1$ + parent); + expressionEditor.setErrorMessage( + BreakpointsMessages.getString("CBreakpointPropertyPage.watchpoint_expression_errorMessage")); //$NON-NLS-1$ + expressionEditor.setEmptyStringAllowed(false); + addField(expressionEditor); + } else { + addField(createLabelEditor(parent, + BreakpointsMessages.getString("CBreakpointPropertyPage.watchpoint_expression_label"), //$NON-NLS-1$ + getPreferenceStore().getString(ICWatchpoint.EXPRESSION))); + } + } + + protected void createWatchMemorySpaceEditor(Composite parent) { + ICBreakpoint breakpoint = getBreakpoint(); + if (breakpoint == null || breakpoint.getMarker() == null) { + // XXX: In pre-CDI removal this set up additional field by getting memory space + // from ICDIMemorySpaceManagement. post-CDT removal memory space is still displayed + // (else below) but cannot be set on new breakpoints + } else { + String memorySpace = getPreferenceStore().getString(ICWatchpoint2.MEMORYSPACE); + if (memorySpace != null && memorySpace.length() != 0) { + addField(createLabelEditor(parent, + BreakpointsMessages.getString("CBreakpointPropertyPage.watchpoint_memorySpace_label"), //$NON-NLS-1$ + getPreferenceStore().getString(ICWatchpoint2.MEMORYSPACE))); + } + } + } + + protected void createWatchRangeEditor(Composite parent) { + ICBreakpoint breakpoint = getBreakpoint(); + if (breakpoint == null || breakpoint.getMarker() == null) { + addField(new WatchpointRangeFieldEditor(ICWatchpoint2.RANGE, + BreakpointsMessages.getString("CBreakpointPropertyPage.watchpoint_range_label"), //$NON-NLS-1$ + parent)); + } else { + addField(createLabelEditor(parent, + BreakpointsMessages.getString("CBreakpointPropertyPage.watchpoint_range_label"), //$NON-NLS-1$ + getPreferenceStore().getString(ICWatchpoint2.RANGE))); + } } - protected void createWatchExpressionEditor( Composite parent ) { - ICBreakpoint breakpoint = getBreakpoint(); - if (breakpoint == null || breakpoint.getMarker() == null) { - BreakpointStringFieldEditor expressionEditor =new BreakpointStringFieldEditor( - ICWatchpoint.EXPRESSION, - BreakpointsMessages.getString("CBreakpointPropertyPage.watchpoint_expression_label"), //$NON-NLS-1$ - parent); - expressionEditor.setErrorMessage(BreakpointsMessages.getString("CBreakpointPropertyPage.watchpoint_expression_errorMessage")); //$NON-NLS-1$ - expressionEditor.setEmptyStringAllowed(false); - addField(expressionEditor); - } else { - addField(createLabelEditor( - parent, - BreakpointsMessages.getString("CBreakpointPropertyPage.watchpoint_expression_label"), //$NON-NLS-1$ - getPreferenceStore().getString(ICWatchpoint.EXPRESSION) )); - } - } - - protected void createWatchMemorySpaceEditor( Composite parent ) { - ICBreakpoint breakpoint = getBreakpoint(); - if (breakpoint == null || breakpoint.getMarker() == null) { - // XXX: In pre-CDI removal this set up additional field by getting memory space - // from ICDIMemorySpaceManagement. post-CDT removal memory space is still displayed - // (else below) but cannot be set on new breakpoints - } else { - String memorySpace = getPreferenceStore().getString(ICWatchpoint2.MEMORYSPACE); - if (memorySpace != null && memorySpace.length() != 0) { - addField(createLabelEditor( - parent, - BreakpointsMessages.getString("CBreakpointPropertyPage.watchpoint_memorySpace_label"), //$NON-NLS-1$ - getPreferenceStore().getString(ICWatchpoint2.MEMORYSPACE) )); - } - } - } - - protected void createWatchRangeEditor( Composite parent ) { - ICBreakpoint breakpoint = getBreakpoint(); - if (breakpoint == null || breakpoint.getMarker() == null) { - addField( new WatchpointRangeFieldEditor( - ICWatchpoint2.RANGE, - BreakpointsMessages.getString("CBreakpointPropertyPage.watchpoint_range_label"), //$NON-NLS-1$ - parent) ); - } else { - addField(createLabelEditor( - parent, - BreakpointsMessages.getString("CBreakpointPropertyPage.watchpoint_range_label"), //$NON-NLS-1$ - getPreferenceStore().getString(ICWatchpoint2.RANGE) )); - } - } - - protected void createWatchTypeEditors( Composite parent ) { - // Edit read/write options only when creating the breakpoint. - ICBreakpoint breakpoint = getBreakpoint(); - if (breakpoint != null && breakpoint.getMarker() == null) { - addField( new BooleanFieldEditor( - ICWatchpoint.READ, - BreakpointsMessages.getString("CBreakpointPropertyPage.watchpointType_read_label"), //$NON-NLS-1$ - parent) ); - addField( new BooleanFieldEditor( - ICWatchpoint.WRITE, - BreakpointsMessages.getString("CBreakpointPropertyPage.watchpointType_write_label"), //$NON-NLS-1$ - parent) ); - } - } - - protected void createEnabledField( Composite parent ) { - fEnabled = new BooleanFieldEditor( ICBreakpoint.ENABLED, BreakpointsMessages.getString( "CBreakpointPropertyPage.enabled_label" ), parent ); //$NON-NLS-1$ - addField( fEnabled ); + protected void createWatchTypeEditors(Composite parent) { + // Edit read/write options only when creating the breakpoint. + ICBreakpoint breakpoint = getBreakpoint(); + if (breakpoint != null && breakpoint.getMarker() == null) { + addField(new BooleanFieldEditor(ICWatchpoint.READ, + BreakpointsMessages.getString("CBreakpointPropertyPage.watchpointType_read_label"), //$NON-NLS-1$ + parent)); + addField(new BooleanFieldEditor(ICWatchpoint.WRITE, + BreakpointsMessages.getString("CBreakpointPropertyPage.watchpointType_write_label"), //$NON-NLS-1$ + parent)); + } } - protected void createConditionEditor( Composite parent ) { - fCondition = new BreakpointStringFieldEditor( ICBreakpoint.CONDITION, BreakpointsMessages.getString( "CBreakpointPropertyPage.condition_label" ), parent ); //$NON-NLS-1$ - fCondition.setEmptyStringAllowed( true ); - fCondition.setErrorMessage( BreakpointsMessages.getString( "CBreakpointPropertyPage.condition_invalidValue_message" ) ); //$NON-NLS-1$ - addField( fCondition ); + protected void createEnabledField(Composite parent) { + fEnabled = new BooleanFieldEditor(ICBreakpoint.ENABLED, + BreakpointsMessages.getString("CBreakpointPropertyPage.enabled_label"), parent); //$NON-NLS-1$ + addField(fEnabled); } - protected void createIgnoreCountEditor( Composite parent ) { - fIgnoreCount = new BreakpointIntegerFieldEditor( ICBreakpoint.IGNORE_COUNT, BreakpointsMessages.getString( "CBreakpointPropertyPage.ignoreCount_label" ), parent ); //$NON-NLS-1$ - fIgnoreCount.setValidRange( 0, Integer.MAX_VALUE ); - fIgnoreCountTextControl = fIgnoreCount.getTextControl( parent ); - fIgnoreCountTextControl.setEnabled( getPreferenceStore().getInt(ICBreakpoint.IGNORE_COUNT) >= 0 ); - addField( fIgnoreCount ); + protected void createConditionEditor(Composite parent) { + fCondition = new BreakpointStringFieldEditor(ICBreakpoint.CONDITION, + BreakpointsMessages.getString("CBreakpointPropertyPage.condition_label"), parent); //$NON-NLS-1$ + fCondition.setEmptyStringAllowed(true); + fCondition.setErrorMessage( + BreakpointsMessages.getString("CBreakpointPropertyPage.condition_invalidValue_message")); //$NON-NLS-1$ + addField(fCondition); } - protected FieldEditor createLabelEditor( Composite parent, String title, String value ) { - return new LabelFieldEditor( parent, title, value ); + protected void createIgnoreCountEditor(Composite parent) { + fIgnoreCount = new BreakpointIntegerFieldEditor(ICBreakpoint.IGNORE_COUNT, + BreakpointsMessages.getString("CBreakpointPropertyPage.ignoreCount_label"), parent); //$NON-NLS-1$ + fIgnoreCount.setValidRange(0, Integer.MAX_VALUE); + fIgnoreCountTextControl = fIgnoreCount.getTextControl(parent); + fIgnoreCountTextControl.setEnabled(getPreferenceStore().getInt(ICBreakpoint.IGNORE_COUNT) >= 0); + addField(fIgnoreCount); + } + + protected FieldEditor createLabelEditor(Composite parent, String title, String value) { + return new LabelFieldEditor(parent, title, value); } @Override @@ -824,16 +822,14 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement // Don't allow to create a duplicate breakpoint return super.isValid() && !fDuplicateBreakpoint; } - + @Override public void propertyChange(PropertyChangeEvent event) { super.propertyChange(event); ICBreakpoint currentBp = getBreakpoint(); - if (!(currentBp instanceof ICFunctionBreakpoint) && - !(currentBp instanceof ICAddressBreakpoint) && - !(currentBp instanceof ICWatchpoint) && - !(currentBp instanceof ICEventBreakpoint)) { + if (!(currentBp instanceof ICFunctionBreakpoint) && !(currentBp instanceof ICAddressBreakpoint) + && !(currentBp instanceof ICWatchpoint) && !(currentBp instanceof ICEventBreakpoint)) { // Check for duplication of line breakpoints if (event.getProperty().equals(FieldEditor.VALUE)) { if (super.isValid()) { @@ -844,7 +840,8 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement fDuplicateBreakpoint = isDuplicateBreakpoint(); if (oldValue != fDuplicateBreakpoint) { if (fDuplicateBreakpoint) { - setErrorMessage(BreakpointsMessages.getString("CBreakpointPropertyPage.breakpoint_already_exists_errorMessage")); //$NON-NLS-1$ + setErrorMessage(BreakpointsMessages + .getString("CBreakpointPropertyPage.breakpoint_already_exists_errorMessage")); //$NON-NLS-1$ } else { setErrorMessage(null); } @@ -859,7 +856,7 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement } } } - + private boolean isDuplicateBreakpoint() { String source = null; if (fFileEditor != null) { @@ -869,13 +866,13 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement // it from the preference store source = getPreferenceStore().getString(ICBreakpoint.SOURCE_HANDLE); } - + // We only check duplicates for Breakpoints with lines numbers if (fLineEditor == null) { return false; } - - int line = fLineEditor.getIntValue(); + + int line = fLineEditor.getIntValue(); // Look for any breakpoint that has the same source file and line number as what // is currently being inputed. Careful not to compare with the current breakpoint @@ -902,72 +899,70 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement protected ICBreakpoint getBreakpoint() { IAdaptable element = getElement(); if (element instanceof ICBreakpoint) { - return (ICBreakpoint)element; + return (ICBreakpoint) element; } else if (element instanceof ICBreakpointContext) { - return ((ICBreakpointContext)element).getBreakpoint(); + return ((ICBreakpointContext) element).getBreakpoint(); } else { - return element.getAdapter(ICBreakpoint.class); + return element.getAdapter(ICBreakpoint.class); } } protected Object getDebugContext() { - IDebugContextProvider provider = getElement().getAdapter(IDebugContextProvider.class); - if (provider != null) { - ISelection selection = provider.getActiveContext(); - if (selection instanceof IStructuredSelection) { - return ((IStructuredSelection) selection).getFirstElement(); - } - return null; - } - return DebugUITools.getDebugContext(); + IDebugContextProvider provider = getElement().getAdapter(IDebugContextProvider.class); + if (provider != null) { + ISelection selection = provider.getActiveContext(); + if (selection instanceof IStructuredSelection) { + return ((IStructuredSelection) selection).getFirstElement(); + } + return null; + } + return DebugUITools.getDebugContext(); } - protected IResource getResource() { - IAdaptable element = getElement(); - if (element instanceof ICBreakpoint) { - IMarker marker = ((ICBreakpoint)element).getMarker(); - if (marker != null) { - return marker.getResource(); - } - } else if (element instanceof ICBreakpointContext) { - return ((ICBreakpointContext)element).getResource(); - } - return null; + IAdaptable element = getElement(); + if (element instanceof ICBreakpoint) { + IMarker marker = ((ICBreakpoint) element).getMarker(); + if (marker != null) { + return marker.getResource(); + } + } else if (element instanceof ICBreakpointContext) { + return ((ICBreakpointContext) element).getResource(); + } + return null; } @Override public IPreferenceStore getPreferenceStore() { - IAdaptable element = getElement(); - if (element instanceof ICBreakpointContext) { - return ((ICBreakpointContext)element).getPreferenceStore(); - } - - if (fCBreakpointPreferenceStore == null) { - CBreakpointContext bpContext = element instanceof CBreakpointContext ? - (CBreakpointContext)element : null; - fCBreakpointPreferenceStore = new CBreakpointPreferenceStore(bpContext, null); - } - return fCBreakpointPreferenceStore; + IAdaptable element = getElement(); + if (element instanceof ICBreakpointContext) { + return ((ICBreakpointContext) element).getPreferenceStore(); + } + + if (fCBreakpointPreferenceStore == null) { + CBreakpointContext bpContext = element instanceof CBreakpointContext ? (CBreakpointContext) element : null; + fCBreakpointPreferenceStore = new CBreakpointPreferenceStore(bpContext, null); + } + return fCBreakpointPreferenceStore; } @Override public boolean performCancel() { - IPreferenceStore store = getPreferenceStore(); - if (store instanceof CBreakpointPreferenceStore) { - ((CBreakpointPreferenceStore)store).setCanceled(true); - } - return super.performCancel(); + IPreferenceStore store = getPreferenceStore(); + if (store instanceof CBreakpointPreferenceStore) { + ((CBreakpointPreferenceStore) store).setCanceled(true); + } + return super.performCancel(); } @Override - public boolean performOk() { - IPreferenceStore store = getPreferenceStore(); - if (store instanceof CBreakpointPreferenceStore) { - ((CBreakpointPreferenceStore)store).setCanceled(false); - } - return super.performOk(); - } + public boolean performOk() { + IPreferenceStore store = getPreferenceStore(); + if (store instanceof CBreakpointPreferenceStore) { + ((CBreakpointPreferenceStore) store).setCanceled(false); + } + return super.performOk(); + } /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchPropertyPage#getElement() @@ -981,80 +976,79 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement * @see org.eclipse.ui.IWorkbenchPropertyPage#setElement(org.eclipse.core.runtime.IAdaptable) */ @Override - public void setElement( IAdaptable element ) { + public void setElement(IAdaptable element) { if (element instanceof ICBreakpoint) { - fElement = new CBreakpointContext((ICBreakpoint)element, null); - } - else { + fElement = new CBreakpointContext((ICBreakpoint) element, null); + } else { fElement = element; } } protected String[] getDebugModelIds() { - String[] debugModelIds = null; - Object debugContext = getDebugContext(); - IDebugModelProvider debugModelProvider = (IDebugModelProvider) - DebugPlugin.getAdapter(debugContext, IDebugModelProvider.class); - if (debugModelProvider != null) { - debugModelIds = debugModelProvider.getModelIdentifiers(); - } else if (debugContext instanceof IDebugElement) { - debugModelIds = new String[] { ((IDebugElement)debugContext).getModelIdentifier() }; - } - return debugModelIds; + String[] debugModelIds = null; + Object debugContext = getDebugContext(); + IDebugModelProvider debugModelProvider = (IDebugModelProvider) DebugPlugin.getAdapter(debugContext, + IDebugModelProvider.class); + if (debugModelProvider != null) { + debugModelIds = debugModelProvider.getModelIdentifiers(); + } else if (debugContext instanceof IDebugElement) { + debugModelIds = new String[] { ((IDebugElement) debugContext).getModelIdentifier() }; + } + return debugModelIds; } - - private void createEventBreakpointEditor( ICBreakpoint breakpoint, String conMainElement) { + + private void createEventBreakpointEditor(ICBreakpoint breakpoint, String conMainElement) { boolean bAddEventType = true; - Composite parent = getFieldEditorParent(); + Composite parent = getFieldEditorParent(); String[] debugModelIds = getDebugModelIds(); try { - ICBreakpointsUIContribution[] cons; - CBreakpointUIContributionFactory factory = CBreakpointUIContributionFactory.getInstance(); - IPreferenceStore prefStore = getPreferenceStore(); - if (prefStore instanceof CBreakpointPreferenceStore) { - cons = factory.getBreakpointUIContributions( - debugModelIds, breakpoint, ((CBreakpointPreferenceStore) prefStore).getAttributes()); - } else { - cons = factory.getBreakpointUIContributions(breakpoint); - } - - setupEventTypeFieldEditor(cons, breakpoint, conMainElement, parent); + ICBreakpointsUIContribution[] cons; + CBreakpointUIContributionFactory factory = CBreakpointUIContributionFactory.getInstance(); + IPreferenceStore prefStore = getPreferenceStore(); + if (prefStore instanceof CBreakpointPreferenceStore) { + cons = factory.getBreakpointUIContributions(debugModelIds, breakpoint, + ((CBreakpointPreferenceStore) prefStore).getAttributes()); + } else { + cons = factory.getBreakpointUIContributions(breakpoint); + } + + setupEventTypeFieldEditor(cons, breakpoint, conMainElement, parent); for (ICBreakpointsUIContribution con : cons) { - if ( conMainElement.equals(con.getMainElement()) ) { - FieldEditor fieldEditor = null; - if (breakpoint.getMarker() == null && con.getId().equals(ICEventBreakpoint.EVENT_TYPE_ID)) { - continue; - } - else if (con.getMarkerType().equalsIgnoreCase(ICEventBreakpoint.C_EVENT_BREAKPOINT_MARKER)) { - if ( breakpoint.getMarker() == null ) { - setupArgsComposite(parent); - fieldEditor = con.getFieldEditor(con.getId(), con.getLabel() + ":", fEventArgsComposite); //$NON-NLS-1$ - if ( fieldEditor != null ) { - addEditorToComposite(fieldEditor); - fEventArgsComposite.setVisible(true); - } - else { - fEventArgsComposite.setVisible(false); - } - } - else { - if (con.getId().equals(ICEventBreakpoint.EVENT_TYPE_ID)) { - if (bAddEventType == true) bAddEventType = false; - else continue; - } - fieldEditor = con.getFieldEditor(con.getId(), con.getLabel() + ":", parent); //$NON-NLS-1$ - } - } - - if (fieldEditor != null) { - addField(fieldEditor); - } - } + if (conMainElement.equals(con.getMainElement())) { + FieldEditor fieldEditor = null; + if (breakpoint.getMarker() == null && con.getId().equals(ICEventBreakpoint.EVENT_TYPE_ID)) { + continue; + } else if (con.getMarkerType().equalsIgnoreCase(ICEventBreakpoint.C_EVENT_BREAKPOINT_MARKER)) { + if (breakpoint.getMarker() == null) { + setupArgsComposite(parent); + fieldEditor = con.getFieldEditor(con.getId(), con.getLabel() + ":", fEventArgsComposite); //$NON-NLS-1$ + if (fieldEditor != null) { + addEditorToComposite(fieldEditor); + fEventArgsComposite.setVisible(true); + } else { + fEventArgsComposite.setVisible(false); + } + } else { + if (con.getId().equals(ICEventBreakpoint.EVENT_TYPE_ID)) { + if (bAddEventType == true) + bAddEventType = false; + else + continue; + } + fieldEditor = con.getFieldEditor(con.getId(), con.getLabel() + ":", parent); //$NON-NLS-1$ + } + } + + if (fieldEditor != null) { + addField(fieldEditor); + } + } } } catch (CoreException ce) { CDebugUIPlugin.log(ce); - } + } } + /** * Creates field editors contributed using breakpointUIContribution extension point */ @@ -1062,74 +1056,72 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement Composite parent = getFieldEditorParent(); String[] debugModelIds = getDebugModelIds(); try { - ICBreakpointsUIContribution[] cons; - CBreakpointUIContributionFactory factory = CBreakpointUIContributionFactory.getInstance(); - IPreferenceStore prefStore = getPreferenceStore(); - if (prefStore instanceof CBreakpointPreferenceStore) { - cons = factory.getBreakpointUIContributions( - debugModelIds, breakpoint, ((CBreakpointPreferenceStore) prefStore).getAttributes()); - } else { - cons = factory.getBreakpointUIContributions(breakpoint); - } - + ICBreakpointsUIContribution[] cons; + CBreakpointUIContributionFactory factory = CBreakpointUIContributionFactory.getInstance(); + IPreferenceStore prefStore = getPreferenceStore(); + if (prefStore instanceof CBreakpointPreferenceStore) { + cons = factory.getBreakpointUIContributions(debugModelIds, breakpoint, + ((CBreakpointPreferenceStore) prefStore).getAttributes()); + } else { + cons = factory.getBreakpointUIContributions(breakpoint); + } + for (ICBreakpointsUIContribution con : cons) { - if ( conMainElement.equals(con.getMainElement()) ) { - if (con.getMarkerType().equals(ICEventBreakpoint.C_EVENT_BREAKPOINT_MARKER)) { - continue; - } - FieldEditor fieldEditor = con.getFieldEditor(con.getId(), con.getLabel() + ":", parent); //$NON-NLS-1$ - if (fieldEditor != null) { - addField(fieldEditor); - } - } + if (conMainElement.equals(con.getMainElement())) { + if (con.getMarkerType().equals(ICEventBreakpoint.C_EVENT_BREAKPOINT_MARKER)) { + continue; + } + FieldEditor fieldEditor = con.getFieldEditor(con.getId(), con.getLabel() + ":", parent); //$NON-NLS-1$ + if (fieldEditor != null) { + addField(fieldEditor); + } + } } } catch (CoreException ce) { CDebugUIPlugin.log(ce); } } - - private void setupEventTypeFieldEditor(ICBreakpointsUIContribution[] cons, ICBreakpoint breakpoint, String conMainElement, Composite parent) { + + private void setupEventTypeFieldEditor(ICBreakpointsUIContribution[] cons, ICBreakpoint breakpoint, + String conMainElement, Composite parent) { String id = null; ArrayList<String> eventTypeValueList = new ArrayList<String>(); - ArrayList<String> eventTypeLabelList = new ArrayList<String>(); - + ArrayList<String> eventTypeLabelList = new ArrayList<String>(); + // The filter of the debugModelIds should already be done. for (ICBreakpointsUIContribution con : cons) { - if ( conMainElement.equals(con.getMainElement()) ) { - if (breakpoint instanceof CEventBreakpoint && breakpoint.getMarker() == null && - con.getId().equals(ICEventBreakpoint.EVENT_TYPE_ID)) { - id = con.getId(); - for (String value : con.getPossibleValues()) { - eventTypeValueList.add(value); - eventTypeLabelList.add(con.getLabelForValue(value)); - } - } - } + if (conMainElement.equals(con.getMainElement())) { + if (breakpoint instanceof CEventBreakpoint && breakpoint.getMarker() == null + && con.getId().equals(ICEventBreakpoint.EVENT_TYPE_ID)) { + id = con.getId(); + for (String value : con.getPossibleValues()) { + eventTypeValueList.add(value); + eventTypeLabelList.add(con.getLabelForValue(value)); + } + } + } } if (eventTypeValueList.size() != 0) { - EventTypeFieldEditor fieldEditor = new EventTypeFieldEditor( - id, + EventTypeFieldEditor fieldEditor = new EventTypeFieldEditor(id, BreakpointsMessages.getString("CBreakpointPropertyPage.eventType_label"), //$NON-NLS-1$ eventTypeLabelList.toArray(new String[eventTypeLabelList.size()]), - eventTypeValueList.toArray(new String[eventTypeValueList.size()]), - parent, - breakpoint); + eventTypeValueList.toArray(new String[eventTypeValueList.size()]), parent, breakpoint); addField(fieldEditor); setupArgsComposite(parent); fieldEditor.initializeComboBox(getPreferenceStore(), this); } } - + void addEditorToComposite(FieldEditor fieldEditor) { if (fEventArgsFEs == null) { - fEventArgsFEs = new ArrayList<FieldEditor>(); + fEventArgsFEs = new ArrayList<FieldEditor>(); } fEventArgsFEs.add(fieldEditor); } void cleanEditorsFromComposite() { if (fEventArgsFEs != null) { - for (FieldEditor editor : fEventArgsFEs){ + for (FieldEditor editor : fEventArgsFEs) { editor.setPreferenceStore(null); editor.setPage(null); } @@ -1143,50 +1135,51 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement fEventArgsComposite = null; } if (fEventBPComposite == null || fEventBPComposite.isDisposed()) { - fEventBPComposite = new Composite(parent,SWT.NONE); + fEventBPComposite = new Composite(parent, SWT.NONE); fEventBPComposite.setLayout(parent.getLayout()); fEventBPComposite.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false)); GridDataFactory.defaultsFor(fEventBPComposite).grab(true, false).span(2, 1).applyTo(fEventBPComposite); } - fEventArgsComposite = new Composite(fEventBPComposite,SWT.NONE); + fEventArgsComposite = new Composite(fEventBPComposite, SWT.NONE); fEventArgsComposite.setLayout(fEventBPComposite.getLayout()); GridDataFactory.defaultsFor(fEventArgsComposite).grab(true, false).span(2, 1).applyTo(fEventArgsComposite); - GridData gridData = (GridData)fEventArgsComposite.getLayoutData(); + GridData gridData = (GridData) fEventArgsComposite.getLayoutData(); gridData.horizontalIndent = 10; fEventArgsComposite.setLayoutData(gridData); fEventArgsComposite.setVisible(false); } - + private void displayEventArgs(ICBreakpoint breakpoint, Composite parent) { boolean result = false; String[] debugModelIds = getDebugModelIds(); try { - ICBreakpointsUIContribution[] cons; - CBreakpointUIContributionFactory factory = CBreakpointUIContributionFactory.getInstance(); - IPreferenceStore prefStore = getPreferenceStore(); - if (prefStore instanceof CBreakpointPreferenceStore) { - cons = factory.getBreakpointUIContributions( - debugModelIds, breakpoint, ((CBreakpointPreferenceStore) prefStore).getAttributes()); - } else { - cons = factory.getBreakpointUIContributions(breakpoint); - } - for (ICBreakpointsUIContribution con : cons) { - if (con.getMarkerType().equalsIgnoreCase(ICEventBreakpoint.C_EVENT_BREAKPOINT_MARKER) && - !con.getId().equals(ICEventBreakpoint.EVENT_TYPE_ID)) { - setupArgsComposite(parent); - FieldEditor fieldEditor = con.getFieldEditor(con.getId(), con.getLabel() + ":", fEventArgsComposite); //$NON-NLS-1$ - if ( fieldEditor != null ) { - fieldEditor.setPreferenceStore(getPreferenceStore()); - fieldEditor.setPage(this); - addEditorToComposite(fieldEditor); - addField(fieldEditor); - result = true; - } - } - } + ICBreakpointsUIContribution[] cons; + CBreakpointUIContributionFactory factory = CBreakpointUIContributionFactory.getInstance(); + IPreferenceStore prefStore = getPreferenceStore(); + if (prefStore instanceof CBreakpointPreferenceStore) { + cons = factory.getBreakpointUIContributions(debugModelIds, breakpoint, + ((CBreakpointPreferenceStore) prefStore).getAttributes()); + } else { + cons = factory.getBreakpointUIContributions(breakpoint); + } + for (ICBreakpointsUIContribution con : cons) { + if (con.getMarkerType().equalsIgnoreCase(ICEventBreakpoint.C_EVENT_BREAKPOINT_MARKER) + && !con.getId().equals(ICEventBreakpoint.EVENT_TYPE_ID)) { + setupArgsComposite(parent); + FieldEditor fieldEditor = con.getFieldEditor(con.getId(), con.getLabel() + ":", //$NON-NLS-1$ + fEventArgsComposite); + if (fieldEditor != null) { + fieldEditor.setPreferenceStore(getPreferenceStore()); + fieldEditor.setPage(this); + addEditorToComposite(fieldEditor); + addField(fieldEditor); + result = true; + } + } + } } catch (CoreException ce) { - CDebugUIPlugin.log(ce); + CDebugUIPlugin.log(ce); } if (fEventArgsComposite != null && !fEventArgsComposite.isDisposed()) { @@ -1196,49 +1189,50 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement } } - class EventTypeFieldEditor extends ComboFieldEditor { - - final Combo fCombo; - final Composite fParent; - final ICBreakpoint fBreakpoint; - - class EventTypeSelectionListener implements SelectionListener { - @Override - public void widgetSelected(SelectionEvent e) { - doStore(); - displayEventArgs(fBreakpoint, fParent); - fParent.layout(); - } - @Override - public void widgetDefaultSelected(SelectionEvent e) { - widgetSelected(e); - } - } - - public EventTypeFieldEditor( String name, String labelText, String[] eventTypesLabels, String[] eventTypesValues, Composite parent, ICBreakpoint breakpoint ) { - super( name, labelText, joinToArray2D(eventTypesLabels,eventTypesValues), parent); - fBreakpoint = breakpoint; - fParent = parent; - fCombo = this.getComboBoxControl(); - fCombo.select(0); - fCombo.addSelectionListener(new EventTypeSelectionListener()); - } - - public void initializeComboBox(IPreferenceStore prefStore, CBreakpointPropertyPage page) { - if (getPage() == null) { - setPage(page); - } - if (getPreferenceStore() == null) { - setPreferenceStore(prefStore); - } - else - prefStore = getPreferenceStore(); - - String value = getValueForName(fCombo.getText()); - if (prefStore instanceof CBreakpointPreferenceStore) { - prefStore.setValue(ICEventBreakpoint.EVENT_TYPE_ID, value); - } - displayEventArgs(fBreakpoint, fParent); - } - } + class EventTypeFieldEditor extends ComboFieldEditor { + + final Combo fCombo; + final Composite fParent; + final ICBreakpoint fBreakpoint; + + class EventTypeSelectionListener implements SelectionListener { + @Override + public void widgetSelected(SelectionEvent e) { + doStore(); + displayEventArgs(fBreakpoint, fParent); + fParent.layout(); + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + widgetSelected(e); + } + } + + public EventTypeFieldEditor(String name, String labelText, String[] eventTypesLabels, String[] eventTypesValues, + Composite parent, ICBreakpoint breakpoint) { + super(name, labelText, joinToArray2D(eventTypesLabels, eventTypesValues), parent); + fBreakpoint = breakpoint; + fParent = parent; + fCombo = this.getComboBoxControl(); + fCombo.select(0); + fCombo.addSelectionListener(new EventTypeSelectionListener()); + } + + public void initializeComboBox(IPreferenceStore prefStore, CBreakpointPropertyPage page) { + if (getPage() == null) { + setPage(page); + } + if (getPreferenceStore() == null) { + setPreferenceStore(prefStore); + } else + prefStore = getPreferenceStore(); + + String value = getValueForName(fCombo.getText()); + if (prefStore instanceof CBreakpointPreferenceStore) { + prefStore.setValue(ICEventBreakpoint.EVENT_TYPE_ID, value); + } + displayEventArgs(fBreakpoint, fParent); + } + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointUpdater.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointUpdater.java index 70adce2afd5..b750e41ab6c 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointUpdater.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointUpdater.java @@ -32,7 +32,7 @@ public class CBreakpointUpdater implements ICBreakpointListener { private static CBreakpointUpdater fInstance; public static CBreakpointUpdater getInstance() { - if ( fInstance == null ) { + if (fInstance == null) { fInstance = new CBreakpointUpdater(); } return fInstance; @@ -40,84 +40,83 @@ public class CBreakpointUpdater implements ICBreakpointListener { /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.debug.core.ICBreakpointListener#installingBreakpoint(org.eclipse.debug.core.model.IDebugTarget, * org.eclipse.debug.core.model.IBreakpoint) */ @Override - public boolean installingBreakpoint( IDebugTarget target, IBreakpoint breakpoint ) { + public boolean installingBreakpoint(IDebugTarget target, IBreakpoint breakpoint) { return true; } /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.debug.core.ICBreakpointListener#breakpointInstalled(org.eclipse.debug.core.model.IDebugTarget, * org.eclipse.debug.core.model.IBreakpoint) */ @Override - public void breakpointInstalled( final IDebugTarget target, IBreakpoint breakpoint ) { + public void breakpointInstalled(final IDebugTarget target, IBreakpoint breakpoint) { } /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.debug.core.ICBreakpointListener#breakpointChanged(org.eclipse.debug.core.model.IDebugTarget, * org.eclipse.debug.core.model.IBreakpoint, java.util.Map) */ @Override - public void breakpointChanged( IDebugTarget target, final IBreakpoint breakpoint, @SuppressWarnings("rawtypes") final Map attributes ) { - asyncExec( new Runnable() { + public void breakpointChanged(IDebugTarget target, final IBreakpoint breakpoint, + @SuppressWarnings("rawtypes") final Map attributes) { + asyncExec(new Runnable() { @Override public void run() { try { - Boolean enabled = (Boolean)attributes.get( IBreakpoint.ENABLED ); - breakpoint.setEnabled( (enabled != null) ? enabled.booleanValue() : false ); - Integer ignoreCount = (Integer)attributes.get( ICBreakpoint.IGNORE_COUNT ); - ((ICBreakpoint)breakpoint).setIgnoreCount( (ignoreCount != null) ? ignoreCount.intValue() : 0 ); - String condition = (String)attributes.get( ICBreakpoint.CONDITION ); - ((ICBreakpoint)breakpoint).setCondition( (condition != null) ? condition : "" ); //$NON-NLS-1$ - } - catch( CoreException e ) { - CDebugUIPlugin.log( e.getStatus() ); + Boolean enabled = (Boolean) attributes.get(IBreakpoint.ENABLED); + breakpoint.setEnabled((enabled != null) ? enabled.booleanValue() : false); + Integer ignoreCount = (Integer) attributes.get(ICBreakpoint.IGNORE_COUNT); + ((ICBreakpoint) breakpoint).setIgnoreCount((ignoreCount != null) ? ignoreCount.intValue() : 0); + String condition = (String) attributes.get(ICBreakpoint.CONDITION); + ((ICBreakpoint) breakpoint).setCondition((condition != null) ? condition : ""); //$NON-NLS-1$ + } catch (CoreException e) { + CDebugUIPlugin.log(e.getStatus()); } } - } ); + }); } /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.debug.core.ICBreakpointListener#breakpointRemoved(org.eclipse.debug.core.model.IDebugTarget, * org.eclipse.debug.core.model.IBreakpoint[]) */ @Override - public void breakpointsRemoved( IDebugTarget target, final IBreakpoint[] breakpoints ) { - asyncExec( new Runnable() { + public void breakpointsRemoved(IDebugTarget target, final IBreakpoint[] breakpoints) { + asyncExec(new Runnable() { @Override public void run() { - for ( int i = 0; i < breakpoints.length; ++i ) { + for (int i = 0; i < breakpoints.length; ++i) { try { - if ( ((ICBreakpoint)breakpoints[i]).decrementInstallCount() == 0 ) - DebugPlugin.getDefault().getBreakpointManager().fireBreakpointChanged( breakpoints[i] ); - } - catch( CoreException e ) { - // ensureMarker throws this exception - // if breakpoint has already been deleted + if (((ICBreakpoint) breakpoints[i]).decrementInstallCount() == 0) + DebugPlugin.getDefault().getBreakpointManager().fireBreakpointChanged(breakpoints[i]); + } catch (CoreException e) { + // ensureMarker throws this exception + // if breakpoint has already been deleted } } } - } ); + }); } public void dispose() { } - private void asyncExec( Runnable r ) { + private void asyncExec(Runnable r) { Display display = Display.getDefault(); - if ( display != null ) - display.asyncExec( r ); + if (display != null) + display.asyncExec(r); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointWorkbenchAdapterFactory.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointWorkbenchAdapterFactory.java index 1ef4fca925f..e8bb5903be6 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointWorkbenchAdapterFactory.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointWorkbenchAdapterFactory.java @@ -11,7 +11,7 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.breakpoints; +package org.eclipse.cdt.debug.internal.ui.breakpoints; import org.eclipse.cdt.debug.core.model.ICBreakpoint; import org.eclipse.cdt.debug.core.model.ICLineBreakpoint; @@ -28,26 +28,26 @@ public class CBreakpointWorkbenchAdapterFactory implements IAdapterFactory { @SuppressWarnings("unchecked") @Override - public <T> T getAdapter( Object adaptableObject, Class<T> adapterType ) { - if ( adapterType != IWorkbenchAdapter.class || !(adaptableObject instanceof ICBreakpoint) ) { + public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) { + if (adapterType != IWorkbenchAdapter.class || !(adaptableObject instanceof ICBreakpoint)) { return null; } return (T) new WorkbenchAdapter() { @Override - public String getLabel( Object o ) { + public String getLabel(Object o) { // for now - if ( o instanceof ICLineBreakpoint ) { - return CDebugUIMessages.getString( "CBreakpointWorkbenchAdapterFactory.0" ); //$NON-NLS-1$ + if (o instanceof ICLineBreakpoint) { + return CDebugUIMessages.getString("CBreakpointWorkbenchAdapterFactory.0"); //$NON-NLS-1$ } - if ( o instanceof ICWatchpoint ) { - return CDebugUIMessages.getString( "CBreakpointWorkbenchAdapterFactory.1" ); //$NON-NLS-1$ + if (o instanceof ICWatchpoint) { + return CDebugUIMessages.getString("CBreakpointWorkbenchAdapterFactory.1"); //$NON-NLS-1$ } - return super.getLabel( o ); + return super.getLabel(o); } }; } - @Override + @Override public Class<?>[] getAdapterList() { return new Class[] { IWorkbenchAdapter.class }; } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CreateBreakpointTester.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CreateBreakpointTester.java index bbc4f8bb31d..5773f839961 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CreateBreakpointTester.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CreateBreakpointTester.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation *******************************************************************************/ @@ -20,27 +20,25 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; /** - * + * */ public class CreateBreakpointTester extends PropertyTester { - private final static String PROP_CREATE_BREAKPOINT_ADAPT = "createBreakpointAdapt"; //$NON-NLS-1$ - - @Override - public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { - if (PROP_CREATE_BREAKPOINT_ADAPT.equals(property) && - receiver instanceof ICBreakpointContext && - expectedValue instanceof String) - { - try { - Class<?> expectedClass = Class.forName((String)expectedValue); - return expectedClass.isAssignableFrom( - ((ICBreakpointContext)receiver).getBreakpoint().getClass()); - } catch (ClassNotFoundException e) { - CDebugUIPlugin.log(new Status(IStatus.ERROR, CDebugUIPlugin.PLUGIN_ID, "Unable to create class: " + expectedValue, e)); //$NON-NLS-1$ - } - } - return false; - } + private final static String PROP_CREATE_BREAKPOINT_ADAPT = "createBreakpointAdapt"; //$NON-NLS-1$ + + @Override + public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { + if (PROP_CREATE_BREAKPOINT_ADAPT.equals(property) && receiver instanceof ICBreakpointContext + && expectedValue instanceof String) { + try { + Class<?> expectedClass = Class.forName((String) expectedValue); + return expectedClass.isAssignableFrom(((ICBreakpointContext) receiver).getBreakpoint().getClass()); + } catch (ClassNotFoundException e) { + CDebugUIPlugin.log(new Status(IStatus.ERROR, CDebugUIPlugin.PLUGIN_ID, + "Unable to create class: " + expectedValue, e)); //$NON-NLS-1$ + } + } + return false; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/ToggleCBreakpointTester.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/ToggleCBreakpointTester.java index 2c844cbe10f..3f24fc2a925 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/ToggleCBreakpointTester.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/ToggleCBreakpointTester.java @@ -9,7 +9,7 @@ * SPDX-License-Identifier: EPL-2.0 * * Contributors: - * Patrick Chuong (Texas Instruments) - + * Patrick Chuong (Texas Instruments) - * Update CDT ToggleBreakpointTargetFactory enablement (340177) * Patrick Chuong (Texas Instruments) - Bug 375871 *****************************************************************/ @@ -31,7 +31,7 @@ import org.eclipse.core.resources.IResource; /** * Toggle breakpoint factor enablement tester for editors and IDeclaration. - * + * * @since 7.1 */ public class ToggleCBreakpointTester extends PropertyTester { @@ -41,7 +41,7 @@ public class ToggleCBreakpointTester extends PropertyTester { if ("isCEditorSupportsCBreakpoint".equals(property) && (receiver instanceof CEditor)) { //$NON-NLS-1$ if (!CDebugUtils.isCustomToggleBreakpointFactory()) return true; - + CEditor editor = (CEditor) receiver; ICElement cElement = editor.getInputCElement(); if (cElement != null) { @@ -53,20 +53,20 @@ public class ToggleCBreakpointTester extends PropertyTester { IResource resource = cElement.getResource(); if (resource == null || !resource.exists()) return true; - + if (CDebugUtils.isStandardCBreakpointFactory(cproject.getProject())) return true; - + } else { return true; // can't figure the associated project, enable it by default. } } - - // test for AsmEditor + + // test for AsmEditor } else if ("isAsmEditorSupportsCBreakpoint".equals(property) && (receiver instanceof AsmTextEditor)) { //$NON-NLS-1$ if (!CDebugUtils.isCustomToggleBreakpointFactory()) return true; - + AsmTextEditor editor = (AsmTextEditor) receiver; ICElement cElement = editor.getInputCElement(); if (cElement != null) { @@ -76,51 +76,49 @@ public class ToggleCBreakpointTester extends PropertyTester { IResource resource = cElement.getResource(); if (resource == null || !resource.exists()) return true; - + ICProject cproject = cElement.getCProject(); if (cproject != null) { if (CDebugUtils.isStandardCBreakpointFactory(cproject.getProject())) return true; - + } else { return true; // can't figure the associated project, enable it by default. } } - - // test for IVariableDeclaration, IFunctionDeclaration, IMethodDeclaration + + // test for IVariableDeclaration, IFunctionDeclaration, IMethodDeclaration } else if ("isCDeclarationSupportsCBreakpoint".equals(property) && (receiver instanceof List<?>)) { //$NON-NLS-1$ List<?> list = (List<?>) receiver; if (list.size() == 1) { Object element = list.get(0); - if ((element instanceof IDeclaration) && - (element instanceof IVariableDeclaration || - element instanceof IFunctionDeclaration || - element instanceof IMethodDeclaration)) { + if ((element instanceof IDeclaration) && (element instanceof IVariableDeclaration + || element instanceof IFunctionDeclaration || element instanceof IMethodDeclaration)) { if (!CDebugUtils.isCustomToggleBreakpointFactory()) return true; - + IDeclaration cElement = (IDeclaration) element; - + // Handles the case for external file, check to see whether the file exist. // This is to workaround the EditorUtility wrongly assign the project for // external file. IResource resource = cElement.getResource(); if (resource == null || !resource.exists()) return true; - + ICProject cproject = cElement.getCProject(); if (cproject != null) { if (CDebugUtils.isStandardCBreakpointFactory(cproject.getProject())) return true; - + } else { return true; // can't figure the associated project, enable it by default. } } } } - + return false; } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ConnectCommandHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ConnectCommandHandler.java index e6b5f6c8f60..e9744a08c19 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ConnectCommandHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ConnectCommandHandler.java @@ -18,12 +18,12 @@ import org.eclipse.debug.ui.actions.DebugCommandHandler; /** * Command handler to trigger a connect operation - * + * * @since 7.3 */ public class ConnectCommandHandler extends DebugCommandHandler { - @Override - protected Class<?> getCommandType() { - return IConnectHandler.class; - } + @Override + protected Class<?> getCommandType() { + return IConnectHandler.class; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/GroupDebugContextsCommandHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/GroupDebugContextsCommandHandler.java index 1b34e7c2ee6..279e98852a9 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/GroupDebugContextsCommandHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/GroupDebugContextsCommandHandler.java @@ -18,13 +18,13 @@ import org.eclipse.debug.ui.actions.DebugCommandHandler; /** * Command handler to trigger grouping of debug contexts operation. - * - * @since 7.1 + * + * @since 7.1 */ public class GroupDebugContextsCommandHandler extends DebugCommandHandler { - - @Override - protected Class<?> getCommandType() { - return IGroupDebugContextsHandler.class; - } + + @Override + protected Class<?> getCommandType() { + return IGroupDebugContextsHandler.class; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/Messages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/Messages.java index 52951417e90..c707c790739 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/Messages.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/Messages.java @@ -18,7 +18,7 @@ public class Messages extends NLS { public static String ReverseDebugging_ToggleHardwareTrace; public static String ReverseDebugging_ToggleSoftwareTrace; public static String ReverseDebugging_ToggleReverseDebugging; - + static { // initialize resource bundle NLS.initializeMessages(Messages.class.getName(), Messages.class); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ResumeWithoutSignalCommand.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ResumeWithoutSignalCommand.java index 67ce5322fd3..57357405a51 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ResumeWithoutSignalCommand.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ResumeWithoutSignalCommand.java @@ -24,28 +24,29 @@ import org.eclipse.debug.core.commands.IEnabledStateRequest; /** * The handler for the "Resume Without Signal" command. - * - * @since 7.0 + * + * @since 7.0 */ public class ResumeWithoutSignalCommand extends AbstractDebugCommand implements IResumeWithoutSignalHandler { @Override protected void doExecute(Object[] targets, IProgressMonitor monitor, IRequest request) throws CoreException { - if (targets.length != 1) { - return; - } + if (targets.length != 1) { + return; + } - IResumeWithoutSignal target = (IResumeWithoutSignal)targets[0]; + IResumeWithoutSignal target = (IResumeWithoutSignal) targets[0]; target.resumeWithoutSignal(); } @Override - protected boolean isExecutable(Object[] targets, IProgressMonitor monitor, IEnabledStateRequest request) throws CoreException { - if (targets.length != 1) { - return false; - } + protected boolean isExecutable(Object[] targets, IProgressMonitor monitor, IEnabledStateRequest request) + throws CoreException { + if (targets.length != 1) { + return false; + } - IResumeWithoutSignal target = (IResumeWithoutSignal)targets[0]; + IResumeWithoutSignal target = (IResumeWithoutSignal) targets[0]; return target.canResumeWithoutSignal(); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ResumeWithoutSignalCommandHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ResumeWithoutSignalCommandHandler.java index b9a4db86c2f..5cea8047b2a 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ResumeWithoutSignalCommandHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ResumeWithoutSignalCommandHandler.java @@ -18,12 +18,12 @@ import org.eclipse.debug.ui.actions.DebugCommandHandler; /** * Command handler to trigger a resume without signal operation - * + * * @since 7.0 */ public class ResumeWithoutSignalCommandHandler extends DebugCommandHandler { - @Override - protected Class<?> getCommandType() { - return IResumeWithoutSignalHandler.class; - } + @Override + protected Class<?> getCommandType() { + return IResumeWithoutSignalHandler.class; + } }
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ReverseResumeCommandHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ReverseResumeCommandHandler.java index 9682c18f918..c754b53c2a3 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ReverseResumeCommandHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ReverseResumeCommandHandler.java @@ -18,12 +18,12 @@ import org.eclipse.debug.ui.actions.DebugCommandHandler; /** * Command handler to trigger a reverse resume operation - * + * * @since 7.0 */ public class ReverseResumeCommandHandler extends DebugCommandHandler { - @Override - protected Class<?> getCommandType() { - return IReverseResumeHandler.class; - } + @Override + protected Class<?> getCommandType() { + return IReverseResumeHandler.class; + } }
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ReverseStepIntoCommandHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ReverseStepIntoCommandHandler.java index 5d4260e2e9b..fcff4dff289 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ReverseStepIntoCommandHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ReverseStepIntoCommandHandler.java @@ -18,12 +18,12 @@ import org.eclipse.debug.ui.actions.DebugCommandHandler; /** * Command handler to trigger a reverse stepinto operation - * + * * @since 7.0 */ public class ReverseStepIntoCommandHandler extends DebugCommandHandler { - @Override - protected Class<?> getCommandType() { - return IReverseStepIntoHandler.class; - } + @Override + protected Class<?> getCommandType() { + return IReverseStepIntoHandler.class; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ReverseStepOverCommandHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ReverseStepOverCommandHandler.java index 0fb83f6945f..9523de314f0 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ReverseStepOverCommandHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ReverseStepOverCommandHandler.java @@ -18,12 +18,12 @@ import org.eclipse.debug.ui.actions.DebugCommandHandler; /** * Command handler to trigger a reverse stepover operation - * + * * @since 7.0 */ public class ReverseStepOverCommandHandler extends DebugCommandHandler { - @Override - protected Class<?> getCommandType() { - return IReverseStepOverHandler.class; - } + @Override + protected Class<?> getCommandType() { + return IReverseStepOverHandler.class; + } }
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ReverseToggleCommandHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ReverseToggleCommandHandler.java index bbe6f0b501e..7083b65b939 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ReverseToggleCommandHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ReverseToggleCommandHandler.java @@ -60,245 +60,254 @@ import org.osgi.framework.Bundle; */ public class ReverseToggleCommandHandler extends DebugCommandHandler implements IDebugContextListener, IElementUpdater { - private static final ImageDescriptor REVERSE_TOGGLE_DEFAULT_IMAGE = getImageDescriptor("icons/obj16/reverse_toggle.gif"); //$NON-NLS-1$ - private static final ImageDescriptor REVERSE_TOGGLE_SOFTWARE_ON_IMAGE = getImageDescriptor("icons/obj16/reverse_toggle_sw_on.png"); //$NON-NLS-1$ - private static final ImageDescriptor REVERSE_TOGGLE_SOFTWARE_OFF_IMAGE = getImageDescriptor("icons/obj16/reverse_toggle_sw_off.png"); //$NON-NLS-1$ - private static final ImageDescriptor REVERSE_TOGGLE_HARDWARE_ON_IMAGE = getImageDescriptor("icons/obj16/reverse_toggle_hw_on.png"); //$NON-NLS-1$ - private static final ImageDescriptor REVERSE_TOGGLE_HARDWARE_OFF_IMAGE = getImageDescriptor("icons/obj16/reverse_toggle_hw_off.png"); //$NON-NLS-1$ + private static final ImageDescriptor REVERSE_TOGGLE_DEFAULT_IMAGE = getImageDescriptor( + "icons/obj16/reverse_toggle.gif"); //$NON-NLS-1$ + private static final ImageDescriptor REVERSE_TOGGLE_SOFTWARE_ON_IMAGE = getImageDescriptor( + "icons/obj16/reverse_toggle_sw_on.png"); //$NON-NLS-1$ + private static final ImageDescriptor REVERSE_TOGGLE_SOFTWARE_OFF_IMAGE = getImageDescriptor( + "icons/obj16/reverse_toggle_sw_off.png"); //$NON-NLS-1$ + private static final ImageDescriptor REVERSE_TOGGLE_HARDWARE_ON_IMAGE = getImageDescriptor( + "icons/obj16/reverse_toggle_hw_on.png"); //$NON-NLS-1$ + private static final ImageDescriptor REVERSE_TOGGLE_HARDWARE_OFF_IMAGE = getImageDescriptor( + "icons/obj16/reverse_toggle_hw_off.png"); //$NON-NLS-1$ - @Override + @Override protected Class<?> getCommandType() { return IReverseToggleHandler.class; } - // - // The below logic allows us to keep the checked state of the toggle button - // properly set. This is because in some case, the checked state may change - // without the user actually pressing the button. For instance, if we restart - // the inferior, the toggle may automatically turn off. - // To figure this out, whenever a debug context changes, we make sure we are - // showing the proper checked state. - // + // + // The below logic allows us to keep the checked state of the toggle button + // properly set. This is because in some case, the checked state may change + // without the user actually pressing the button. For instance, if we restart + // the inferior, the toggle may automatically turn off. + // To figure this out, whenever a debug context changes, we make sure we are + // showing the proper checked state. + // - // We must hard-code the command id so as to know it from the very start (bug 290699) - private static final String REVERSE_TOGGLE_COMMAND_ID = "org.eclipse.cdt.debug.ui.command.reverseToggle"; //$NON-NLS-1$ + // We must hard-code the command id so as to know it from the very start (bug 290699) + private static final String REVERSE_TOGGLE_COMMAND_ID = "org.eclipse.cdt.debug.ui.command.reverseToggle"; //$NON-NLS-1$ - private Object fActiveContext; - private IReverseToggleHandler fTargetAdapter; - private IDebugContextService fContextService; + private Object fActiveContext; + private IReverseToggleHandler fTargetAdapter; + private IDebugContextService fContextService; - private static ImageDescriptor getImageDescriptor (String path) { - Bundle bundle = Platform.getBundle("org.eclipse.cdt.debug.ui"); //$NON-NLS-1$ - URL url = null; - if (bundle != null) { - url = FileLocator.find(bundle, new Path(path), null); - if (url != null) { - return ImageDescriptor.createFromURL(url); - } - } - return null; - } + private static ImageDescriptor getImageDescriptor(String path) { + Bundle bundle = Platform.getBundle("org.eclipse.cdt.debug.ui"); //$NON-NLS-1$ + URL url = null; + if (bundle != null) { + url = FileLocator.find(bundle, new Path(path), null); + if (url != null) { + return ImageDescriptor.createFromURL(url); + } + } + return null; + } - public ReverseToggleCommandHandler() { - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window != null) { - fContextService = DebugUITools.getDebugContextManager().getContextService(window); - if (fContextService != null) { - fContextService.addPostDebugContextListener(this); + public ReverseToggleCommandHandler() { + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window != null) { + fContextService = DebugUITools.getDebugContextManager().getContextService(window); + if (fContextService != null) { + fContextService.addPostDebugContextListener(this); - // This constructor might be called after the launch, so we must refresh here too. - // This can happen if we activate the action set after the launch. - refresh(fContextService.getActiveContext()); - } - } - } + // This constructor might be called after the launch, so we must refresh here too. + // This can happen if we activate the action set after the launch. + refresh(fContextService.getActiveContext()); + } + } + } - @Override - public void dispose() { - // Must use the stored context service. If we try to fetch the service - // again with the workbenchWindow, it may fail if the window is - // already closed. - if (fContextService != null) { - fContextService.removePostDebugContextListener(this); - } - fTargetAdapter = null; - fActiveContext = null; - super.dispose(); - } + @Override + public void dispose() { + // Must use the stored context service. If we try to fetch the service + // again with the workbenchWindow, it may fail if the window is + // already closed. + if (fContextService != null) { + fContextService.removePostDebugContextListener(this); + } + fTargetAdapter = null; + fActiveContext = null; + super.dispose(); + } - @Override + @Override public void debugContextChanged(DebugContextEvent event) { - refresh(event.getContext()); - } + refresh(event.getContext()); + } + + private void refresh(ISelection selection) { + fTargetAdapter = null; + fActiveContext = null; + if (selection instanceof IStructuredSelection) { + IStructuredSelection ss = (IStructuredSelection) selection; + if (!ss.isEmpty()) { + fActiveContext = ss.getFirstElement(); + if (fActiveContext instanceof IAdaptable) { + fTargetAdapter = getAdapter((IAdaptable) fActiveContext); + } + } + } - private void refresh(ISelection selection) { - fTargetAdapter = null; - fActiveContext = null; - if (selection instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection) selection; - if (!ss.isEmpty()) { - fActiveContext = ss.getFirstElement(); - if (fActiveContext instanceof IAdaptable) { - fTargetAdapter = getAdapter((IAdaptable) fActiveContext); - } - } - } + ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class); + if (commandService != null) { + commandService.refreshElements(REVERSE_TOGGLE_COMMAND_ID, null); + } + } - ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class); - if (commandService != null) { - commandService.refreshElements(REVERSE_TOGGLE_COMMAND_ID, null); - } - } + private IReverseToggleHandler getAdapter(IAdaptable adaptable) { + IReverseToggleHandler adapter = adaptable.getAdapter(IReverseToggleHandler.class); + if (adapter == null) { + IAdapterManager adapterManager = Platform.getAdapterManager(); + if (adapterManager.hasAdapter(adaptable, getCommandType().getName())) { + adapter = (IReverseToggleHandler) adapterManager.loadAdapter(adaptable, + IReverseToggleHandler.class.getName()); + } + } + if (adapter instanceof IChangeReverseMethodHandler) { + return adapter; + } else { + return null; + } + } - private IReverseToggleHandler getAdapter(IAdaptable adaptable) { - IReverseToggleHandler adapter = adaptable.getAdapter(IReverseToggleHandler.class); - if (adapter == null) { - IAdapterManager adapterManager = Platform.getAdapterManager(); - if (adapterManager.hasAdapter(adaptable, getCommandType().getName())) { - adapter = (IReverseToggleHandler)adapterManager.loadAdapter(adaptable, IReverseToggleHandler.class.getName()); - } - } - if (adapter instanceof IChangeReverseMethodHandler) { - return adapter; - } else { - return null; - } - } + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + ReverseDebugMethod newMethod; + try { + if (HandlerUtil.matchesRadioState(event)) { + return null; + } - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - ReverseDebugMethod newMethod; - try { - if (HandlerUtil.matchesRadioState(event)) { - return null; - } + String radioState = event.getParameter(RadioState.PARAMETER_ID); - String radioState = event.getParameter(RadioState.PARAMETER_ID); + if (radioState.equals("UseSoftTrace")) { //$NON-NLS-1$ + newMethod = ReverseDebugMethod.SOFTWARE; + } else if (radioState.equals("TraceOff")) { //$NON-NLS-1$ + newMethod = ReverseDebugMethod.OFF; + } else if (radioState.equals("UseHardTrace")) { //$NON-NLS-1$ + newMethod = ReverseDebugMethod.HARDWARE; + } else { + // undefined trace method + throw new ExecutionException(Messages.ReverseDebugging_UndefinedTraceMethod); + } - if (radioState.equals("UseSoftTrace")) { //$NON-NLS-1$ - newMethod = ReverseDebugMethod.SOFTWARE; - } else if (radioState.equals("TraceOff")) { //$NON-NLS-1$ - newMethod = ReverseDebugMethod.OFF; - } else if (radioState.equals("UseHardTrace")) { //$NON-NLS-1$ - newMethod = ReverseDebugMethod.HARDWARE; - } else { - // undefined trace method - throw new ExecutionException(Messages.ReverseDebugging_UndefinedTraceMethod); - } + // store the parameter in the gdb command handler class + if (fTargetAdapter != null && fTargetAdapter instanceof IChangeReverseMethodHandler) { + ReverseDebugMethod currMethod = ((IChangeReverseMethodHandler) fTargetAdapter) + .getReverseDebugMethod(fActiveContext); + if (currMethod == newMethod) { + return null; + } + ((IChangeReverseMethodHandler) fTargetAdapter).setReverseDebugMethod(newMethod); + } - // store the parameter in the gdb command handler class - if (fTargetAdapter != null && fTargetAdapter instanceof IChangeReverseMethodHandler) { - ReverseDebugMethod currMethod = ((IChangeReverseMethodHandler)fTargetAdapter).getReverseDebugMethod(fActiveContext); - if (currMethod == newMethod) { - return null; - } - ((IChangeReverseMethodHandler)fTargetAdapter).setReverseDebugMethod(newMethod); - } + // execute the event + super.execute(event); - // execute the event - super.execute(event); + // and finally update the radio current state + HandlerUtil.updateRadioState(event.getCommand(), radioState); - // and finally update the radio current state - HandlerUtil.updateRadioState(event.getCommand(), radioState); + return null; + } catch (NullPointerException | ExecutionException e) { + // Disable tracing + if (fTargetAdapter != null && fTargetAdapter instanceof IChangeReverseMethodHandler) { + if (fTargetAdapter.toggleNeedsUpdating()) { + ReverseDebugMethod currMethod = ((IChangeReverseMethodHandler) fTargetAdapter) + .getReverseDebugMethod(fActiveContext); + if (currMethod == ReverseDebugMethod.OFF) { + ReverseDebugMethod prevMethod = ((IChangeReverseMethodHandler) fTargetAdapter) + .getPreviousReverseDebugMethod(fActiveContext); + if (prevMethod == ReverseDebugMethod.HARDWARE) { + newMethod = ReverseDebugMethod.HARDWARE; + } else { + newMethod = ReverseDebugMethod.SOFTWARE; + } + } else { + newMethod = ReverseDebugMethod.OFF; + } + ((IChangeReverseMethodHandler) fTargetAdapter).setReverseDebugMethod(newMethod); + } + } + super.execute(event); + return null; + } + } - return null; - } catch (NullPointerException | ExecutionException e) { - // Disable tracing - if (fTargetAdapter != null && fTargetAdapter instanceof IChangeReverseMethodHandler) { - if (fTargetAdapter.toggleNeedsUpdating()) { - ReverseDebugMethod currMethod = ((IChangeReverseMethodHandler)fTargetAdapter).getReverseDebugMethod(fActiveContext); - if (currMethod == ReverseDebugMethod.OFF) { - ReverseDebugMethod prevMethod = ((IChangeReverseMethodHandler)fTargetAdapter).getPreviousReverseDebugMethod(fActiveContext); - if (prevMethod == ReverseDebugMethod.HARDWARE) { - newMethod = ReverseDebugMethod.HARDWARE; - } else { - newMethod = ReverseDebugMethod.SOFTWARE; - } - } else { - newMethod = ReverseDebugMethod.OFF; - } - ((IChangeReverseMethodHandler)fTargetAdapter).setReverseDebugMethod(newMethod); - } - } - super.execute(event); - return null; - } - } + /* + * (non-Javadoc) + * @see org.eclipse.debug.ui.actions.DebugCommandHandler#postExecute(org.eclipse.debug.core.IRequest, java.lang.Object[]) + * + * We keep this logic for users that may not do the refresh themselves. + */ + @Override + protected void postExecute(final IRequest request, Object[] targets) { + super.postExecute(request, targets); + new WorkbenchJob("") { //$NON-NLS-1$ + @Override + public IStatus runInUIThread(IProgressMonitor monitor) { + if (request.getStatus() != null && request.getStatus().getCode() != 0) { + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + Shell activeShell = null; + if (window != null) { + activeShell = window.getShell(); + } else { + activeShell = new Shell(PlatformUI.getWorkbench().getDisplay()); + } + MessageDialog dialogbox = new MessageDialog(activeShell, Messages.ReverseDebugging_Error, null, + request.getStatus().getMessage(), MessageDialog.ERROR, + new String[] { IDialogConstants.OK_LABEL }, 0); + dialogbox.open(); + } + // Request re-evaluation of property "org.eclipse.cdt.debug.ui.isReverseDebuggingEnabled" to update + // visibility of reverse stepping commands. + IEvaluationService exprService = PlatformUI.getWorkbench().getService(IEvaluationService.class); + if (exprService != null) { + exprService.requestEvaluation("org.eclipse.cdt.debug.ui.isReverseDebuggingEnabled"); //$NON-NLS-1$ + } + // Refresh reverse toggle commands with the new state of reverse enabled. + // This is in order to keep multiple toggle actions in UI in sync. + ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class); + if (commandService != null) { + commandService.refreshElements(REVERSE_TOGGLE_COMMAND_ID, null); + } - /* - * (non-Javadoc) - * @see org.eclipse.debug.ui.actions.DebugCommandHandler#postExecute(org.eclipse.debug.core.IRequest, java.lang.Object[]) - * - * We keep this logic for users that may not do the refresh themselves. - */ - @Override - protected void postExecute(final IRequest request, Object[] targets) { - super.postExecute(request, targets); - new WorkbenchJob("") { //$NON-NLS-1$ - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - if (request.getStatus() != null && request.getStatus().getCode() != 0) { - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - Shell activeShell = null; - if (window != null) { - activeShell = window.getShell(); - } else { - activeShell = new Shell(PlatformUI.getWorkbench().getDisplay()); - } - MessageDialog dialogbox = new MessageDialog(activeShell, Messages.ReverseDebugging_Error, - null, request.getStatus().getMessage(), MessageDialog.ERROR, - new String[] {IDialogConstants.OK_LABEL}, 0); - dialogbox.open(); - } - // Request re-evaluation of property "org.eclipse.cdt.debug.ui.isReverseDebuggingEnabled" to update - // visibility of reverse stepping commands. - IEvaluationService exprService = PlatformUI.getWorkbench().getService(IEvaluationService.class); - if (exprService != null) { - exprService.requestEvaluation("org.eclipse.cdt.debug.ui.isReverseDebuggingEnabled"); //$NON-NLS-1$ - } - // Refresh reverse toggle commands with the new state of reverse enabled. - // This is in order to keep multiple toggle actions in UI in sync. - ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class); - if (commandService != null) { - commandService.refreshElements(REVERSE_TOGGLE_COMMAND_ID, null); - } - - return Status.OK_STATUS; - } - }.schedule(); - } + return Status.OK_STATUS; + } + }.schedule(); + } - @Override - public void updateElement(UIElement element, - @SuppressWarnings("rawtypes") Map parameters) { - if (fTargetAdapter != null && fTargetAdapter instanceof IChangeReverseMethodHandler) { - ReverseDebugMethod currMethod = ((IChangeReverseMethodHandler)fTargetAdapter).getReverseDebugMethod(fActiveContext); - ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class); - try{ - if (currMethod == ReverseDebugMethod.HARDWARE) { - HandlerUtil.updateRadioState(commandService.getCommand(REVERSE_TOGGLE_COMMAND_ID), "UseHardTrace"); //$NON-NLS-1$ - element.setTooltip(Messages.ReverseDebugging_ToggleHardwareTrace); - element.setIcon(REVERSE_TOGGLE_HARDWARE_ON_IMAGE); - } else if (currMethod == ReverseDebugMethod.SOFTWARE) { - HandlerUtil.updateRadioState(commandService.getCommand(REVERSE_TOGGLE_COMMAND_ID), "UseSoftTrace"); //$NON-NLS-1$ - element.setTooltip(Messages.ReverseDebugging_ToggleSoftwareTrace); - element.setIcon(REVERSE_TOGGLE_SOFTWARE_ON_IMAGE); - } else { - HandlerUtil.updateRadioState(commandService.getCommand(REVERSE_TOGGLE_COMMAND_ID), "TraceOff"); //$NON-NLS-1$ - element.setTooltip(Messages.ReverseDebugging_ToggleReverseDebugging); - ReverseDebugMethod prevMethod = ((IChangeReverseMethodHandler)fTargetAdapter).getPreviousReverseDebugMethod(fActiveContext); - if (prevMethod == ReverseDebugMethod.HARDWARE) { - element.setIcon(REVERSE_TOGGLE_HARDWARE_OFF_IMAGE); - } else if (prevMethod == ReverseDebugMethod.SOFTWARE) { - element.setIcon(REVERSE_TOGGLE_SOFTWARE_OFF_IMAGE); - } else { - element.setIcon(REVERSE_TOGGLE_DEFAULT_IMAGE); - } - } - } - catch(ExecutionException e){ - // Do nothing - } - } - } + @Override + public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map parameters) { + if (fTargetAdapter != null && fTargetAdapter instanceof IChangeReverseMethodHandler) { + ReverseDebugMethod currMethod = ((IChangeReverseMethodHandler) fTargetAdapter) + .getReverseDebugMethod(fActiveContext); + ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class); + try { + if (currMethod == ReverseDebugMethod.HARDWARE) { + HandlerUtil.updateRadioState(commandService.getCommand(REVERSE_TOGGLE_COMMAND_ID), "UseHardTrace"); //$NON-NLS-1$ + element.setTooltip(Messages.ReverseDebugging_ToggleHardwareTrace); + element.setIcon(REVERSE_TOGGLE_HARDWARE_ON_IMAGE); + } else if (currMethod == ReverseDebugMethod.SOFTWARE) { + HandlerUtil.updateRadioState(commandService.getCommand(REVERSE_TOGGLE_COMMAND_ID), "UseSoftTrace"); //$NON-NLS-1$ + element.setTooltip(Messages.ReverseDebugging_ToggleSoftwareTrace); + element.setIcon(REVERSE_TOGGLE_SOFTWARE_ON_IMAGE); + } else { + HandlerUtil.updateRadioState(commandService.getCommand(REVERSE_TOGGLE_COMMAND_ID), "TraceOff"); //$NON-NLS-1$ + element.setTooltip(Messages.ReverseDebugging_ToggleReverseDebugging); + ReverseDebugMethod prevMethod = ((IChangeReverseMethodHandler) fTargetAdapter) + .getPreviousReverseDebugMethod(fActiveContext); + if (prevMethod == ReverseDebugMethod.HARDWARE) { + element.setIcon(REVERSE_TOGGLE_HARDWARE_OFF_IMAGE); + } else if (prevMethod == ReverseDebugMethod.SOFTWARE) { + element.setIcon(REVERSE_TOGGLE_SOFTWARE_OFF_IMAGE); + } else { + element.setIcon(REVERSE_TOGGLE_DEFAULT_IMAGE); + } + } + } catch (ExecutionException e) { + // Do nothing + } + } + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/SaveTraceDataCommandHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/SaveTraceDataCommandHandler.java index 28e0e0db4f8..f2a82bd5c7d 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/SaveTraceDataCommandHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/SaveTraceDataCommandHandler.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Ericsson - initial API and implementation *******************************************************************************/ @@ -18,7 +18,7 @@ import org.eclipse.debug.ui.actions.DebugCommandHandler; /** * Command handler to save the trace data to a file - * + * * @since 7.0 */ public class SaveTraceDataCommandHandler extends DebugCommandHandler { diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/StartTracingCommandHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/StartTracingCommandHandler.java index d819bbc7a8d..cdf6b60fbbf 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/StartTracingCommandHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/StartTracingCommandHandler.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Ericsson - initial API and implementation *******************************************************************************/ @@ -18,7 +18,7 @@ import org.eclipse.debug.ui.actions.DebugCommandHandler; /** * Command handler to request the start of tracing - * + * * @since 7.0 */ public class StartTracingCommandHandler extends DebugCommandHandler { diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/StepIntoSelectionCommandHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/StepIntoSelectionCommandHandler.java index 43eb1068d0f..25a55c39c1b 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/StepIntoSelectionCommandHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/StepIntoSelectionCommandHandler.java @@ -16,7 +16,6 @@ package org.eclipse.cdt.debug.internal.ui.commands; import org.eclipse.cdt.debug.core.model.IStepIntoSelectionHandler; import org.eclipse.debug.ui.actions.DebugCommandHandler; - public class StepIntoSelectionCommandHandler extends DebugCommandHandler { @Override protected Class<?> getCommandType() { diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/StopTracingCommandHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/StopTracingCommandHandler.java index 63f22fe5fdb..0cf898b4a28 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/StopTracingCommandHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/StopTracingCommandHandler.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Ericsson - initial API and implementation *******************************************************************************/ @@ -18,7 +18,7 @@ import org.eclipse.debug.ui.actions.DebugCommandHandler; /** * Command handler to request the stop of tracing - * + * * @since 7.0 */ public class StopTracingCommandHandler extends DebugCommandHandler { diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/UncallCommandHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/UncallCommandHandler.java index 924dc30aafa..e77af49df9e 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/UncallCommandHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/UncallCommandHandler.java @@ -18,12 +18,12 @@ import org.eclipse.debug.ui.actions.DebugCommandHandler; /** * Command handler to trigger an uncall operation - * + * * @since 7.0 */ public class UncallCommandHandler extends DebugCommandHandler { - @Override - protected Class<?> getCommandType() { - return IUncallHandler.class; - } + @Override + protected Class<?> getCommandType() { + return IUncallHandler.class; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/UngroupDebugContextsCommandHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/UngroupDebugContextsCommandHandler.java index b93244cc7d4..551caad00d2 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/UngroupDebugContextsCommandHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/UngroupDebugContextsCommandHandler.java @@ -18,13 +18,13 @@ import org.eclipse.debug.ui.actions.DebugCommandHandler; /** * Command handler to trigger ungrouping of debug contexts operation. - * - * @since 7.1 + * + * @since 7.1 */ public class UngroupDebugContextsCommandHandler extends DebugCommandHandler { - - @Override - protected Class<?> getCommandType() { - return IUngroupDebugContextsHandler.class; - } + + @Override + protected Class<?> getCommandType() { + return IUngroupDebugContextsHandler.class; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/CheckedListDialogField.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/CheckedListDialogField.java index 46d70eca1a0..9c0afb4d01f 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/CheckedListDialogField.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/CheckedListDialogField.java @@ -34,48 +34,47 @@ import org.eclipse.swt.widgets.Table; * DialogFields controls are: Label, List and Composite containing buttons. */ public class CheckedListDialogField extends ListDialogField { - + private int fCheckAllButtonIndex; private int fUncheckAllButtonIndex; - + private List fCheckElements; public CheckedListDialogField(IListAdapter adapter, String[] customButtonLabels, ILabelProvider lprovider) { super(adapter, customButtonLabels, lprovider); - fCheckElements= new ArrayList(); - - fCheckAllButtonIndex= -1; - fUncheckAllButtonIndex= -1; + fCheckElements = new ArrayList(); + + 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; + 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; + fUncheckAllButtonIndex = uncheckButtonIndex; } - /* * @see ListDialogField#createTableViewer */ @Override protected TableViewer createTableViewer(Composite parent) { - Table table= new Table(parent, SWT.CHECK + getListStyle()); - CheckboxTableViewer tableViewer= new CheckboxTableViewer(table); + Table table = new Table(parent, SWT.CHECK + getListStyle()); + CheckboxTableViewer tableViewer = new CheckboxTableViewer(table); tableViewer.addCheckStateListener(new ICheckStateListener() { @Override public void checkStateChanged(CheckStateChangedEvent e) { @@ -83,39 +82,38 @@ public class CheckedListDialogField extends ListDialogField { } }); return tableViewer; - } - - + } + /* * @see ListDialogField#getListControl */ @Override public Control getListControl(Composite parent) { - Control control= super.getListControl(parent); + Control control = super.getListControl(parent); if (parent != null) { - ((CheckboxTableViewer)fTable).setCheckedElements(fCheckElements.toArray()); + ((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--) { + 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. @@ -123,79 +121,77 @@ public class CheckedListDialogField extends ListDialogField { public List getCheckedElements() { return new ArrayList(fCheckElements); } - + /** * Returns true if the element is checked. */ public boolean isChecked(Object obj) { return fCheckElements.contains(obj); - } - + } + /** * Sets the checked elements. - */ + */ public void setCheckedElements(List list) { - fCheckElements= new ArrayList(list); + fCheckElements = new ArrayList(list); if (fTable != null) { - ((CheckboxTableViewer)fTable).setCheckedElements(list.toArray()); + ((CheckboxTableViewer) fTable).setCheckedElements(list.toArray()); } checkStateChanged(); } /** * Sets the checked state of an element. - */ + */ public void setChecked(Object object, boolean state) { setCheckedWithoutUpdate(object, state); checkStateChanged(); } - + /** * Sets the checked state of an element. no dialog changed listener informed - */ + */ public void setCheckedWithoutUpdate(Object object, boolean state) { if (state) { if (!fCheckElements.contains(object)) { fCheckElements.add(object); } - } - else { + } else { if (fCheckElements.contains(object)) { fCheckElements.remove(object); } } if (fTable != null) { - ((CheckboxTableViewer)fTable).setChecked(object, state); + ((CheckboxTableViewer) fTable).setChecked(object, state); } } /** * Sets the check state of all elements - */ + */ public void checkAll(boolean state) { if (state) { - fCheckElements= getElements(); + fCheckElements = getElements(); } else { fCheckElements.clear(); } if (fTable != null) { - ((CheckboxTableViewer)fTable).setAllChecked(state); + ((CheckboxTableViewer) fTable).setAllChecked(state); } checkStateChanged(); } - - + protected void doCheckStateChanged(CheckStateChangedEvent e) { if (e.getChecked()) { fCheckElements.add(e.getElement()); } else { fCheckElements.remove(e.getElement()); - } + } checkStateChanged(); } - + // ------ enable / disable management - + /* * @see ListDialogField#getManagedButtonState */ @@ -207,11 +203,11 @@ public class CheckedListDialogField extends ListDialogField { return !fElements.isEmpty(); } return super.getManagedButtonState(sel, index); - } + } /* * @see ListDialogField#extraButtonPressed - */ + */ @Override protected boolean managedButtonPressed(int index) { if (index == fCheckAllButtonIndex) { @@ -223,9 +219,5 @@ public class CheckedListDialogField extends ListDialogField { } return true; } - - - - } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/ComboDialogField.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/ComboDialogField.java index 9e8b767eb23..879b672b6c6 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/ComboDialogField.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/ComboDialogField.java @@ -27,57 +27,57 @@ 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; + 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 label = getLabelControl(parent); label.setLayoutData(gridDataForLabel(1)); - Combo combo= getComboControl(parent); + Combo combo = getComboControl(parent); combo.setLayoutData(gridDataForCombo(nColumns - 1)); - + return new Control[] { label, combo }; - } + } /* * @see DialogField#getNumberOfControls */ @Override public int getNumberOfControls() { - return 2; + return 2; } - + protected static GridData gridDataForCombo(int span) { - GridData gd= new GridData(); - gd.horizontalAlignment= GridData.FILL; - gd.grabExcessHorizontalSpace= false; - gd.horizontalSpan= span; + GridData gd = new GridData(); + gd.horizontalAlignment = GridData.FILL; + gd.grabExcessHorizontalSpace = false; + gd.horizontalSpan = span; return gd; - } - + } + // ------- focus methods - + /* * @see DialogField#setFocus */ @@ -88,35 +88,35 @@ public class ComboDialogField extends DialogField { } return true; } - - // ------- ui creation + + // ------- 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() { + fModifyListener = new ModifyListener() { @Override public void modifyText(ModifyEvent e) { doModifyText(e); } }; - SelectionListener selectionListener= new SelectionListener() { + SelectionListener selectionListener = new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { doSelectionChanged(e); } - + @Override - public void widgetDefaultSelected(SelectionEvent e) { + public void widgetDefaultSelected(SelectionEvent e) { } }; - - fComboControl= new Combo(parent, fFlags); + + fComboControl = new Combo(parent, fFlags); // moved up due to 1GEUNW2 fComboControl.setItems(fItems); if (fSelectionIndex != -1) { @@ -130,107 +130,106 @@ public class ComboDialogField extends DialogField { fComboControl.setEnabled(isEnabled()); } return fComboControl; - } - + } + protected void doModifyText(ModifyEvent e) { if (isOkToUse(fComboControl)) { - fText= fComboControl.getText(); - fSelectionIndex= fComboControl.getSelectionIndex(); + fText = fComboControl.getText(); + fSelectionIndex = fComboControl.getSelectionIndex(); } dialogFieldChanged(); } - + protected void doSelectionChanged(SelectionEvent e) { if (isOkToUse(fComboControl)) { - fItems= fComboControl.getItems(); - fText= fComboControl.getText(); - fSelectionIndex= fComboControl.getSelectionIndex(); + fItems = fComboControl.getItems(); + fText = fComboControl.getText(); + fSelectionIndex = fComboControl.getSelectionIndex(); } - dialogFieldChanged(); + dialogFieldChanged(); } - + // ------ enable / disable management - + /* * @see DialogField#updateEnableState - */ + */ @Override protected void updateEnableState() { - super.updateEnableState(); + super.updateEnableState(); if (isOkToUse(fComboControl)) { fComboControl.setEnabled(isEnabled()); - } - } - - // ------ text access - + } + } + + // ------ 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; + 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; + 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; + 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; + fText = text; if (isOkToUse(fComboControl)) { fComboControl.removeModifyListener(fModifyListener); fComboControl.setText(text); fComboControl.addModifyListener(fModifyListener); } } - + }
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/DialogField.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/DialogField.java index 5dead082d38..64e850d5336 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/DialogField.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/DialogField.java @@ -28,51 +28,51 @@ import org.eclipse.swt.widgets.Label; * from the creation time of the widgets. * - support for automated layouting. * - enable / disable, set focus a concept of the base class. - * + * * DialogField have a 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$ + fEnabled = true; + fLabel = null; + fLabelText = ""; //$NON-NLS-1$ } - + /** * Sets the label of the dialog field. */ public void setLabelText(String labeltext) { - fLabelText= labeltext; + fLabelText = labeltext; } - + // ------ change listener - + /** * Defines the listener for this dialog field. - */ + */ public final void setDialogFieldListener(IDialogFieldListener listener) { - fDialogFieldListener= listener; + fDialogFieldListener = listener; } /** * Programatical 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. @@ -84,22 +84,20 @@ public class DialogField { /** * Posts <code>setFocus</code> to the display event queue. - */ + */ public void postSetFocusOnDialogField(Display display) { if (display != null) { - display.asyncExec( - new Runnable() { - @Override - public void run() { - setFocus(); - } + display.asyncExec(new Runnable() { + @Override + 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 @@ -109,48 +107,48 @@ public class DialogField { */ public Control[] doFillIntoGrid(Composite parent, int nColumns) { assertEnoughColumns(nColumns); - - Label label= getLabelControl(parent); + + 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; - } - + return 1; + } + protected static GridData gridDataForLabel(int span) { - GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); - gd.horizontalSpan= 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 | SWT.WRAP); + + fLabel = new Label(parent, SWT.LEFT | SWT.WRAP); fLabel.setFont(parent.getFont()); - fLabel.setEnabled(fEnabled); + fLabel.setEnabled(fEnabled); if (fLabelText != null && !fLabelText.isEmpty()) { fLabel.setText(fLabelText); } else { // XXX: to avoid a 16 pixel wide empty label - revisit fLabel.setText("."); //$NON-NLS-1$ fLabel.setVisible(false); - } + } } return fLabel; } @@ -159,7 +157,7 @@ public class DialogField { * Creates a spacer control. * * @param parent The parent composite - */ + */ public static Control createEmptySpace(Composite parent) { return createEmptySpace(parent, 1); } @@ -169,39 +167,39 @@ public class DialogField { * The composite is assumed to have {@link GridLayout} 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 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; + fEnabled = enabled; updateEnableState(); } } - + /** * Called when the enable state changed. * To be extended by dialog field implementors. @@ -214,7 +212,7 @@ public class DialogField { /** * Gets the enable state of the dialog field. - */ + */ public final boolean isEnabled() { return fEnabled; } @@ -222,12 +220,9 @@ public class DialogField { 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/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/IDialogFieldListener.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/IDialogFieldListener.java index 59f9e0bd364..6a98d648f08 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/IDialogFieldListener.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/IDialogFieldListener.java @@ -17,7 +17,7 @@ package org.eclipse.cdt.debug.internal.ui.dialogfields; * Change listener used by <code>DialogField</code> */ public interface IDialogFieldListener { - + /** * The dialog field has changed. */ diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/IListAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/IListAdapter.java index dd5bb3451c5..49929235aa6 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/IListAdapter.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/IListAdapter.java @@ -17,15 +17,15 @@ package org.eclipse.cdt.debug.internal.ui.dialogfields; * Change listener used by <code>ListDialogField</code> and <code>CheckedListDialogField</code> */ public interface IListAdapter { - + /** * A button from the button bar has been pressed. */ void customButtonPressed(DialogField field, int index); - + /** * The selection of the list has changed. - */ + */ void selectionChanged(DialogField field); }
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/IStringButtonAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/IStringButtonAdapter.java index 0b2c628ce44..b67e59e5090 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/IStringButtonAdapter.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/IStringButtonAdapter.java @@ -17,7 +17,7 @@ package org.eclipse.cdt.debug.internal.ui.dialogfields; * Change listener used by <code>StringButtonDialogField</code> */ public interface IStringButtonAdapter { - + void changeControlPressed(DialogField field); }
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/LayoutUtil.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/LayoutUtil.java index cbe7e207901..5bfe1db0cbf 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/LayoutUtil.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/LayoutUtil.java @@ -20,22 +20,22 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; public class LayoutUtil { - + /** * Calculates the number of columns needed by field editors */ public static int getNumberOfColumns(DialogField[] editors) { - int nCulumns= 0; - for (int i= 0; i < editors.length; i++) { - nCulumns= Math.max(editors[i].getNumberOfControls(), nCulumns); + int nCulumns = 0; + for (int i = 0; i < editors.length; i++) { + nCulumns = Math.max(editors[i].getNumberOfControls(), nCulumns); } return nCulumns; } - + /** * 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); } @@ -44,9 +44,10 @@ public class LayoutUtil { * 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 minHeight The minimal height of the composite */ - public static void doDefaultLayout(Composite parent, DialogField[] editors, boolean labelOnTop, int minWidth, int minHeight) { + public static void doDefaultLayout(Composite parent, DialogField[] editors, boolean labelOnTop, int minWidth, + int minHeight) { doDefaultLayout(parent, editors, labelOnTop, minWidth, minHeight, 0, 0); } @@ -58,87 +59,88 @@ public class LayoutUtil { * @param marginWidth The margin width to be used by the composite * @param marginHeight The margin height to be used by the composite * @deprecated - */ + */ @Deprecated - public 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); + public 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(); + GridLayout layout = new GridLayout(); if (marginWidth != SWT.DEFAULT) { - layout.marginWidth= marginWidth; + layout.marginWidth = marginWidth; } if (marginHeight != SWT.DEFAULT) { - layout.marginHeight= marginHeight; + layout.marginHeight = marginHeight; } - layout.numColumns= nCulumns; + layout.numColumns = nCulumns; parent.setLayout(layout); } - + private static void modifyLabelSpans(Control[][] controls, int nCulumns) { - for (int i= 0; i < controls.length; i++) { + 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(); + Object ld = control.getLayoutData(); if (ld instanceof GridData) { - ((GridData)ld).horizontalSpan= span; + ((GridData) ld).horizontalSpan = span; } else if (span != 1) { - GridData gd= new GridData(); - gd.horizontalSpan= span; + 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(); + Object ld = control.getLayoutData(); if (ld instanceof GridData) { - ((GridData)ld).widthHint= widthHint; + ((GridData) ld).widthHint = widthHint; } } - + /** * Sets the heigthHint hint of a control. Assumes that GridData is used. */ public static void setHeigthHint(Control control, int heigthHint) { - Object ld= control.getLayoutData(); + Object ld = control.getLayoutData(); if (ld instanceof GridData) { - ((GridData)ld).heightHint= heigthHint; + ((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(); + Object ld = control.getLayoutData(); if (ld instanceof GridData) { - ((GridData)ld).horizontalIndent= horizontalIndent; + ((GridData) ld).horizontalIndent = horizontalIndent; } } - + /** * Sets the horizontal indent of a control. Assumes that GridData is used. */ public static void setHorizontalGrabbing(Control control) { - Object ld= control.getLayoutData(); + Object ld = control.getLayoutData(); if (ld instanceof GridData) { - ((GridData)ld).grabExcessHorizontalSpace= true; + ((GridData) ld).grabExcessHorizontalSpace = true; } - } + } }
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/ListDialogField.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/ListDialogField.java index f0b6d0e8242..5c51ebb132d 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/ListDialogField.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/ListDialogField.java @@ -13,7 +13,6 @@ *******************************************************************************/ package org.eclipse.cdt.debug.internal.ui.dialogfields; - import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -50,7 +49,7 @@ import org.eclipse.swt.widgets.Table; * DialogFields controls are: Label, List and Composite containing buttons. */ public class ListDialogField extends DialogField { - + protected TableViewer fTable; protected ILabelProvider fLabelProvider; protected ListViewerAdapter fListViewerAdapter; @@ -59,21 +58,21 @@ public class ListDialogField extends DialogField { protected String[] fButtonLabels; private Button[] fButtonControls; - + private boolean[] fButtonsEnabled; - + private int fRemoveButtonIndex; private int fUpButtonIndex; private int fDownButtonIndex; - + private Label fLastSeparator; - + protected Table fTableControl; private Composite fButtonsControl; private ISelection fSelectionWhenEnabled; - + private IListAdapter fListAdapter; - + private Object fParentElement; /** @@ -82,81 +81,81 @@ public class ListDialogField extends DialogField { * @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 adapter, String[] buttonLabels, ILabelProvider lprovider) { super(); - fListAdapter= adapter; + fListAdapter = adapter; + + fLabelProvider = lprovider; + fListViewerAdapter = new ListViewerAdapter(); + fParentElement = this; - fLabelProvider= lprovider; - fListViewerAdapter= new ListViewerAdapter(); - fParentElement= this; + fElements = new ArrayList(10); - fElements= new ArrayList(10); - - fButtonLabels= buttonLabels; + fButtonLabels = buttonLabels; if (fButtonLabels != null) { - int nButtons= fButtonLabels.length; - fButtonsEnabled= new boolean[nButtons]; - for (int i= 0; i < nButtons; i++) { - fButtonsEnabled[i]= true; + int nButtons = fButtonLabels.length; + fButtonsEnabled = new boolean[nButtons]; + for (int i = 0; i < nButtons; i++) { + fButtonsEnabled[i] = true; } - } - - fTable= null; - fTableControl= null; - fButtonsControl= null; - - fRemoveButtonIndex= -1; - fUpButtonIndex= -1; - fDownButtonIndex= -1; - } - + } + + fTable = null; + fTableControl = null; + fButtonsControl = 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; + 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; + 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; + fDownButtonIndex = downButtonIndex; } - + /** * Sets the viewerSorter. * @param viewerSorter The viewerSorter to set */ public void setViewerSorter(ViewerSorter viewerSorter) { - fViewerSorter= viewerSorter; - } - + fViewerSorter = viewerSorter; + } + // ------ adapter communication - + private void buttonPressed(int index) { if (!managedButtonPressed(index)) { fListAdapter.customButtonPressed(this, index); } } - + /** * Checks if the button pressed is handled internally * @return Returns true if button has been handled. @@ -173,68 +172,66 @@ public class ListDialogField extends DialogField { } return true; } - // ------ layout helpers - + /* * @see DialogField#doFillIntoGrid */ @Override public Control[] doFillIntoGrid(Composite parent, int nColumns) { - PixelConverter converter= new PixelConverter(parent); - + PixelConverter converter = new PixelConverter(parent); + assertEnoughColumns(nColumns); - - Label label= getLabelControl(parent); - GridData gd= gridDataForLabel(1); - gd.verticalAlignment= GridData.BEGINNING; + + 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= false; - gd.verticalAlignment= GridData.FILL; - gd.grabExcessVerticalSpace= true; - gd.horizontalSpan= nColumns - 2; - gd.widthHint= converter.convertWidthInCharsToPixels(50); - gd.heightHint= converter.convertHeightInCharsToPixels(6); + + Control list = getListControl(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; + + 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; + 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; + ((GridData) fLastSeparator.getLayoutData()).widthHint = minWidth; } } - - + // ------ ui creation - + /** * Returns the list control. When called the first time, the control will be created. * @param The parent composite when called the first time, or <code>null</code> @@ -243,20 +240,20 @@ public class ListDialogField extends DialogField { public Control getListControl(Composite parent) { if (fTableControl == null) { assertCompositeNotNull(parent); - - fTable= createTableViewer(parent); + + fTable = createTableViewer(parent); fTable.setContentProvider(fListViewerAdapter); fTable.setLabelProvider(fLabelProvider); fTable.addSelectionChangedListener(fListViewerAdapter); - - fTableControl= (Table)fTable.getControl(); - + + fTableControl = (Table) fTable.getControl(); + fTable.setInput(fParentElement); - + if (fViewerSorter != null) { fTable.setSorter(fViewerSorter); } - + fTableControl.setEnabled(isEnabled()); if (fSelectionWhenEnabled != null) { postSetSelection(fSelectionWhenEnabled); @@ -267,136 +264,137 @@ public class ListDialogField extends DialogField { /** * Returns the internally used table viewer. - */ + */ public TableViewer getTableViewer() { return fTable; } - - /* + + /* * Subclasses may override to specify a different style. */ - protected int getListStyle(){ + protected int getListStyle() { return SWT.BORDER + SWT.MULTI + SWT.H_SCROLL + SWT.V_SCROLL; } - + protected TableViewer createTableViewer(Composite parent) { - Table table= new Table(parent, getListStyle()); + 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 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; + 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); + 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; + 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 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() { + + SelectionListener listener = new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { doButtonSelected(e); } + @Override public void widgetSelected(SelectionEvent e) { doButtonSelected(e); } }; - - Composite contents= new Composite(parent, SWT.NULL); - GridLayout layout= new GridLayout(); - layout.marginWidth= 0; - layout.marginHeight= 0; + + 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]; + 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] = createButton(contents, currLabel, listener); fButtonControls[i].setEnabled(isEnabled() && fButtonsEnabled[i]); } else { - fButtonControls[i]= null; + fButtonControls[i] = null; createSeparator(contents); } } } - - fLastSeparator= createSeparator(contents); - + + fLastSeparator = createSeparator(contents); + updateButtonState(); - fButtonsControl= contents; + fButtonsControl = contents; } - + return fButtonsControl; } - + protected void doButtonSelected(SelectionEvent e) { if (fButtonControls != null) { - for (int i= 0; i < fButtonControls.length; i++) { + for (int i = 0; i < fButtonControls.length; i++) { if (e.widget == fButtonControls[i]) { buttonPressed(i); return; } } } - } - + } + // ------ 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]; + ISelection sel = fTable.getSelection(); + for (int i = 0; i < fButtonControls.length; i++) { + Button button = fButtonControls[i]; if (isOkToUse(button)) { - boolean extraState= getManagedButtonState(sel, i); + boolean extraState = getManagedButtonState(sel, i); button.setEnabled(isEnabled() && extraState && fButtonsEnabled[i]); - } + } } } } - + protected boolean getManagedButtonState(ISelection sel, int index) { if (index == fRemoveButtonIndex) { return !sel.isEmpty(); @@ -406,23 +404,23 @@ public class ListDialogField extends DialogField { return !sel.isEmpty() && canMoveDown(); } return true; - } + } /* * @see DialogField#updateEnableState - */ + */ @Override protected void updateEnableState() { super.updateEnableState(); - - boolean enabled= isEnabled(); + + boolean enabled = isEnabled(); if (isOkToUse(fTableControl)) { if (!enabled) { - fSelectionWhenEnabled= fTable.getSelection(); + fSelectionWhenEnabled = fTable.getSelection(); selectElements(null); } else { selectElements(fSelectionWhenEnabled); - fSelectionWhenEnabled= null; + fSelectionWhenEnabled = null; } fTableControl.setEnabled(enabled); } @@ -431,21 +429,21 @@ public class ListDialogField extends DialogField { /** * Sets a button enabled or disabled. - */ + */ public void enableButton(int index, boolean enable) { if (fButtonsEnabled != null && index < fButtonsEnabled.length) { - fButtonsEnabled[index]= enable; + fButtonsEnabled[index] = enable; updateButtonState(); } } // ------ model access - + /** * Sets the elements shown in the list. */ public void setElements(List elements) { - fElements= new ArrayList(elements); + fElements = new ArrayList(elements); if (fTable != null) { fTable.refresh(); } @@ -455,30 +453,30 @@ public class ListDialogField extends DialogField { /** * Gets the elements shown in the list. * The list returned is a copy, so it can be modified by the user. - */ + */ public List getElements() { return new ArrayList(fElements); } /** * Gets the elements shown at the given index. - */ + */ public Object getElement(int index) { return fElements.get(index); - } + } /** * Replace an element. - */ - public void replaceElement(Object oldElement, Object newElement) throws IllegalArgumentException { - int idx= fElements.indexOf(oldElement); + */ + public void replaceElement(Object oldElement, Object newElement) throws IllegalArgumentException { + int idx = fElements.indexOf(oldElement); if (idx != -1) { if (oldElement.equals(newElement) || fElements.contains(newElement)) { return; } fElements.set(idx, newElement); if (fTable != null) { - List selected= getSelectedElements(); + List selected = getSelectedElements(); if (selected.remove(oldElement)) { selected.add(newElement); } @@ -489,12 +487,12 @@ public class ListDialogField extends DialogField { } else { throw new IllegalArgumentException(); } - } + } /** * Adds an element at the end of the list. - */ - public void addElement(Object element) { + */ + public void addElement(Object element) { if (fElements.contains(element)) { return; } @@ -507,19 +505,19 @@ public class ListDialogField extends DialogField { /** * Adds elements at the end of the list. - */ + */ public void addElements(List elements) { - int nElements= elements.size(); - + int nElements = elements.size(); + if (nElements > 0) { // filter duplicated - ArrayList elementsToAdd= new ArrayList(nElements); - - for (int i= 0; i < nElements; i++) { - Object elem= elements.get(i); + ArrayList elementsToAdd = new ArrayList(nElements); + + for (int i = 0; i < nElements; i++) { + Object elem = elements.get(i); if (!fElements.contains(elem)) { elementsToAdd.add(elem); - } + } } fElements.addAll(elementsToAdd); if (fTable != null) { @@ -527,11 +525,11 @@ public class ListDialogField extends DialogField { } dialogFieldChanged(); } - } + } /** * Adds an element at a position. - */ + */ public void insertElementAt(Object element, int index) { if (fElements.contains(element)) { return; @@ -540,14 +538,13 @@ public class ListDialogField extends DialogField { if (fTable != null) { fTable.add(element); } - - dialogFieldChanged(); - } + dialogFieldChanged(); + } /** * Adds an element at a position. - */ + */ public void removeAllElements() { if (fElements.size() > 0) { fElements.clear(); @@ -557,10 +554,10 @@ public class ListDialogField extends DialogField { dialogFieldChanged(); } } - + /** * Removes an element from the list. - */ + */ public void removeElement(Object element) throws IllegalArgumentException { if (fElements.remove(element)) { if (fTable != null) { @@ -574,7 +571,7 @@ public class ListDialogField extends DialogField { /** * Removes elements from the list. - */ + */ public void removeElements(List elements) { if (elements.size() > 0) { fElements.removeAll(elements); @@ -587,41 +584,39 @@ public class ListDialogField extends DialogField { /** * Gets the number of elements - */ + */ public int getSize() { return fElements.size(); } - public void selectElements(ISelection selection) { - fSelectionWhenEnabled= selection; + fSelectionWhenEnabled = selection; if (fTable != null) { fTable.setSelection(selection, true); } } - + public void selectFirstElement() { - Object element= null; + Object element = null; if (fViewerSorter != null) { - Object[] arr= fElements.toArray(); + Object[] arr = fElements.toArray(); fViewerSorter.sort(fTable, arr); if (arr.length > 0) { - element= arr[0]; + element = arr[0]; } } else { if (fElements.size() > 0) { - element= fElements.get(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(); + Display d = fTableControl.getDisplay(); d.asyncExec(new Runnable() { @Override public void run() { @@ -632,76 +627,75 @@ public class ListDialogField extends DialogField { }); } } - + /** * Refreshes the table. */ public void refresh() { fTable.refresh(); } - + // ------- list maintenance - + private List moveUp(List elements, List move) { - int nElements= elements.size(); - List res= new ArrayList(nElements); - Object floating= null; - for (int i= 0; i < nElements; i++) { - Object curr= elements.get(i); + int nElements = elements.size(); + List res = new ArrayList(nElements); + Object floating = null; + for (int i = 0; i < nElements; i++) { + Object curr = elements.get(i); if (move.contains(curr)) { res.add(curr); } else { if (floating != null) { res.add(floating); } - floating= curr; + floating = curr; } } if (floating != null) { res.add(floating); } return res; - } - + } + private void moveUp(List toMoveUp) { if (toMoveUp.size() > 0) { setElements(moveUp(fElements, toMoveUp)); fTable.reveal(toMoveUp.get(0)); } } - + private void moveDown(List toMoveDown) { if (toMoveDown.size() > 0) { setElements(reverse(moveUp(reverse(fElements), toMoveDown))); fTable.reveal(toMoveDown.get(toMoveDown.size() - 1)); } } - + private List reverse(List p) { - List reverse= new ArrayList(p.size()); - for (int i= p.size()-1; i >= 0; i--) { + List reverse = new ArrayList(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= fTableControl.getSelectionIndices(); - for (int i= 0; i < indc.length; i++) { + int[] indc = fTableControl.getSelectionIndices(); + for (int i = 0; i < indc.length; i++) { if (indc[i] != i) { return true; } @@ -709,29 +703,29 @@ public class ListDialogField extends DialogField { } return false; } - + private boolean canMoveDown() { if (isOkToUse(fTableControl)) { - int[] indc= fTableControl.getSelectionIndices(); - int k= fElements.size() - 1; - for (int i= indc.length - 1; i >= 0 ; i--, k--) { + int[] indc = fTableControl.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 getSelectedElements() { - List result= new ArrayList(); + List result = new ArrayList(); if (fTable != null) { - ISelection selection= fTable.getSelection(); + ISelection selection = fTable.getSelection(); if (selection instanceof IStructuredSelection) { - Iterator iter= ((IStructuredSelection)selection).iterator(); + Iterator iter = ((IStructuredSelection) selection).iterator(); while (iter.hasNext()) { result.add(iter.next()); } @@ -739,44 +733,41 @@ public class ListDialogField extends DialogField { } return result; } - + // ------- ListViewerAdapter - + private class ListViewerAdapter implements IStructuredContentProvider, ISelectionChangedListener { // ------- ITableContentProvider Interface ------------ - + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { // will never happen } - + @Override public void dispose() { } - + @Override public Object[] getElements(Object obj) { return fElements.toArray(); } - + // ------- ISelectionChangedListener Interface ------------ - + @Override public void selectionChanged(SelectionChangedEvent event) { doListSelected(event); } } - - + protected void doListSelected(SelectionChangedEvent event) { updateButtonState(); if (fListAdapter != null) { fListAdapter.selectionChanged(this); } - } - - + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/SelectionButtonDialogField.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/SelectionButtonDialogField.java index 6fadb1b8b61..d36663d3fd2 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/SelectionButtonDialogField.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/SelectionButtonDialogField.java @@ -26,7 +26,7 @@ import org.eclipse.swt.widgets.Control; * Dialog Field containing a single button: e.g. radio or checkbox button. */ public class SelectionButtonDialogField extends DialogField { - + private Button fButton; private boolean fIsSelected; private DialogField[] fAttachedDialogFields; @@ -38,11 +38,11 @@ public class SelectionButtonDialogField extends DialogField { */ public SelectionButtonDialogField(int buttonStyle) { super(); - fIsSelected= false; - fAttachedDialogFields= null; - fButtonStyle= buttonStyle; + 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. @@ -54,20 +54,20 @@ public class SelectionButtonDialogField extends 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++) { + 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++) { + for (int i = 0; i < fAttachedDialogFields.length; i++) { if (fAttachedDialogFields[i] == editor) { return true; } @@ -75,50 +75,50 @@ public class SelectionButtonDialogField extends DialogField { } 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; + + 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 + return 1; + } + + // ------- ui creation /** * Returns the selection button widget. When called the first time, the widget will be created. * @param 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 = new Button(group, fButtonStyle); + fButton.setFont(group.getFont()); fButton.setText(fLabelText); fButton.setEnabled(isEnabled()); fButton.setSelection(fIsSelected); @@ -127,30 +127,31 @@ public class SelectionButtonDialogField extends DialogField { public void widgetDefaultSelected(SelectionEvent e) { doWidgetSelected(e); } + @Override 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; + fIsSelected = newState; if (fAttachedDialogFields != null) { - boolean focusSet= false; - for (int i= 0; i < fAttachedDialogFields.length; i++) { + boolean focusSet = false; + for (int i = 0; i < fAttachedDialogFields.length; i++) { fAttachedDialogFields[i].setEnabled(fIsSelected); if (fIsSelected && !focusSet) { - focusSet= fAttachedDialogFields[i].setFocus(); + focusSet = fAttachedDialogFields[i].setFocus(); } } } @@ -158,10 +159,10 @@ public class SelectionButtonDialogField extends DialogField { } else if (fButtonStyle == SWT.PUSH) { dialogFieldChanged(); } - } + } + + // ------ model access - // ------ model access - /** * Returns the selection state of the button. */ @@ -171,7 +172,7 @@ public class SelectionButtonDialogField extends DialogField { /** * Sets the selection state of the button. - */ + */ public void setSelection(boolean selected) { changeValue(selected); if (isOkToUse(fButton)) { @@ -183,16 +184,13 @@ public class SelectionButtonDialogField extends DialogField { /* * @see DialogField#updateEnableState - */ + */ @Override protected void updateEnableState() { super.updateEnableState(); if (isOkToUse(fButton)) { fButton.setEnabled(isEnabled()); - } + } } - - - - + }
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/SelectionButtonDialogFieldGroup.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/SelectionButtonDialogFieldGroup.java index 93bca90831a..fc92171323b 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/SelectionButtonDialogFieldGroup.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/SelectionButtonDialogFieldGroup.java @@ -29,96 +29,95 @@ import org.eclipse.swt.widgets.Label; * 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; - + private int fButtonsStyle; + /** * Creates a group without border. */ public SelectionButtonDialogFieldGroup(int buttonsStyle, String[] buttonNames, int nColumns) { - this(buttonsStyle, buttonNames, nColumns, SWT.NONE); - } - - + 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; + 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 (buttonsStyle == SWT.RADIO) { - fButtonsSelected[0]= true; + fButtonsSelected[0] = true; } - - fGroupBorderStyle= borderStyle; - fGroupNumberOfColumns= (nColumns <= 0) ? nButtons : nColumns; - - fButtonsStyle= buttonsStyle; - + + 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 label = getLabelControl(parent); label.setLayoutData(gridDataForLabel(1)); - - Composite buttonsgroup= getSelectionButtonsGroup(parent); - GridData gd= new GridData(); - gd.horizontalSpan= nColumns - 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; + 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 button = new Button(group, fButtonsStyle | SWT.LEFT); + button.setFont(group.getFont()); button.setText(fButtonNames[index]); button.setEnabled(isEnabled() && fButtonsEnabled[index]); button.setSelection(fButtonsSelected[index]); @@ -135,43 +134,44 @@ public class SelectionButtonDialogFieldGroup extends DialogField { public Composite getSelectionButtonsGroup(Composite parent) { if (fButtonComposite == null) { assertCompositeNotNull(parent); - - GridLayout layout= new GridLayout(); - layout.makeColumnsEqualWidth= true; - layout.numColumns= fGroupNumberOfColumns; - + + GridLayout layout = new GridLayout(); + layout.makeColumnsEqualWidth = true; + layout.numColumns = fGroupNumberOfColumns; + if (fGroupBorderStyle != SWT.NONE) { - Group group= new Group(parent, fGroupBorderStyle); + Group group = new Group(parent, fGroupBorderStyle); if (fLabelText != null && fLabelText.length() > 0) { group.setText(fLabelText); } - fButtonComposite= group; + fButtonComposite = group; } else { - fButtonComposite= new Composite(parent, SWT.NULL); - layout.marginHeight= 0; - layout.marginWidth= 0; + fButtonComposite = new Composite(parent, SWT.NULL); + layout.marginHeight = 0; + layout.marginWidth = 0; } fButtonComposite.setLayout(layout); - - SelectionListener listener= new SelectionListener() { + + SelectionListener listener = new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { doWidgetSelected(e); } + @Override 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 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++) { + int nRows = nButtons / fGroupNumberOfColumns; + int nFillElements = nRows * fGroupNumberOfColumns - nButtons; + for (int i = 0; i < nFillElements; i++) { createEmptySpace(fButtonComposite); } } @@ -180,26 +180,26 @@ public class SelectionButtonDialogFieldGroup extends DialogField { /** * 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++) { + Button button = (Button) e.widget; + for (int i = 0; i < fButtons.length; i++) { if (fButtons[i] == button) { - fButtonsSelected[i]= button.getSelection(); + fButtonsSelected[i] = button.getSelection(); dialogFieldChanged(); return; } } - } - - // ------ model access + } + + // ------ model access /** * Returns the selection state of a button contained in the group. @@ -211,16 +211,16 @@ public class SelectionButtonDialogFieldGroup extends DialogField { } 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; + fButtonsSelected[index] = selected; if (fButtons != null) { - Button button= fButtons[index]; + Button button = fButtons[index]; if (isOkToUse(button)) { button.setSelection(selected); } @@ -230,33 +230,33 @@ public class SelectionButtonDialogFieldGroup extends DialogField { } // ------ 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]; + 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; + fButtonsEnabled[index] = enable; if (fButtons != null) { - Button button= fButtons[index]; + Button button = fButtons[index]; if (isOkToUse(button)) { button.setEnabled(isEnabled() && enable); } } } - } + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/Separator.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/Separator.java index 2c84158a282..19ad7b63b6d 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/Separator.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/Separator.java @@ -23,41 +23,41 @@ import org.eclipse.swt.widgets.Label; * 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; + 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); + + 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); @@ -65,33 +65,33 @@ public class Separator extends DialogField { /* * @see DialogField#getNumberOfControls - */ + */ @Override public int getNumberOfControls() { - return 1; + 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; + GridData gd = new GridData(); + gd.horizontalAlignment = GridData.FILL; + gd.verticalAlignment = GridData.BEGINNING; + gd.heightHint = height; + gd.horizontalSpan = span; return gd; } - - // ------- ui creation + + // ------- 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); - } + fSeparator = new Label(parent, fStyle); + } return fSeparator; } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/StringButtonDialogField.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/StringButtonDialogField.java index 93c60fa0fb8..557ba1e227e 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/StringButtonDialogField.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/StringButtonDialogField.java @@ -28,84 +28,84 @@ import org.eclipse.swt.widgets.Text; * 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; + fStringButtonAdapter = adapter; + fBrowseButtonLabel = "!Browse...!"; //$NON-NLS-1$ + fButtonEnabled = true; } /** * Sets the label of the button. */ public void setButtonLabel(String label) { - fBrowseButtonLabel= 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 label = getLabelControl(parent); label.setLayoutData(gridDataForLabel(1)); - Text text= getTextControl(parent); + Text text = getTextControl(parent); text.setLayoutData(gridDataForText(nColumns - 2)); - Button button= getChangeControl(parent); + Button button = getChangeControl(parent); button.setLayoutData(gridDataForButton(button, 1)); - + return new Control[] { label, text, button }; - } + } /* * @see DialogField#getNumberOfControls - */ + */ @Override public int getNumberOfControls() { - return 3; + 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); + GridData gd = new GridData(); + gd.horizontalAlignment = GridData.FILL; + gd.grabExcessHorizontalSpace = false; + gd.horizontalSpan = span; + gd.widthHint = SWTUtil.getButtonWidthHint(button); return gd; - } - - // ------- ui creation + } + + // ------- 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 = new Button(parent, SWT.PUSH); fBrowseButton.setText(fBrowseButtonLabel); fBrowseButton.setEnabled(isEnabled() && fButtonEnabled); fBrowseButton.addSelectionListener(new SelectionListener() { @@ -113,18 +113,19 @@ public class StringButtonDialogField extends StringDialogField { public void widgetDefaultSelected(SelectionEvent e) { changeControlPressed(); } + @Override public void widgetSelected(SelectionEvent e) { changeControlPressed(); } - }); - + }); + } return fBrowseButton; } - + // ------ enable / disable management - + /** * Sets the enable state of the button. */ @@ -132,17 +133,17 @@ public class StringButtonDialogField extends StringDialogField { if (isOkToUse(fBrowseButton)) { fBrowseButton.setEnabled(isEnabled() && enable); } - fButtonEnabled= enable; + fButtonEnabled = enable; } /* * @see DialogField#updateEnableState - */ + */ @Override protected void updateEnableState() { super.updateEnableState(); if (isOkToUse(fBrowseButton)) { fBrowseButton.setEnabled(isEnabled() && fButtonEnabled); } - } + } }
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/StringButtonStatusDialogField.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/StringButtonStatusDialogField.java index 7d6683a0181..9296ad582ae 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/StringButtonStatusDialogField.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/StringButtonStatusDialogField.java @@ -29,32 +29,32 @@ import org.eclipse.swt.widgets.Text; * additional information about the current element chosen. */ public class StringButtonStatusDialogField extends StringButtonDialogField { - + private Label fStatusLabelControl; - private Object fStatus; // String or ImageDescriptor - + private Object fStatus; // String or ImageDescriptor + private String fWidthHintString; - private int fWidthHint; - + private int fWidthHint; + public StringButtonStatusDialogField(IStringButtonAdapter adapter) { super(adapter); - fStatus= null; - fWidthHintString= null; - fWidthHint= -1; + fStatus = null; + fWidthHintString = null; + fWidthHint = -1; } - + // ------ set status /** * Sets the status string. - */ + */ public void setStatus(String status) { if (isOkToUse(fStatusLabelControl)) { fStatusLabelControl.setText(status); } - fStatus= status; + fStatus = status; } - + /** * Sets the status image. * Caller is responsible to dispose image @@ -67,106 +67,106 @@ public class StringButtonStatusDialogField extends StringButtonDialogField { fStatusLabelControl.setImage(image); } } - fStatus= image; - } + fStatus = image; + } /** * Sets the staus string hint of the status label. * The string is used to calculate the size of the status label. - */ + */ public void setStatusWidthHint(String widthHintString) { - fWidthHintString= widthHintString; - fWidthHint= -1; + fWidthHintString = widthHintString; + fWidthHint = -1; } - + /** * Sets the width hint of the status label. */ public void setStatusWidthHint(int widthHint) { - fWidthHint= widthHint; - fWidthHintString= null; + fWidthHint = widthHint; + fWidthHintString = null; } - - // ------- layout helpers + + // ------- layout helpers /* * @see DialogField#doFillIntoGrid - */ + */ @Override public Control[] doFillIntoGrid(Composite parent, int nColumns) { assertEnoughColumns(nColumns); - - Label label= getLabelControl(parent); + + Label label = getLabelControl(parent); label.setLayoutData(gridDataForLabel(1)); - Text text= getTextControl(parent); + Text text = getTextControl(parent); text.setLayoutData(gridDataForText(nColumns - 3)); - Label status= getStatusLabelControl(parent); + Label status = getStatusLabelControl(parent); status.setLayoutData(gridDataForStatusLabel(parent, 1)); - Button button= getChangeControl(parent); + Button button = getChangeControl(parent); button.setLayoutData(gridDataForButton(button, 1)); - + return new Control[] { label, text, status, button }; } - + /* * @see DialogField#getNumberOfControls */ @Override public int getNumberOfControls() { - return 4; + return 4; } - + protected GridData gridDataForStatusLabel(Control aControl, int span) { - GridData gd= new GridData(); - gd.horizontalAlignment= GridData.BEGINNING; - gd.grabExcessHorizontalSpace= false; - gd.horizontalIndent= 0; + GridData gd = new GridData(); + gd.horizontalAlignment = GridData.BEGINNING; + gd.grabExcessHorizontalSpace = false; + gd.horizontalIndent = 0; if (fWidthHintString != null) { - GC gc= new GC(aControl); - gd.widthHint= gc.textExtent(fWidthHintString).x; + GC gc = new GC(aControl); + gd.widthHint = gc.textExtent(fWidthHintString).x; gc.dispose(); } else if (fWidthHint != -1) { - gd.widthHint= fWidthHint; + gd.widthHint = fWidthHint; } else { - gd.widthHint= SWT.DEFAULT; - } + gd.widthHint = SWT.DEFAULT; + } return gd; } - - // ------- ui creation + + // ------- ui creation /** * Creates or returns the created status label widget. * @param parent The parent composite or <code>null</code> when the widget has * already been created. - */ + */ public Label getStatusLabelControl(Composite parent) { if (fStatusLabelControl == null) { - assertCompositeNotNull(parent); - fStatusLabelControl= new Label(parent, SWT.LEFT); + assertCompositeNotNull(parent); + fStatusLabelControl = new Label(parent, SWT.LEFT); fStatusLabelControl.setFont(parent.getFont()); fStatusLabelControl.setEnabled(isEnabled()); if (fStatus instanceof Image) { - fStatusLabelControl.setImage((Image)fStatus); + fStatusLabelControl.setImage((Image) fStatus); } else if (fStatus instanceof String) { - fStatusLabelControl.setText((String)fStatus); + fStatusLabelControl.setText((String) fStatus); } else { // must be null } } return fStatusLabelControl; } - + // ------ enable / disable management /* * @see DialogField#updateEnableState - */ + */ @Override protected void updateEnableState() { super.updateEnableState(); if (isOkToUse(fStatusLabelControl)) { fStatusLabelControl.setEnabled(isEnabled()); } - } + } }
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/StringDialogField.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/StringDialogField.java index ce17fbbf112..320bc2fa9cf 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/StringDialogField.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogfields/StringDialogField.java @@ -26,51 +26,51 @@ import org.eclipse.swt.widgets.Text; * Dialog field containing a label and a text control. */ public class StringDialogField extends DialogField { - + private String fText; private Text fTextControl; private ModifyListener fModifyListener; - + public StringDialogField() { super(); - fText= ""; //$NON-NLS-1$ + fText = ""; //$NON-NLS-1$ } - + // ------- layout helpers - + /* * @see DialogField#doFillIntoGrid */ @Override public Control[] doFillIntoGrid(Composite parent, int nColumns) { assertEnoughColumns(nColumns); - - Label label= getLabelControl(parent); + + Label label = getLabelControl(parent); label.setLayoutData(gridDataForLabel(1)); - Text text= getTextControl(parent); + Text text = getTextControl(parent); text.setLayoutData(gridDataForText(nColumns - 1)); - + return new Control[] { label, text }; - } + } /* * @see DialogField#getNumberOfControls */ @Override public int getNumberOfControls() { - return 2; + return 2; } - + protected static GridData gridDataForText(int span) { - GridData gd= new GridData(); - gd.horizontalAlignment= GridData.FILL; - gd.grabExcessHorizontalSpace= false; - gd.horizontalSpan= span; + GridData gd = new GridData(); + gd.horizontalAlignment = GridData.FILL; + gd.grabExcessHorizontalSpace = false; + gd.horizontalSpan = span; return gd; - } - + } + // ------- focus methods - + /* * @see DialogField#setFocus */ @@ -82,86 +82,86 @@ public class StringDialogField extends DialogField { } return true; } - - // ------- ui creation + + // ------- 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() { + fModifyListener = new ModifyListener() { @Override public void modifyText(ModifyEvent e) { doModifyText(e); } }; - - fTextControl= new Text(parent, SWT.SINGLE | SWT.BORDER); + + 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(); + fText = fTextControl.getText(); } dialogFieldChanged(); - } - + } + // ------ enable / disable management - + /* * @see DialogField#updateEnableState - */ + */ @Override protected void updateEnableState() { - super.updateEnableState(); + super.updateEnableState(); if (isOkToUse(fTextControl)) { fTextControl.setEnabled(isEnabled()); - } - } - - // ------ text access - + } + } + + // ------ 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; + 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; + fText = text; if (isOkToUse(fTextControl)) { fTextControl.removeModifyListener(fModifyListener); fTextControl.setText(text); fTextControl.addModifyListener(fModifyListener); } } - + }
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogs/AddEventBreakpointDialog.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogs/AddEventBreakpointDialog.java index 171a9dd3340..f500d1980a2 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogs/AddEventBreakpointDialog.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogs/AddEventBreakpointDialog.java @@ -83,11 +83,12 @@ public class AddEventBreakpointDialog extends Dialog implements ModifyListener, .getBreakpointUIContributions(modelId, ICEventBreakpoint.C_EVENT_BREAKPOINT_MARKER, map); for (ICBreakpointsUIContribution con : cons) { - if (con.getId().equals(ICEventBreakpoint.EVENT_TYPE_ID)) continue; - if (con.getId().equals(ICBreakpointType.TYPE)) continue; - FieldEditor fieldEditor = con.getFieldEditor(con.getId(), con.getLabel(), - parent); - getPreferenceStore().setValue(con.getId(),""); //$NON-NLS-1$ + if (con.getId().equals(ICEventBreakpoint.EVENT_TYPE_ID)) + continue; + if (con.getId().equals(ICBreakpointType.TYPE)) + continue; + FieldEditor fieldEditor = con.getFieldEditor(con.getId(), con.getLabel(), parent); + getPreferenceStore().setValue(con.getId(), ""); //$NON-NLS-1$ if (fieldEditor != null) addField(fieldEditor); } @@ -100,7 +101,7 @@ public class AddEventBreakpointDialog extends Dialog implements ModifyListener, /** * Constructor - * + * * @param parentShell */ public AddEventBreakpointDialog(Shell parentShell) { @@ -118,7 +119,7 @@ public class AddEventBreakpointDialog extends Dialog implements ModifyListener, private void loadEventTypes() { ICBreakpointsUIContribution[] cons = factory.getBreakpointUIContributions(debugModelId, - ICEventBreakpoint.C_EVENT_BREAKPOINT_MARKER, null); + ICEventBreakpoint.C_EVENT_BREAKPOINT_MARKER, null); for (int i = 0; i < cons.length; i++) { ICBreakpointsUIContribution con = cons[i]; if (con.getId().equals(ICEventBreakpoint.EVENT_TYPE_ID)) { @@ -133,7 +134,7 @@ public class AddEventBreakpointDialog extends Dialog implements ModifyListener, /* * (non-Javadoc) - * + * * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) */ @Override @@ -146,8 +147,8 @@ public class AddEventBreakpointDialog extends Dialog implements ModifyListener, Composite composite = new Composite(parent, SWT.None); GridData layoutData = new GridData(GridData.FILL_BOTH); - - layoutData.heightHint=100; + + layoutData.heightHint = 100; composite.setLayoutData(layoutData); composite.setLayout(new GridLayout(1, false)); @@ -222,12 +223,13 @@ public class AddEventBreakpointDialog extends Dialog implements ModifyListener, } } - public boolean isActive(){ - return fIdLabelMap.size()>0; + public boolean isActive() { + return fIdLabelMap.size() > 0; } + /* * (non-Javadoc) - * + * * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) */ @Override @@ -238,7 +240,7 @@ public class AddEventBreakpointDialog extends Dialog implements ModifyListener, /* * (non-Javadoc) - * + * * @see org.eclipse.jface.dialogs.Dialog#okPressed() */ @Override @@ -251,8 +253,7 @@ public class AddEventBreakpointDialog extends Dialog implements ModifyListener, IPreferenceStore preferenceStore = page.getPreferenceStore(); if (preferenceStore != null) { fEventArgument = preferenceStore.getString(ICEventBreakpoint.EVENT_ARG); - } - else + } else fEventArgument = null; } @@ -271,7 +272,7 @@ public class AddEventBreakpointDialog extends Dialog implements ModifyListener, /* * (non-Javadoc) - * + * * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent) */ @Override @@ -284,7 +285,7 @@ public class AddEventBreakpointDialog extends Dialog implements ModifyListener, /* * (non-Javadoc) - * + * * @see org.eclipse.jface.dialogs.TrayDialog#createButtonBar(org.eclipse.swt.widgets.Composite) */ @Override @@ -294,7 +295,7 @@ public class AddEventBreakpointDialog extends Dialog implements ModifyListener, /* * (non-Javadoc) - * + * * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) */ @Override @@ -304,7 +305,7 @@ public class AddEventBreakpointDialog extends Dialog implements ModifyListener, /* * (non-Javadoc) - * + * * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) */ @Override @@ -338,8 +339,7 @@ public class AddEventBreakpointDialog extends Dialog implements ModifyListener, @Override protected void createButtonsForButtonBar(Composite parent) { // override so we can change the initial okay enabled state - createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true).setEnabled( - okayEnabled()); + createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true).setEnabled(okayEnabled()); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogs/DialogMessages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogs/DialogMessages.java index 9395bd06a8b..b6c86e08148 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogs/DialogMessages.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/dialogs/DialogMessages.java @@ -20,16 +20,15 @@ public class DialogMessages { private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.dialogs.DialogMessages"; //$NON-NLS-1$ - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); private DialogMessages() { } - public static String getString( String key ) { + public static String getString(String key) { try { - return RESOURCE_BUNDLE.getString( key ); - } - catch( MissingResourceException e ) { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { return '!' + key + '!'; } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/commands/DisassemblyDisplayModeHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/commands/DisassemblyDisplayModeHandler.java index 03ae86a3317..3684ce7f473 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/commands/DisassemblyDisplayModeHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/commands/DisassemblyDisplayModeHandler.java @@ -38,68 +38,67 @@ import org.eclipse.ui.texteditor.ITextEditor; public class DisassemblyDisplayModeHandler extends AbstractHandler implements IElementUpdater { - private static final String ID_PARAMETER_MODE = "org.eclipse.cdt.debug.command.disassemblyDisplayMode.parameterMode"; //$NON-NLS-1$ + private static final String ID_PARAMETER_MODE = "org.eclipse.cdt.debug.command.disassemblyDisplayMode.parameterMode"; //$NON-NLS-1$ - /* (non-Javadoc) - * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) - */ - @Override - public Object execute( ExecutionEvent event ) throws ExecutionException { - DisassemblyEditorPresentation presentation = getEditorPresentation( event ); - if ( presentation != null ) { - String param = event.getParameter( ID_PARAMETER_MODE ); - if ( IInternalCDebugUIConstants.DISASM_DISPLAY_MODE_INSTRUCTIONS.equals( param ) ) { - presentation.setShowIntstructions( !presentation.showIntstructions() ); - } - else if ( IInternalCDebugUIConstants.DISASM_DISPLAY_MODE_SOURCE.equals( param ) ) { - presentation.setShowSource( !presentation.showSource() ); - } - } - return null; - } + /* (non-Javadoc) + * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) + */ + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + DisassemblyEditorPresentation presentation = getEditorPresentation(event); + if (presentation != null) { + String param = event.getParameter(ID_PARAMETER_MODE); + if (IInternalCDebugUIConstants.DISASM_DISPLAY_MODE_INSTRUCTIONS.equals(param)) { + presentation.setShowIntstructions(!presentation.showIntstructions()); + } else if (IInternalCDebugUIConstants.DISASM_DISPLAY_MODE_SOURCE.equals(param)) { + presentation.setShowSource(!presentation.showSource()); + } + } + return null; + } - /* (non-Javadoc) - * @see org.eclipse.ui.commands.IElementUpdater#updateElement(org.eclipse.ui.menus.UIElement, java.util.Map) - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.ui.commands.IElementUpdater#updateElement(org.eclipse.ui.menus.UIElement, java.util.Map) + */ + @Override @SuppressWarnings("rawtypes") - public void updateElement( UIElement element, Map parameters ) { - IWorkbenchPartSite site = element.getServiceLocator().getService( IWorkbenchPartSite.class ); - if ( site != null ) { - IWorkbenchPart part = site.getPart(); - if ( part instanceof ITextEditor ) { - IEditorInput input = ((ITextEditor)part).getEditorInput(); - if ( input instanceof DisassemblyEditorInput ) { - IDocumentProvider dp = ((ITextEditor)part).getDocumentProvider(); - if ( dp instanceof DisassemblyDocumentProvider ) { - IDocumentPresentation p = ((DisassemblyDocumentProvider)dp).getDocumentPresentation( input ); - if ( p instanceof DisassemblyEditorPresentation ) { - DisassemblyEditorPresentation presentation = (DisassemblyEditorPresentation)p; - String param = (String)parameters.get( ID_PARAMETER_MODE ); - if ( IInternalCDebugUIConstants.DISASM_DISPLAY_MODE_INSTRUCTIONS.equals( param ) ) { - element.setChecked( presentation.showIntstructions() ); - } - else if ( IInternalCDebugUIConstants.DISASM_DISPLAY_MODE_SOURCE.equals( param ) ) { - element.setChecked( presentation.showSource() ); - } - } - } - } - } - } - } + public void updateElement(UIElement element, Map parameters) { + IWorkbenchPartSite site = element.getServiceLocator().getService(IWorkbenchPartSite.class); + if (site != null) { + IWorkbenchPart part = site.getPart(); + if (part instanceof ITextEditor) { + IEditorInput input = ((ITextEditor) part).getEditorInput(); + if (input instanceof DisassemblyEditorInput) { + IDocumentProvider dp = ((ITextEditor) part).getDocumentProvider(); + if (dp instanceof DisassemblyDocumentProvider) { + IDocumentPresentation p = ((DisassemblyDocumentProvider) dp).getDocumentPresentation(input); + if (p instanceof DisassemblyEditorPresentation) { + DisassemblyEditorPresentation presentation = (DisassemblyEditorPresentation) p; + String param = (String) parameters.get(ID_PARAMETER_MODE); + if (IInternalCDebugUIConstants.DISASM_DISPLAY_MODE_INSTRUCTIONS.equals(param)) { + element.setChecked(presentation.showIntstructions()); + } else if (IInternalCDebugUIConstants.DISASM_DISPLAY_MODE_SOURCE.equals(param)) { + element.setChecked(presentation.showSource()); + } + } + } + } + } + } + } - private DisassemblyEditorPresentation getEditorPresentation( ExecutionEvent event ) throws ExecutionException { - ISelection s = HandlerUtil.getActiveMenuEditorInputChecked( event ); - if ( s instanceof IStructuredSelection ) { - Object o = ((IStructuredSelection)s).getFirstElement(); - if ( o instanceof DisassemblyEditorInput ) { - DisassemblyDocumentProvider dp = CDebugUIPlugin.getDefault().getDisassemblyEditorManager().getDocumentProvider(); - if ( dp != null ) { - return (DisassemblyEditorPresentation)dp.getDocumentPresentation( o ); - } - } - } - return null; - } + private DisassemblyEditorPresentation getEditorPresentation(ExecutionEvent event) throws ExecutionException { + ISelection s = HandlerUtil.getActiveMenuEditorInputChecked(event); + if (s instanceof IStructuredSelection) { + Object o = ((IStructuredSelection) s).getFirstElement(); + if (o instanceof DisassemblyEditorInput) { + DisassemblyDocumentProvider dp = CDebugUIPlugin.getDefault().getDisassemblyEditorManager() + .getDocumentProvider(); + if (dp != null) { + return (DisassemblyEditorPresentation) dp.getDocumentPresentation(o); + } + } + } + return null; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/commands/OpenDisassemblyHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/commands/OpenDisassemblyHandler.java index 834aa570de5..327f0021682 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/commands/OpenDisassemblyHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/commands/OpenDisassemblyHandler.java @@ -25,29 +25,28 @@ import org.eclipse.ui.IWorkbenchSite; import org.eclipse.ui.handlers.HandlerUtil; /** - * org.eclipse.cdt.debug.internal.ui.disassembly.commands.OpenDisassemblyHandler: + * org.eclipse.cdt.debug.internal.ui.disassembly.commands.OpenDisassemblyHandler: * //TODO Add description. */ public class OpenDisassemblyHandler extends AbstractHandler { - /* (non-Javadoc) - * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) - */ - @Override - public Object execute( ExecutionEvent event ) throws ExecutionException { - ISelection s = HandlerUtil.getCurrentSelection( event ); - if ( s instanceof IStructuredSelection ) { - Object element = ((IStructuredSelection)s).getFirstElement(); - IWorkbenchSite site = HandlerUtil.getActiveSite( event ); - if ( element != null && site != null ) { - try { - CDebugUIPlugin.getDefault().getDisassemblyEditorManager().openEditor( site.getPage(), element ); - } - catch( DebugException e ) { - throw new ExecutionException( "Error openning disassembly.", e ); - } - } - } - return null; - } + /* (non-Javadoc) + * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) + */ + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + ISelection s = HandlerUtil.getCurrentSelection(event); + if (s instanceof IStructuredSelection) { + Object element = ((IStructuredSelection) s).getFirstElement(); + IWorkbenchSite site = HandlerUtil.getActiveSite(event); + if (element != null && site != null) { + try { + CDebugUIPlugin.getDefault().getDisassemblyEditorManager().openEditor(site.getPage(), element); + } catch (DebugException e) { + throw new ExecutionException("Error openning disassembly.", e); + } + } + } + return null; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/commands/SetSteppingModeHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/commands/SetSteppingModeHandler.java index d3d127a5a23..e2150a37958 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/commands/SetSteppingModeHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/commands/SetSteppingModeHandler.java @@ -34,76 +34,76 @@ import org.eclipse.ui.handlers.HandlerUtil; import org.eclipse.ui.menus.UIElement; /** - * org.eclipse.cdt.debug.internal.ui.disassembly.commands.SetSteppingModeHandler: + * org.eclipse.cdt.debug.internal.ui.disassembly.commands.SetSteppingModeHandler: * //TODO Add description. */ public class SetSteppingModeHandler extends AbstractHandler implements IElementUpdater { - private static final String ID_PARAMETER_MODE = "com.arm.eclipse.rvd.ui.command.steppingMode.parameterMode"; //$NON-NLS-1$ + private static final String ID_PARAMETER_MODE = "com.arm.eclipse.rvd.ui.command.steppingMode.parameterMode"; //$NON-NLS-1$ - private String fCurrentValue = null; + private String fCurrentValue = null; - public SetSteppingModeHandler() { - super(); - fCurrentValue = CDebugCorePlugin.getDefault().getPluginPreferences().getString( ICDebugConstants.PREF_STEP_MODE ); - } + public SetSteppingModeHandler() { + super(); + fCurrentValue = CDebugCorePlugin.getDefault().getPluginPreferences().getString(ICDebugConstants.PREF_STEP_MODE); + } - /* (non-Javadoc) - * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) - */ - @Override - public Object execute( ExecutionEvent event ) throws ExecutionException { - String param = event.getParameter( ID_PARAMETER_MODE ); - if ( param == null || param.equals( fCurrentValue ) ) - return null; - - fCurrentValue = param; - CDebugCorePlugin.getDefault().getPluginPreferences().setValue( ICDebugConstants.PREF_STEP_MODE, fCurrentValue ); + /* (non-Javadoc) + * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) + */ + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + String param = event.getParameter(ID_PARAMETER_MODE); + if (param == null || param.equals(fCurrentValue)) + return null; - IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked( event ); - ICommandService service = window.getService( ICommandService.class ); - service.refreshElements( event.getCommand().getId(), null ); + fCurrentValue = param; + CDebugCorePlugin.getDefault().getPluginPreferences().setValue(ICDebugConstants.PREF_STEP_MODE, fCurrentValue); - return null; - } + IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); + ICommandService service = window.getService(ICommandService.class); + service.refreshElements(event.getCommand().getId(), null); - /* (non-Javadoc) - * @see org.eclipse.ui.commands.IElementUpdater#updateElement(org.eclipse.ui.menus.UIElement, java.util.Map) - */ - @Override + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.commands.IElementUpdater#updateElement(org.eclipse.ui.menus.UIElement, java.util.Map) + */ + @Override @SuppressWarnings("rawtypes") - public void updateElement( UIElement element, Map parameters ) { - String param = (String)parameters.get( ID_PARAMETER_MODE ); - if ( param != null ) { - element.setChecked( ( fCurrentValue != null && fCurrentValue.equals( param ) ) ); - } - } + public void updateElement(UIElement element, Map parameters) { + String param = (String) parameters.get(ID_PARAMETER_MODE); + if (param != null) { + element.setChecked((fCurrentValue != null && fCurrentValue.equals(param))); + } + } - /* (non-Javadoc) - * @see org.eclipse.core.commands.AbstractHandler#isEnabled() - */ - @Override - public boolean isEnabled() { - IWorkbenchWindow window = CDebugUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow(); - return ( window != null && getSteppingModeTarget( window ) != null ); - } + /* (non-Javadoc) + * @see org.eclipse.core.commands.AbstractHandler#isEnabled() + */ + @Override + public boolean isEnabled() { + IWorkbenchWindow window = CDebugUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow(); + return (window != null && getSteppingModeTarget(window) != null); + } - /* (non-Javadoc) - * @see org.eclipse.core.commands.AbstractHandler#isHandled() - */ - @Override - public boolean isHandled() { - IWorkbenchWindow window = CDebugUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow(); - return ( window != null && getSteppingModeTarget( window ) != null ); - } + /* (non-Javadoc) + * @see org.eclipse.core.commands.AbstractHandler#isHandled() + */ + @Override + public boolean isHandled() { + IWorkbenchWindow window = CDebugUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow(); + return (window != null && getSteppingModeTarget(window) != null); + } - private ISteppingModeTarget getSteppingModeTarget( IWorkbenchWindow window ) { - ISelection selection = DebugUITools.getDebugContextManager().getContextService( window ).getActiveContext(); - if ( selection instanceof IStructuredSelection ) { - Object element = ((IStructuredSelection)selection).getFirstElement(); - if ( element instanceof IAdaptable ) - return ((IAdaptable)element).getAdapter( ISteppingModeTarget.class ); - } - return null; - } + private ISteppingModeTarget getSteppingModeTarget(IWorkbenchWindow window) { + ISelection selection = DebugUITools.getDebugContextManager().getContextService(window).getActiveContext(); + if (selection instanceof IStructuredSelection) { + Object element = ((IStructuredSelection) selection).getFirstElement(); + if (element instanceof IAdaptable) + return ((IAdaptable) element).getAdapter(ISteppingModeTarget.class); + } + return null; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/AbstractDisassemblyBackend.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/AbstractDisassemblyBackend.java index d48d18e93f9..859430ca30a 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/AbstractDisassemblyBackend.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/AbstractDisassemblyBackend.java @@ -49,20 +49,19 @@ public abstract class AbstractDisassemblyBackend implements IDisassemblyBackend */ public abstract BigInteger evaluateAddressExpression(String expression, boolean suppressError); - @Override public String evaluateRegister(String register) { return null; } - @Override + @Override public String getHoverInfoData(AddressRangePosition pos, String ident) { - return null; + return null; } /** * Default error handler, sub-class can override this method to provide it's own error handling. - * + * * @param status */ protected void handleError(final IStatus status) { @@ -71,7 +70,7 @@ public abstract class AbstractDisassemblyBackend implements IDisassemblyBackend public void run() { ErrorDialog.openError(fCallback.getSite().getShell(), "Error", null, status); //$NON-NLS-1$ } - }); + }); } /** @@ -80,12 +79,12 @@ public abstract class AbstractDisassemblyBackend implements IDisassemblyBackend @Override public void updateExtendedPCAnnotation(IAnnotationModel model) { } - + @Override public boolean canDisassemble() { return true; } - + @Override public BigInteger getLastKnownAddress() { return UNKNOWN_ADDRESS; diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/AddressRangePosition.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/AddressRangePosition.java index 4aff087e2ee..dff2261bb0f 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/AddressRangePosition.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/AddressRangePosition.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation *******************************************************************************/ @@ -42,7 +42,8 @@ public class AddressRangePosition extends Position { * @param length * @param valid */ - public AddressRangePosition(int offset, int length, BigInteger addressOffset, BigInteger addressLength, boolean valid) { + public AddressRangePosition(int offset, int length, BigInteger addressOffset, BigInteger addressLength, + boolean valid) { super(offset, length); fAddressOffset = addressOffset; fAddressLength = addressLength; @@ -54,8 +55,7 @@ public class AddressRangePosition extends Position { * @return */ public boolean containsAddress(BigInteger address) { - return address.compareTo(fAddressOffset) >= 0 - && address.compareTo(fAddressOffset.add(fAddressLength)) < 0; + return address.compareTo(fAddressOffset) >= 0 && address.compareTo(fAddressOffset.add(fAddressLength)) < 0; } /* (non-Javadoc) @@ -66,15 +66,15 @@ public class AddressRangePosition extends Position { // identity comparison return this == other; } - + /* (non-Javadoc) * @see org.eclipse.jface.text.Position#toString() */ @Override public String toString() { - return getClass().getSimpleName() + '@' + Integer.toHexString(System.identityHashCode(this)) - + (fValid ? "" : "[INVALID]") //$NON-NLS-1$ //$NON-NLS-2$ - + '[' + offset + ':' + length + "]->[" + fAddressOffset.toString(16) //$NON-NLS-1$ - + ':' + fAddressLength.toString(16) + ']'; + return getClass().getSimpleName() + '@' + Integer.toHexString(System.identityHashCode(this)) + + (fValid ? "" : "[INVALID]") //$NON-NLS-1$ //$NON-NLS-2$ + + '[' + offset + ':' + length + "]->[" + fAddressOffset.toString(16) //$NON-NLS-1$ + + ':' + fAddressLength.toString(16) + ']'; } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/DisassemblyPosition.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/DisassemblyPosition.java index a3ad93518ab..0c52fe8d6d0 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/DisassemblyPosition.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/DisassemblyPosition.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation *******************************************************************************/ @@ -31,12 +31,13 @@ public class DisassemblyPosition extends AddressRangePosition { * @param functionOffset * @param opcodes */ - public DisassemblyPosition(int offset, int length, BigInteger addressOffset, BigInteger addressLength, String functionOffset, BigInteger opcodes) { + public DisassemblyPosition(int offset, int length, BigInteger addressOffset, BigInteger addressLength, + String functionOffset, BigInteger opcodes) { super(offset, length, addressOffset, addressLength); fOpcodes = opcodes; fFunction = functionOffset.toCharArray(); - } - + } + /** * @return source file */ diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/DisassemblyUtils.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/DisassemblyUtils.java index 637e9ffab75..5dde9afa17a 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/DisassemblyUtils.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/DisassemblyUtils.java @@ -28,8 +28,9 @@ public class DisassemblyUtils { * Trace option. The view started out and continues to be in DSF but * backends can be non-DSF. */ - public final static boolean DEBUG = Boolean.parseBoolean(Platform.getDebugOption("org.eclipse.cdt.dsf.ui/debug/disassembly")); //$NON-NLS-1$ - + public final static boolean DEBUG = Boolean + .parseBoolean(Platform.getDebugOption("org.eclipse.cdt.dsf.ui/debug/disassembly")); //$NON-NLS-1$ + public static String getAddressText(BigInteger address) { if (address == null) { return "<null>"; //$NON-NLS-1$ @@ -47,6 +48,7 @@ public class DisassemblyUtils { CDebugUIPlugin.log(e); } } + public static BigInteger decodeAddress(String string) { if (string.startsWith("0x")) { //$NON-NLS-1$ return new BigInteger(string.substring(2), 16); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/ErrorPosition.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/ErrorPosition.java index 0cae53c945c..a2ab07b5076 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/ErrorPosition.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/ErrorPosition.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation *******************************************************************************/ @@ -40,7 +40,7 @@ public class ErrorPosition extends AddressRangePosition { public int hashCode() { return fHashCode; } - + /* (non-Javadoc) * @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.AddressRangePosition#toString() */ diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/IDisassemblyBackend.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/IDisassemblyBackend.java index 42ac8f03c2f..e2aec17959e 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/IDisassemblyBackend.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/IDisassemblyBackend.java @@ -145,7 +145,8 @@ public interface IDisassemblyBackend { * @param showDisassembly * @param linesHint */ - void retrieveDisassembly(BigInteger startAddress, BigInteger endAddress, String file, int lineNumber, int lines, boolean mixed, boolean showSymbols, boolean showDisassembly, int linesHint); + void retrieveDisassembly(BigInteger startAddress, BigInteger endAddress, String file, int lineNumber, int lines, + boolean mixed, boolean showSymbols, boolean showDisassembly, int linesHint); Object insertSource(Position pos, BigInteger address, final String file, int lineNumber); @@ -163,7 +164,8 @@ public interface IDisassemblyBackend { * @param showSymbols * @param showDisassembly */ - void retrieveDisassembly(String file, int lines, BigInteger endAddress, boolean mixed, boolean showSymbols, boolean showDisassembly); + void retrieveDisassembly(String file, int lines, BigInteger endAddress, boolean mixed, boolean showSymbols, + boolean showDisassembly); /** * Evaluate an expression for text hover @@ -197,22 +199,22 @@ public interface IDisassemblyBackend { * Called when the Disassembly view has no further use for this backend. */ void dispose(); - + /** - * Update the extended PC annotation. + * Update the extended PC annotation. */ void updateExtendedPCAnnotation(IAnnotationModel model); - + /** * This is a test for the current context. - * - * @return true if backend can perform disassemble, otherwise false + * + * @return true if backend can perform disassemble, otherwise false */ boolean canDisassemble(); - + /** * Returns the last known address, this API will be call if the selected debug context is not a stackframe. - * + * * @return the last know address, -1 if unknown */ BigInteger getLastKnownAddress(); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/IDisassemblyDocument.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/IDisassemblyDocument.java index 464c6dad737..f91d1d49f7f 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/IDisassemblyDocument.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/IDisassemblyDocument.java @@ -27,20 +27,20 @@ public interface IDisassemblyDocument { void addInvalidAddressRange(AddressRangePosition p); - AddressRangePosition insertLabel(AddressRangePosition pos, - BigInteger address, String label, boolean showLabels) + AddressRangePosition insertLabel(AddressRangePosition pos, BigInteger address, String label, boolean showLabels) throws BadLocationException; - AddressRangePosition insertDisassemblyLine(AddressRangePosition p, - BigInteger address, int intValue, String functionOffset, String instruction, - String compilationPath, int lineNumber) throws BadLocationException; + AddressRangePosition insertDisassemblyLine(AddressRangePosition p, BigInteger address, int intValue, + String functionOffset, String instruction, String compilationPath, int lineNumber) + throws BadLocationException; - AddressRangePosition insertDisassemblyLine(AddressRangePosition p, - BigInteger address, int length, String functionOffset, BigInteger opcode, - String instruction, String compilationPath, int lineNumber) + AddressRangePosition insertDisassemblyLine(AddressRangePosition p, BigInteger address, int length, + String functionOffset, BigInteger opcode, String instruction, String compilationPath, int lineNumber) throws BadLocationException; - + AddressRangePosition getDisassemblyPosition(BigInteger address); + BigInteger getAddressOfLine(int line); + int getNumberOfLines(); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/IDisassemblyPartCallback.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/IDisassemblyPartCallback.java index d704431021f..15b90547bcd 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/IDisassemblyPartCallback.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/IDisassemblyPartCallback.java @@ -23,7 +23,7 @@ import org.eclipse.ui.IWorkbenchPartSite; * into the part (editor/view) that created them. Except where noted, methods * must be invoked on the GUI thread. A disassembly backend has to call back * into the editor/view to carry out its duties. - * + * * <p> * This interface was born of the refactoring which allowed the DSF Disassembly * view to work with both DSF and CDI. Before that, the functionality of @@ -33,48 +33,76 @@ import org.eclipse.ui.IWorkbenchPartSite; * DisassemblyPart all along. Documentation for those methods were sparse, and * thus this interface is likewise. See the DisassemblyPart for any available * documentation. - * + * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ public interface IDisassemblyPartCallback { void gotoFrame(int frame); + void gotoFrameIfActive(int frame); + void updateVisibleArea(); + void updateInvalidSource(); - void retrieveDisassembly(final BigInteger startAddress, BigInteger endAddress, final int linesHint, boolean mixed, boolean ignoreFile); + + void retrieveDisassembly(final BigInteger startAddress, BigInteger endAddress, final int linesHint, boolean mixed, + boolean ignoreFile); + void insertError(BigInteger address, String message); + int getAddressSize(); + void addressSizeChanged(int addressSize); + AddressRangePosition getPositionOfAddress(BigInteger address); + void gotoFrame(int frame, BigInteger address); + void updatePC(BigInteger pc); + void doPending(); + void doScrollLocked(final Runnable doit); + void lockScroller(); + void unlockScroller(); + void insertSource(AddressRangePosition pos); + AddressRangePosition insertSource(AddressRangePosition pos, BigInteger address, final String file, int lineNumber); - AddressRangePosition insertSource(AddressRangePosition pos, BigInteger address, final String file, int firstLine, int lastLine); - void setUpdatePending(boolean pending); + + AddressRangePosition insertSource(AddressRangePosition pos, BigInteger address, final String file, int firstLine, + int lastLine); + + void setUpdatePending(boolean pending); + boolean getUpdatePending(); + void setGotoAddressPending(BigInteger address); + BigInteger getGotoAddressPending(); + IDisassemblyDocument getDocument(); + Object getStorageForFile(String file); + void gotoAddress(BigInteger address); + IWorkbenchPartSite getSite(); + boolean hasViewer(); - + /** Thread-safe */ void handleTargetSuspended(); - + /** Thread-safe */ void handleTargetResumed(); - + /** Thread-safe */ void handleTargetEnded(); - + /** Thread-safe */ - void asyncExec(Runnable runnable); + void asyncExec(Runnable runnable); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/IDisassemblyRetrieval.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/IDisassemblyRetrieval.java index 005175c6a75..c1415d97208 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/IDisassemblyRetrieval.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/IDisassemblyRetrieval.java @@ -26,11 +26,13 @@ public interface IDisassemblyRetrieval { interface AddressRequest extends IRequest { BigInteger getAddress(); + void setAddress(BigInteger address); } interface DisassemblyRequest extends IRequest { IDisassemblyBlock getDisassemblyBlock(); + void setDisassemblyBlock(IDisassemblyBlock disassemblyBlock); } @@ -52,4 +54,3 @@ public interface IDisassemblyRetrieval { boolean mixed, DisassemblyRequest disassemblyRequest); } - diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/LabelPosition.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/LabelPosition.java index a05e369daa0..fd374f84441 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/LabelPosition.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/LabelPosition.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation *******************************************************************************/ @@ -31,7 +31,7 @@ public class LabelPosition extends AddressRangePosition { super(offset, length, addressOffset, BigInteger.ZERO); fLabel = label; } - + /* (non-Javadoc) * @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.AddressRangePosition#toString() */ diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/editor/DisassemblyEditorInput.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/editor/DisassemblyEditorInput.java index e515348c398..926cfaa8938 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/editor/DisassemblyEditorInput.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/editor/DisassemblyEditorInput.java @@ -20,70 +20,70 @@ import org.eclipse.ui.IPersistableElement; public class DisassemblyEditorInput implements IEditorInput { - private Object fDebugContext; - private Object fDisassemblyContext; + private Object fDebugContext; + private Object fDisassemblyContext; - public DisassemblyEditorInput( Object debugContext, Object disassemblyContext ) { - fDisassemblyContext = disassemblyContext; - fDebugContext = debugContext; - } + public DisassemblyEditorInput(Object debugContext, Object disassemblyContext) { + fDisassemblyContext = disassemblyContext; + fDebugContext = debugContext; + } - /* (non-Javadoc) - * @see org.eclipse.ui.IEditorInput#exists() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.ui.IEditorInput#exists() + */ + @Override public boolean exists() { - // TODO Auto-generated method stub - return false; - } + // TODO Auto-generated method stub + return false; + } - /* (non-Javadoc) - * @see org.eclipse.ui.IEditorInput#getImageDescriptor() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.ui.IEditorInput#getImageDescriptor() + */ + @Override public ImageDescriptor getImageDescriptor() { - // TODO Auto-generated method stub - return null; - } + // TODO Auto-generated method stub + return null; + } - /* (non-Javadoc) - * @see org.eclipse.ui.IEditorInput#getName() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.ui.IEditorInput#getName() + */ + @Override public String getName() { - // TODO Auto-generated method stub - return ""; //$NON-NLS-1$ - } + // TODO Auto-generated method stub + return ""; //$NON-NLS-1$ + } - /* (non-Javadoc) - * @see org.eclipse.ui.IEditorInput#getPersistable() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.ui.IEditorInput#getPersistable() + */ + @Override public IPersistableElement getPersistable() { - // TODO Auto-generated method stub - return null; - } + // TODO Auto-generated method stub + return null; + } - /* (non-Javadoc) - * @see org.eclipse.ui.IEditorInput#getToolTipText() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.ui.IEditorInput#getToolTipText() + */ + @Override public String getToolTipText() { - // TODO Auto-generated method stub - return ""; //$NON-NLS-1$ - } + // TODO Auto-generated method stub + return ""; //$NON-NLS-1$ + } - @Override - public <T> T getAdapter( Class<T> adapter ) { - // TODO Auto-generated method stub - return null; - } + @Override + public <T> T getAdapter(Class<T> adapter) { + // TODO Auto-generated method stub + return null; + } - public Object getDisassemblyContext() { - return fDisassemblyContext; - } + public Object getDisassemblyContext() { + return fDisassemblyContext; + } - public Object getDebugContext() { - return fDebugContext; - } + public Object getDebugContext() { + return fDebugContext; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/editor/DisassemblyEditorManager.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/editor/DisassemblyEditorManager.java index 0bd9fa2527e..3d95bb39fa7 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/editor/DisassemblyEditorManager.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/editor/DisassemblyEditorManager.java @@ -49,294 +49,293 @@ import org.eclipse.ui.progress.UIJob; public class DisassemblyEditorManager implements IWindowListener, IDisassemblyContextListener, IPartListener2 { - private Map<Object, IEditorPart> fEditorParts; - private Map<Object, String> fOpenDisassemblyPolicy; - private Map<Object, ISteppingModeTarget> fSteppingModePolicy; - private DisassemblyDocumentProvider fDocumentProvider; - - public DisassemblyEditorManager() { - fDocumentProvider = new DisassemblyDocumentProvider(); - fEditorParts = new HashMap<Object, IEditorPart>(); - fOpenDisassemblyPolicy = new HashMap<Object, String>(); - fSteppingModePolicy = new HashMap<Object, ISteppingModeTarget>(); - CDebugUIPlugin.getDefault().getWorkbench().addWindowListener( this ); - IWorkbenchWindow window = CDebugUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow(); - if ( window != null ) { - window.getPartService().addPartListener( this ); - } - getDisassemblyManager().addDisassemblyContextListener( this ); - } - - public void dispose() { - getDisassemblyManager().removeDisassemblyContextListener( this ); - CDebugUIPlugin.getDefault().getWorkbench().removeWindowListener( this ); - fSteppingModePolicy.clear(); - fOpenDisassemblyPolicy.clear(); - fEditorParts.clear(); - fDocumentProvider.dispose(); - } - - public DisassemblyDocumentProvider getDocumentProvider() { - return fDocumentProvider; - } - - public void openEditor( IWorkbenchPage page, Object debugContext ) throws DebugException { - Object disassemblyContext = getDiassemblyContext( debugContext ); - if ( disassemblyContext != null ) { - IEditorPart editor = fEditorParts.get( disassemblyContext ); - if ( editor == null ) { - ISourcePresentation sp = getSourcePresentation(); - if ( sp == null ) { - throw new DebugException( new Status( IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), 0, "No disassembly editor found", null ) ); - } - IEditorInput input = sp.getEditorInput( debugContext ); - try { - editor = IDE.openEditor( page, input, sp.getEditorId( input, disassemblyContext ) ); - fEditorParts.put( disassemblyContext, editor ); - ISteppingModeTarget steppingModeTarget = getSteppingModeTarget( debugContext ); - if ( steppingModeTarget != null ) { - if ( ICDebugConstants.PREF_VALUE_STEP_MODE_CONTEXT.equals( - CDebugCorePlugin.getDefault().getPluginPreferences().getString( ICDebugConstants.PREF_STEP_MODE ) ) ) - steppingModeTarget.enableInstructionStepping( true ); - fSteppingModePolicy.put( disassemblyContext, steppingModeTarget ); - } - } - catch( PartInitException e ) { - throw new DebugException( e.getStatus() ); - } - } - page.activate( editor ); - } - } - - public IEditorPart findEditor( IWorkbenchPage page, Object debugContext ) { - Object disassemblyContext = getDiassemblyContext( debugContext ); - return ( disassemblyContext != null ) ? fEditorParts.get( disassemblyContext ) : null; - } - - public String getOpenDisassemblyMode( Object debugContext ) { - String mode = MessageDialogWithToggle.NEVER; - Object disassemblyContext = getDiassemblyContext( debugContext ); - if ( disassemblyContext != null ) { - // shouldn't happen - mode = fOpenDisassemblyPolicy.get( disassemblyContext ); - if ( mode == null ) { - IPreferenceStore prefs = CDebugUIPlugin.getDefault().getPreferenceStore(); - mode = prefs.getString( IInternalCDebugUIConstants.PREF_OPEN_DISASSEMBLY_MODE ); - fOpenDisassemblyPolicy.put( disassemblyContext, mode ); - } - } - return mode; - } - - public void setOpenDisassemblyMode( Object debugContext, String mode ) { - Object disassemblyContext = getDiassemblyContext( debugContext ); - if ( disassemblyContext == null ) - return; - fOpenDisassemblyPolicy.put( disassemblyContext, mode ); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener2#partActivated(org.eclipse.ui.IWorkbenchPartReference) - */ - @Override - public void partActivated( IWorkbenchPartReference partRef ) { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener2#partBroughtToTop(org.eclipse.ui.IWorkbenchPartReference) - */ - @Override - public void partBroughtToTop( IWorkbenchPartReference partRef ) { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener2#partClosed(org.eclipse.ui.IWorkbenchPartReference) - */ - @Override - public void partClosed( IWorkbenchPartReference partRef ) { - if ( isDisassemblyEditorPart( partRef ) ) { - IWorkbenchPart part = partRef.getPart( false ); - if ( part instanceof IEditorPart ) { - IEditorInput input = ((IEditorPart)part).getEditorInput(); - if ( input instanceof DisassemblyEditorInput ) { - Object disassemblyContext = ((DisassemblyEditorInput)input).getDisassemblyContext(); - fEditorParts.remove( disassemblyContext ); - ISteppingModeTarget steppingModeTarget = fSteppingModePolicy.remove( disassemblyContext ); - if ( steppingModeTarget != null - && ICDebugConstants.PREF_VALUE_STEP_MODE_CONTEXT.equals( - CDebugCorePlugin.getDefault().getPluginPreferences().getString( ICDebugConstants.PREF_STEP_MODE ) ) ) - steppingModeTarget.enableInstructionStepping( false ); - } - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener2#partDeactivated(org.eclipse.ui.IWorkbenchPartReference) - */ - @Override - public void partDeactivated( IWorkbenchPartReference partRef ) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener2#partHidden(org.eclipse.ui.IWorkbenchPartReference) - */ - @Override - public void partHidden( IWorkbenchPartReference partRef ) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener2#partInputChanged(org.eclipse.ui.IWorkbenchPartReference) - */ - @Override - public void partInputChanged( IWorkbenchPartReference partRef ) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener2#partOpened(org.eclipse.ui.IWorkbenchPartReference) - */ - @Override - public void partOpened( IWorkbenchPartReference partRef ) { - if ( isDisassemblyEditorPart( partRef ) ) { - IWorkbenchPart part = partRef.getPart( false ); - if ( part instanceof IEditorPart ) { - IEditorInput input = ((IEditorPart)part).getEditorInput(); - if ( input instanceof DisassemblyEditorInput ) { - Object disassemblyContext = ((DisassemblyEditorInput)input).getDisassemblyContext(); - fEditorParts.put( disassemblyContext, (IEditorPart)part ); - } - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener2#partVisible(org.eclipse.ui.IWorkbenchPartReference) - */ - @Override - public void partVisible( IWorkbenchPartReference partRef ) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWindowListener#windowActivated(org.eclipse.ui.IWorkbenchWindow) - */ - @Override - public void windowActivated( IWorkbenchWindow window ) { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWindowListener#windowClosed(org.eclipse.ui.IWorkbenchWindow) - */ - @Override - public void windowClosed( IWorkbenchWindow window ) { - window.getPartService().removePartListener( this ); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWindowListener#windowDeactivated(org.eclipse.ui.IWorkbenchWindow) - */ - @Override - public void windowDeactivated( IWorkbenchWindow window ) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWindowListener#windowOpened(org.eclipse.ui.IWorkbenchWindow) - */ - @Override - public void windowOpened( IWorkbenchWindow window ) { - window.getPartService().addPartListener( this ); - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.core.disassembly.IDisassemblyContextListener#contextAdded(java.lang.Object) - */ - @Override - public void contextAdded( Object context ) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.core.disassembly.IDisassemblyContextListener#contextRemoved(java.lang.Object) - */ - @Override - public void contextRemoved( Object context ) { - final IEditorPart editor = fEditorParts.remove( context ); - if ( editor != null ) { - UIJob job = new UIJob( editor.getSite().getShell().getDisplay(), "Closing disassembly" ) { //$NON-NLS-1$ - - /* (non-Javadoc) - * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) - */ - @Override - public IStatus runInUIThread( IProgressMonitor monitor ) { - editor.getSite().getPage().closeEditor( editor, false ); - return Status.OK_STATUS; - } - }; - job.setSystem( true ); - job.schedule(); - } - } - - private IDisassemblyContextService getDisassemblyManager() { - return CDebugCorePlugin.getDefault().getDisassemblyContextService(); - } - - private boolean isDisassemblyEditorPart( IWorkbenchPartReference partRef ) { - // TODO: check all editors contributed via the extension point - return ( partRef.getId().equals( ICDebugUIConstants.ID_DEFAULT_DISASSEMBLY_EDITOR ) ); - } - - private ISourcePresentation getSourcePresentation() { - - return new ISourcePresentation() { - - @Override - public IEditorInput getEditorInput( Object element ) { - Object disassemblyContext = getDiassemblyContext( element ); - return new DisassemblyEditorInput( element, disassemblyContext ); - } - - @Override - public String getEditorId( IEditorInput input, Object element ) { - return ICDebugUIConstants.ID_DEFAULT_DISASSEMBLY_EDITOR; - } - }; - } - - protected Object getDiassemblyContext( Object element ) { - IDisassemblyContextProvider adapter = getDisassemblyContextProvider( element ); - return ( adapter != null ) ? adapter.getDisassemblyContext( element ) : null; - } - - private IDisassemblyContextProvider getDisassemblyContextProvider( Object element ) { - IDisassemblyContextProvider adapter = null; - if ( element instanceof IDisassemblyContextProvider ) { - adapter = (IDisassemblyContextProvider)element; - } - else if ( element instanceof IAdaptable ) { - IAdaptable adaptable = (IAdaptable)element; - adapter = adaptable.getAdapter( IDisassemblyContextProvider.class ); - } - return adapter; - } - - private ISteppingModeTarget getSteppingModeTarget( Object debugContext ) { - if ( debugContext instanceof ISteppingModeTarget ) - return (ISteppingModeTarget)debugContext; - if ( debugContext instanceof IAdaptable ) - return ((IAdaptable)debugContext).getAdapter( ISteppingModeTarget.class ); - return null; - } + private Map<Object, IEditorPart> fEditorParts; + private Map<Object, String> fOpenDisassemblyPolicy; + private Map<Object, ISteppingModeTarget> fSteppingModePolicy; + private DisassemblyDocumentProvider fDocumentProvider; + + public DisassemblyEditorManager() { + fDocumentProvider = new DisassemblyDocumentProvider(); + fEditorParts = new HashMap<Object, IEditorPart>(); + fOpenDisassemblyPolicy = new HashMap<Object, String>(); + fSteppingModePolicy = new HashMap<Object, ISteppingModeTarget>(); + CDebugUIPlugin.getDefault().getWorkbench().addWindowListener(this); + IWorkbenchWindow window = CDebugUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow(); + if (window != null) { + window.getPartService().addPartListener(this); + } + getDisassemblyManager().addDisassemblyContextListener(this); + } + + public void dispose() { + getDisassemblyManager().removeDisassemblyContextListener(this); + CDebugUIPlugin.getDefault().getWorkbench().removeWindowListener(this); + fSteppingModePolicy.clear(); + fOpenDisassemblyPolicy.clear(); + fEditorParts.clear(); + fDocumentProvider.dispose(); + } + + public DisassemblyDocumentProvider getDocumentProvider() { + return fDocumentProvider; + } + + public void openEditor(IWorkbenchPage page, Object debugContext) throws DebugException { + Object disassemblyContext = getDiassemblyContext(debugContext); + if (disassemblyContext != null) { + IEditorPart editor = fEditorParts.get(disassemblyContext); + if (editor == null) { + ISourcePresentation sp = getSourcePresentation(); + if (sp == null) { + throw new DebugException(new Status(IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), 0, + "No disassembly editor found", null)); + } + IEditorInput input = sp.getEditorInput(debugContext); + try { + editor = IDE.openEditor(page, input, sp.getEditorId(input, disassemblyContext)); + fEditorParts.put(disassemblyContext, editor); + ISteppingModeTarget steppingModeTarget = getSteppingModeTarget(debugContext); + if (steppingModeTarget != null) { + if (ICDebugConstants.PREF_VALUE_STEP_MODE_CONTEXT.equals(CDebugCorePlugin.getDefault() + .getPluginPreferences().getString(ICDebugConstants.PREF_STEP_MODE))) + steppingModeTarget.enableInstructionStepping(true); + fSteppingModePolicy.put(disassemblyContext, steppingModeTarget); + } + } catch (PartInitException e) { + throw new DebugException(e.getStatus()); + } + } + page.activate(editor); + } + } + + public IEditorPart findEditor(IWorkbenchPage page, Object debugContext) { + Object disassemblyContext = getDiassemblyContext(debugContext); + return (disassemblyContext != null) ? fEditorParts.get(disassemblyContext) : null; + } + + public String getOpenDisassemblyMode(Object debugContext) { + String mode = MessageDialogWithToggle.NEVER; + Object disassemblyContext = getDiassemblyContext(debugContext); + if (disassemblyContext != null) { + // shouldn't happen + mode = fOpenDisassemblyPolicy.get(disassemblyContext); + if (mode == null) { + IPreferenceStore prefs = CDebugUIPlugin.getDefault().getPreferenceStore(); + mode = prefs.getString(IInternalCDebugUIConstants.PREF_OPEN_DISASSEMBLY_MODE); + fOpenDisassemblyPolicy.put(disassemblyContext, mode); + } + } + return mode; + } + + public void setOpenDisassemblyMode(Object debugContext, String mode) { + Object disassemblyContext = getDiassemblyContext(debugContext); + if (disassemblyContext == null) + return; + fOpenDisassemblyPolicy.put(disassemblyContext, mode); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPartListener2#partActivated(org.eclipse.ui.IWorkbenchPartReference) + */ + @Override + public void partActivated(IWorkbenchPartReference partRef) { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPartListener2#partBroughtToTop(org.eclipse.ui.IWorkbenchPartReference) + */ + @Override + public void partBroughtToTop(IWorkbenchPartReference partRef) { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPartListener2#partClosed(org.eclipse.ui.IWorkbenchPartReference) + */ + @Override + public void partClosed(IWorkbenchPartReference partRef) { + if (isDisassemblyEditorPart(partRef)) { + IWorkbenchPart part = partRef.getPart(false); + if (part instanceof IEditorPart) { + IEditorInput input = ((IEditorPart) part).getEditorInput(); + if (input instanceof DisassemblyEditorInput) { + Object disassemblyContext = ((DisassemblyEditorInput) input).getDisassemblyContext(); + fEditorParts.remove(disassemblyContext); + ISteppingModeTarget steppingModeTarget = fSteppingModePolicy.remove(disassemblyContext); + if (steppingModeTarget != null + && ICDebugConstants.PREF_VALUE_STEP_MODE_CONTEXT.equals(CDebugCorePlugin.getDefault() + .getPluginPreferences().getString(ICDebugConstants.PREF_STEP_MODE))) + steppingModeTarget.enableInstructionStepping(false); + } + } + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPartListener2#partDeactivated(org.eclipse.ui.IWorkbenchPartReference) + */ + @Override + public void partDeactivated(IWorkbenchPartReference partRef) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPartListener2#partHidden(org.eclipse.ui.IWorkbenchPartReference) + */ + @Override + public void partHidden(IWorkbenchPartReference partRef) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPartListener2#partInputChanged(org.eclipse.ui.IWorkbenchPartReference) + */ + @Override + public void partInputChanged(IWorkbenchPartReference partRef) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPartListener2#partOpened(org.eclipse.ui.IWorkbenchPartReference) + */ + @Override + public void partOpened(IWorkbenchPartReference partRef) { + if (isDisassemblyEditorPart(partRef)) { + IWorkbenchPart part = partRef.getPart(false); + if (part instanceof IEditorPart) { + IEditorInput input = ((IEditorPart) part).getEditorInput(); + if (input instanceof DisassemblyEditorInput) { + Object disassemblyContext = ((DisassemblyEditorInput) input).getDisassemblyContext(); + fEditorParts.put(disassemblyContext, (IEditorPart) part); + } + } + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPartListener2#partVisible(org.eclipse.ui.IWorkbenchPartReference) + */ + @Override + public void partVisible(IWorkbenchPartReference partRef) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWindowListener#windowActivated(org.eclipse.ui.IWorkbenchWindow) + */ + @Override + public void windowActivated(IWorkbenchWindow window) { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWindowListener#windowClosed(org.eclipse.ui.IWorkbenchWindow) + */ + @Override + public void windowClosed(IWorkbenchWindow window) { + window.getPartService().removePartListener(this); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWindowListener#windowDeactivated(org.eclipse.ui.IWorkbenchWindow) + */ + @Override + public void windowDeactivated(IWorkbenchWindow window) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWindowListener#windowOpened(org.eclipse.ui.IWorkbenchWindow) + */ + @Override + public void windowOpened(IWorkbenchWindow window) { + window.getPartService().addPartListener(this); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.disassembly.IDisassemblyContextListener#contextAdded(java.lang.Object) + */ + @Override + public void contextAdded(Object context) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.disassembly.IDisassemblyContextListener#contextRemoved(java.lang.Object) + */ + @Override + public void contextRemoved(Object context) { + final IEditorPart editor = fEditorParts.remove(context); + if (editor != null) { + UIJob job = new UIJob(editor.getSite().getShell().getDisplay(), "Closing disassembly") { //$NON-NLS-1$ + + /* (non-Javadoc) + * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + public IStatus runInUIThread(IProgressMonitor monitor) { + editor.getSite().getPage().closeEditor(editor, false); + return Status.OK_STATUS; + } + }; + job.setSystem(true); + job.schedule(); + } + } + + private IDisassemblyContextService getDisassemblyManager() { + return CDebugCorePlugin.getDefault().getDisassemblyContextService(); + } + + private boolean isDisassemblyEditorPart(IWorkbenchPartReference partRef) { + // TODO: check all editors contributed via the extension point + return (partRef.getId().equals(ICDebugUIConstants.ID_DEFAULT_DISASSEMBLY_EDITOR)); + } + + private ISourcePresentation getSourcePresentation() { + + return new ISourcePresentation() { + + @Override + public IEditorInput getEditorInput(Object element) { + Object disassemblyContext = getDiassemblyContext(element); + return new DisassemblyEditorInput(element, disassemblyContext); + } + + @Override + public String getEditorId(IEditorInput input, Object element) { + return ICDebugUIConstants.ID_DEFAULT_DISASSEMBLY_EDITOR; + } + }; + } + + protected Object getDiassemblyContext(Object element) { + IDisassemblyContextProvider adapter = getDisassemblyContextProvider(element); + return (adapter != null) ? adapter.getDisassemblyContext(element) : null; + } + + private IDisassemblyContextProvider getDisassemblyContextProvider(Object element) { + IDisassemblyContextProvider adapter = null; + if (element instanceof IDisassemblyContextProvider) { + adapter = (IDisassemblyContextProvider) element; + } else if (element instanceof IAdaptable) { + IAdaptable adaptable = (IAdaptable) element; + adapter = adaptable.getAdapter(IDisassemblyContextProvider.class); + } + return adapter; + } + + private ISteppingModeTarget getSteppingModeTarget(Object debugContext) { + if (debugContext instanceof ISteppingModeTarget) + return (ISteppingModeTarget) debugContext; + if (debugContext instanceof IAdaptable) + return ((IAdaptable) debugContext).getAdapter(ISteppingModeTarget.class); + return null; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/editor/DisassemblyEditorPresentation.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/editor/DisassemblyEditorPresentation.java index b3c732075fe..3112e48d594 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/editor/DisassemblyEditorPresentation.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/editor/DisassemblyEditorPresentation.java @@ -21,53 +21,55 @@ import org.eclipse.cdt.debug.ui.disassembly.IDocumentPresentation; import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationContext; /** - * org.eclipse.cdt.debug.internal.ui.disassembly.viewer.DisassemblyEditorPresentation: + * org.eclipse.cdt.debug.internal.ui.disassembly.viewer.DisassemblyEditorPresentation: */ public class DisassemblyEditorPresentation extends PresentationContext implements IDocumentPresentation { - public static final String PROPERTY_SHOW_INSTRUCTIONS = "PROPERTY_SHOW_INSTRUCTIONS"; //$NON-NLS-1$ - public static final String PROPERTY_SHOW_SOURCE = "PROPERTY_SHOW_SOURCE"; //$NON-NLS-1$ - public static final String PROPERTY_SHOW_ADDRESSES = "PROPERTY_SHOW_ADDRESSES"; //$NON-NLS-1$ - public static final String PROPERTY_SHOW_LINE_NUMBERS = "PROPERTY_SHOW_LINE_NUMBERS"; //$NON-NLS-1$ + public static final String PROPERTY_SHOW_INSTRUCTIONS = "PROPERTY_SHOW_INSTRUCTIONS"; //$NON-NLS-1$ + public static final String PROPERTY_SHOW_SOURCE = "PROPERTY_SHOW_SOURCE"; //$NON-NLS-1$ + public static final String PROPERTY_SHOW_ADDRESSES = "PROPERTY_SHOW_ADDRESSES"; //$NON-NLS-1$ + public static final String PROPERTY_SHOW_LINE_NUMBERS = "PROPERTY_SHOW_LINE_NUMBERS"; //$NON-NLS-1$ - private boolean fShowAddresses = true; - private boolean fShowLineNumbers = true; + private boolean fShowAddresses = true; + private boolean fShowLineNumbers = true; - public DisassemblyEditorPresentation() { - super( ICDebugUIConstants.ID_DEFAULT_DISASSEMBLY_EDITOR ); - setProperty( PROPERTY_SHOW_INSTRUCTIONS, Boolean.valueOf( CDebugUIPlugin.getDefault().getPreferenceStore().getBoolean( ICDebugPreferenceConstants.PREF_DISASM_SHOW_INSTRUCTIONS ) ) ); - setProperty( PROPERTY_SHOW_SOURCE, Boolean.valueOf( CDebugUIPlugin.getDefault().getPreferenceStore().getBoolean( ICDebugPreferenceConstants.PREF_DISASM_SHOW_SOURCE ) ) ); - } + public DisassemblyEditorPresentation() { + super(ICDebugUIConstants.ID_DEFAULT_DISASSEMBLY_EDITOR); + setProperty(PROPERTY_SHOW_INSTRUCTIONS, Boolean.valueOf(CDebugUIPlugin.getDefault().getPreferenceStore() + .getBoolean(ICDebugPreferenceConstants.PREF_DISASM_SHOW_INSTRUCTIONS))); + setProperty(PROPERTY_SHOW_SOURCE, Boolean.valueOf(CDebugUIPlugin.getDefault().getPreferenceStore() + .getBoolean(ICDebugPreferenceConstants.PREF_DISASM_SHOW_SOURCE))); + } - public boolean showIntstructions() { - return ((Boolean)getProperty( PROPERTY_SHOW_INSTRUCTIONS )).booleanValue(); - } + public boolean showIntstructions() { + return ((Boolean) getProperty(PROPERTY_SHOW_INSTRUCTIONS)).booleanValue(); + } - public void setShowIntstructions( boolean showIntstructions ) { - setProperty( PROPERTY_SHOW_INSTRUCTIONS, Boolean.valueOf( showIntstructions ) ); - } + public void setShowIntstructions(boolean showIntstructions) { + setProperty(PROPERTY_SHOW_INSTRUCTIONS, Boolean.valueOf(showIntstructions)); + } - public boolean showSource() { - return ((Boolean)getProperty( PROPERTY_SHOW_SOURCE )).booleanValue(); - } + public boolean showSource() { + return ((Boolean) getProperty(PROPERTY_SHOW_SOURCE)).booleanValue(); + } - public void setShowSource( boolean showSource ) { - setProperty( PROPERTY_SHOW_SOURCE, Boolean.valueOf( showSource ) ); - } + public void setShowSource(boolean showSource) { + setProperty(PROPERTY_SHOW_SOURCE, Boolean.valueOf(showSource)); + } - public boolean showAddresses() { - return fShowAddresses; - } + public boolean showAddresses() { + return fShowAddresses; + } - public void setShowAddresses( boolean showAddresses ) { - fShowAddresses = showAddresses; - } + public void setShowAddresses(boolean showAddresses) { + fShowAddresses = showAddresses; + } - public boolean showLineNumbers() { - return fShowLineNumbers; - } + public boolean showLineNumbers() { + return fShowLineNumbers; + } - public void setShowLineNumbers( boolean showLineNumbers ) { - fShowLineNumbers = showLineNumbers; - } + public void setShowLineNumbers(boolean showLineNumbers) { + fShowLineNumbers = showLineNumbers; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DisassemblyDocumentProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DisassemblyDocumentProvider.java index f7968aee599..d8cab82a395 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DisassemblyDocumentProvider.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DisassemblyDocumentProvider.java @@ -29,210 +29,212 @@ import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.IElementStateListener; /** - * org.eclipse.cdt.debug.internal.ui.disassembly.viewer.DisassemblyDocumentProvider: + * org.eclipse.cdt.debug.internal.ui.disassembly.viewer.DisassemblyDocumentProvider: * //TODO Add description. */ public class DisassemblyDocumentProvider implements IDocumentProvider { - class DocumentInfo { - - private VirtualDocument fDocument; - private IAnnotationModel fAnnotationModel; - private IDocumentPresentation fPresentation; - - DocumentInfo( VirtualDocument document, IAnnotationModel annotationModel, IDocumentPresentation presentation ) { - fDocument = document; - fAnnotationModel = annotationModel; - fPresentation = presentation; - } - - VirtualDocument getDocument() { - return fDocument; - } - - IAnnotationModel getAnnotationModel() { - return fAnnotationModel; - } - - IDocumentPresentation getPresentation() { - return fPresentation; - } - - void dispose() { - fPresentation.dispose(); - fPresentation = null; - fAnnotationModel = null; - fDocument.dispose(); - fDocument = null; - } - } - - private Map<Object, DocumentInfo> fDocumentInfos; - - public DisassemblyDocumentProvider() { - fDocumentInfos = new HashMap<Object, DocumentInfo>(); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.texteditor.IDocumentProvider#aboutToChange(java.lang.Object) - */ - @Override - public void aboutToChange( Object element ) { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.texteditor.IDocumentProvider#addElementStateListener(org.eclipse.ui.texteditor.IElementStateListener) - */ - @Override - public void addElementStateListener( IElementStateListener listener ) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.eclipse.ui.texteditor.IDocumentProvider#canSaveDocument(java.lang.Object) - */ - @Override - public boolean canSaveDocument( Object element ) { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.texteditor.IDocumentProvider#changed(java.lang.Object) - */ - @Override - public void changed( Object element ) { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.texteditor.IDocumentProvider#connect(java.lang.Object) - */ - @Override - public synchronized void connect( Object element ) throws CoreException { - Object disassemblyContext = ((DisassemblyEditorInput)element).getDisassemblyContext(); - if ( fDocumentInfos.get( disassemblyContext ) == null ) { - IDocumentPresentation presentation = createDocumentPresentation( disassemblyContext ); - AnnotationModel annotationModel = createAnnotationModel(); - VirtualDocument document = createDocument( disassemblyContext, presentation, annotationModel ); - fDocumentInfos.put( disassemblyContext, new DocumentInfo( document, annotationModel, presentation ) ); - } - } - - /* (non-Javadoc) - * @see org.eclipse.ui.texteditor.IDocumentProvider#disconnect(java.lang.Object) - */ - @Override - public synchronized void disconnect( Object element ) { - Object disassemblyContext = ((DisassemblyEditorInput)element).getDisassemblyContext(); - DocumentInfo info = fDocumentInfos.remove( disassemblyContext ); - if ( info != null ) { - info.dispose(); - } - } - - /* (non-Javadoc) - * @see org.eclipse.ui.texteditor.IDocumentProvider#getAnnotationModel(java.lang.Object) - */ - @Override - public IAnnotationModel getAnnotationModel( Object element ) { - Object disassemblyContext = ((DisassemblyEditorInput)element).getDisassemblyContext(); - DocumentInfo info = fDocumentInfos.get( disassemblyContext ); - return ( info != null ) ? info.getAnnotationModel() : null; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.texteditor.IDocumentProvider#getDocument(java.lang.Object) - */ - @Override - public IDocument getDocument( Object element ) { - Object disassemblyContext = ((DisassemblyEditorInput)element).getDisassemblyContext(); - DocumentInfo info = fDocumentInfos.get( disassemblyContext ); - return ( info != null ) ? info.getDocument() : null; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.texteditor.IDocumentProvider#getModificationStamp(java.lang.Object) - */ - @Override - public long getModificationStamp( Object element ) { - // TODO Auto-generated method stub - return 0; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.texteditor.IDocumentProvider#getSynchronizationStamp(java.lang.Object) - */ - @Override - public long getSynchronizationStamp( Object element ) { - // TODO Auto-generated method stub - return 0; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.texteditor.IDocumentProvider#isDeleted(java.lang.Object) - */ - @Override - public boolean isDeleted( Object element ) { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.texteditor.IDocumentProvider#mustSaveDocument(java.lang.Object) - */ - @Override - public boolean mustSaveDocument( Object element ) { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.texteditor.IDocumentProvider#removeElementStateListener(org.eclipse.ui.texteditor.IElementStateListener) - */ - @Override - public void removeElementStateListener( IElementStateListener listener ) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.eclipse.ui.texteditor.IDocumentProvider#resetDocument(java.lang.Object) - */ - @Override - public void resetDocument( Object element ) throws CoreException { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.eclipse.ui.texteditor.IDocumentProvider#saveDocument(org.eclipse.core.runtime.IProgressMonitor, java.lang.Object, org.eclipse.jface.text.IDocument, boolean) - */ - @Override - public void saveDocument( IProgressMonitor monitor, Object element, IDocument document, boolean overwrite ) throws CoreException { - // TODO Auto-generated method stub - - } - - public void dispose() { - for( DocumentInfo info : fDocumentInfos.values() ) { - info.dispose(); - } - fDocumentInfos.clear(); - } - - public IDocumentPresentation getDocumentPresentation( Object element ) { - Object disassemblyContext = ((DisassemblyEditorInput)element).getDisassemblyContext(); - DocumentInfo info = fDocumentInfos.get( disassemblyContext ); - return ( info != null ) ? info.getPresentation() : null; - } - - private AnnotationModel createAnnotationModel() { - return new AnnotationModel(); - } - - private VirtualDocument createDocument( Object disassemblyContext, IDocumentPresentation presentationContext, AnnotationModel annotationModel ) { - return new VirtualDocument( annotationModel, presentationContext, disassemblyContext ); - } - - private IDocumentPresentation createDocumentPresentation( Object context ) { - return new DisassemblyEditorPresentation(); - } + class DocumentInfo { + + private VirtualDocument fDocument; + private IAnnotationModel fAnnotationModel; + private IDocumentPresentation fPresentation; + + DocumentInfo(VirtualDocument document, IAnnotationModel annotationModel, IDocumentPresentation presentation) { + fDocument = document; + fAnnotationModel = annotationModel; + fPresentation = presentation; + } + + VirtualDocument getDocument() { + return fDocument; + } + + IAnnotationModel getAnnotationModel() { + return fAnnotationModel; + } + + IDocumentPresentation getPresentation() { + return fPresentation; + } + + void dispose() { + fPresentation.dispose(); + fPresentation = null; + fAnnotationModel = null; + fDocument.dispose(); + fDocument = null; + } + } + + private Map<Object, DocumentInfo> fDocumentInfos; + + public DisassemblyDocumentProvider() { + fDocumentInfos = new HashMap<Object, DocumentInfo>(); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.texteditor.IDocumentProvider#aboutToChange(java.lang.Object) + */ + @Override + public void aboutToChange(Object element) { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.texteditor.IDocumentProvider#addElementStateListener(org.eclipse.ui.texteditor.IElementStateListener) + */ + @Override + public void addElementStateListener(IElementStateListener listener) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.eclipse.ui.texteditor.IDocumentProvider#canSaveDocument(java.lang.Object) + */ + @Override + public boolean canSaveDocument(Object element) { + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.texteditor.IDocumentProvider#changed(java.lang.Object) + */ + @Override + public void changed(Object element) { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.texteditor.IDocumentProvider#connect(java.lang.Object) + */ + @Override + public synchronized void connect(Object element) throws CoreException { + Object disassemblyContext = ((DisassemblyEditorInput) element).getDisassemblyContext(); + if (fDocumentInfos.get(disassemblyContext) == null) { + IDocumentPresentation presentation = createDocumentPresentation(disassemblyContext); + AnnotationModel annotationModel = createAnnotationModel(); + VirtualDocument document = createDocument(disassemblyContext, presentation, annotationModel); + fDocumentInfos.put(disassemblyContext, new DocumentInfo(document, annotationModel, presentation)); + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.texteditor.IDocumentProvider#disconnect(java.lang.Object) + */ + @Override + public synchronized void disconnect(Object element) { + Object disassemblyContext = ((DisassemblyEditorInput) element).getDisassemblyContext(); + DocumentInfo info = fDocumentInfos.remove(disassemblyContext); + if (info != null) { + info.dispose(); + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.texteditor.IDocumentProvider#getAnnotationModel(java.lang.Object) + */ + @Override + public IAnnotationModel getAnnotationModel(Object element) { + Object disassemblyContext = ((DisassemblyEditorInput) element).getDisassemblyContext(); + DocumentInfo info = fDocumentInfos.get(disassemblyContext); + return (info != null) ? info.getAnnotationModel() : null; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.texteditor.IDocumentProvider#getDocument(java.lang.Object) + */ + @Override + public IDocument getDocument(Object element) { + Object disassemblyContext = ((DisassemblyEditorInput) element).getDisassemblyContext(); + DocumentInfo info = fDocumentInfos.get(disassemblyContext); + return (info != null) ? info.getDocument() : null; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.texteditor.IDocumentProvider#getModificationStamp(java.lang.Object) + */ + @Override + public long getModificationStamp(Object element) { + // TODO Auto-generated method stub + return 0; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.texteditor.IDocumentProvider#getSynchronizationStamp(java.lang.Object) + */ + @Override + public long getSynchronizationStamp(Object element) { + // TODO Auto-generated method stub + return 0; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.texteditor.IDocumentProvider#isDeleted(java.lang.Object) + */ + @Override + public boolean isDeleted(Object element) { + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.texteditor.IDocumentProvider#mustSaveDocument(java.lang.Object) + */ + @Override + public boolean mustSaveDocument(Object element) { + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.texteditor.IDocumentProvider#removeElementStateListener(org.eclipse.ui.texteditor.IElementStateListener) + */ + @Override + public void removeElementStateListener(IElementStateListener listener) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.eclipse.ui.texteditor.IDocumentProvider#resetDocument(java.lang.Object) + */ + @Override + public void resetDocument(Object element) throws CoreException { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.eclipse.ui.texteditor.IDocumentProvider#saveDocument(org.eclipse.core.runtime.IProgressMonitor, java.lang.Object, org.eclipse.jface.text.IDocument, boolean) + */ + @Override + public void saveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) + throws CoreException { + // TODO Auto-generated method stub + + } + + public void dispose() { + for (DocumentInfo info : fDocumentInfos.values()) { + info.dispose(); + } + fDocumentInfos.clear(); + } + + public IDocumentPresentation getDocumentPresentation(Object element) { + Object disassemblyContext = ((DisassemblyEditorInput) element).getDisassemblyContext(); + DocumentInfo info = fDocumentInfos.get(disassemblyContext); + return (info != null) ? info.getPresentation() : null; + } + + private AnnotationModel createAnnotationModel() { + return new AnnotationModel(); + } + + private VirtualDocument createDocument(Object disassemblyContext, IDocumentPresentation presentationContext, + AnnotationModel annotationModel) { + return new VirtualDocument(annotationModel, presentationContext, disassemblyContext); + } + + private IDocumentPresentation createDocumentPresentation(Object context) { + return new DisassemblyEditorPresentation(); + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DisassemblyPane.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DisassemblyPane.java index 09a83ae0eff..97fbfb70832 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DisassemblyPane.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DisassemblyPane.java @@ -64,361 +64,360 @@ import org.eclipse.ui.texteditor.SourceViewerDecorationSupport; public class DisassemblyPane implements IPropertyChangeListener { - private final static int VERTICAL_RULER_WIDTH = 12; - private final static String CURRENT_LINE = AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE; - private final static String CURRENT_LINE_COLOR = AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR; - - private Composite fControl; - private VirtualSourceViewer fViewer; - - private IVerticalRuler fVerticalRuler; - private IOverviewRuler fOverviewRuler; - - private SourceViewerDecorationSupport fSourceViewerDecorationSupport; - private IAnnotationAccess fAnnotationAccess; - private MarkerAnnotationPreferences fAnnotationPreferences; - - private String fViewContextMenuId; - private String fRulerContextMenuId; - - private MenuManager fTextMenuManager; - private MenuManager fRulerMenuManager; - - private Menu fRulerContextMenu; - private Menu fTextContextMenu; - - private IMenuListener fMenuListener; - private MouseListener fMouseListener; - - private Map<String, IAction> fActions = new HashMap<String, IAction>( 10 ); - - public DisassemblyPane( String contextMenuId, String rulerMenuId ) { - fAnnotationPreferences = new MarkerAnnotationPreferences(); - setViewContextMenuId( contextMenuId ); - setRulerContextMenuId( rulerMenuId ); - } - - public void create( Composite parent ) { - Composite composite = new Composite( parent, SWT.NONE ); - composite.setLayout( new GridLayout() ); - GridData data = new GridData( SWT.FILL, SWT.FILL, true, true ); - composite.setLayoutData( data ); - - fVerticalRuler = createCompositeRuler(); - fOverviewRuler = createOverviewRuler( getSharedColors() ); - - createActions(); - - fViewer = createViewer( composite, fVerticalRuler, fOverviewRuler ); - - fControl = composite; - - createViewContextMenu(); - createRulerContextMenu(); - - if ( fSourceViewerDecorationSupport != null ) { - fSourceViewerDecorationSupport.install( getEditorPreferenceStore() ); - } - } - - public Control getControl() { - return fControl; - } - - public VirtualSourceViewer getViewer() { - return fViewer; - } - - public void dispose() { - getEditorPreferenceStore().removePropertyChangeListener( this ); - JFaceResources.getFontRegistry().removeListener( this ); - JFaceResources.getColorRegistry().removeListener( this ); - if ( fSourceViewerDecorationSupport != null ) { - fSourceViewerDecorationSupport.dispose(); - fSourceViewerDecorationSupport = null; - } - if ( fActions != null ) { - fActions.clear(); - fActions = null; - } - } - - protected void createActions() { - } - - public void setAction( String actionID, IAction action ) { - Assert.isNotNull( actionID ); - if ( action == null ) { - fActions.remove( actionID ); - } - else { - fActions.put( actionID, action ); - } - } - - public IAction getAction( String actionID ) { - Assert.isNotNull( actionID ); - return fActions.get( actionID ); - } - - protected void rulerContextMenuAboutToShow( IMenuManager menu ) { - menu.add( new Separator( ITextEditorActionConstants.GROUP_REST ) ); - menu.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) ); - addAction( menu, IInternalCDebugUIConstants.ACTION_TOGGLE_BREAKPOINT ); - addAction( menu, IInternalCDebugUIConstants.ACTION_ENABLE_DISABLE_BREAKPOINT ); - addAction( menu, IInternalCDebugUIConstants.ACTION_BREAKPOINT_PROPERTIES ); - } - - protected void viewContextMenuAboutToShow( IMenuManager menu ) { - menu.add( new Separator( ITextEditorActionConstants.GROUP_REST ) ); - menu.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) ); - } - - protected void addAction( IMenuManager menu, String group, String actionId ) { - IAction action = getAction( actionId ); - if ( action != null ) { - if ( action instanceof IUpdate ) - ((IUpdate)action).update(); - IMenuManager subMenu = menu.findMenuUsingPath( group ); - if ( subMenu != null ) - subMenu.add( action ); - else - menu.appendToGroup( group, action ); - } - } - - protected void addAction( IMenuManager menu, String actionId ) { - IAction action = getAction( actionId ); - if ( action != null ) { - if ( action instanceof IUpdate ) - ((IUpdate)action).update(); - menu.add( action ); - } - } - - protected final IMenuListener getContextMenuListener() { - if ( fMenuListener == null ) { - fMenuListener = new IMenuListener() { - - @Override - public void menuAboutToShow( IMenuManager menu ) { - String id = menu.getId(); - if ( getRulerContextMenuId().equals( id ) ) { -// setFocus(); - rulerContextMenuAboutToShow( menu ); - } - else if ( getViewContextMenuId().equals( id ) ) { -// setFocus(); - viewContextMenuAboutToShow( menu ); - } - } - }; - } - return fMenuListener; - } - - protected final MouseListener getRulerMouseListener() { - if ( fMouseListener == null ) { - fMouseListener = new MouseListener() { - - private boolean fDoubleClicked = false; - - private void triggerAction( String actionID ) { - IAction action = getAction( actionID ); - if ( action != null ) { - if ( action instanceof IUpdate ) - ((IUpdate)action).update(); - if ( action.isEnabled() ) - action.run(); - } - } - - @Override - public void mouseUp( MouseEvent e ) { -// setFocus(); - if ( 1 == e.button && !fDoubleClicked ) - triggerAction( ITextEditorActionConstants.RULER_CLICK ); - fDoubleClicked = false; - } - - @Override - public void mouseDoubleClick( MouseEvent e ) { - if ( 1 == e.button ) { - fDoubleClicked = true; - triggerAction( IInternalCDebugUIConstants.ACTION_TOGGLE_BREAKPOINT ); - } - } - - @Override - public void mouseDown( MouseEvent e ) { - StyledText text = getViewer().getTextWidget(); - if ( text != null && !text.isDisposed() ) { - Display display = text.getDisplay(); - Point location = display.getCursorLocation(); - getRulerContextMenu().setLocation( location.x, location.y ); - } - } - }; - } - return fMouseListener; - } - - private Menu getTextContextMenu() { - return this.fTextContextMenu; - } - - private void setTextContextMenu( Menu textContextMenu ) { - this.fTextContextMenu = textContextMenu; - } - - protected Menu getRulerContextMenu() { - return this.fRulerContextMenu; - } - - private void setRulerContextMenu( Menu rulerContextMenu ) { - this.fRulerContextMenu = rulerContextMenu; - } - - public String getRulerContextMenuId() { - return fRulerContextMenuId; - } - - private void setRulerContextMenuId( String rulerContextMenuId ) { - Assert.isNotNull( rulerContextMenuId ); - fRulerContextMenuId = rulerContextMenuId; - } - - public String getViewContextMenuId() { - return fViewContextMenuId; - } - - private void setViewContextMenuId( String viewContextMenuId ) { - Assert.isNotNull( viewContextMenuId ); - fViewContextMenuId = viewContextMenuId; - } - - private void createViewContextMenu() { - String id = getViewContextMenuId(); - fTextMenuManager = new MenuManager( id, id ); - fTextMenuManager.setRemoveAllWhenShown( true ); - fTextMenuManager.addMenuListener( getContextMenuListener() ); - StyledText styledText = getViewer().getTextWidget(); - setTextContextMenu( fTextMenuManager.createContextMenu( styledText ) ); - styledText.setMenu( getTextContextMenu() ); - } - - private void createRulerContextMenu() { - String id = getRulerContextMenuId(); - fRulerMenuManager = new MenuManager( id, id ); - fRulerMenuManager.setRemoveAllWhenShown( true ); - fRulerMenuManager.addMenuListener( getContextMenuListener() ); - Control rulerControl = fVerticalRuler.getControl(); - setRulerContextMenu( fRulerMenuManager.createContextMenu( rulerControl ) ); - rulerControl.setMenu( getRulerContextMenu() ); - rulerControl.addMouseListener( getRulerMouseListener() ); - } - - protected SourceViewerDecorationSupport getSourceViewerDecorationSupport( ISourceViewer viewer ) { - if ( fSourceViewerDecorationSupport == null ) { - fSourceViewerDecorationSupport = new SourceViewerDecorationSupport( viewer, getOverviewRuler(), getAnnotationAccess(), getSharedColors() ); - configureSourceViewerDecorationSupport( fSourceViewerDecorationSupport ); - } - return fSourceViewerDecorationSupport; - } - - protected VirtualSourceViewer createViewer( Composite parent, IVerticalRuler vertRuler, IOverviewRuler ovRuler ) { - int styles = SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION; - VirtualSourceViewer viewer = new VirtualSourceViewer( parent, fVerticalRuler, fOverviewRuler, true, styles ); - viewer.getControl().setLayoutData( parent.getLayoutData() ); - viewer.setEditable( false ); - viewer.getTextWidget().setFont( JFaceResources.getFont( IInternalCDebugUIConstants.DISASSEMBLY_FONT ) ); - viewer.setRangeIndicator( new DefaultRangeIndicator() ); - getSourceViewerDecorationSupport( viewer ); - viewer.configure( new SourceViewerConfiguration() ); - JFaceResources.getFontRegistry().addListener( this ); - JFaceResources.getColorRegistry().addListener( this ); - getEditorPreferenceStore().addPropertyChangeListener( this ); - return viewer; - } - - private IAnnotationAccess createAnnotationAccess() { - return new DefaultMarkerAnnotationAccess(); - } - - private void configureSourceViewerDecorationSupport( SourceViewerDecorationSupport support ) { - for( Object pref : fAnnotationPreferences.getAnnotationPreferences() ) { - support.setAnnotationPreference( (AnnotationPreference)pref ); - } - support.setCursorLinePainterPreferenceKeys( CURRENT_LINE, CURRENT_LINE_COLOR ); - } - - private IAnnotationAccess getAnnotationAccess() { - if ( fAnnotationAccess == null ) - fAnnotationAccess = createAnnotationAccess(); - return fAnnotationAccess; - } - - private ISharedTextColors getSharedColors() { - return EditorsUI.getSharedTextColors(); - } - - @SuppressWarnings("rawtypes") - protected IVerticalRuler createCompositeRuler() { - CompositeRuler ruler = new CompositeRuler(); - ruler.addDecorator( 0, new AnnotationRulerColumn( VERTICAL_RULER_WIDTH, getAnnotationAccess() ) ); - for( Iterator iter = ruler.getDecoratorIterator(); iter.hasNext(); ) { - IVerticalRulerColumn col = (IVerticalRulerColumn)iter.next(); - if ( col instanceof AnnotationRulerColumn ) { - AnnotationRulerColumn column = (AnnotationRulerColumn)col; - for( Iterator iter2 = fAnnotationPreferences.getAnnotationPreferences().iterator(); iter2.hasNext(); ) { - AnnotationPreference preference = (AnnotationPreference)iter2.next(); - column.addAnnotationType( preference.getAnnotationType() ); - } - column.addAnnotationType( Annotation.TYPE_UNKNOWN ); - break; - } - } - return ruler; - } - - private IOverviewRuler createOverviewRuler( ISharedTextColors sharedColors ) { - IOverviewRuler ruler = new OverviewRuler( getAnnotationAccess(), VERTICAL_RULER_WIDTH, sharedColors ); - for( Object o : fAnnotationPreferences.getAnnotationPreferences() ) { - AnnotationPreference preference = (AnnotationPreference)o; - if ( preference.contributesToHeader() ) - ruler.addHeaderAnnotationType( preference.getAnnotationType() ); - } - return ruler; - } - - private IOverviewRuler getOverviewRuler() { - if ( fOverviewRuler == null ) - fOverviewRuler = createOverviewRuler( getSharedColors() ); - return fOverviewRuler; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) - */ - @Override - public void propertyChange( PropertyChangeEvent event ) { - // TODO Auto-generated method stub - - } - - private IPreferenceStore getEditorPreferenceStore() { - return EditorsUI.getPreferenceStore(); - } - - public MenuManager getTextMenuManager() { - return fTextMenuManager; - } - - public MenuManager getRulerMenuManager() { - return fRulerMenuManager; - } - - public IVerticalRuler getVerticalRuler() { - return fVerticalRuler; - } + private final static int VERTICAL_RULER_WIDTH = 12; + private final static String CURRENT_LINE = AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE; + private final static String CURRENT_LINE_COLOR = AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR; + + private Composite fControl; + private VirtualSourceViewer fViewer; + + private IVerticalRuler fVerticalRuler; + private IOverviewRuler fOverviewRuler; + + private SourceViewerDecorationSupport fSourceViewerDecorationSupport; + private IAnnotationAccess fAnnotationAccess; + private MarkerAnnotationPreferences fAnnotationPreferences; + + private String fViewContextMenuId; + private String fRulerContextMenuId; + + private MenuManager fTextMenuManager; + private MenuManager fRulerMenuManager; + + private Menu fRulerContextMenu; + private Menu fTextContextMenu; + + private IMenuListener fMenuListener; + private MouseListener fMouseListener; + + private Map<String, IAction> fActions = new HashMap<String, IAction>(10); + + public DisassemblyPane(String contextMenuId, String rulerMenuId) { + fAnnotationPreferences = new MarkerAnnotationPreferences(); + setViewContextMenuId(contextMenuId); + setRulerContextMenuId(rulerMenuId); + } + + public void create(Composite parent) { + Composite composite = new Composite(parent, SWT.NONE); + composite.setLayout(new GridLayout()); + GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); + composite.setLayoutData(data); + + fVerticalRuler = createCompositeRuler(); + fOverviewRuler = createOverviewRuler(getSharedColors()); + + createActions(); + + fViewer = createViewer(composite, fVerticalRuler, fOverviewRuler); + + fControl = composite; + + createViewContextMenu(); + createRulerContextMenu(); + + if (fSourceViewerDecorationSupport != null) { + fSourceViewerDecorationSupport.install(getEditorPreferenceStore()); + } + } + + public Control getControl() { + return fControl; + } + + public VirtualSourceViewer getViewer() { + return fViewer; + } + + public void dispose() { + getEditorPreferenceStore().removePropertyChangeListener(this); + JFaceResources.getFontRegistry().removeListener(this); + JFaceResources.getColorRegistry().removeListener(this); + if (fSourceViewerDecorationSupport != null) { + fSourceViewerDecorationSupport.dispose(); + fSourceViewerDecorationSupport = null; + } + if (fActions != null) { + fActions.clear(); + fActions = null; + } + } + + protected void createActions() { + } + + public void setAction(String actionID, IAction action) { + Assert.isNotNull(actionID); + if (action == null) { + fActions.remove(actionID); + } else { + fActions.put(actionID, action); + } + } + + public IAction getAction(String actionID) { + Assert.isNotNull(actionID); + return fActions.get(actionID); + } + + protected void rulerContextMenuAboutToShow(IMenuManager menu) { + menu.add(new Separator(ITextEditorActionConstants.GROUP_REST)); + menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); + addAction(menu, IInternalCDebugUIConstants.ACTION_TOGGLE_BREAKPOINT); + addAction(menu, IInternalCDebugUIConstants.ACTION_ENABLE_DISABLE_BREAKPOINT); + addAction(menu, IInternalCDebugUIConstants.ACTION_BREAKPOINT_PROPERTIES); + } + + protected void viewContextMenuAboutToShow(IMenuManager menu) { + menu.add(new Separator(ITextEditorActionConstants.GROUP_REST)); + menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); + } + + protected void addAction(IMenuManager menu, String group, String actionId) { + IAction action = getAction(actionId); + if (action != null) { + if (action instanceof IUpdate) + ((IUpdate) action).update(); + IMenuManager subMenu = menu.findMenuUsingPath(group); + if (subMenu != null) + subMenu.add(action); + else + menu.appendToGroup(group, action); + } + } + + protected void addAction(IMenuManager menu, String actionId) { + IAction action = getAction(actionId); + if (action != null) { + if (action instanceof IUpdate) + ((IUpdate) action).update(); + menu.add(action); + } + } + + protected final IMenuListener getContextMenuListener() { + if (fMenuListener == null) { + fMenuListener = new IMenuListener() { + + @Override + public void menuAboutToShow(IMenuManager menu) { + String id = menu.getId(); + if (getRulerContextMenuId().equals(id)) { + // setFocus(); + rulerContextMenuAboutToShow(menu); + } else if (getViewContextMenuId().equals(id)) { + // setFocus(); + viewContextMenuAboutToShow(menu); + } + } + }; + } + return fMenuListener; + } + + protected final MouseListener getRulerMouseListener() { + if (fMouseListener == null) { + fMouseListener = new MouseListener() { + + private boolean fDoubleClicked = false; + + private void triggerAction(String actionID) { + IAction action = getAction(actionID); + if (action != null) { + if (action instanceof IUpdate) + ((IUpdate) action).update(); + if (action.isEnabled()) + action.run(); + } + } + + @Override + public void mouseUp(MouseEvent e) { + // setFocus(); + if (1 == e.button && !fDoubleClicked) + triggerAction(ITextEditorActionConstants.RULER_CLICK); + fDoubleClicked = false; + } + + @Override + public void mouseDoubleClick(MouseEvent e) { + if (1 == e.button) { + fDoubleClicked = true; + triggerAction(IInternalCDebugUIConstants.ACTION_TOGGLE_BREAKPOINT); + } + } + + @Override + public void mouseDown(MouseEvent e) { + StyledText text = getViewer().getTextWidget(); + if (text != null && !text.isDisposed()) { + Display display = text.getDisplay(); + Point location = display.getCursorLocation(); + getRulerContextMenu().setLocation(location.x, location.y); + } + } + }; + } + return fMouseListener; + } + + private Menu getTextContextMenu() { + return this.fTextContextMenu; + } + + private void setTextContextMenu(Menu textContextMenu) { + this.fTextContextMenu = textContextMenu; + } + + protected Menu getRulerContextMenu() { + return this.fRulerContextMenu; + } + + private void setRulerContextMenu(Menu rulerContextMenu) { + this.fRulerContextMenu = rulerContextMenu; + } + + public String getRulerContextMenuId() { + return fRulerContextMenuId; + } + + private void setRulerContextMenuId(String rulerContextMenuId) { + Assert.isNotNull(rulerContextMenuId); + fRulerContextMenuId = rulerContextMenuId; + } + + public String getViewContextMenuId() { + return fViewContextMenuId; + } + + private void setViewContextMenuId(String viewContextMenuId) { + Assert.isNotNull(viewContextMenuId); + fViewContextMenuId = viewContextMenuId; + } + + private void createViewContextMenu() { + String id = getViewContextMenuId(); + fTextMenuManager = new MenuManager(id, id); + fTextMenuManager.setRemoveAllWhenShown(true); + fTextMenuManager.addMenuListener(getContextMenuListener()); + StyledText styledText = getViewer().getTextWidget(); + setTextContextMenu(fTextMenuManager.createContextMenu(styledText)); + styledText.setMenu(getTextContextMenu()); + } + + private void createRulerContextMenu() { + String id = getRulerContextMenuId(); + fRulerMenuManager = new MenuManager(id, id); + fRulerMenuManager.setRemoveAllWhenShown(true); + fRulerMenuManager.addMenuListener(getContextMenuListener()); + Control rulerControl = fVerticalRuler.getControl(); + setRulerContextMenu(fRulerMenuManager.createContextMenu(rulerControl)); + rulerControl.setMenu(getRulerContextMenu()); + rulerControl.addMouseListener(getRulerMouseListener()); + } + + protected SourceViewerDecorationSupport getSourceViewerDecorationSupport(ISourceViewer viewer) { + if (fSourceViewerDecorationSupport == null) { + fSourceViewerDecorationSupport = new SourceViewerDecorationSupport(viewer, getOverviewRuler(), + getAnnotationAccess(), getSharedColors()); + configureSourceViewerDecorationSupport(fSourceViewerDecorationSupport); + } + return fSourceViewerDecorationSupport; + } + + protected VirtualSourceViewer createViewer(Composite parent, IVerticalRuler vertRuler, IOverviewRuler ovRuler) { + int styles = SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION; + VirtualSourceViewer viewer = new VirtualSourceViewer(parent, fVerticalRuler, fOverviewRuler, true, styles); + viewer.getControl().setLayoutData(parent.getLayoutData()); + viewer.setEditable(false); + viewer.getTextWidget().setFont(JFaceResources.getFont(IInternalCDebugUIConstants.DISASSEMBLY_FONT)); + viewer.setRangeIndicator(new DefaultRangeIndicator()); + getSourceViewerDecorationSupport(viewer); + viewer.configure(new SourceViewerConfiguration()); + JFaceResources.getFontRegistry().addListener(this); + JFaceResources.getColorRegistry().addListener(this); + getEditorPreferenceStore().addPropertyChangeListener(this); + return viewer; + } + + private IAnnotationAccess createAnnotationAccess() { + return new DefaultMarkerAnnotationAccess(); + } + + private void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) { + for (Object pref : fAnnotationPreferences.getAnnotationPreferences()) { + support.setAnnotationPreference((AnnotationPreference) pref); + } + support.setCursorLinePainterPreferenceKeys(CURRENT_LINE, CURRENT_LINE_COLOR); + } + + private IAnnotationAccess getAnnotationAccess() { + if (fAnnotationAccess == null) + fAnnotationAccess = createAnnotationAccess(); + return fAnnotationAccess; + } + + private ISharedTextColors getSharedColors() { + return EditorsUI.getSharedTextColors(); + } + + @SuppressWarnings("rawtypes") + protected IVerticalRuler createCompositeRuler() { + CompositeRuler ruler = new CompositeRuler(); + ruler.addDecorator(0, new AnnotationRulerColumn(VERTICAL_RULER_WIDTH, getAnnotationAccess())); + for (Iterator iter = ruler.getDecoratorIterator(); iter.hasNext();) { + IVerticalRulerColumn col = (IVerticalRulerColumn) iter.next(); + if (col instanceof AnnotationRulerColumn) { + AnnotationRulerColumn column = (AnnotationRulerColumn) col; + for (Iterator iter2 = fAnnotationPreferences.getAnnotationPreferences().iterator(); iter2.hasNext();) { + AnnotationPreference preference = (AnnotationPreference) iter2.next(); + column.addAnnotationType(preference.getAnnotationType()); + } + column.addAnnotationType(Annotation.TYPE_UNKNOWN); + break; + } + } + return ruler; + } + + private IOverviewRuler createOverviewRuler(ISharedTextColors sharedColors) { + IOverviewRuler ruler = new OverviewRuler(getAnnotationAccess(), VERTICAL_RULER_WIDTH, sharedColors); + for (Object o : fAnnotationPreferences.getAnnotationPreferences()) { + AnnotationPreference preference = (AnnotationPreference) o; + if (preference.contributesToHeader()) + ruler.addHeaderAnnotationType(preference.getAnnotationType()); + } + return ruler; + } + + private IOverviewRuler getOverviewRuler() { + if (fOverviewRuler == null) + fOverviewRuler = createOverviewRuler(getSharedColors()); + return fOverviewRuler; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) + */ + @Override + public void propertyChange(PropertyChangeEvent event) { + // TODO Auto-generated method stub + + } + + private IPreferenceStore getEditorPreferenceStore() { + return EditorsUI.getPreferenceStore(); + } + + public MenuManager getTextMenuManager() { + return fTextMenuManager; + } + + public MenuManager getRulerMenuManager() { + return fRulerMenuManager; + } + + public IVerticalRuler getVerticalRuler() { + return fVerticalRuler; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentAnnotationProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentAnnotationProvider.java index a7a46a28fdc..099a307c706 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentAnnotationProvider.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentAnnotationProvider.java @@ -24,80 +24,80 @@ import org.eclipse.jface.text.source.Annotation; import org.eclipse.ui.progress.UIJob; /** - * org.eclipse.cdt.debug.internal.ui.disassembly.viewer.DocumentAnnotationProvider: + * org.eclipse.cdt.debug.internal.ui.disassembly.viewer.DocumentAnnotationProvider: * //TODO Add description. */ public class DocumentAnnotationProvider { - private VirtualDocument fDocument; + private VirtualDocument fDocument; - public DocumentAnnotationProvider( VirtualDocument document ) { - fDocument = document; - } + public DocumentAnnotationProvider(VirtualDocument document) { + fDocument = document; + } - public void dispose() { - fDocument = null; - } + public void dispose() { + fDocument = null; + } - public void update( Object parent, Object[] elements, IDocumentPresentation context ) { - IDocumentElementAnnotationProvider annotationProvider = getAnnotationAdapter( parent ); - if ( annotationProvider != null ) { - Object root = getDocument().getContentProvider().getRoot(); - Object base = getDocument().getContentProvider().getBase(); - DocumentAnnotationUpdate[] updates = new DocumentAnnotationUpdate[elements.length]; - for ( int i = 0; i < elements.length; ++i ) { - updates[i] = new DocumentAnnotationUpdate( this, context, root, base, elements[i], i ); - } - annotationProvider.update( updates ); - } - } + public void update(Object parent, Object[] elements, IDocumentPresentation context) { + IDocumentElementAnnotationProvider annotationProvider = getAnnotationAdapter(parent); + if (annotationProvider != null) { + Object root = getDocument().getContentProvider().getRoot(); + Object base = getDocument().getContentProvider().getBase(); + DocumentAnnotationUpdate[] updates = new DocumentAnnotationUpdate[elements.length]; + for (int i = 0; i < elements.length; ++i) { + updates[i] = new DocumentAnnotationUpdate(this, context, root, base, elements[i], i); + } + annotationProvider.update(updates); + } + } - public void update( Object parent, Object element, int index, IDocumentPresentation context ) { - IDocumentElementAnnotationProvider annotationProvider = getAnnotationAdapter( element ); - if ( annotationProvider != null ) { - Object root = getDocument().getContentProvider().getRoot(); - Object base = getDocument().getContentProvider().getBase(); - annotationProvider.update( new DocumentAnnotationUpdate[] { new DocumentAnnotationUpdate( this, context, root, base, element, index ) } ); - } - } + public void update(Object parent, Object element, int index, IDocumentPresentation context) { + IDocumentElementAnnotationProvider annotationProvider = getAnnotationAdapter(element); + if (annotationProvider != null) { + Object root = getDocument().getContentProvider().getRoot(); + Object base = getDocument().getContentProvider().getBase(); + annotationProvider.update(new DocumentAnnotationUpdate[] { + new DocumentAnnotationUpdate(this, context, root, base, element, index) }); + } + } - public void completed( DocumentAnnotationUpdate update ) { - if ( update.isCanceled() ) - return; - - final int index = update.getIndex(); - final Annotation[] annotations = update.getAnnotations(); - UIJob uiJob = new UIJob( "Add annotations" ) { //$NON-NLS-1$ - - /* (non-Javadoc) - * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) - */ - @Override - public IStatus runInUIThread( IProgressMonitor monitor ) { - VirtualDocument document = getDocument(); - if ( document != null ) { - getDocument().updateAnnotations( index, annotations ); - } - return Status.OK_STATUS; - } - }; - uiJob.setSystem( true ); - uiJob.schedule(); - } + public void completed(DocumentAnnotationUpdate update) { + if (update.isCanceled()) + return; - protected IDocumentElementAnnotationProvider getAnnotationAdapter( Object element ) { - IDocumentElementAnnotationProvider adapter = null; - if ( element instanceof IDocumentElementAnnotationProvider ) { - adapter = (IDocumentElementAnnotationProvider)element; - } - else if ( element instanceof IAdaptable ) { - IAdaptable adaptable = (IAdaptable)element; - adapter = adaptable.getAdapter( IDocumentElementAnnotationProvider.class ); - } - return adapter; - } + final int index = update.getIndex(); + final Annotation[] annotations = update.getAnnotations(); + UIJob uiJob = new UIJob("Add annotations") { //$NON-NLS-1$ - protected VirtualDocument getDocument() { - return fDocument; - } + /* (non-Javadoc) + * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + public IStatus runInUIThread(IProgressMonitor monitor) { + VirtualDocument document = getDocument(); + if (document != null) { + getDocument().updateAnnotations(index, annotations); + } + return Status.OK_STATUS; + } + }; + uiJob.setSystem(true); + uiJob.schedule(); + } + + protected IDocumentElementAnnotationProvider getAnnotationAdapter(Object element) { + IDocumentElementAnnotationProvider adapter = null; + if (element instanceof IDocumentElementAnnotationProvider) { + adapter = (IDocumentElementAnnotationProvider) element; + } else if (element instanceof IAdaptable) { + IAdaptable adaptable = (IAdaptable) element; + adapter = adaptable.getAdapter(IDocumentElementAnnotationProvider.class); + } + return adapter; + } + + protected VirtualDocument getDocument() { + return fDocument; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentAnnotationUpdate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentAnnotationUpdate.java index 0296c8fb5a6..650deb25530 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentAnnotationUpdate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentAnnotationUpdate.java @@ -22,54 +22,55 @@ import org.eclipse.cdt.debug.ui.disassembly.IDocumentPresentation; import org.eclipse.jface.text.source.Annotation; /** - * org.eclipse.cdt.debug.internal.ui.disassembly.viewer.DocumentAnnotationUpdate: + * org.eclipse.cdt.debug.internal.ui.disassembly.viewer.DocumentAnnotationUpdate: * //TODO Add description. */ public class DocumentAnnotationUpdate extends DocumentUpdate implements IDocumentElementAnnotationUpdate { - private DocumentAnnotationProvider fAnnotationProvider; - private int fIndex = 0; - private List<Annotation> fAnnotations; + private DocumentAnnotationProvider fAnnotationProvider; + private int fIndex = 0; + private List<Annotation> fAnnotations; - public DocumentAnnotationUpdate( DocumentAnnotationProvider annotationProvider, IDocumentPresentation presentationContext, Object root, Object base, Object element, int index ) { - super( presentationContext, root, base, element ); - fAnnotationProvider = annotationProvider; - fIndex = index; - fAnnotations = new ArrayList<Annotation>(); - } + public DocumentAnnotationUpdate(DocumentAnnotationProvider annotationProvider, + IDocumentPresentation presentationContext, Object root, Object base, Object element, int index) { + super(presentationContext, root, base, element); + fAnnotationProvider = annotationProvider; + fIndex = index; + fAnnotations = new ArrayList<Annotation>(); + } - /* (non-Javadoc) - * @see com.arm.eclipse.rvd.ui.disassembly.IDocumentElementAnnotationUpdate#addAnnotation(org.eclipse.jface.text.source.Annotation) - */ - @Override - public void addAnnotation( Annotation annotation ) { - fAnnotations.add( annotation ); - } + /* (non-Javadoc) + * @see com.arm.eclipse.rvd.ui.disassembly.IDocumentElementAnnotationUpdate#addAnnotation(org.eclipse.jface.text.source.Annotation) + */ + @Override + public void addAnnotation(Annotation annotation) { + fAnnotations.add(annotation); + } - public int getIndex() { - return fIndex; - } + public int getIndex() { + return fIndex; + } - public Annotation[] getAnnotations() { - return fAnnotations.toArray( new Annotation[fAnnotations.size()] ); - } + public Annotation[] getAnnotations() { + return fAnnotations.toArray(new Annotation[fAnnotations.size()]); + } - protected DocumentAnnotationProvider getAnnotationProvider() { - return fAnnotationProvider; - } + protected DocumentAnnotationProvider getAnnotationProvider() { + return fAnnotationProvider; + } - /* (non-Javadoc) - * @see com.arm.eclipse.rvd.internal.ui.disassembly.DocumentUpdate#done() - */ - @Override - public void done() { - super.done(); - getAnnotationProvider().completed( this ); - } + /* (non-Javadoc) + * @see com.arm.eclipse.rvd.internal.ui.disassembly.DocumentUpdate#done() + */ + @Override + public void done() { + super.done(); + getAnnotationProvider().completed(this); + } - /* (non-Javadoc) - * @see com.arm.eclipse.rvd.internal.ui.disassembly.DocumentUpdate#startRequest() - */ - @Override - void startRequest() { - } + /* (non-Javadoc) + * @see com.arm.eclipse.rvd.internal.ui.disassembly.DocumentUpdate#startRequest() + */ + @Override + void startRequest() { + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentBaseChangeUpdate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentBaseChangeUpdate.java index 57e4edd92a3..4ca4420da10 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentBaseChangeUpdate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentBaseChangeUpdate.java @@ -20,69 +20,71 @@ import org.eclipse.cdt.debug.ui.disassembly.IDocumentPresentation; public class DocumentBaseChangeUpdate extends DocumentUpdate implements IDocumentBaseChangeUpdate { - private DocumentContentProvider fContentProvider; - private IDocumentElementContentProvider fElementContentProvider; - private int fOriginalOffset = 0; - private int fOffset = 0; + private DocumentContentProvider fContentProvider; + private IDocumentElementContentProvider fElementContentProvider; + private int fOriginalOffset = 0; + private int fOffset = 0; - public DocumentBaseChangeUpdate( DocumentContentProvider contentProvider, IDocumentElementContentProvider elementContentProvider, IDocumentPresentation presentationContext, Object root, Object base, Object input, int offset ) { - super( presentationContext, root, base, input ); - fContentProvider = contentProvider; - fElementContentProvider = elementContentProvider; - fOriginalOffset = offset; - fOffset = offset; - } + public DocumentBaseChangeUpdate(DocumentContentProvider contentProvider, + IDocumentElementContentProvider elementContentProvider, IDocumentPresentation presentationContext, + Object root, Object base, Object input, int offset) { + super(presentationContext, root, base, input); + fContentProvider = contentProvider; + fElementContentProvider = elementContentProvider; + fOriginalOffset = offset; + fOffset = offset; + } - /* (non-Javadoc) - * @see com.arm.eclipse.rvd.ui.disassembly.IDocumentBaseChangeUpdate#setBaseElement(java.lang.Object) - */ - @Override - public void setBaseElement( Object base ) { - super.setBaseElement( base ); - } + /* (non-Javadoc) + * @see com.arm.eclipse.rvd.ui.disassembly.IDocumentBaseChangeUpdate#setBaseElement(java.lang.Object) + */ + @Override + public void setBaseElement(Object base) { + super.setBaseElement(base); + } - /* (non-Javadoc) - * @see com.arm.eclipse.rvd.ui.disassembly.IDocumentBaseChangeUpdate#setOffset(int) - */ - @Override - public void setOffset( int offset ) { - fOffset = offset; - } + /* (non-Javadoc) + * @see com.arm.eclipse.rvd.ui.disassembly.IDocumentBaseChangeUpdate#setOffset(int) + */ + @Override + public void setOffset(int offset) { + fOffset = offset; + } - /* (non-Javadoc) - * @see com.arm.eclipse.rvd.ui.disassembly.IDocumentBaseChangeUpdate#getOriginalOffset() - */ - @Override + /* (non-Javadoc) + * @see com.arm.eclipse.rvd.ui.disassembly.IDocumentBaseChangeUpdate#getOriginalOffset() + */ + @Override public int getOriginalOffset() { - return fOriginalOffset; - } + return fOriginalOffset; + } - /* (non-Javadoc) - * @see org.eclipse.debug.internal.core.commands.Request#done() - */ - @Override - public void done() { - super.done(); - getContentProvider().inputChanged( this ); - } + /* (non-Javadoc) + * @see org.eclipse.debug.internal.core.commands.Request#done() + */ + @Override + public void done() { + super.done(); + getContentProvider().inputChanged(this); + } - public int getOffset() { - return fOffset; - } + public int getOffset() { + return fOffset; + } - /* (non-Javadoc) - * @see com.arm.eclipse.rvd.internal.ui.disassembly.DocumentUpdate#startRequest() - */ - @Override - void startRequest() { - getElementContentProvider().updateInput( this ); - } + /* (non-Javadoc) + * @see com.arm.eclipse.rvd.internal.ui.disassembly.DocumentUpdate#startRequest() + */ + @Override + void startRequest() { + getElementContentProvider().updateInput(this); + } - protected DocumentContentProvider getContentProvider() { - return fContentProvider; - } + protected DocumentContentProvider getContentProvider() { + return fContentProvider; + } - protected IDocumentElementContentProvider getElementContentProvider() { - return fElementContentProvider; - } + protected IDocumentElementContentProvider getElementContentProvider() { + return fElementContentProvider; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentContentProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentContentProvider.java index 25957f2e5a5..52c274873af 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentContentProvider.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentContentProvider.java @@ -34,436 +34,434 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationCont import org.eclipse.ui.progress.WorkbenchJob; /** - * Manages the mapping between the viewer model and the underlying debug model - * through the content, label and annotation adapters. + * Manages the mapping between the viewer model and the underlying debug model + * through the content, label and annotation adapters. * Maintains the list of model proxies and reacts to the debug model changes. */ public class DocumentContentProvider implements IModelChangedListener { - private VirtualSourceViewer fViewer; - private VirtualDocument fDocument; - - private Object fRoot; - private Object fBase; - private Object fInput; - - private IModelProxy fRootProxy; - private IModelProxy fBaseProxy; - private List<IModelProxy> fLineProxies = new ArrayList<IModelProxy>( 50 ); - private Map<Object, Integer> fLineElements = new HashMap<Object, Integer>( 20 ); - - private DocumentUpdate fUpdateInProgress; - - public DocumentContentProvider( VirtualDocument document ) { - super(); - fDocument = document; - } - - protected void init( Object root ) { - fRoot = root; - installRootProxy( fRoot ); - } - - public void update( IDocumentPresentation presentationContext, int lineCount, int offset, boolean reveal ) { - IDocumentElementContentProvider contentAdapter = getContentAdapter( getInput() ); - if ( contentAdapter != null && getRoot() != null && getBase() != null ) { - DocumentContentUpdate update = new DocumentContentUpdate( this, contentAdapter, presentationContext, getRoot(), getBase(), getInput(), lineCount, offset, reveal ); - schedule( update ); - } - else { - updateCompleted( new DocumentContentUpdate( this, contentAdapter, presentationContext, getRoot(), getBase(), getInput(), lineCount, offset, reveal ) ); - } - } - - public synchronized void updateCompleted( DocumentContentUpdate update ) { - if ( fUpdateInProgress == update ) { - fUpdateInProgress = null; - } - if ( !update.isCanceled() ) { - disposeLineProxies(); - fLineElements.clear(); - getDocument().setCurrentOffset( update.getOffset() ); - Object[] elements = update.getElements(); - for ( int i = 0; i < elements.length; ++i ) { - fLineElements.put( elements[i], Integer.valueOf( i ) ); - installLineProxy( i, elements[i] ); - getDocument().updateElement( getInput(), i, elements[i] ); - } - } - // TODO: display error content if status is not OK - } - - protected IDocumentElementContentProvider getContentAdapter( Object element ) { - IDocumentElementContentProvider adapter = null; - if ( element instanceof IDocumentElementContentProvider ) { - adapter = (IDocumentElementContentProvider)element; - } - else if ( element instanceof IAdaptable ) { - IAdaptable adaptable = (IAdaptable)element; - adapter = adaptable.getAdapter( IDocumentElementContentProvider.class ); - } - return adapter; - } - - protected VirtualDocument getDocument() { - return fDocument; - } - - public Object getRoot() { - return fRoot; - } - - public Object getInput() { - return fInput; - } - - public Object getBase() { - return fBase; - } - - public void dispose() { - synchronized( this ) { - if ( fUpdateInProgress != null ) { - fUpdateInProgress.cancel(); - } - } - disposeRootProxy(); - fDocument = null; - fInput = null; - fViewer = null; - } - - public void changeInput( VirtualSourceViewer viewer, IDocumentPresentation presentationContext, Object oldInput, Object newInput, int offset ) { - fViewer = viewer; - fInput = newInput; - IDocumentElementContentProvider contentAdapter = getContentAdapter( getInput() ); - if ( contentAdapter != null ) { - DocumentBaseChangeUpdate update = new DocumentBaseChangeUpdate( this, contentAdapter, presentationContext, getRoot(), getBase(), getInput(), offset ); - schedule( update ); - } - else { - inputChanged( new DocumentBaseChangeUpdate( this, contentAdapter, presentationContext, getRoot(), getBase(), getInput(), offset ) ); - } - } - - public synchronized void inputChanged( DocumentBaseChangeUpdate update ) { - if ( fUpdateInProgress == update ) { - fUpdateInProgress = null; - } - Object newBase = update.getBaseElement(); - int newOffset = update.getOffset(); - VirtualDocument document = getDocument(); - if ( document != null ) { - boolean needsUpdate = false; - if ( newBase != getBase() ) { - fBase = newBase; - disposeBaseProxy(); - installBaseProxy( fBase ); - needsUpdate = true; - } - if ( newOffset != document.getCurrentOffset() ) { - document.setCurrentOffset( newOffset ); - needsUpdate = true; - } - if ( needsUpdate ) { - WorkbenchJob job = new WorkbenchJob( "refresh content" ) { //$NON-NLS-1$ - - /* (non-Javadoc) - * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) - */ - @Override - public IStatus runInUIThread( IProgressMonitor monitor ) { - getViewer().refresh( true ); - return Status.OK_STATUS; - } - }; - job.setSystem( true ); - job.schedule(); - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IModelChangedListener#modelChanged(org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta, org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxy) - */ - @Override - public void modelChanged( final IModelDelta delta, final IModelProxy proxy ) { - WorkbenchJob job = new WorkbenchJob( "process model delta" ) { //$NON-NLS-1$ - - /* (non-Javadoc) - * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) - */ - @Override - public IStatus runInUIThread( IProgressMonitor monitor ) { - if ( !proxy.isDisposed() ) { - handleModelChanges( delta ); - } - return Status.OK_STATUS; - } - }; - job.setSystem( true ); - job.schedule(); - } - - protected void handleModelChanges( IModelDelta delta ) { - updateNodes( new IModelDelta[] { delta } ); - } - - protected void updateNodes( IModelDelta[] nodes ) { - for( int i = 0; i < nodes.length; i++ ) { - IModelDelta node = nodes[i]; - int flags = node.getFlags(); - - if ( (flags & IModelDelta.ADDED) != 0 ) { - handleAdd( node ); - } - if ( (flags & IModelDelta.REMOVED) != 0 ) { - handleRemove( node ); - } - if ( (flags & IModelDelta.CONTENT) != 0 ) { - handleContent( node ); - } - if ( (flags & IModelDelta.SELECT) != 0 ) { - handleSelect( node ); - } - if ( (flags & IModelDelta.STATE) != 0 ) { - handleState( node ); - } - if ( (flags & IModelDelta.INSERTED) != 0 ) { - handleInsert( node ); - } - if ( (flags & IModelDelta.REPLACED) != 0 ) { - handleReplace( node ); - } - if ( (flags & IModelDelta.INSTALL) != 0 ) { - handleInstall( node ); - } - if ( (flags & IModelDelta.UNINSTALL) != 0 ) { - handleUninstall( node ); - } - if ( (flags & IModelDelta.REVEAL) != 0 ) { - handleReveal( node ); - } - updateNodes( node.getChildDeltas() ); - } - } - - protected void handleState( IModelDelta delta ) { - int index = getElementIndex( delta.getElement() ); - if ( index >= 0 ) { - getDocument().updateElement( getInput(), index, delta.getElement() ); - } - } - - protected void handleSelect( IModelDelta delta ) { - - } - - protected void handleContent( IModelDelta delta ) { - if ( delta.getElement().equals( getRoot() ) || delta.getElement().equals( getBase() ) ) { - getViewer().refresh(); - } - } - - protected void handleRemove( IModelDelta delta ) { - - } - - protected void handleAdd( IModelDelta delta ) { - - } - - protected void handleInsert( IModelDelta delta ) { - - } - - protected void handleReplace( IModelDelta delta ) { - - } - - protected void handleReveal( IModelDelta delta ) { - - } - - protected void handleInstall( IModelDelta delta ) { - } - - protected void handleUninstall( IModelDelta delta ) { - } - - protected synchronized void installRootProxy( Object element ) { - if ( element != null && (!element.equals( getRoot()) || fRootProxy == null) ) { - disposeRootProxy(); - IModelProxyFactory modelProxyFactory = getModelProxyFactoryAdapter( element ); - if ( modelProxyFactory != null ) { - final IModelProxy proxy = modelProxyFactory.createModelProxy( element, getPresentationContext() ); - if ( proxy != null ) { - fRootProxy = proxy; - Job job = new Job( "Model Proxy installed notification job" ) {//$NON-NLS-1$ - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) - */ - @Override - protected IStatus run( IProgressMonitor monitor ) { - if ( !monitor.isCanceled() ) { - proxy.init( getPresentationContext() ); - proxy.addModelChangedListener( DocumentContentProvider.this ); - proxy.installed( getViewer() ); - } - return Status.OK_STATUS; - } - }; - job.setSystem( true ); - job.schedule(); - } - } - } - } - - protected synchronized void installBaseProxy( Object element ) { - if ( element != null && (!element.equals( getBase()) || fBaseProxy == null) ) { - IModelProxyFactory modelProxyFactory = getModelProxyFactoryAdapter( element ); - if ( modelProxyFactory != null ) { - final IModelProxy proxy = modelProxyFactory.createModelProxy( element, getPresentationContext() ); - if ( proxy != null ) { - fBaseProxy = proxy; - Job job = new Job( "Model Proxy installed notification job" ) {//$NON-NLS-1$ - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) - */ - @Override - protected IStatus run( IProgressMonitor monitor ) { - if ( !monitor.isCanceled() ) { - proxy.init( getPresentationContext() ); - proxy.addModelChangedListener( DocumentContentProvider.this ); - proxy.installed( getViewer() ); - } - return Status.OK_STATUS; - } - }; - job.setSystem( true ); - job.schedule(); - } - } - } - } - - protected synchronized void installLineProxy( int index, Object element ) { - IModelProxyFactory modelProxyFactory = getModelProxyFactoryAdapter( element ); - if ( modelProxyFactory != null ) { - final IModelProxy proxy = modelProxyFactory.createModelProxy( element, getPresentationContext() ); - if ( proxy != null ) { - fLineProxies.add( index, proxy ); - Job job = new Job( "Model Proxy installed notification job" ) {//$NON-NLS-1$ - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) - */ - @Override - protected IStatus run( IProgressMonitor monitor ) { - if ( !monitor.isCanceled() ) { - proxy.init( getPresentationContext() ); - proxy.addModelChangedListener( DocumentContentProvider.this ); - proxy.installed( getViewer() ); - } - return Status.OK_STATUS; - } - }; - job.setSystem( true ); - job.schedule(); - } - } - } - - protected IModelProxyFactory getModelProxyFactoryAdapter( Object element ) { - IModelProxyFactory adapter = null; - if ( element instanceof IModelProxyFactory ) { - adapter = (IModelProxyFactory)element; - } - else if ( element instanceof IAdaptable ) { - IAdaptable adaptable = (IAdaptable)element; - adapter = adaptable.getAdapter( IModelProxyFactory.class ); - } - return adapter; - } - - protected IPresentationContext getPresentationContext() { - return getDocument().getPresentationContext(); - } - - protected synchronized void disposeRootProxy() { - disposeBaseProxy(); - if ( fRootProxy != null ) { - fRootProxy.dispose(); - } - fRootProxy = null; - } - - protected synchronized void disposeBaseProxy() { - disposeLineProxies(); - if ( fBaseProxy != null ) { - fBaseProxy.dispose(); - } - fBaseProxy = null; - } - - protected synchronized void disposeLineProxies() { - for ( IModelProxy proxy : fLineProxies ) { - proxy.dispose(); - } - fLineProxies.clear(); - } - - protected VirtualSourceViewer getViewer() { - return fViewer; - } - - synchronized void schedule( DocumentUpdate update ) { - if ( fUpdateInProgress != null ) { - if ( update instanceof DocumentBaseChangeUpdate ) { - // cancel the earlier update and start the latest - fUpdateInProgress.cancel(); - fUpdateInProgress.done(); - fUpdateInProgress = update; - fUpdateInProgress.start(); - } - else if ( fUpdateInProgress instanceof DocumentBaseChangeUpdate - && update instanceof DocumentContentUpdate ) { - // cancel the content update because the base change update - // will start a new one - update.cancel(); - update.done(); - } - else if ( fUpdateInProgress instanceof DocumentContentUpdate - && update instanceof DocumentBaseChangeUpdate ) { - // cancel the content update and start the base change update - fUpdateInProgress.cancel(); - fUpdateInProgress.done(); - fUpdateInProgress = update; - fUpdateInProgress.start(); - } - } - else { - fUpdateInProgress = update; - fUpdateInProgress.start(); - } - } - - private int getElementIndex( Object element ) { - Integer index = fLineElements.get( element ); - return ( index != null ) ? index.intValue() : -1; - } - - protected Object getElementAtLine( int lineNumber ) { - synchronized( fLineElements ) { - for ( Object element : fLineElements.keySet() ) { - if ( fLineElements.get( element ).intValue() == lineNumber ) { - return element; - } - } - } - return null; - } + private VirtualSourceViewer fViewer; + private VirtualDocument fDocument; + + private Object fRoot; + private Object fBase; + private Object fInput; + + private IModelProxy fRootProxy; + private IModelProxy fBaseProxy; + private List<IModelProxy> fLineProxies = new ArrayList<IModelProxy>(50); + private Map<Object, Integer> fLineElements = new HashMap<Object, Integer>(20); + + private DocumentUpdate fUpdateInProgress; + + public DocumentContentProvider(VirtualDocument document) { + super(); + fDocument = document; + } + + protected void init(Object root) { + fRoot = root; + installRootProxy(fRoot); + } + + public void update(IDocumentPresentation presentationContext, int lineCount, int offset, boolean reveal) { + IDocumentElementContentProvider contentAdapter = getContentAdapter(getInput()); + if (contentAdapter != null && getRoot() != null && getBase() != null) { + DocumentContentUpdate update = new DocumentContentUpdate(this, contentAdapter, presentationContext, + getRoot(), getBase(), getInput(), lineCount, offset, reveal); + schedule(update); + } else { + updateCompleted(new DocumentContentUpdate(this, contentAdapter, presentationContext, getRoot(), getBase(), + getInput(), lineCount, offset, reveal)); + } + } + + public synchronized void updateCompleted(DocumentContentUpdate update) { + if (fUpdateInProgress == update) { + fUpdateInProgress = null; + } + if (!update.isCanceled()) { + disposeLineProxies(); + fLineElements.clear(); + getDocument().setCurrentOffset(update.getOffset()); + Object[] elements = update.getElements(); + for (int i = 0; i < elements.length; ++i) { + fLineElements.put(elements[i], Integer.valueOf(i)); + installLineProxy(i, elements[i]); + getDocument().updateElement(getInput(), i, elements[i]); + } + } + // TODO: display error content if status is not OK + } + + protected IDocumentElementContentProvider getContentAdapter(Object element) { + IDocumentElementContentProvider adapter = null; + if (element instanceof IDocumentElementContentProvider) { + adapter = (IDocumentElementContentProvider) element; + } else if (element instanceof IAdaptable) { + IAdaptable adaptable = (IAdaptable) element; + adapter = adaptable.getAdapter(IDocumentElementContentProvider.class); + } + return adapter; + } + + protected VirtualDocument getDocument() { + return fDocument; + } + + public Object getRoot() { + return fRoot; + } + + public Object getInput() { + return fInput; + } + + public Object getBase() { + return fBase; + } + + public void dispose() { + synchronized (this) { + if (fUpdateInProgress != null) { + fUpdateInProgress.cancel(); + } + } + disposeRootProxy(); + fDocument = null; + fInput = null; + fViewer = null; + } + + public void changeInput(VirtualSourceViewer viewer, IDocumentPresentation presentationContext, Object oldInput, + Object newInput, int offset) { + fViewer = viewer; + fInput = newInput; + IDocumentElementContentProvider contentAdapter = getContentAdapter(getInput()); + if (contentAdapter != null) { + DocumentBaseChangeUpdate update = new DocumentBaseChangeUpdate(this, contentAdapter, presentationContext, + getRoot(), getBase(), getInput(), offset); + schedule(update); + } else { + inputChanged(new DocumentBaseChangeUpdate(this, contentAdapter, presentationContext, getRoot(), getBase(), + getInput(), offset)); + } + } + + public synchronized void inputChanged(DocumentBaseChangeUpdate update) { + if (fUpdateInProgress == update) { + fUpdateInProgress = null; + } + Object newBase = update.getBaseElement(); + int newOffset = update.getOffset(); + VirtualDocument document = getDocument(); + if (document != null) { + boolean needsUpdate = false; + if (newBase != getBase()) { + fBase = newBase; + disposeBaseProxy(); + installBaseProxy(fBase); + needsUpdate = true; + } + if (newOffset != document.getCurrentOffset()) { + document.setCurrentOffset(newOffset); + needsUpdate = true; + } + if (needsUpdate) { + WorkbenchJob job = new WorkbenchJob("refresh content") { //$NON-NLS-1$ + + /* (non-Javadoc) + * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + public IStatus runInUIThread(IProgressMonitor monitor) { + getViewer().refresh(true); + return Status.OK_STATUS; + } + }; + job.setSystem(true); + job.schedule(); + } + } + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IModelChangedListener#modelChanged(org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta, org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxy) + */ + @Override + public void modelChanged(final IModelDelta delta, final IModelProxy proxy) { + WorkbenchJob job = new WorkbenchJob("process model delta") { //$NON-NLS-1$ + + /* (non-Javadoc) + * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + public IStatus runInUIThread(IProgressMonitor monitor) { + if (!proxy.isDisposed()) { + handleModelChanges(delta); + } + return Status.OK_STATUS; + } + }; + job.setSystem(true); + job.schedule(); + } + + protected void handleModelChanges(IModelDelta delta) { + updateNodes(new IModelDelta[] { delta }); + } + + protected void updateNodes(IModelDelta[] nodes) { + for (int i = 0; i < nodes.length; i++) { + IModelDelta node = nodes[i]; + int flags = node.getFlags(); + + if ((flags & IModelDelta.ADDED) != 0) { + handleAdd(node); + } + if ((flags & IModelDelta.REMOVED) != 0) { + handleRemove(node); + } + if ((flags & IModelDelta.CONTENT) != 0) { + handleContent(node); + } + if ((flags & IModelDelta.SELECT) != 0) { + handleSelect(node); + } + if ((flags & IModelDelta.STATE) != 0) { + handleState(node); + } + if ((flags & IModelDelta.INSERTED) != 0) { + handleInsert(node); + } + if ((flags & IModelDelta.REPLACED) != 0) { + handleReplace(node); + } + if ((flags & IModelDelta.INSTALL) != 0) { + handleInstall(node); + } + if ((flags & IModelDelta.UNINSTALL) != 0) { + handleUninstall(node); + } + if ((flags & IModelDelta.REVEAL) != 0) { + handleReveal(node); + } + updateNodes(node.getChildDeltas()); + } + } + + protected void handleState(IModelDelta delta) { + int index = getElementIndex(delta.getElement()); + if (index >= 0) { + getDocument().updateElement(getInput(), index, delta.getElement()); + } + } + + protected void handleSelect(IModelDelta delta) { + + } + + protected void handleContent(IModelDelta delta) { + if (delta.getElement().equals(getRoot()) || delta.getElement().equals(getBase())) { + getViewer().refresh(); + } + } + + protected void handleRemove(IModelDelta delta) { + + } + + protected void handleAdd(IModelDelta delta) { + + } + + protected void handleInsert(IModelDelta delta) { + + } + + protected void handleReplace(IModelDelta delta) { + + } + + protected void handleReveal(IModelDelta delta) { + + } + + protected void handleInstall(IModelDelta delta) { + } + + protected void handleUninstall(IModelDelta delta) { + } + + protected synchronized void installRootProxy(Object element) { + if (element != null && (!element.equals(getRoot()) || fRootProxy == null)) { + disposeRootProxy(); + IModelProxyFactory modelProxyFactory = getModelProxyFactoryAdapter(element); + if (modelProxyFactory != null) { + final IModelProxy proxy = modelProxyFactory.createModelProxy(element, getPresentationContext()); + if (proxy != null) { + fRootProxy = proxy; + Job job = new Job("Model Proxy installed notification job") {//$NON-NLS-1$ + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + protected IStatus run(IProgressMonitor monitor) { + if (!monitor.isCanceled()) { + proxy.init(getPresentationContext()); + proxy.addModelChangedListener(DocumentContentProvider.this); + proxy.installed(getViewer()); + } + return Status.OK_STATUS; + } + }; + job.setSystem(true); + job.schedule(); + } + } + } + } + + protected synchronized void installBaseProxy(Object element) { + if (element != null && (!element.equals(getBase()) || fBaseProxy == null)) { + IModelProxyFactory modelProxyFactory = getModelProxyFactoryAdapter(element); + if (modelProxyFactory != null) { + final IModelProxy proxy = modelProxyFactory.createModelProxy(element, getPresentationContext()); + if (proxy != null) { + fBaseProxy = proxy; + Job job = new Job("Model Proxy installed notification job") {//$NON-NLS-1$ + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + protected IStatus run(IProgressMonitor monitor) { + if (!monitor.isCanceled()) { + proxy.init(getPresentationContext()); + proxy.addModelChangedListener(DocumentContentProvider.this); + proxy.installed(getViewer()); + } + return Status.OK_STATUS; + } + }; + job.setSystem(true); + job.schedule(); + } + } + } + } + + protected synchronized void installLineProxy(int index, Object element) { + IModelProxyFactory modelProxyFactory = getModelProxyFactoryAdapter(element); + if (modelProxyFactory != null) { + final IModelProxy proxy = modelProxyFactory.createModelProxy(element, getPresentationContext()); + if (proxy != null) { + fLineProxies.add(index, proxy); + Job job = new Job("Model Proxy installed notification job") {//$NON-NLS-1$ + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + protected IStatus run(IProgressMonitor monitor) { + if (!monitor.isCanceled()) { + proxy.init(getPresentationContext()); + proxy.addModelChangedListener(DocumentContentProvider.this); + proxy.installed(getViewer()); + } + return Status.OK_STATUS; + } + }; + job.setSystem(true); + job.schedule(); + } + } + } + + protected IModelProxyFactory getModelProxyFactoryAdapter(Object element) { + IModelProxyFactory adapter = null; + if (element instanceof IModelProxyFactory) { + adapter = (IModelProxyFactory) element; + } else if (element instanceof IAdaptable) { + IAdaptable adaptable = (IAdaptable) element; + adapter = adaptable.getAdapter(IModelProxyFactory.class); + } + return adapter; + } + + protected IPresentationContext getPresentationContext() { + return getDocument().getPresentationContext(); + } + + protected synchronized void disposeRootProxy() { + disposeBaseProxy(); + if (fRootProxy != null) { + fRootProxy.dispose(); + } + fRootProxy = null; + } + + protected synchronized void disposeBaseProxy() { + disposeLineProxies(); + if (fBaseProxy != null) { + fBaseProxy.dispose(); + } + fBaseProxy = null; + } + + protected synchronized void disposeLineProxies() { + for (IModelProxy proxy : fLineProxies) { + proxy.dispose(); + } + fLineProxies.clear(); + } + + protected VirtualSourceViewer getViewer() { + return fViewer; + } + + synchronized void schedule(DocumentUpdate update) { + if (fUpdateInProgress != null) { + if (update instanceof DocumentBaseChangeUpdate) { + // cancel the earlier update and start the latest + fUpdateInProgress.cancel(); + fUpdateInProgress.done(); + fUpdateInProgress = update; + fUpdateInProgress.start(); + } else if (fUpdateInProgress instanceof DocumentBaseChangeUpdate + && update instanceof DocumentContentUpdate) { + // cancel the content update because the base change update + // will start a new one + update.cancel(); + update.done(); + } else if (fUpdateInProgress instanceof DocumentContentUpdate + && update instanceof DocumentBaseChangeUpdate) { + // cancel the content update and start the base change update + fUpdateInProgress.cancel(); + fUpdateInProgress.done(); + fUpdateInProgress = update; + fUpdateInProgress.start(); + } + } else { + fUpdateInProgress = update; + fUpdateInProgress.start(); + } + } + + private int getElementIndex(Object element) { + Integer index = fLineElements.get(element); + return (index != null) ? index.intValue() : -1; + } + + protected Object getElementAtLine(int lineNumber) { + synchronized (fLineElements) { + for (Object element : fLineElements.keySet()) { + if (fLineElements.get(element).intValue() == lineNumber) { + return element; + } + } + } + return null; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentContentUpdate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentContentUpdate.java index bb93cb986aa..bc636eefba2 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentContentUpdate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentContentUpdate.java @@ -20,109 +20,111 @@ import org.eclipse.cdt.debug.ui.disassembly.IDocumentPresentation; public class DocumentContentUpdate extends DocumentUpdate implements IDocumentElementContentUpdate { - private DocumentContentProvider fContentProvider; - private IDocumentElementContentProvider fElementContentProvider; - private int fLineCount = 0; - private int fOriginalOffset = 0; - private int fOffset = 0; - private Object[] fElements; - boolean fReveal = true; - - public DocumentContentUpdate( DocumentContentProvider contentProvider, IDocumentElementContentProvider elementContentProvider, IDocumentPresentation presentationContext, Object rootElement, Object baseElement, Object input, int lineCount, int offset, boolean reveal ) { - super( presentationContext, rootElement, baseElement, input ); - fContentProvider = contentProvider; - fElementContentProvider = elementContentProvider; - fLineCount = lineCount; - fOriginalOffset = offset; - fOffset = offset; - fElements = new Object[lineCount]; - fReveal = reveal; - } - - /* (non-Javadoc) - * @see com.arm.eclipse.rvd.ui.disassembly.IDocumentElementContentUpdate#setLineCount(int) - */ - @Override - public void setLineCount( int lineCount ) { - fElements = new Object[lineCount]; - } - - /* (non-Javadoc) - * @see com.arm.eclipse.rvd.ui.disassembly.IDocumentElementContentUpdate#addElement(int, java.lang.Object) - */ - @Override - public void addElement( int line, Object element ) throws IndexOutOfBoundsException { - if ( line < 0 || line >= fElements.length ) - throw new IndexOutOfBoundsException( Integer.toString( line ) ); - fElements[line] = element; - } - - /* (non-Javadoc) - * @see com.arm.eclipse.rvd.ui.disassembly.IDocumentElementContentUpdate#getOriginalOffset() - */ - @Override + private DocumentContentProvider fContentProvider; + private IDocumentElementContentProvider fElementContentProvider; + private int fLineCount = 0; + private int fOriginalOffset = 0; + private int fOffset = 0; + private Object[] fElements; + boolean fReveal = true; + + public DocumentContentUpdate(DocumentContentProvider contentProvider, + IDocumentElementContentProvider elementContentProvider, IDocumentPresentation presentationContext, + Object rootElement, Object baseElement, Object input, int lineCount, int offset, boolean reveal) { + super(presentationContext, rootElement, baseElement, input); + fContentProvider = contentProvider; + fElementContentProvider = elementContentProvider; + fLineCount = lineCount; + fOriginalOffset = offset; + fOffset = offset; + fElements = new Object[lineCount]; + fReveal = reveal; + } + + /* (non-Javadoc) + * @see com.arm.eclipse.rvd.ui.disassembly.IDocumentElementContentUpdate#setLineCount(int) + */ + @Override + public void setLineCount(int lineCount) { + fElements = new Object[lineCount]; + } + + /* (non-Javadoc) + * @see com.arm.eclipse.rvd.ui.disassembly.IDocumentElementContentUpdate#addElement(int, java.lang.Object) + */ + @Override + public void addElement(int line, Object element) throws IndexOutOfBoundsException { + if (line < 0 || line >= fElements.length) + throw new IndexOutOfBoundsException(Integer.toString(line)); + fElements[line] = element; + } + + /* (non-Javadoc) + * @see com.arm.eclipse.rvd.ui.disassembly.IDocumentElementContentUpdate#getOriginalOffset() + */ + @Override public int getOriginalOffset() { - return fOriginalOffset; - } + return fOriginalOffset; + } - /* (non-Javadoc) - * @see com.arm.eclipse.rvd.ui.disassembly.IDocumentElementContentUpdate#getRequestedLineCount() - */ - @Override + /* (non-Javadoc) + * @see com.arm.eclipse.rvd.ui.disassembly.IDocumentElementContentUpdate#getRequestedLineCount() + */ + @Override public int getRequestedLineCount() { - return fLineCount; - } - - /* (non-Javadoc) - * @see com.arm.eclipse.rvd.ui.disassembly.IDocumentElementContentUpdate#setOffset(int) - */ - @Override - public void setOffset( int offset ) { - fOffset = offset; - } - - /* (non-Javadoc) - * @see com.arm.eclipse.rvd.ui.disassembly.IDocumentElementContentUpdate#reveal() - */ - @Override + return fLineCount; + } + + /* (non-Javadoc) + * @see com.arm.eclipse.rvd.ui.disassembly.IDocumentElementContentUpdate#setOffset(int) + */ + @Override + public void setOffset(int offset) { + fOffset = offset; + } + + /* (non-Javadoc) + * @see com.arm.eclipse.rvd.ui.disassembly.IDocumentElementContentUpdate#reveal() + */ + @Override public boolean reveal() { - return fReveal; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.core.commands.Request#done() - */ - @Override - public void done() { - super.done(); - getContentProvider().updateCompleted( this ); - } - - protected Object[] getElements() { - return fElements; - } - - protected int getLineCount() { - return fElements.length; - } - - protected int getOffset() { - return fOffset; - } - - protected DocumentContentProvider getContentProvider() { - return fContentProvider; - } - - protected IDocumentElementContentProvider getElementContentProvider() { - return fElementContentProvider; - } - - /* (non-Javadoc) - * @see com.arm.eclipse.rvd.internal.ui.disassembly.DocumentUpdate#startRequest() - */ - @Override - void startRequest() { - getElementContentProvider().updateContent( this ); - } + return fReveal; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.core.commands.Request#done() + */ + @Override + public void done() { + super.done(); + getContentProvider().updateCompleted(this); + } + + protected Object[] getElements() { + return fElements; + } + + protected int getLineCount() { + return fElements.length; + } + + protected int getOffset() { + return fOffset; + } + + protected DocumentContentProvider getContentProvider() { + return fContentProvider; + } + + protected IDocumentElementContentProvider getElementContentProvider() { + return fElementContentProvider; + } + + /* (non-Javadoc) + * @see com.arm.eclipse.rvd.internal.ui.disassembly.DocumentUpdate#startRequest() + */ + @Override + void startRequest() { + getElementContentProvider().updateContent(this); + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentLabelProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentLabelProvider.java index d8d4d370235..f394bfb78d5 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentLabelProvider.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentLabelProvider.java @@ -27,87 +27,86 @@ import org.eclipse.ui.progress.UIJob; public class DocumentLabelProvider extends BaseLabelProvider { - private VirtualDocument fDocument; + private VirtualDocument fDocument; - public DocumentLabelProvider( VirtualDocument document ) { - super(); - fDocument = document; - } -// -// public void update( Object parent, Object[] elements, IDocumentPresentation context ) { -// IDocumentElementLabelProvider labelProvider = getLabelAdapter( parent ); -// if ( labelProvider != null ) { -// Object root = getDocument().getContentProvider().getRoot(); -// Object base = getDocument().getContentProvider().getBase(); -// DocumentLabelUpdate[] updates = new DocumentLabelUpdate[elements.length]; -// for ( int i = 0; i < elements.length; ++i ) { -// updates[i] = new DocumentLabelUpdate( this, context, root, base, elements[i], i ); -// } -// labelProvider.update( updates ); -// } -// } + public DocumentLabelProvider(VirtualDocument document) { + super(); + fDocument = document; + } + // + // public void update( Object parent, Object[] elements, IDocumentPresentation context ) { + // IDocumentElementLabelProvider labelProvider = getLabelAdapter( parent ); + // if ( labelProvider != null ) { + // Object root = getDocument().getContentProvider().getRoot(); + // Object base = getDocument().getContentProvider().getBase(); + // DocumentLabelUpdate[] updates = new DocumentLabelUpdate[elements.length]; + // for ( int i = 0; i < elements.length; ++i ) { + // updates[i] = new DocumentLabelUpdate( this, context, root, base, elements[i], i ); + // } + // labelProvider.update( updates ); + // } + // } - public void update( Object parent, Object element, int index, IDocumentPresentation context ) { - IDocumentElementLabelProvider labelProvider = getLabelAdapter( element ); - if ( labelProvider != null ) { - Object root = getDocument().getContentProvider().getRoot(); - Object base = getDocument().getContentProvider().getBase(); - labelProvider.update( new DocumentLabelUpdate[] { new DocumentLabelUpdate( this, context, root, base, element, index ) } ); - } - } + public void update(Object parent, Object element, int index, IDocumentPresentation context) { + IDocumentElementLabelProvider labelProvider = getLabelAdapter(element); + if (labelProvider != null) { + Object root = getDocument().getContentProvider().getRoot(); + Object base = getDocument().getContentProvider().getBase(); + labelProvider.update( + new DocumentLabelUpdate[] { new DocumentLabelUpdate(this, context, root, base, element, index) }); + } + } - public void completed( DocumentLabelUpdate update ) { - if ( update.isCanceled() ) - return; - - UIJob uiJob = null; - final int index = update.getIndex(); - if ( update.getElement() != null ) { - final Object element = update.getElement(); - final Properties labels = update.getLabels(); + public void completed(DocumentLabelUpdate update) { + if (update.isCanceled()) + return; - uiJob = new UIJob( "Replace line" ) { //$NON-NLS-1$ - - /* (non-Javadoc) - * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) - */ - @Override - public IStatus runInUIThread( IProgressMonitor monitor ) { - getDocument().labelDone( element, index, labels ); - return Status.OK_STATUS; - } - }; - } - else { - uiJob = new UIJob( "Remove line" ) { //$NON-NLS-1$ - - /* (non-Javadoc) - * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) - */ - @Override - public IStatus runInUIThread( IProgressMonitor monitor ) { - getDocument().removeLine( index ); - return Status.OK_STATUS; - } - }; - } - uiJob.setSystem( true ); - uiJob.schedule(); - } + UIJob uiJob = null; + final int index = update.getIndex(); + if (update.getElement() != null) { + final Object element = update.getElement(); + final Properties labels = update.getLabels(); - protected VirtualDocument getDocument() { - return fDocument; - } + uiJob = new UIJob("Replace line") { //$NON-NLS-1$ - protected IDocumentElementLabelProvider getLabelAdapter( Object element ) { - IDocumentElementLabelProvider adapter = null; - if ( element instanceof IDocumentElementLabelProvider ) { - adapter = (IDocumentElementLabelProvider)element; - } - else if ( element instanceof IAdaptable ) { - IAdaptable adaptable = (IAdaptable)element; - adapter = adaptable.getAdapter( IDocumentElementLabelProvider.class ); - } - return adapter; - } + /* (non-Javadoc) + * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + public IStatus runInUIThread(IProgressMonitor monitor) { + getDocument().labelDone(element, index, labels); + return Status.OK_STATUS; + } + }; + } else { + uiJob = new UIJob("Remove line") { //$NON-NLS-1$ + + /* (non-Javadoc) + * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + public IStatus runInUIThread(IProgressMonitor monitor) { + getDocument().removeLine(index); + return Status.OK_STATUS; + } + }; + } + uiJob.setSystem(true); + uiJob.schedule(); + } + + protected VirtualDocument getDocument() { + return fDocument; + } + + protected IDocumentElementLabelProvider getLabelAdapter(Object element) { + IDocumentElementLabelProvider adapter = null; + if (element instanceof IDocumentElementLabelProvider) { + adapter = (IDocumentElementLabelProvider) element; + } else if (element instanceof IAdaptable) { + IAdaptable adaptable = (IAdaptable) element; + adapter = adaptable.getAdapter(IDocumentElementLabelProvider.class); + } + return adapter; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentLabelUpdate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentLabelUpdate.java index b39b3954b70..ed702a486a0 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentLabelUpdate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentLabelUpdate.java @@ -20,50 +20,51 @@ import org.eclipse.cdt.debug.ui.disassembly.IDocumentElementLabelUpdate; import org.eclipse.cdt.debug.ui.disassembly.IDocumentPresentation; public class DocumentLabelUpdate extends DocumentUpdate implements IDocumentElementLabelUpdate { - private DocumentLabelProvider fLabelProvider; - private int fIndex = 0; - private Properties fLabels; + private DocumentLabelProvider fLabelProvider; + private int fIndex = 0; + private Properties fLabels; - public DocumentLabelUpdate( DocumentLabelProvider labelProvider, IDocumentPresentation presentationContext, Object root, Object base, Object element, int index ) { - super( presentationContext, root, base, element ); - fLabelProvider = labelProvider; - fIndex = index; - fLabels = new Properties(); - } + public DocumentLabelUpdate(DocumentLabelProvider labelProvider, IDocumentPresentation presentationContext, + Object root, Object base, Object element, int index) { + super(presentationContext, root, base, element); + fLabelProvider = labelProvider; + fIndex = index; + fLabels = new Properties(); + } - /* (non-Javadoc) - * @see com.arm.eclipse.rvd.ui.disassembly.IDocumentElementLabelUpdate#setLabel(java.lang.String, java.lang.String) - */ - @Override - public void setLabel( String attribute, String text ) { - fLabels.put( attribute, text ); - } + /* (non-Javadoc) + * @see com.arm.eclipse.rvd.ui.disassembly.IDocumentElementLabelUpdate#setLabel(java.lang.String, java.lang.String) + */ + @Override + public void setLabel(String attribute, String text) { + fLabels.put(attribute, text); + } - /* (non-Javadoc) - * @see org.eclipse.debug.internal.core.commands.Request#done() - */ - @Override - public void done() { - super.done(); - getLabelProvider().completed( this ); - } + /* (non-Javadoc) + * @see org.eclipse.debug.internal.core.commands.Request#done() + */ + @Override + public void done() { + super.done(); + getLabelProvider().completed(this); + } - public int getIndex() { - return fIndex; - } - - protected DocumentLabelProvider getLabelProvider() { - return fLabelProvider; - } + public int getIndex() { + return fIndex; + } - protected Properties getLabels() { - return fLabels; - } + protected DocumentLabelProvider getLabelProvider() { + return fLabelProvider; + } - /* (non-Javadoc) - * @see com.arm.eclipse.rvd.internal.ui.disassembly.DocumentUpdate#startRequest() - */ - @Override - void startRequest() { - } + protected Properties getLabels() { + return fLabels; + } + + /* (non-Javadoc) + * @see com.arm.eclipse.rvd.internal.ui.disassembly.DocumentUpdate#startRequest() + */ + @Override + void startRequest() { + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentUpdate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentUpdate.java index 5f9c0b4bc65..3901c5997fc 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentUpdate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/DocumentUpdate.java @@ -22,116 +22,116 @@ import org.eclipse.jface.viewers.TreePath; public abstract class DocumentUpdate extends Request implements IDocumentUpdate { - private Object fRootElement; - private Object fBaseElement; - private Object fElement; - private IDocumentPresentation fPresentationContext; - - private boolean fDone = false; - private boolean fStarted = false; - - public DocumentUpdate( IDocumentPresentation presentationContext, Object rootElement, Object baseElement, Object element ) { - super(); - fRootElement = rootElement; - fBaseElement = baseElement; - fElement = element; - fPresentationContext = presentationContext; - } - - /* (non-Javadoc) - * @see com.arm.eclipse.rvd.ui.disassembly.IDocumentUpdate#getBaseElement() - */ - @Override + private Object fRootElement; + private Object fBaseElement; + private Object fElement; + private IDocumentPresentation fPresentationContext; + + private boolean fDone = false; + private boolean fStarted = false; + + public DocumentUpdate(IDocumentPresentation presentationContext, Object rootElement, Object baseElement, + Object element) { + super(); + fRootElement = rootElement; + fBaseElement = baseElement; + fElement = element; + fPresentationContext = presentationContext; + } + + /* (non-Javadoc) + * @see com.arm.eclipse.rvd.ui.disassembly.IDocumentUpdate#getBaseElement() + */ + @Override public Object getBaseElement() { - return fBaseElement; - } + return fBaseElement; + } - /* (non-Javadoc) - * @see com.arm.eclipse.rvd.ui.disassembly.IDocumentUpdate#getRootElement() - */ - @Override + /* (non-Javadoc) + * @see com.arm.eclipse.rvd.ui.disassembly.IDocumentUpdate#getRootElement() + */ + @Override public Object getRootElement() { - return fRootElement; - } + return fRootElement; + } - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate#getElement() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate#getElement() + */ + @Override public Object getElement() { - return fElement; - } + return fElement; + } - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate#getElementPath() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate#getElementPath() + */ + @Override public TreePath getElementPath() { - // TODO Auto-generated method stub - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate#getPresentationContext() - */ - @Override + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate#getPresentationContext() + */ + @Override public IPresentationContext getPresentationContext() { - return fPresentationContext; - } - - /** - * Starts this request. Subclasses must override startRequest(). - */ - final void start() { - synchronized( this ) { - if ( fStarted ) { - return; - } - fStarted = true; - } - if ( !isCanceled() ) { - startRequest(); - } - else { - done(); - } - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.core.commands.Request#done() - */ - @Override - public void done() { - synchronized( this ) { - if ( isDone() ) { - return; - } - fDone = true; - } - } - - void setRootElement( Object rootElement ) { - fRootElement = rootElement; - } - - void setBaseElement( Object baseElement ) { - fBaseElement = baseElement; - } - - protected synchronized boolean isDone() { - return fDone; - } - - /** - * Subclasses must override to initiate specific request types. - */ - abstract void startRequest(); - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate#getViewerInput() - */ - @Override + return fPresentationContext; + } + + /** + * Starts this request. Subclasses must override startRequest(). + */ + final void start() { + synchronized (this) { + if (fStarted) { + return; + } + fStarted = true; + } + if (!isCanceled()) { + startRequest(); + } else { + done(); + } + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.core.commands.Request#done() + */ + @Override + public void done() { + synchronized (this) { + if (isDone()) { + return; + } + fDone = true; + } + } + + void setRootElement(Object rootElement) { + fRootElement = rootElement; + } + + void setBaseElement(Object baseElement) { + fBaseElement = baseElement; + } + + protected synchronized boolean isDone() { + return fDone; + } + + /** + * Subclasses must override to initiate specific request types. + */ + abstract void startRequest(); + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate#getViewerInput() + */ + @Override public Object getViewerInput() { - return null; - } + return null; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/VirtualDocument.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/VirtualDocument.java index 5e53b6ddee7..1c01e6cd301 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/VirtualDocument.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/VirtualDocument.java @@ -33,247 +33,236 @@ import org.eclipse.jface.text.source.IAnnotationModel; * Converts the model elements into the text content */ public class VirtualDocument extends Document { - - public class LinePosition extends Position { - - private int fDistance = 0; - - LinePosition( int offset, int distance ) { - super( offset ); - fDistance = distance; - } - - LinePosition( int offset, int length, int distance ) { - super( offset, length ); - fDistance = distance; - } - - int getDistance() { - return fDistance; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.text.Position#equals(java.lang.Object) - */ - @Override - public boolean equals( Object other ) { - if ( !(other instanceof LinePosition) ) - return false; - return ( getDistance() == ((LinePosition)other).getDistance() ); - } - } - - public final static String CATEGORY_LINE = "category_line"; // "category_line"; //$NON-NLS-1$ - private static final String PENDING_LINE = ".............................."; //$NON-NLS-1$ - - private Object fRoot; - private int fCurrentOffset = 0; - - private IDocumentPresentation fPresentationContext; - private AnnotationModel fAnnotationModel; - private DocumentContentProvider fContentProvider; - private DocumentLabelProvider fLabelProvider; - private DocumentAnnotationProvider fAnnotationProvider; - - public VirtualDocument( AnnotationModel annotationModel, IDocumentPresentation presentationContext, Object root ) { - super(); - fRoot = root; - fPresentationContext = presentationContext; - fAnnotationModel = annotationModel; - fContentProvider = new DocumentContentProvider( this ); - fLabelProvider = new DocumentLabelProvider( this ); - fAnnotationProvider = new DocumentAnnotationProvider( this ); - getContentProvider().init( fRoot ); - } - - public void dispose() { - getContentProvider().dispose(); - getLabelProvider().dispose(); - getAnnotationProvider().dispose(); - fRoot = null; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.text.AbstractDocument#completeInitialization() - */ - @Override - protected void completeInitialization() { - super.completeInitialization(); - addPositionCategory( CATEGORY_LINE ); - addPositionUpdater( new DefaultPositionUpdater( CATEGORY_LINE ) ); - } - - public IDocumentPresentation getPresentationContext() { - return fPresentationContext; - } - - public AnnotationModel getAnnotationModel() { - return fAnnotationModel; - } - - public DocumentContentProvider getContentProvider() { - return fContentProvider; - } - - protected DocumentLabelProvider getLabelProvider() { - return fLabelProvider; - } - - protected DocumentAnnotationProvider getAnnotationProvider() { - return fAnnotationProvider; - } - - private String createPendingContent( int lineCount, int oldOffset, int offset ) { - int oldLineCount = getNumberOfLines() - 1; - int intersectStart = Math.max( oldOffset, offset ); - int intersectEnd = Math.min( oldOffset + oldLineCount, offset + lineCount ); - int intersectCount = intersectEnd - intersectStart; - StringBuilder sb = new StringBuilder(); - int line = 0; - if ( oldOffset > offset ) { // scrolling up - for ( int i = 0; i < oldOffset - offset; ++i ) { - try { - addPosition( CATEGORY_LINE, new LinePosition( sb.length(), offset - i ) ); - sb.append( PENDING_LINE ).append( '\n' ); - ++line; - } - catch( BadLocationException e ) { - // shouldn't happen - } - catch( BadPositionCategoryException e ) { - // shouldn't happen - } - } - } - else { // scrolling down - line += offset - oldOffset; - } - for ( int i = 0; i < intersectCount; ++i ) { - try { - IRegion region = getLineInformation( line++ ); - sb.append( get( region.getOffset(), region.getLength() ) ).append( '\n' ); - } - catch( BadLocationException e ) { - // shouldn't happen - } - } - // Assuming the offset isn't changed when resizing - int pendingLines = 0; - if ( oldLineCount < lineCount ) { // resizing - pendingLines = lineCount - oldLineCount; - } - else if ( offset > oldOffset ) { // scrolling down - pendingLines = offset - oldOffset; - } - for ( int i = 0; i < pendingLines; ++i ) { - sb.append( PENDING_LINE ).append( '\n' ); - ++line; - } - return sb.toString(); - } - - public int getCurrentOffset() { - return fCurrentOffset; - } - - public void setCurrentOffset( int offset ) { - fCurrentOffset = offset; - } - - public Object getElementAtLine( int line ) { - return getContentProvider().getElementAtLine( line ); - } - - public void updateContent( int lineCount, int offset, boolean revealInput ) { - int oldOffset = fCurrentOffset; - fCurrentOffset = offset; - removePositions(); - getAnnotationModel().removeAllAnnotations(); - set( createPendingContent( lineCount, oldOffset, offset ) ); - setPositions(); - getContentProvider().update( getPresentationContext(), lineCount, offset, revealInput ); - } - - protected void updateElement( Object input, int index, Object element ) { - getLabelProvider().update( input, element, index, getPresentationContext() ); - getAnnotationProvider().update( getContentProvider().getInput(), element, index, getPresentationContext() ); - } - - @SuppressWarnings("rawtypes") - protected void updateAnnotations( int lineNumber, Annotation[] annotations ) { - IAnnotationModel annotationModel = getAnnotationModel(); - try { - Position[] positions = getPositions( CATEGORY_LINE ); - if ( lineNumber < positions.length ) { - Iterator it = annotationModel.getAnnotationIterator(); - ArrayList<Annotation> oldAnnotations = new ArrayList<Annotation>( 3 ); - while( it.hasNext() ) { - Annotation ann = (Annotation)it.next(); - if ( positions[lineNumber].equals( annotationModel.getPosition( ann ) ) ) { - oldAnnotations.add( ann ); - } - } - for ( Annotation ann : oldAnnotations ) { - annotationModel.removeAnnotation( ann ); - } - for ( Annotation ann : annotations ) { - annotationModel.addAnnotation( ann, positions[lineNumber] ); - } - } - } - catch( BadPositionCategoryException e ) { - } - } - - final void labelDone( Object element, int lineNumber, Properties labels ) { - try { - String line = labels.getProperty( IDocumentPresentation.ATTR_LINE_LABEL ); - IRegion region = getLineInformation( lineNumber ); - if ( get( region.getOffset(), region.getLength() ).compareTo( line ) != 0 ) - replace( region.getOffset(), region.getLength(), line ); - } - catch( BadLocationException e ) { - } - } - - protected void removeLine( int lineNumber ) { - try { - IRegion region = getLineInformation( lineNumber ); - replace( region.getOffset(), region.getLength(), "" ); //$NON-NLS-1$ - } - catch( BadLocationException e ) { - } - } - - private void removePositions() { - try { - Position[] oldPositions = getPositions( CATEGORY_LINE ); - for ( Position p : oldPositions ) { - removePosition( CATEGORY_LINE, p ); - } - } - catch( BadPositionCategoryException e ) { - } - } - - private void setPositions() { - try { - Position[] oldPositions = getPositions( CATEGORY_LINE ); - int offset = getCurrentOffset(); - int lines = getNumberOfLines(); - for ( Position p : oldPositions ) { - removePosition( CATEGORY_LINE, p ); - } - for ( int i = 0; i < lines; ++i ) { - IRegion info = getLineInformation( i ); - addPosition( CATEGORY_LINE, new LinePosition( info.getOffset(), info.getLength(), offset + i ) ); - } - } - catch( BadPositionCategoryException e ) { - // shouldn't happen - } - catch( BadLocationException e ) { - // shouldn't happen - } - } + + public class LinePosition extends Position { + + private int fDistance = 0; + + LinePosition(int offset, int distance) { + super(offset); + fDistance = distance; + } + + LinePosition(int offset, int length, int distance) { + super(offset, length); + fDistance = distance; + } + + int getDistance() { + return fDistance; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.text.Position#equals(java.lang.Object) + */ + @Override + public boolean equals(Object other) { + if (!(other instanceof LinePosition)) + return false; + return (getDistance() == ((LinePosition) other).getDistance()); + } + } + + public final static String CATEGORY_LINE = "category_line"; // "category_line"; //$NON-NLS-1$ + private static final String PENDING_LINE = ".............................."; //$NON-NLS-1$ + + private Object fRoot; + private int fCurrentOffset = 0; + + private IDocumentPresentation fPresentationContext; + private AnnotationModel fAnnotationModel; + private DocumentContentProvider fContentProvider; + private DocumentLabelProvider fLabelProvider; + private DocumentAnnotationProvider fAnnotationProvider; + + public VirtualDocument(AnnotationModel annotationModel, IDocumentPresentation presentationContext, Object root) { + super(); + fRoot = root; + fPresentationContext = presentationContext; + fAnnotationModel = annotationModel; + fContentProvider = new DocumentContentProvider(this); + fLabelProvider = new DocumentLabelProvider(this); + fAnnotationProvider = new DocumentAnnotationProvider(this); + getContentProvider().init(fRoot); + } + + public void dispose() { + getContentProvider().dispose(); + getLabelProvider().dispose(); + getAnnotationProvider().dispose(); + fRoot = null; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.text.AbstractDocument#completeInitialization() + */ + @Override + protected void completeInitialization() { + super.completeInitialization(); + addPositionCategory(CATEGORY_LINE); + addPositionUpdater(new DefaultPositionUpdater(CATEGORY_LINE)); + } + + public IDocumentPresentation getPresentationContext() { + return fPresentationContext; + } + + public AnnotationModel getAnnotationModel() { + return fAnnotationModel; + } + + public DocumentContentProvider getContentProvider() { + return fContentProvider; + } + + protected DocumentLabelProvider getLabelProvider() { + return fLabelProvider; + } + + protected DocumentAnnotationProvider getAnnotationProvider() { + return fAnnotationProvider; + } + + private String createPendingContent(int lineCount, int oldOffset, int offset) { + int oldLineCount = getNumberOfLines() - 1; + int intersectStart = Math.max(oldOffset, offset); + int intersectEnd = Math.min(oldOffset + oldLineCount, offset + lineCount); + int intersectCount = intersectEnd - intersectStart; + StringBuilder sb = new StringBuilder(); + int line = 0; + if (oldOffset > offset) { // scrolling up + for (int i = 0; i < oldOffset - offset; ++i) { + try { + addPosition(CATEGORY_LINE, new LinePosition(sb.length(), offset - i)); + sb.append(PENDING_LINE).append('\n'); + ++line; + } catch (BadLocationException e) { + // shouldn't happen + } catch (BadPositionCategoryException e) { + // shouldn't happen + } + } + } else { // scrolling down + line += offset - oldOffset; + } + for (int i = 0; i < intersectCount; ++i) { + try { + IRegion region = getLineInformation(line++); + sb.append(get(region.getOffset(), region.getLength())).append('\n'); + } catch (BadLocationException e) { + // shouldn't happen + } + } + // Assuming the offset isn't changed when resizing + int pendingLines = 0; + if (oldLineCount < lineCount) { // resizing + pendingLines = lineCount - oldLineCount; + } else if (offset > oldOffset) { // scrolling down + pendingLines = offset - oldOffset; + } + for (int i = 0; i < pendingLines; ++i) { + sb.append(PENDING_LINE).append('\n'); + ++line; + } + return sb.toString(); + } + + public int getCurrentOffset() { + return fCurrentOffset; + } + + public void setCurrentOffset(int offset) { + fCurrentOffset = offset; + } + + public Object getElementAtLine(int line) { + return getContentProvider().getElementAtLine(line); + } + + public void updateContent(int lineCount, int offset, boolean revealInput) { + int oldOffset = fCurrentOffset; + fCurrentOffset = offset; + removePositions(); + getAnnotationModel().removeAllAnnotations(); + set(createPendingContent(lineCount, oldOffset, offset)); + setPositions(); + getContentProvider().update(getPresentationContext(), lineCount, offset, revealInput); + } + + protected void updateElement(Object input, int index, Object element) { + getLabelProvider().update(input, element, index, getPresentationContext()); + getAnnotationProvider().update(getContentProvider().getInput(), element, index, getPresentationContext()); + } + + @SuppressWarnings("rawtypes") + protected void updateAnnotations(int lineNumber, Annotation[] annotations) { + IAnnotationModel annotationModel = getAnnotationModel(); + try { + Position[] positions = getPositions(CATEGORY_LINE); + if (lineNumber < positions.length) { + Iterator it = annotationModel.getAnnotationIterator(); + ArrayList<Annotation> oldAnnotations = new ArrayList<Annotation>(3); + while (it.hasNext()) { + Annotation ann = (Annotation) it.next(); + if (positions[lineNumber].equals(annotationModel.getPosition(ann))) { + oldAnnotations.add(ann); + } + } + for (Annotation ann : oldAnnotations) { + annotationModel.removeAnnotation(ann); + } + for (Annotation ann : annotations) { + annotationModel.addAnnotation(ann, positions[lineNumber]); + } + } + } catch (BadPositionCategoryException e) { + } + } + + final void labelDone(Object element, int lineNumber, Properties labels) { + try { + String line = labels.getProperty(IDocumentPresentation.ATTR_LINE_LABEL); + IRegion region = getLineInformation(lineNumber); + if (get(region.getOffset(), region.getLength()).compareTo(line) != 0) + replace(region.getOffset(), region.getLength(), line); + } catch (BadLocationException e) { + } + } + + protected void removeLine(int lineNumber) { + try { + IRegion region = getLineInformation(lineNumber); + replace(region.getOffset(), region.getLength(), ""); //$NON-NLS-1$ + } catch (BadLocationException e) { + } + } + + private void removePositions() { + try { + Position[] oldPositions = getPositions(CATEGORY_LINE); + for (Position p : oldPositions) { + removePosition(CATEGORY_LINE, p); + } + } catch (BadPositionCategoryException e) { + } + } + + private void setPositions() { + try { + Position[] oldPositions = getPositions(CATEGORY_LINE); + int offset = getCurrentOffset(); + int lines = getNumberOfLines(); + for (Position p : oldPositions) { + removePosition(CATEGORY_LINE, p); + } + for (int i = 0; i < lines; ++i) { + IRegion info = getLineInformation(i); + addPosition(CATEGORY_LINE, new LinePosition(info.getOffset(), info.getLength(), offset + i)); + } + } catch (BadPositionCategoryException e) { + // shouldn't happen + } catch (BadLocationException e) { + // shouldn't happen + } + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/VirtualSourceViewer.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/VirtualSourceViewer.java index c9084a14c77..1ee1649a485 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/VirtualSourceViewer.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/viewer/VirtualSourceViewer.java @@ -32,107 +32,103 @@ import org.eclipse.swt.widgets.ScrollBar; */ public class VirtualSourceViewer extends SourceViewer { - private SelectionListener fScrollSelectionListener; - - public VirtualSourceViewer( Composite parent, IVerticalRuler ruler, int styles ) { - this( parent, ruler, null, false, styles ); - } - - public VirtualSourceViewer( Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean showAnnotationsOverview, int styles ) { - super( parent, verticalRuler, overviewRuler, showAnnotationsOverview, styles ); - initScrollBarListener(); - initControlListener(); - } - - public VirtualDocument getVirtualDocument() { - return (VirtualDocument)getDocument(); - } - - private void initControlListener() { - getTextWidget().addControlListener( new ControlListener() { - - @Override - public void controlMoved( ControlEvent e ) { - } - - @Override - public void controlResized( ControlEvent e ) { - handleControlResized(); - } - } ); - } - - private void initScrollBarListener() { - ScrollBar scroll = getTextWidget().getVerticalBar(); - fScrollSelectionListener = new SelectionAdapter() { - - /* (non-Javadoc) - * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) - */ - @Override - public void widgetSelected( SelectionEvent e ) { - handleScrollBarSelection( e ); - } - }; - scroll.addSelectionListener( fScrollSelectionListener ); - } - - public int getNumberOfVisibleLines() { - StyledText widget = getTextWidget(); - if ( widget != null ) { - Rectangle clArea = widget.getClientArea(); - if ( !clArea.isEmpty() ) { - return (clArea.height / widget.getLineHeight()) + 1; - } - } - return 0; - } - - protected void handleScrollBarSelection( SelectionEvent e ) { - int offset = getVirtualDocument().getCurrentOffset(); - int lines = getNumberOfVisibleLines(); - if ( e.detail == SWT.ARROW_UP ) { - --offset; - } - else if ( e.detail == SWT.ARROW_DOWN ) { - ++offset; - } - else if ( e.detail == SWT.PAGE_UP ) { - offset -= lines; - } - else if ( e.detail == SWT.PAGE_DOWN ) { - offset += lines; - } - else if ( e.detail == SWT.HOME ) { - } - else if ( e.detail == SWT.END ) { - } - getVirtualDocument().updateContent( lines, offset, false ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.text.TextViewer#refresh() - */ - @Override - public void refresh() { - refresh( false ); - } - - public void refresh( boolean revealInput ) { - VirtualDocument document = getVirtualDocument(); - document.updateContent( getNumberOfVisibleLines(), getVirtualDocument().getCurrentOffset(), revealInput ); - } - - protected void handleControlResized() { - getVirtualDocument().updateContent( getNumberOfVisibleLines(), getVirtualDocument().getCurrentOffset(), false ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.text.source.SourceViewer#handleDispose() - */ - @Override - protected void handleDispose() { - getVirtualDocument().dispose(); - super.handleDispose(); - } + private SelectionListener fScrollSelectionListener; + + public VirtualSourceViewer(Composite parent, IVerticalRuler ruler, int styles) { + this(parent, ruler, null, false, styles); + } + + public VirtualSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, + boolean showAnnotationsOverview, int styles) { + super(parent, verticalRuler, overviewRuler, showAnnotationsOverview, styles); + initScrollBarListener(); + initControlListener(); + } + + public VirtualDocument getVirtualDocument() { + return (VirtualDocument) getDocument(); + } + + private void initControlListener() { + getTextWidget().addControlListener(new ControlListener() { + + @Override + public void controlMoved(ControlEvent e) { + } + + @Override + public void controlResized(ControlEvent e) { + handleControlResized(); + } + }); + } + + private void initScrollBarListener() { + ScrollBar scroll = getTextWidget().getVerticalBar(); + fScrollSelectionListener = new SelectionAdapter() { + + /* (non-Javadoc) + * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) + */ + @Override + public void widgetSelected(SelectionEvent e) { + handleScrollBarSelection(e); + } + }; + scroll.addSelectionListener(fScrollSelectionListener); + } + + public int getNumberOfVisibleLines() { + StyledText widget = getTextWidget(); + if (widget != null) { + Rectangle clArea = widget.getClientArea(); + if (!clArea.isEmpty()) { + return (clArea.height / widget.getLineHeight()) + 1; + } + } + return 0; + } + + protected void handleScrollBarSelection(SelectionEvent e) { + int offset = getVirtualDocument().getCurrentOffset(); + int lines = getNumberOfVisibleLines(); + if (e.detail == SWT.ARROW_UP) { + --offset; + } else if (e.detail == SWT.ARROW_DOWN) { + ++offset; + } else if (e.detail == SWT.PAGE_UP) { + offset -= lines; + } else if (e.detail == SWT.PAGE_DOWN) { + offset += lines; + } else if (e.detail == SWT.HOME) { + } else if (e.detail == SWT.END) { + } + getVirtualDocument().updateContent(lines, offset, false); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.text.TextViewer#refresh() + */ + @Override + public void refresh() { + refresh(false); + } + + public void refresh(boolean revealInput) { + VirtualDocument document = getVirtualDocument(); + document.updateContent(getNumberOfVisibleLines(), getVirtualDocument().getCurrentOffset(), revealInput); + } + + protected void handleControlResized() { + getVirtualDocument().updateContent(getNumberOfVisibleLines(), getVirtualDocument().getCurrentOffset(), false); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.text.source.SourceViewer#handleDispose() + */ + @Override + protected void handleDispose() { + getVirtualDocument().dispose(); + super.handleDispose(); + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DebugTextHover.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DebugTextHover.java index 7f97cfc3a50..85c28fe6cdc 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DebugTextHover.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DebugTextHover.java @@ -28,15 +28,15 @@ public class DebugTextHover extends AbstractDebugTextHover { /** * Returns the evaluation stack frame, or <code>null</code> if none. - * + * * @return the evaluation stack frame, or <code>null</code> if none */ protected ICStackFrame getFrame() { - IAdaptable adaptable = getSelectionAdaptable(); - if (adaptable != null) { - return adaptable.getAdapter(ICStackFrame.class); - } - return null; + IAdaptable adaptable = getSelectionAdaptable(); + if (adaptable != null) { + return adaptable.getAdapter(ICStackFrame.class); + } + return null; } @Override @@ -44,7 +44,7 @@ public class DebugTextHover extends AbstractDebugTextHover { ICStackFrame frame = getFrame(); if (frame != null) return frame.canEvaluate(); - + return false; } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DebugTextHoverAdapterFactory.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DebugTextHoverAdapterFactory.java index b0e06df6e4f..eecd2ae2cdc 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DebugTextHoverAdapterFactory.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DebugTextHoverAdapterFactory.java @@ -19,26 +19,26 @@ import org.eclipse.core.runtime.IAdapterFactory; /** * Adapter factory adapting an {@link ICStackFrame} to an {@link ICEditorTextHover}. - * + * * @since 7.0 */ public class DebugTextHoverAdapterFactory implements IAdapterFactory { - private static final Class<?>[] TYPES = { ICEditorTextHover.class }; - private static final Object fDebugTextHover= new DebugTextHover(); - - @SuppressWarnings("unchecked") + private static final Class<?>[] TYPES = { ICEditorTextHover.class }; + private static final Object fDebugTextHover = new DebugTextHover(); + + @SuppressWarnings("unchecked") @Override - public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) { - if (adaptableObject instanceof ICStackFrame) { - return (T) fDebugTextHover; - } - return null; - } + public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) { + if (adaptableObject instanceof ICStackFrame) { + return (T) fDebugTextHover; + } + return null; + } - @Override - public Class<?>[] getAdapterList() { - return TYPES; - } + @Override + public Class<?>[] getAdapterList() { + return TYPES; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DelegatingDebugTextHover.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DelegatingDebugTextHover.java index 2a2f25980f8..bbd0f06bfe2 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DelegatingDebugTextHover.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DelegatingDebugTextHover.java @@ -31,7 +31,7 @@ import org.eclipse.ui.IEditorPart; */ public class DelegatingDebugTextHover implements ICEditorTextHover, ITextHoverExtension, ITextHoverExtension2 { - private IEditorPart fEditor; + private IEditorPart fEditor; private ICEditorTextHover fDelegate; /* @@ -41,70 +41,70 @@ public class DelegatingDebugTextHover implements ICEditorTextHover, ITextHoverEx public IRegion getHoverRegion(ITextViewer viewer, int offset) { fDelegate = getDelegate(); if (fDelegate != null) { - return fDelegate.getHoverRegion(viewer, offset); + return fDelegate.getHoverRegion(viewer, offset); } return null; } - - /* - * @see org.eclipse.jface.text.ITextHover#getHoverInfo(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion) - */ - @Override + + /* + * @see org.eclipse.jface.text.ITextHover#getHoverInfo(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion) + */ + @Override @SuppressWarnings("deprecation") - public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { - fDelegate = getDelegate(); - if (fDelegate != null) { - return fDelegate.getHoverInfo(textViewer, hoverRegion); - } - return null; - } + public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { + fDelegate = getDelegate(); + if (fDelegate != null) { + return fDelegate.getHoverInfo(textViewer, hoverRegion); + } + return null; + } - /* - * @see org.eclipse.jface.text.ITextHoverExtension2#getHoverInfo2(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion) - */ - @Override + /* + * @see org.eclipse.jface.text.ITextHoverExtension2#getHoverInfo2(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion) + */ + @Override @SuppressWarnings("deprecation") - public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) { - fDelegate = getDelegate(); - if (fDelegate instanceof ITextHoverExtension2) { - return ((ITextHoverExtension2) fDelegate).getHoverInfo2(textViewer, hoverRegion); - } - // fall back to legacy method - if (fDelegate != null) { - return fDelegate.getHoverInfo(textViewer, hoverRegion); - } - return null; - } + public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) { + fDelegate = getDelegate(); + if (fDelegate instanceof ITextHoverExtension2) { + return ((ITextHoverExtension2) fDelegate).getHoverInfo2(textViewer, hoverRegion); + } + // fall back to legacy method + if (fDelegate != null) { + return fDelegate.getHoverInfo(textViewer, hoverRegion); + } + return null; + } - /* - * @see org.eclipse.jface.text.ITextHoverExtension#getHoverControlCreator() - */ - @Override + /* + * @see org.eclipse.jface.text.ITextHoverExtension#getHoverControlCreator() + */ + @Override public IInformationControlCreator getHoverControlCreator() { - if (fDelegate instanceof ITextHoverExtension) { - return ((ITextHoverExtension) fDelegate).getHoverControlCreator(); - } - return null; - } + if (fDelegate instanceof ITextHoverExtension) { + return ((ITextHoverExtension) fDelegate).getHoverControlCreator(); + } + return null; + } - /* - * @see org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover#setEditor(org.eclipse.ui.IEditorPart) - */ - @Override + /* + * @see org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover#setEditor(org.eclipse.ui.IEditorPart) + */ + @Override public final void setEditor(IEditorPart editor) { - fEditor = editor; - } + fEditor = editor; + } - private ICEditorTextHover getDelegate() { - IAdaptable context = DebugUITools.getDebugContext(); - if (context != null) { - ICEditorTextHover hover = context.getAdapter(ICEditorTextHover.class); - if (hover != null) { - hover.setEditor(fEditor); - } - return hover; - } - return null; - } + private ICEditorTextHover getDelegate() { + IAdaptable context = DebugUITools.getDebugContext(); + if (context != null) { + ICEditorTextHover hover = context.getAdapter(ICEditorTextHover.class); + if (hover != null) { + hover.setEditor(fEditor); + } + return hover; + } + return null; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/elements/adapters/CMemoryAdapterFactory.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/elements/adapters/CMemoryAdapterFactory.java index f0cc22911e0..6340ddf69fe 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/elements/adapters/CMemoryAdapterFactory.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/elements/adapters/CMemoryAdapterFactory.java @@ -43,7 +43,7 @@ public class CMemoryAdapterFactory implements IAdapterFactory { return (T) fgAddMemoryBlocks; } } - + return null; } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/CApplicationLaunchShortcut.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/CApplicationLaunchShortcut.java index 33ec93767c0..c6e1b6445a1 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/CApplicationLaunchShortcut.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/CApplicationLaunchShortcut.java @@ -67,7 +67,7 @@ import org.eclipse.ui.dialogs.TwoPaneElementSelector; public class CApplicationLaunchShortcut implements ILaunchShortcut2 { private final static String CONNECTION_URI = "org.eclipse.cdt.docker.launcher.connection_uri"; //$NON-NLS-1$ - + @Override public void launch(IEditorPart editor, String mode) { searchAndLaunch(new Object[] { editor.getEditorInput() }, mode); @@ -81,15 +81,15 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut2 { } public void launch(IBinary bin, String mode) { - ILaunchConfiguration config = findLaunchConfiguration(bin, mode); - if (config != null) { - DebugUITools.launch(config, mode); - } - } + ILaunchConfiguration config = findLaunchConfiguration(bin, mode); + if (config != null) { + DebugUITools.launch(config, mode); + } + } /** * Locate a configuration to relaunch for the given type. If one cannot be found, create one. - * + * * @return a re-usable config or <code>null</code> if none */ protected ILaunchConfiguration findLaunchConfiguration(IBinary bin, String mode) { @@ -104,7 +104,7 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut2 { String projectName = CDebugUtils.getProjectName(config); IPath name = bin.getResource().getProjectRelativePath(); // don't match any launch config that is used for a Container launch - String connectionURI = config.getAttribute(CONNECTION_URI, (String)null); + String connectionURI = config.getAttribute(CONNECTION_URI, (String) null); if (connectionURI == null) { if (programPath != null && programPath.equals(name)) { if (projectName != null && projectName.equals(bin.getCProject().getProject().getName())) { @@ -114,7 +114,7 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut2 { } } } catch (CoreException e) { - CDebugUIPlugin.log(e); + CDebugUIPlugin.log(e); } // If there are no existing configs associated with the IBinary, create one. @@ -145,8 +145,8 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut2 { try { String projectName = bin.getResource().getProjectRelativePath().toString(); ILaunchConfigurationType configType = getCLaunchConfigType(); - ILaunchConfigurationWorkingCopy wc = - configType.newInstance(null, getLaunchManager().generateLaunchConfigurationName(bin.getElementName())); + ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, + getLaunchManager().generateLaunchConfigurationName(bin.getElementName())); wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, projectName); wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, bin.getCProject().getElementName()); wc.setMappedResources(new IResource[] { bin.getResource().getProject() }); @@ -154,10 +154,11 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut2 { wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN); - ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(bin.getCProject().getProject()); + ICProjectDescription projDes = CCorePlugin.getDefault() + .getProjectDescription(bin.getCProject().getProject()); if (projDes != null) { String buildConfigID = projDes.getActiveConfiguration().getId(); - wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, buildConfigID); + wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, buildConfigID); } config = wc.doSave(); @@ -184,10 +185,10 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut2 { */ protected Shell getShell() { IWorkbenchWindow w = CDebugUIPlugin.getActiveWorkbenchWindow(); - if (w != null) { - return w.getShell(); - } - return null; + if (w != null) { + return w.getShell(); + } + return null; } /** @@ -199,8 +200,8 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut2 { IDebugModelPresentation labelProvider = DebugUITools.newDebugModelPresentation(); ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider); dialog.setElements(configList.toArray()); - dialog.setTitle(getLaunchSelectionDialogTitleString(configList, mode)); - dialog.setMessage(getLaunchSelectionDialogMessageString(configList, mode)); + dialog.setTitle(getLaunchSelectionDialogTitleString(configList, mode)); + dialog.setMessage(getLaunchSelectionDialogMessageString(configList, mode)); dialog.setMultipleSelection(false); int result = dialog.open(); labelProvider.dispose(); @@ -211,21 +212,21 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut2 { } protected String getLaunchSelectionDialogTitleString(List<ILaunchConfiguration> configList, String mode) { - return LaunchMessages.getString("CApplicationLaunchShortcut.LaunchConfigSelection"); //$NON-NLS-1$ + return LaunchMessages.getString("CApplicationLaunchShortcut.LaunchConfigSelection"); //$NON-NLS-1$ } - + protected String getLaunchSelectionDialogMessageString(List<ILaunchConfiguration> binList, String mode) { if (mode.equals(ILaunchManager.DEBUG_MODE)) { - return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseLaunchConfigToDebug"); //$NON-NLS-1$ + return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseLaunchConfigToDebug"); //$NON-NLS-1$ } else if (mode.equals(ILaunchManager.RUN_MODE)) { - return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseLaunchConfigToRun"); //$NON-NLS-1$ + return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseLaunchConfigToRun"); //$NON-NLS-1$ } return LaunchMessages.getString("CApplicationLaunchShortcut.Invalid_launch_mode_2"); //$NON-NLS-1$ } /** * Prompts the user to select a binary - * + * * @return the selected binary or <code>null</code> if none. */ protected IBinary chooseBinary(List<IBinary> binList, String mode) { @@ -233,7 +234,7 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut2 { @Override public String getText(Object element) { if (element instanceof IBinary) { - IBinary bin = (IBinary)element; + IBinary bin = (IBinary) element; StringBuilder name = new StringBuilder(); name.append(bin.getPath().lastSegment()); return name.toString(); @@ -246,7 +247,7 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut2 { @Override public String getText(Object element) { if (element instanceof IBinary) { - IBinary bin = (IBinary)element; + IBinary bin = (IBinary) element; StringBuilder name = new StringBuilder(); name.append(bin.getCPU()).append(bin.isLittleEndian() ? "le" : "be"); //$NON-NLS-1$ //$NON-NLS-2$ name.append(" - "); //$NON-NLS-1$ @@ -256,8 +257,9 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut2 { return super.getText(element); } }; - - TwoPaneElementSelector dialog = new TwoPaneElementSelector(getShell(), programLabelProvider, qualifierLabelProvider); + + TwoPaneElementSelector dialog = new TwoPaneElementSelector(getShell(), programLabelProvider, + qualifierLabelProvider); dialog.setElements(binList.toArray()); dialog.setTitle(getBinarySelectionDialogTitleString(binList, mode)); dialog.setMessage(getBinarySelectionDialogMessageString(binList, mode)); @@ -270,16 +272,16 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut2 { return null; } - + protected String getBinarySelectionDialogTitleString(List<IBinary> binList, String mode) { - return LaunchMessages.getString("CApplicationLaunchShortcut.CLocalApplication"); //$NON-NLS-1$ + return LaunchMessages.getString("CApplicationLaunchShortcut.CLocalApplication"); //$NON-NLS-1$ } - + protected String getBinarySelectionDialogMessageString(List<IBinary> binList, String mode) { if (mode.equals(ILaunchManager.DEBUG_MODE)) { - return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseLocalAppToDebug"); //$NON-NLS-1$ + return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseLocalAppToDebug"); //$NON-NLS-1$ } else if (mode.equals(ILaunchManager.RUN_MODE)) { - return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseLocalAppToRun"); //$NON-NLS-1$ + return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseLocalAppToRun"); //$NON-NLS-1$ } return LaunchMessages.getString("CApplicationLaunchShortcut.Invalid_launch_mode_3"); //$NON-NLS-1$ } @@ -293,7 +295,7 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut2 { if (elements != null && elements.length > 0) { IBinary bin = null; if (elements.length == 1 && elements[0] instanceof IBinary) { - bin = (IBinary)elements[0]; + bin = (IBinary) elements[0]; } else { final List<IBinary> results = new ArrayList<IBinary>(); ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); @@ -338,12 +340,16 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut2 { } catch (InterruptedException e) { return; } catch (InvocationTargetException e) { - MessageDialog.openError(getShell(), LaunchMessages.getString("CApplicationLaunchShortcut.Application_Launcher"), e.getMessage()); //$NON-NLS-1$ + MessageDialog.openError(getShell(), + LaunchMessages.getString("CApplicationLaunchShortcut.Application_Launcher"), //$NON-NLS-1$ + e.getMessage()); return; } int count = results.size(); - if (count == 0) { - MessageDialog.openError(getShell(), LaunchMessages.getString("CApplicationLaunchShortcut.Application_Launcher"), LaunchMessages.getString("CApplicationLaunchShortcut.Launch_failed_no_binaries")); //$NON-NLS-1$ //$NON-NLS-2$ + if (count == 0) { + MessageDialog.openError(getShell(), + LaunchMessages.getString("CApplicationLaunchShortcut.Application_Launcher"), //$NON-NLS-1$ + LaunchMessages.getString("CApplicationLaunchShortcut.Launch_failed_no_binaries")); //$NON-NLS-1$ } else if (count > 1) { bin = chooseBinary(results, mode); } else { @@ -354,7 +360,9 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut2 { launch(bin, mode); } } else { - MessageDialog.openError(getShell(), LaunchMessages.getString("CApplicationLaunchShortcut.Application_Launcher"), LaunchMessages.getString("CApplicationLaunchShortcut.Launch_failed_no_project_selected")); //$NON-NLS-1$ //$NON-NLS-2$ + MessageDialog.openError(getShell(), + LaunchMessages.getString("CApplicationLaunchShortcut.Application_Launcher"), //$NON-NLS-1$ + LaunchMessages.getString("CApplicationLaunchShortcut.Launch_failed_no_project_selected")); //$NON-NLS-1$ } } @@ -384,14 +392,14 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut2 { return file.getProject(); } if (firstElement instanceof Executable) { - return ((Executable)firstElement).getProject(); + return ((Executable) firstElement).getProject(); } if (firstElement instanceof IBinary) { - return ((IBinary)firstElement).getResource().getProject(); + return ((IBinary) firstElement).getResource().getProject(); } } } - List<IProject> projects = getProjectsFromSelection(selection); + List<IProject> projects = getProjectsFromSelection(selection); if (projects.size() > 0) { return projects.get(0); } @@ -408,15 +416,15 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut2 { if (selection != null && !selection.isEmpty()) { if (selection instanceof ITextSelection) { - - IWorkbenchWindow activeWindow = CDebugUIPlugin.getActiveWorkbenchWindow(); + + IWorkbenchWindow activeWindow = CDebugUIPlugin.getActiveWorkbenchWindow(); IWorkbenchPage wpage = activeWindow.getActivePage(); if (wpage != null) { IEditorPart ep = wpage.getActiveEditor(); if (ep != null) { IEditorInput editorInput = ep.getEditorInput(); if (editorInput instanceof IFileEditorInput) { - IFile file = ((IFileEditorInput)editorInput).getFile(); + IFile file = ((IFileEditorInput) editorInput).getFile(); if (file != null) { projects.add(file.getProject()); } @@ -425,32 +433,32 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut2 { } } else if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; - + for (Iterator<?> iter = structuredSelection.iterator(); iter.hasNext();) { Object element = iter.next(); if (element != null) { if (element instanceof ICProject) { - projects.add(((ICProject)element).getProject()); + projects.add(((ICProject) element).getProject()); } else if (element instanceof IResource) { - projects.add(((IResource)element).getProject()); + projects.add(((IResource) element).getProject()); } else if (element instanceof ICElement) { ICElement unit = (ICElement) element; // Get parent of the Element until we reach the owner project. - while (unit != null && ! (unit instanceof ICProject)) + while (unit != null && !(unit instanceof ICProject)) unit = unit.getParent(); - + if (unit != null) { - projects.add(((ICProject)unit).getProject()); + projects.add(((ICProject) unit).getProject()); } } else if (element instanceof IAdaptable) { - Object adapter = ((IAdaptable)element).getAdapter(IResource.class); + Object adapter = ((IAdaptable) element).getAdapter(IResource.class); if (adapter != null && adapter instanceof IResource) { - projects.add(((IResource)adapter).getProject()); + projects.add(((IResource) adapter).getProject()); } else { - adapter = ((IAdaptable)element).getAdapter(ICProject.class); + adapter = ((IAdaptable) element).getAdapter(ICProject.class); if (adapter != null && adapter instanceof ICProject) { - projects.add(((ICProject)adapter).getProject()); + projects.add(((ICProject) adapter).getProject()); } } } @@ -466,7 +474,7 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut2 { // This handles the case where the selection is text in an editor. IEditorInput editorInput = editorpart.getEditorInput(); if (editorInput instanceof IFileEditorInput) { - IFile file = ((IFileEditorInput)editorInput).getFile(); + IFile file = ((IFileEditorInput) editorInput).getFile(); if (file != null) { return file.getProject(); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/CPropertyTester.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/CPropertyTester.java index 44b3721b1a9..d6d837420cd 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/CPropertyTester.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/CPropertyTester.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial implementation * Ken Ryall (Nokia) - Modified to launch on a project context. @@ -46,7 +46,7 @@ public class CPropertyTester extends PropertyTester { } return celement != null && celement instanceof IBinary; } - + private boolean isCProject(Object receiver) { if (receiver instanceof IProject) return CoreModel.hasCNature((IProject) receiver); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/InvalidLaunchableAdapterFactory.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/InvalidLaunchableAdapterFactory.java index b48bb267711..ca7951149eb 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/InvalidLaunchableAdapterFactory.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/InvalidLaunchableAdapterFactory.java @@ -27,52 +27,52 @@ import org.eclipse.debug.ui.actions.ILaunchable; * the ILaunchable interface and Bugzilla : 396822. */ public class InvalidLaunchableAdapterFactory implements IAdapterFactory { - private static final Class<?>[] TYPES = { ILaunchable.class }; - private static ArrayList<String> currentTraces = new ArrayList<String>(); - - @Override - public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) { - /* - * Calculate the trace to see if we already have seen this one. We only - * want to report new instances of the violation. - */ - String trace = getStackTrace(); - - if (!currentTraces.contains(trace)) { - /* - * Note we have seen this one for the first time. - */ - currentTraces.add(trace); - - /* - * Generate a message for this in the log file. - */ - String msg = LaunchMessages.getString("Launch.ILaunchable.Interface.Error"); //$NON-NLS-1$ - - CDebugUIPlugin.log(new Status(IStatus.INFO, CDebugUIPlugin.PLUGIN_ID, 0, msg, new Throwable(""))); //$NON-NLS-1$ - } - - // We do not actually provide an adapter factory for this. - return null; - } + private static final Class<?>[] TYPES = { ILaunchable.class }; + private static ArrayList<String> currentTraces = new ArrayList<String>(); - /* - * Constructs the stack trace for comparison to see if we have seen this exact trace before. - * We only report each unique instance once. - */ - private String getStackTrace() { - String trace = ""; //$NON-NLS-1$ - for (StackTraceElement elem : new Throwable().getStackTrace()) { - trace += elem.getClassName() + elem.getMethodName() + elem.getFileName() + elem.getLineNumber(); - } - return trace; - } - - /* - * Indicates that we are adapting ILaunchable. - */ - @Override - public Class<?>[] getAdapterList() { - return TYPES; - } + @Override + public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) { + /* + * Calculate the trace to see if we already have seen this one. We only + * want to report new instances of the violation. + */ + String trace = getStackTrace(); + + if (!currentTraces.contains(trace)) { + /* + * Note we have seen this one for the first time. + */ + currentTraces.add(trace); + + /* + * Generate a message for this in the log file. + */ + String msg = LaunchMessages.getString("Launch.ILaunchable.Interface.Error"); //$NON-NLS-1$ + + CDebugUIPlugin.log(new Status(IStatus.INFO, CDebugUIPlugin.PLUGIN_ID, 0, msg, new Throwable(""))); //$NON-NLS-1$ + } + + // We do not actually provide an adapter factory for this. + return null; + } + + /* + * Constructs the stack trace for comparison to see if we have seen this exact trace before. + * We only report each unique instance once. + */ + private String getStackTrace() { + String trace = ""; //$NON-NLS-1$ + for (StackTraceElement elem : new Throwable().getStackTrace()) { + trace += elem.getClassName() + elem.getMethodName() + elem.getFileName() + elem.getLineNumber(); + } + return trace; + } + + /* + * Indicates that we are adapting ILaunchable. + */ + @Override + public Class<?>[] getAdapterList() { + return TYPES; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/LaunchMessages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/LaunchMessages.java index 1983814390b..b1ad4ec1d2b 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/LaunchMessages.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/LaunchMessages.java @@ -30,7 +30,7 @@ public class LaunchMessages { } public static String getFormattedString(String key, String[] args) { - return MessageFormat.format(getString(key), (Object[])args); + return MessageFormat.format(getString(key), (Object[]) args); } public static String getString(String key) { diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizardPage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizardPage.java index 44ce2b6b5d5..03bac89a531 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizardPage.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizardPage.java @@ -71,7 +71,7 @@ public class NewGenericTargetWizardPage extends WizardPage { archText.setText(arch); } } - + setControl(comp); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/PlaceHolderLaunchConfigurationTabGroup.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/PlaceHolderLaunchConfigurationTabGroup.java index 9171b93bc76..aa7d0baf3ba 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/PlaceHolderLaunchConfigurationTabGroup.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/PlaceHolderLaunchConfigurationTabGroup.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation *******************************************************************************/ @@ -22,12 +22,12 @@ import org.eclipse.debug.ui.ILaunchConfigurationTab; * via the launchConfigurationTabGroups extension-point. Thus we just provide an * empty array of tab objects. The platform will add the ones declared in the * extension. - * + * * @since 6.0 */ public class PlaceHolderLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup { - @Override + @Override public void createTabs(ILaunchConfigurationDialog dialog, String mode) { - setTabs(new ILaunchConfigurationTab[0]); - } + setTabs(new ILaunchConfigurationTab[0]); + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/pinclone/DebugContextPinProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/pinclone/DebugContextPinProvider.java index d53f3bf8f3b..90e1daf0692 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/pinclone/DebugContextPinProvider.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/pinclone/DebugContextPinProvider.java @@ -35,7 +35,7 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IWorkbenchPart; /** - * Pin debug context provider. + * Pin debug context provider. * It takes a debug context and translates it to a handle for pinning purpose. */ public class DebugContextPinProvider extends AbstractDebugContextProvider implements IDebugContextProvider2 { @@ -43,10 +43,10 @@ public class DebugContextPinProvider extends AbstractDebugContextProvider implem private final Set<IPinElementHandle> fPinHandles; private final IWorkbenchPart fWorkbenchPart; private final Map<IPinElementHandle, IPinProvider> fPinProvider; - + /** * Constructor. - * + * * @param part the workbench part of where the pin action takes place * @param activeContext the debug context selection */ @@ -54,19 +54,18 @@ public class DebugContextPinProvider extends AbstractDebugContextProvider implem super(part); fWorkbenchPart = part; fPinProvider = new HashMap<IPinElementHandle, IPinProvider>(); - + fActiveContext = activeContext; fPinHandles = pin(part, activeContext, new IPinModelListener() { @Override public void modelChanged(ISelection selection) { - // send a change notification for the view to update - delegateEvent(new DebugContextEvent(DebugContextPinProvider.this, - selection == null ? new StructuredSelection() : selection, - DebugContextEvent.ACTIVATED)); + // send a change notification for the view to update + delegateEvent(new DebugContextEvent(DebugContextPinProvider.this, + selection == null ? new StructuredSelection() : selection, DebugContextEvent.ACTIVATED)); } }); } - + /** * Dispose the provider. */ @@ -75,7 +74,7 @@ public class DebugContextPinProvider extends AbstractDebugContextProvider implem entry.getValue().unpin(fWorkbenchPart, entry.getKey()); } } - + /* * (non-Javadoc) * @see org.eclipse.debug.ui.contexts.IDebugContextProvider2#isWindowContextProvider() @@ -84,7 +83,7 @@ public class DebugContextPinProvider extends AbstractDebugContextProvider implem public boolean isWindowContextProvider() { return false; } - + /* * (non-Javadoc) * @see org.eclipse.debug.ui.contexts.IDebugContextProvider#getActiveContext() @@ -93,68 +92,70 @@ public class DebugContextPinProvider extends AbstractDebugContextProvider implem public ISelection getActiveContext() { return fActiveContext; } - + /** * Returns the pinned debug context handles. - * + * * @return the handle set */ public Set<IPinElementHandle> getPinHandles() { return fPinHandles; } - + /** * Returns whether the current pinned handles are pinned to the given debug context. - * + * * @param debugContext the debug context in question * @return true if the pinned handles are pinned to the debug context */ public boolean isPinnedTo(Object debugContext) { - return PinCloneUtils.isPinnedTo(fPinHandles, debugContext); + return PinCloneUtils.isPinnedTo(fPinHandles, debugContext); } - + /** * Pin the given debug context selection. - * + * * @param part the workbench part where the pin action is requested * @param selection the debug context selection * @param listener pin model listener * @return a set of pinned handle */ - Set<IPinElementHandle> handles = new HashSet<IPinElementHandle>(); - private Set<IPinElementHandle> pin(IWorkbenchPart part, ISelection selection, IPinModelListener listener) { - + Set<IPinElementHandle> handles = new HashSet<IPinElementHandle>(); + + private Set<IPinElementHandle> pin(IWorkbenchPart part, ISelection selection, IPinModelListener listener) { + if (selection instanceof IStructuredSelection) { - for (Object element : ((IStructuredSelection)selection).toList()) { + for (Object element : ((IStructuredSelection) selection).toList()) { IPinProvider pinProvider = null; if (element instanceof IAdaptable) { - pinProvider = ((IAdaptable)element).getAdapter(IPinProvider.class); + pinProvider = ((IAdaptable) element).getAdapter(IPinProvider.class); } - + if (pinProvider != null) { IPinElementHandle handle = pinProvider.pin(fWorkbenchPart, element, listener); handles.add(handle); - fPinProvider.put(handle, pinProvider); + fPinProvider.put(handle, pinProvider); } else - handles.add(new PinElementHandle(element, null, PinCloneUtils.getDefaultPinElementColorDescriptor())); + handles.add( + new PinElementHandle(element, null, PinCloneUtils.getDefaultPinElementColorDescriptor())); } - } - + } + return handles; } - + /** * Delegates debug event to the listener. - * + * * @param event debug event */ public void delegateEvent(final DebugContextEvent event) { - Display.getDefault().syncExec(new Runnable() { + Display.getDefault().syncExec(new Runnable() { @Override public void run() { fActiveContext = event.getContext(); fire(event); } - }); + }); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/pinclone/DebugEventFilterService.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/pinclone/DebugEventFilterService.java index ee4d5930297..b8150346fa3 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/pinclone/DebugEventFilterService.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/pinclone/DebugEventFilterService.java @@ -31,19 +31,19 @@ import org.eclipse.ui.IWorkbenchPart; /** * This class provides debug event filtering service for the pin-able views. */ -public class DebugEventFilterService { - +public class DebugEventFilterService { + /** - * A debug context event listen that provides filter support + * A debug context event listen that provides filter support * for the pinned debug context. */ private class DebugEventFilter implements IDebugContextListener { private final DebugContextPinProvider fProvider; - + private DebugEventFilter(DebugContextPinProvider provider) { fProvider = provider; } - + /* * (non-Javadoc) * @see org.eclipse.debug.ui.contexts.IDebugContextListener#debugContextChanged(org.eclipse.debug.ui.contexts.DebugContextEvent) @@ -53,7 +53,7 @@ public class DebugEventFilterService { ISelection eventContext = event.getContext(); if (eventContext instanceof IStructuredSelection) { List<Object> filteredContextList = new ArrayList<Object>(); - List<?> eventContextList = ((IStructuredSelection)eventContext).toList(); + List<?> eventContextList = ((IStructuredSelection) eventContext).toList(); for (Object o : eventContextList) { if (fProvider.isPinnedTo(o)) { if (fProvider != event.getDebugContextProvider()) { @@ -62,32 +62,33 @@ public class DebugEventFilterService { } } if (filteredContextList.size() > 0) { - fProvider.delegateEvent(new DebugContextEvent(fProvider, new StructuredSelection(filteredContextList), event.getFlags())); + fProvider.delegateEvent(new DebugContextEvent(fProvider, + new StructuredSelection(filteredContextList), event.getFlags())); } } - } - + } + public DebugContextPinProvider getTranslator() { return fProvider; } } - + private static DebugEventFilterService INSTANCE; private Map<IWorkbenchPart, DebugEventFilter> fFilterMap = new HashMap<IWorkbenchPart, DebugEventFilter>(); - + private DebugEventFilterService() { } - + public static synchronized DebugEventFilterService getInstance() { - if (INSTANCE == null) + if (INSTANCE == null) INSTANCE = new DebugEventFilterService(); return INSTANCE; } - + /** - * Add debug event filter for the provided part and filter debug context change + * Add debug event filter for the provided part and filter debug context change * event for the provided debug context. - * + * * @param part the part to filter debug context change event. * @param debugContext the debug context that filter should stick to. * @return the debug context provider that handles the filtering. @@ -95,50 +96,53 @@ public class DebugEventFilterService { public DebugContextPinProvider addDebugEventFilter(IWorkbenchPart part, ISelection debugContext) { DebugContextPinProvider contextProvider = null; DebugEventFilter filter = null; - + synchronized (fFilterMap) { if (fFilterMap.containsKey(part)) { return null; - } - + } + contextProvider = new DebugContextPinProvider(part, debugContext); filter = new DebugEventFilter(contextProvider); fFilterMap.put(part, filter); } - + assert contextProvider != null && filter != null; - - IDebugContextService contextService = DebugUITools.getDebugContextManager().getContextService(part.getSite().getWorkbenchWindow()); + + IDebugContextService contextService = DebugUITools.getDebugContextManager() + .getContextService(part.getSite().getWorkbenchWindow()); contextService.addDebugContextProvider(contextProvider); contextService.addDebugContextListener(filter); - + return contextProvider; } - + /** * Remove debug event filter for the provided part. - * + * * @param part the workbench part. */ public void removeDebugEventFilter(IWorkbenchPart part) { DebugEventFilter filter = null; - + synchronized (fFilterMap) { if (!fFilterMap.containsKey(part)) { return; } - + filter = fFilterMap.remove(part); } assert filter != null; - + DebugContextPinProvider contextProvider = filter.getTranslator(); - IDebugContextService contextService = DebugUITools.getDebugContextManager().getContextService(part.getSite().getWorkbenchWindow()); - + IDebugContextService contextService = DebugUITools.getDebugContextManager() + .getContextService(part.getSite().getWorkbenchWindow()); + // send a change notification to the listener to update with selected context - contextProvider.delegateEvent(new DebugContextEvent(contextProvider, contextService.getActiveContext(), DebugContextEvent.ACTIVATED)); - + contextProvider.delegateEvent( + new DebugContextEvent(contextProvider, contextService.getActiveContext(), DebugContextEvent.ACTIVATED)); + // removes the listener and provider contextService.removeDebugContextListener(filter); contextService.removeDebugContextProvider(contextProvider); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/pinclone/PinCloneUtils.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/pinclone/PinCloneUtils.java index a8e6e785664..547152b1c42 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/pinclone/PinCloneUtils.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/pinclone/PinCloneUtils.java @@ -36,9 +36,9 @@ import org.eclipse.ui.part.WorkbenchPart; */ public class PinCloneUtils { public static String PIN_CLONE_VIEW_TAG = "PIN_CLONE_VIEW_"; //$NON-NLS-1$ - + private static final DefaultPinElementColorDescriptor DEFAULT_PIN_ELEMENT_COLOR_DESCRIPTOR = new DefaultPinElementColorDescriptor(); - + /** * Default pin element color descriptor. */ @@ -47,34 +47,35 @@ public class PinCloneUtils { public int getOverlayColor() { return GREEN; } + @Override public ImageDescriptor getToolbarIconDescriptor() { return null; - } + } } - + /** * Returns the default pin element color descriptor. - * + * * @return the color descriptor */ public static IPinElementColorDescriptor getDefaultPinElementColorDescriptor() { return DEFAULT_PIN_ELEMENT_COLOR_DESCRIPTOR; } - + /** * Encodes cloned part secondary id. - * + * * @param secondaryId the part's secondary id. * @return an encoded part secondary id, can be <code>null</code>. */ public static String encodeClonedPartSecondaryId(String secondaryId) { return PIN_CLONE_VIEW_TAG + secondaryId; } - + /** * Decodes cloned part secondary id. - * + * * @param secondaryId the part's secondary id * @return a decoded part secondary id */ @@ -83,21 +84,21 @@ public class PinCloneUtils { return ""; //$NON-NLS-1$ return secondaryId.replaceFirst(PIN_CLONE_VIEW_TAG, ""); //$NON-NLS-1$ } - + /** * Determine whether the view part is a cloned part. - * + * * @param part the view part * @return true if it is a cloned part */ public static boolean isClonedPart(IViewPart part) { String secondaryId = part.getViewSite().getSecondaryId(); - return hasCloneTag(secondaryId); + return hasCloneTag(secondaryId); } - + /** * Determine whether the view reference is a cloned part. - * + * * @param ref the view reference * @return true if it is a cloned part */ @@ -105,42 +106,42 @@ public class PinCloneUtils { String secondaryId = ref.getSecondaryId(); return hasCloneTag(secondaryId); } - + /** * Returns whether the id has the <code>PIN_CLONE_VIEW_TAG</code>. - * + * * @param id view id * @return true if it has the tag, otherwise false */ private static boolean hasCloneTag(String id) { return id != null && id.startsWith(PIN_CLONE_VIEW_TAG); - } - + } + /** * Set the part title to include the secondary id as part of the title. - * + * * @param part the view part */ public static void setPartTitle(IViewPart part) { try { if (!isClonedPart(part)) return; - + String secondaryId = part.getViewSite().getSecondaryId(); - secondaryId = decodeClonedPartSecondaryId(secondaryId); - + secondaryId = decodeClonedPartSecondaryId(secondaryId); + // use reflection to set the part name of the new view Method method = WorkbenchPart.class.getDeclaredMethod("setPartName", String.class); //$NON-NLS-1$ - if (method != null) { + if (method != null) { if (part instanceof WorkbenchPart) { String name = ((WorkbenchPart) part).getPartName(); - - String tag = " <" + secondaryId + ">"; //$NON-NLS-1$//$NON-NLS-2$ + + String tag = " <" + secondaryId + ">"; //$NON-NLS-1$//$NON-NLS-2$ if (!name.contains(tag)) { name = name + tag; - + method.setAccessible(true); - method.invoke(part, name); + method.invoke(part, name); } } } @@ -148,10 +149,10 @@ public class PinCloneUtils { CDebugUIPlugin.log(e); } } - + /** * Set the part content description. - * + * * @param part the part * @param description the new description */ @@ -161,106 +162,109 @@ public class PinCloneUtils { if (method != null) { method.setAccessible(true); method.invoke(part, description); - } + } } catch (Exception e) { CDebugUIPlugin.log(e); } } - + /** * Returns whether the debug context selection is pinnable. - * + * * @param part the workbench part were the pin action is triggered * @param selection the debug context selection * @return true if all elements are pinnable, otherwise false */ public static boolean isPinnable(IWorkbenchPart part, ISelection selection) { boolean pinnable = false; - + if (selection instanceof IStructuredSelection) { - List <?> list = ((IStructuredSelection) selection).toList(); + List<?> list = ((IStructuredSelection) selection).toList(); for (Object element : list) { pinnable = false; - + /* IPinProvider */ - if (element instanceof IAdaptable) { - IPinProvider pinProvider = ((IAdaptable)element).getAdapter(IPinProvider.class); + if (element instanceof IAdaptable) { + IPinProvider pinProvider = ((IAdaptable) element).getAdapter(IPinProvider.class); if (pinProvider != null) { - if (pinProvider.isPinnable(part, element)) + if (pinProvider.isPinnable(part, element)) pinnable = true; } - } + } + + // TODO: support for CDI + // /* support CDebugElement */ + // if (!pinnable && (element instanceof ICDebugElement)) { + // pinnable = true; + // } -// TODO: support for CDI -// /* support CDebugElement */ -// if (!pinnable && (element instanceof ICDebugElement)) { -// pinnable = true; -// } - - if (!pinnable) break; + if (!pinnable) + break; } } - + return pinnable; } - + /** * Returns the pin element color descriptor for the set of handles. If there are multiple pinned handles, * then return the default element color descriptor. - * + * * @param handles the pinned debug handles * @param debugContext the debug context to compare with against the handles * @return the element color descriptor, can be <code>null</code>; */ - public static IPinElementColorDescriptor getPinElementColorDescriptor(Set<IPinElementHandle> handles, Object debugContext) { + public static IPinElementColorDescriptor getPinElementColorDescriptor(Set<IPinElementHandle> handles, + Object debugContext) { int color = IPinElementColorDescriptor.UNDEFINED; IPinElementColorDescriptor colorDesc = null; - - for (IPinElementHandle handle : handles) { - if (debugContext instanceof IAdaptable) { - IPinProvider pinProvider = ((IAdaptable) debugContext).getAdapter(IPinProvider.class); - if (pinProvider != null) { - if (pinProvider.isPinnedTo(debugContext, handle)) { - colorDesc = handle.getPinElementColorDescriptor(); - if (colorDesc != null) { - int overlayColor = colorDesc.getOverlayColor(); - if (color == IPinElementColorDescriptor.UNDEFINED) color = overlayColor; - if (color != overlayColor) { - colorDesc = null; - break; - } - } - } - } - } - } + for (IPinElementHandle handle : handles) { + if (debugContext instanceof IAdaptable) { + + IPinProvider pinProvider = ((IAdaptable) debugContext).getAdapter(IPinProvider.class); + if (pinProvider != null) { + if (pinProvider.isPinnedTo(debugContext, handle)) { + colorDesc = handle.getPinElementColorDescriptor(); + if (colorDesc != null) { + int overlayColor = colorDesc.getOverlayColor(); + if (color == IPinElementColorDescriptor.UNDEFINED) + color = overlayColor; + if (color != overlayColor) { + colorDesc = null; + break; + } + } + } + } + } + } + + if (colorDesc == null) + colorDesc = getDefaultPinElementColorDescriptor(); - if (colorDesc == null) - colorDesc = getDefaultPinElementColorDescriptor(); - - return colorDesc; + return colorDesc; } - + /** * Returns whether the debug context is pinned to any one of these handles. - * + * * @param handles the handles * @param debugContext the debug context * @return true if pinned to any one of these handles */ public static boolean isPinnedTo(Set<IPinElementHandle> handles, Object debugContext) { for (IPinElementHandle handle : handles) { - if (debugContext instanceof IAdaptable) { - IPinProvider pinProvider = ((IAdaptable) debugContext).getAdapter(IPinProvider.class); - if (pinProvider != null) { - if (pinProvider.isPinnedTo(debugContext, handle)) { - return true; - } - } - } - } - + if (debugContext instanceof IAdaptable) { + IPinProvider pinProvider = ((IAdaptable) debugContext).getAdapter(IPinProvider.class); + if (pinProvider != null) { + if (pinProvider.isPinnedTo(debugContext, handle)) { + return true; + } + } + } + } + return false; } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/pinclone/ViewIDCounterManager.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/pinclone/ViewIDCounterManager.java index e7f07353975..7fc14d9697e 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/pinclone/ViewIDCounterManager.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/pinclone/ViewIDCounterManager.java @@ -42,17 +42,18 @@ import org.eclipse.ui.progress.WorkbenchJob; public final class ViewIDCounterManager { private static ViewIDCounterManager INSTANCE; private static boolean fInitialized = false; - + private boolean fShuttingDown = false; - private final Map<String, Set<Integer>> viewIdToNextCounterMap = Collections.synchronizedMap(new HashMap<String, Set<Integer>>()); - + private final Map<String, Set<Integer>> viewIdToNextCounterMap = Collections + .synchronizedMap(new HashMap<String, Set<Integer>>()); + private ViewIDCounterManager() { initListeners(); } - + /** * Returns an instance of the view id counter manager. - * + * * @return the counter manager. */ synchronized public static ViewIDCounterManager getInstance() { @@ -60,18 +61,22 @@ public final class ViewIDCounterManager { INSTANCE = new ViewIDCounterManager(); } return INSTANCE; - } - + } + /** * Initialize this view ID counter manager. Catch up opened view and set the title * accordingly from the view's secondary id. */ synchronized public void init() { - if (fInitialized) return; + if (fInitialized) + return; fInitialized = true; - + new WorkbenchJob("Initializing pinnable view") { //$NON-NLS-1$ - { setSystem(true); } + { + setSystem(true); + } + @Override public IStatus runInUIThread(IProgressMonitor monitor) { IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows(); @@ -80,61 +85,73 @@ public final class ViewIDCounterManager { for (IViewReference viewRef : viewRefs) { try { // initialize the view id counter map - if (PinCloneUtils.isClonedPart(viewRef)) { - String id = viewRef.getId(); - String secondaryId = viewRef.getSecondaryId(); - Set<Integer> secondaryIdSet = viewIdToNextCounterMap.get(id); - if (secondaryIdSet == null) { - secondaryIdSet = new HashSet<Integer>(); - viewIdToNextCounterMap.put(id, secondaryIdSet); - } - secondaryId = PinCloneUtils.decodeClonedPartSecondaryId(secondaryId); - secondaryIdSet.add(Integer.valueOf(secondaryId)); - } - - // set the view title - IViewPart part = viewRef.getView(false); - if (part != null && PinCloneUtils.isClonedPart(part)) { - PinCloneUtils.setPartTitle(part); - } + if (PinCloneUtils.isClonedPart(viewRef)) { + String id = viewRef.getId(); + String secondaryId = viewRef.getSecondaryId(); + Set<Integer> secondaryIdSet = viewIdToNextCounterMap.get(id); + if (secondaryIdSet == null) { + secondaryIdSet = new HashSet<Integer>(); + viewIdToNextCounterMap.put(id, secondaryIdSet); + } + secondaryId = PinCloneUtils.decodeClonedPartSecondaryId(secondaryId); + secondaryIdSet.add(Integer.valueOf(secondaryId)); + } + + // set the view title + IViewPart part = viewRef.getView(false); + if (part != null && PinCloneUtils.isClonedPart(part)) { + PinCloneUtils.setPartTitle(part); + } } catch (Exception e) { - CDebugUIPlugin.log(e); + CDebugUIPlugin.log(e); } - } + } } return Status.OK_STATUS; } }.schedule(); } - + private void initListeners() { try { // add a workbench listener to listen to preShutdown and ignore view part close event IWorkbench wb = PlatformUI.getWorkbench(); wb.addWorkbenchListener(new IWorkbenchListener() { @Override - public void postShutdown(IWorkbench workbench) {} - + public void postShutdown(IWorkbench workbench) { + } + @Override public boolean preShutdown(IWorkbench workbench, boolean forced) { fShuttingDown = true; return true; } }); - + final IPartListener2 partListener = new IPartListener2() { @Override - public void partVisible(IWorkbenchPartReference partRef) {} + public void partVisible(IWorkbenchPartReference partRef) { + } + @Override - public void partInputChanged(IWorkbenchPartReference partRef) {} + public void partInputChanged(IWorkbenchPartReference partRef) { + } + @Override - public void partHidden(IWorkbenchPartReference partRef) {} + public void partHidden(IWorkbenchPartReference partRef) { + } + @Override - public void partDeactivated(IWorkbenchPartReference partRef) {} + public void partDeactivated(IWorkbenchPartReference partRef) { + } + @Override - public void partBroughtToTop(IWorkbenchPartReference partRef) {} + public void partBroughtToTop(IWorkbenchPartReference partRef) { + } + @Override - public void partActivated(IWorkbenchPartReference partRef) {} + public void partActivated(IWorkbenchPartReference partRef) { + } @Override public void partOpened(IWorkbenchPartReference partRef) { @@ -143,66 +160,71 @@ public final class ViewIDCounterManager { if (part != null && PinCloneUtils.isClonedPart(part)) { PinCloneUtils.setPartTitle(part); } - } + } } - + @Override public void partClosed(IWorkbenchPartReference partRef) { if (!fShuttingDown) recycleCounterId(partRef); } }; - + // subscribe to existing workbench window listener for (IWorkbenchWindow ww : wb.getWorkbenchWindows()) { ww.getPartService().addPartListener(partListener); } - + // subscribe to new workbench window listener - wb.addWindowListener(new IWindowListener() { + wb.addWindowListener(new IWindowListener() { @Override - public void windowDeactivated(IWorkbenchWindow window) {} + public void windowDeactivated(IWorkbenchWindow window) { + } + @Override - public void windowActivated(IWorkbenchWindow window) {} + public void windowActivated(IWorkbenchWindow window) { + } + @Override - public void windowClosed(IWorkbenchWindow window) {} - + public void windowClosed(IWorkbenchWindow window) { + } + @Override public void windowOpened(IWorkbenchWindow window) { window.getPartService().addPartListener(partListener); - } + } }); } catch (Exception e) { CDebugUIPlugin.log(e); } } - + private void recycleCounterId(IWorkbenchPartReference partRef) { if (partRef instanceof IViewReference) { IViewReference viewRef = ((IViewReference) partRef); IWorkbenchPart part = viewRef.getPart(false); - if ( !(part instanceof IViewPart) || !PinCloneUtils.isClonedPart((IViewPart) part)) + if (!(part instanceof IViewPart) || !PinCloneUtils.isClonedPart((IViewPart) part)) return; - + String viewId = viewRef.getId(); String secondaryId = viewRef.getSecondaryId(); - + if (secondaryId != null) { Set<Integer> secondaryIdSet = viewIdToNextCounterMap.get(viewId); - if (secondaryIdSet != null) { + if (secondaryIdSet != null) { secondaryIdSet.remove(Integer.valueOf(PinCloneUtils.decodeClonedPartSecondaryId(secondaryId))); } } } } - + public Integer getNextCounter(String viewId) { Set<Integer> secondaryIdSet = viewIdToNextCounterMap.get(viewId); if (secondaryIdSet == null) { secondaryIdSet = new HashSet<Integer>(); viewIdToNextCounterMap.put(viewId, secondaryIdSet); } - + for (int i = 1; i < Integer.MAX_VALUE; ++i) { Integer next = Integer.valueOf(i); if (!secondaryIdSet.contains(next)) { @@ -210,7 +232,7 @@ public final class ViewIDCounterManager { return next; } } - + return Integer.valueOf(0); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/CDebugPreferencePage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/CDebugPreferencePage.java index 9fdc5ae3b80..99efee59fb4 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/CDebugPreferencePage.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/CDebugPreferencePage.java @@ -391,22 +391,25 @@ public class CDebugPreferencePage extends PreferencePage implements IWorkbenchPr // Store the show source file editor if (fShowSourceNotFoundAllTime.getSelection()) { - InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID) - .put(CCorePreferenceConstants.SHOW_SOURCE_NOT_FOUND_EDITOR, CCorePreferenceConstants.SHOW_SOURCE_NOT_FOUND_EDITOR_ALL_THE_TIME); + InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).put( + CCorePreferenceConstants.SHOW_SOURCE_NOT_FOUND_EDITOR, + CCorePreferenceConstants.SHOW_SOURCE_NOT_FOUND_EDITOR_ALL_THE_TIME); } if (fShowSourceNotFoundOnlyCaseSourceNotFound.getSelection()) { - InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID) - .put(CCorePreferenceConstants.SHOW_SOURCE_NOT_FOUND_EDITOR, CCorePreferenceConstants.SHOW_SOURCE_NOT_FOUND_EDITOR_SOMETIMES); + InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).put( + CCorePreferenceConstants.SHOW_SOURCE_NOT_FOUND_EDITOR, + CCorePreferenceConstants.SHOW_SOURCE_NOT_FOUND_EDITOR_SOMETIMES); } if (fShowSourceNotFoundNever.getSelection()) { - InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID) - .put(CCorePreferenceConstants.SHOW_SOURCE_NOT_FOUND_EDITOR, CCorePreferenceConstants.SHOW_SOURCE_NOT_FOUND_EDITOR_NEVER); + InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).put( + CCorePreferenceConstants.SHOW_SOURCE_NOT_FOUND_EDITOR, + CCorePreferenceConstants.SHOW_SOURCE_NOT_FOUND_EDITOR_NEVER); } } /** * Sets the default preferences. - * + * * @see PreferencePage#performDefaults() */ @Override @@ -414,9 +417,8 @@ public class CDebugPreferencePage extends PreferencePage implements IWorkbenchPr setDefaultValues(); super.performDefaults(); } - - private void setShowEditorButtons(String value) - { + + private void setShowEditorButtons(String value) { switch (value) { case CCorePreferenceConstants.SHOW_SOURCE_NOT_FOUND_EDITOR_SOMETIMES: fShowSourceNotFoundOnlyCaseSourceNotFound.setSelection(true); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/ComboFieldEditor.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/ComboFieldEditor.java index 6d64a59b486..aa8db6f1a02 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/ComboFieldEditor.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/ComboFieldEditor.java @@ -34,35 +34,35 @@ public class ComboFieldEditor extends FieldEditor { * The <code>Combo</code> widget. */ protected Combo fCombo; - + /** * The value (not the name) of the currently selected item in the Combo widget. */ protected String fValue; - + /** * The names (labels) and underlying values to populate the combo widget. These should be * arranged as: { {name1, value1}, {name2, value2}, ...} */ private String[][] fEntryNamesAndValues; - /** - * Create combo field editor with all choice values. - * @param name - property name, must be the same as breakpoint attribute - * @param labelText - text in front of field - * @param entryNamesAndValues - The names (labels) and underlying values to populate the combo widget. - * These should be arranged as: { {name1, value1}, {name2, value2}, ...} - * @param parent the parent control - */ + /** + * Create combo field editor with all choice values. + * @param name - property name, must be the same as breakpoint attribute + * @param labelText - text in front of field + * @param entryNamesAndValues - The names (labels) and underlying values to populate the combo widget. + * These should be arranged as: { {name1, value1}, {name2, value2}, ...} + * @param parent the parent control + */ public ComboFieldEditor(String name, String labelText, String[][] entryNamesAndValues, Composite parent) { init(name, labelText); Assert.isTrue(checkArray(entryNamesAndValues)); fEntryNamesAndValues = entryNamesAndValues; - createControl(parent); + createControl(parent); } /** - * Checks whether given <code>String[][]</code> is of "type" + * 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 @@ -85,15 +85,15 @@ public class ComboFieldEditor extends FieldEditor { */ @Override protected void adjustForNumColumns(int numColumns) { - if ( numColumns <= 1 ) + if (numColumns <= 1) return; int span = numColumns; Control control = getLabelControl(); if (control != null) { - ((GridData)control.getLayoutData()).horizontalSpan = 1; + ((GridData) control.getLayoutData()).horizontalSpan = 1; --span; } - ((GridData)fCombo.getLayoutData()).horizontalSpan = span; + ((GridData) fCombo.getLayoutData()).horizontalSpan = span; } /** @@ -136,7 +136,7 @@ public class ComboFieldEditor extends FieldEditor { getPreferenceStore().setToDefault(getPreferenceName()); return; } - + getPreferenceStore().setValue(getPreferenceName(), fValue); } @@ -157,7 +157,7 @@ public class ComboFieldEditor extends FieldEditor { for (int i = 0; i < fEntryNamesAndValues.length; i++) { fCombo.add(fEntryNamesAndValues[i][0], i); } - + fCombo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent evt) { @@ -165,17 +165,17 @@ public class ComboFieldEditor extends FieldEditor { String name = fCombo.getText(); fValue = getValueForName(name); setPresentsDefaultValue(false); - fireValueChanged(VALUE, oldValue, fValue); + fireValueChanged(VALUE, oldValue, fValue); } }); } return fCombo; } - + protected Combo getComboBoxControl() { - return fCombo; + return fCombo; } - + /** * Given the name (label) of an entry, return the corresponding value. */ @@ -188,7 +188,7 @@ public class ComboFieldEditor extends FieldEditor { } return fEntryNamesAndValues[0][0]; } - + /** * Set the name in the combo widget to match the specified value. */ @@ -209,18 +209,16 @@ public class ComboFieldEditor extends FieldEditor { * @see org.eclipse.jface.preference.FieldEditor#fireValueChanged(String, Object, Object) */ @Override - protected void fireValueChanged( String property, Object oldValue, Object newValue ) - { - super.fireValueChanged( property, oldValue, newValue ); + protected void fireValueChanged(String property, Object oldValue, Object newValue) { + super.fireValueChanged(property, oldValue, newValue); } /* (non-Javadoc) * @see org.eclipse.jface.preference.FieldEditor#setPresentsDefaultValue(boolean) */ @Override - protected void setPresentsDefaultValue( boolean b ) - { - super.setPresentsDefaultValue( b ); + protected void setPresentsDefaultValue(boolean b) { + super.setPresentsDefaultValue(b); } /** @@ -236,7 +234,7 @@ public class ComboFieldEditor extends FieldEditor { combo.removeAll(); } //load values from contribution - for (int i=0; i<fEntryNamesAndValues.length; ++i) { + for (int i = 0; i < fEntryNamesAndValues.length; ++i) { combo.add(fEntryNamesAndValues[i][0], i); } fCombo.select(0); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/DisassemblyPreferencePage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/DisassemblyPreferencePage.java index 8eb89eaf4d0..1e3079a52b2 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/DisassemblyPreferencePage.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/DisassemblyPreferencePage.java @@ -27,57 +27,47 @@ import org.eclipse.ui.IWorkbenchPreferencePage; public class DisassemblyPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { - public DisassemblyPreferencePage() { - super( GRID ); - IPreferenceStore store = CDebugUIPlugin.getDefault().getPreferenceStore(); - setPreferenceStore( store ); - setDescription( "Disassembly Settings" ); - } + public DisassemblyPreferencePage() { + super(GRID); + IPreferenceStore store = CDebugUIPlugin.getDefault().getPreferenceStore(); + setPreferenceStore(store); + setDescription("Disassembly Settings"); + } - /* (non-Javadoc) - * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() - */ - @Override - protected void createFieldEditors() { - Group group = ControlFactory.createGroup( getFieldEditorParent(), "Open disassembly options", 1 ); - Composite spacer = ControlFactory.createComposite( group, 1 ); - FieldEditor edit = new BooleanFieldEditor( - ICDebugPreferenceConstants.PREF_DISASM_OPEN_NO_SOURCE_INFO, - "Source information is not available", - spacer ); - edit.fillIntoGrid( spacer, 2 ); - addField( edit ); + /* (non-Javadoc) + * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() + */ + @Override + protected void createFieldEditors() { + Group group = ControlFactory.createGroup(getFieldEditorParent(), "Open disassembly options", 1); + Composite spacer = ControlFactory.createComposite(group, 1); + FieldEditor edit = new BooleanFieldEditor(ICDebugPreferenceConstants.PREF_DISASM_OPEN_NO_SOURCE_INFO, + "Source information is not available", spacer); + edit.fillIntoGrid(spacer, 2); + addField(edit); - edit = new BooleanFieldEditor( - ICDebugPreferenceConstants.PREF_DISASM_OPEN_SOURCE_NOT_FOUND, - "Source file not found", - spacer ); - edit.fillIntoGrid( spacer, 2 ); - addField( edit ); + edit = new BooleanFieldEditor(ICDebugPreferenceConstants.PREF_DISASM_OPEN_SOURCE_NOT_FOUND, + "Source file not found", spacer); + edit.fillIntoGrid(spacer, 2); + addField(edit); + group = ControlFactory.createGroup(getFieldEditorParent(), "Display settings", 1); + spacer = ControlFactory.createComposite(group, 1); - group = ControlFactory.createGroup( getFieldEditorParent(), "Display settings", 1 ); - spacer = ControlFactory.createComposite( group, 1 ); + edit = new BooleanFieldEditor(ICDebugPreferenceConstants.PREF_DISASM_SHOW_INSTRUCTIONS, "Show instructions", + spacer); + edit.fillIntoGrid(spacer, 2); + addField(edit); - edit = new BooleanFieldEditor( - ICDebugPreferenceConstants.PREF_DISASM_SHOW_INSTRUCTIONS, - "Show instructions", - spacer ); - edit.fillIntoGrid( spacer, 2 ); - addField( edit ); + edit = new BooleanFieldEditor(ICDebugPreferenceConstants.PREF_DISASM_SHOW_SOURCE, "Show source", spacer); + edit.fillIntoGrid(spacer, 2); + addField(edit); + } - edit = new BooleanFieldEditor( - ICDebugPreferenceConstants.PREF_DISASM_SHOW_SOURCE, - "Show source", - spacer ); - edit.fillIntoGrid( spacer, 2 ); - addField( edit ); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) - */ - @Override - public void init( IWorkbench workbench ) { - } + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) + */ + @Override + public void init(IWorkbench workbench) { + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/ICDebugPreferenceConstants.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/ICDebugPreferenceConstants.java index 5a389524937..196446ee1ad 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/ICDebugPreferenceConstants.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/ICDebugPreferenceConstants.java @@ -17,7 +17,7 @@ import org.eclipse.cdt.debug.ui.ICDebugUIConstants; /** * Constants defining the keys to be used for accessing preferences inside the debug ui plugin's preference bundle. - * In descriptions (of the keys) below describe the preference stored at the given key. + * In descriptions (of the keys) below describe the preference stored at the given key. * The type indicates type of the stored preferences * The preference store is loaded by the plugin (CDebugUIPlugin). * @see CDebugUIPlugin.initializeDefaultPreferences(IPreferenceStore) - for initialization of the store @@ -34,23 +34,26 @@ public interface ICDebugPreferenceConstants { */ public static final String PREF_SHOW_CHAR_VALUES = ICDebugUIConstants.PLUGIN_ID + ".cDebug.showCharValues"; //$NON-NLS-1$ - /** - * Boolean preference controlling whether the disassembly instructions is to be shown in the disassembly window. - */ - public static final String PREF_DISASM_SHOW_INSTRUCTIONS = ICDebugUIConstants.PLUGIN_ID + ".disassembly.showInstructions"; //$NON-NLS-1$ - - /** - * Boolean preference controlling whether the source lines is to be shown in the disassembly window. - */ - public static final String PREF_DISASM_SHOW_SOURCE = ICDebugUIConstants.PLUGIN_ID + ".disassembly.showSource"; //$NON-NLS-1$ - - /** - * Boolean preference controlling whether the disassembly editor is be activated if the source information is not available. - */ - public static final String PREF_DISASM_OPEN_NO_SOURCE_INFO = ICDebugUIConstants.PLUGIN_ID + ".disassembly.openNoSourceInfo"; //$NON-NLS-1$ - - /** - * Boolean preference controlling whether the disassembly editor is be activated if the source file can't be found. - */ - public static final String PREF_DISASM_OPEN_SOURCE_NOT_FOUND = ICDebugUIConstants.PLUGIN_ID + ".disassembly.openSourceNotFound"; //$NON-NLS-1$ + /** + * Boolean preference controlling whether the disassembly instructions is to be shown in the disassembly window. + */ + public static final String PREF_DISASM_SHOW_INSTRUCTIONS = ICDebugUIConstants.PLUGIN_ID + + ".disassembly.showInstructions"; //$NON-NLS-1$ + + /** + * Boolean preference controlling whether the source lines is to be shown in the disassembly window. + */ + public static final String PREF_DISASM_SHOW_SOURCE = ICDebugUIConstants.PLUGIN_ID + ".disassembly.showSource"; //$NON-NLS-1$ + + /** + * Boolean preference controlling whether the disassembly editor is be activated if the source information is not available. + */ + public static final String PREF_DISASM_OPEN_NO_SOURCE_INFO = ICDebugUIConstants.PLUGIN_ID + + ".disassembly.openNoSourceInfo"; //$NON-NLS-1$ + + /** + * Boolean preference controlling whether the disassembly editor is be activated if the source file can't be found. + */ + public static final String PREF_DISASM_OPEN_SOURCE_NOT_FOUND = ICDebugUIConstants.PLUGIN_ID + + ".disassembly.openSourceNotFound"; //$NON-NLS-1$ } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/PreferenceMessages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/PreferenceMessages.java index 5e918fa40bb..9d2d54e2908 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/PreferenceMessages.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/PreferenceMessages.java @@ -20,16 +20,15 @@ public class PreferenceMessages { private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.preferences.PreferenceMessages";//$NON-NLS-1$ - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); private PreferenceMessages() { } - public static String getString( String key ) { + public static String getString(String key) { try { - return RESOURCE_BUNDLE.getString( key ); - } - catch( MissingResourceException e ) { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { return '!' + key + '!'; } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/SourcePreferencePage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/SourcePreferencePage.java index 18fba5b9a77..550fe657f69 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/SourcePreferencePage.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/SourcePreferencePage.java @@ -11,7 +11,7 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.preferences; +package org.eclipse.cdt.debug.internal.ui.preferences; import java.util.ArrayList; import java.util.List; @@ -50,7 +50,7 @@ public class SourcePreferencePage extends PreferencePage implements IWorkbenchPr private SourceContainerViewer fPathViewer; private List<SourceContainerAction> fActions = new ArrayList<SourceContainerAction>(6); private IWorkbench fWorkbench; - private AddContainerAction fAddAction; + private AddContainerAction fAddAction; private EditContainerAction fEditAction; /* (non-Javadoc) @@ -117,7 +117,7 @@ public class SourcePreferencePage extends PreferencePage implements IWorkbenchPr /* * (non-Javadoc) - * + * * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) */ @Override diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/StringSetSerializer.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/StringSetSerializer.java index 96a7edc6df2..28d46c789eb 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/StringSetSerializer.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/StringSetSerializer.java @@ -21,14 +21,15 @@ import java.util.StringTokenizer; import org.eclipse.core.runtime.Assert; public final class StringSetSerializer { - private static final String DELIM= "\0"; //$NON-NLS-1$ + private static final String DELIM = "\0"; //$NON-NLS-1$ + private StringSetSerializer() { } public static String serialize(Set<String> strings) { Assert.isLegal(strings != null); - StringBuilder buf= new StringBuilder(strings.size() * 20); - for (Iterator<String> it= strings.iterator(); it.hasNext();) { + StringBuilder buf = new StringBuilder(strings.size() * 20); + for (Iterator<String> it = strings.iterator(); it.hasNext();) { buf.append(it.next()); if (it.hasNext()) buf.append(DELIM); @@ -38,17 +39,17 @@ public final class StringSetSerializer { public static Set<String> deserialize(String serialized) { Assert.isLegal(serialized != null); - Set<String> marked= new HashSet<String>(); - StringTokenizer tok= new StringTokenizer(serialized, DELIM); + Set<String> marked = new HashSet<String>(); + StringTokenizer tok = new StringTokenizer(serialized, DELIM); while (tok.hasMoreTokens()) marked.add(tok.nextToken()); return marked; } public static String[] getDifference(String oldValue, String newValue) { - Set<String> oldSet= deserialize(oldValue); - Set<String> newSet= deserialize(newValue); - Set<String> intersection= new HashSet<String>(oldSet); + Set<String> oldSet = deserialize(oldValue); + Set<String> newSet = deserialize(newValue); + Set<String> intersection = new HashSet<String>(oldSet); intersection.retainAll(newSet); oldSet.removeAll(intersection); newSet.removeAll(intersection); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/propertypages/ModuleProperties.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/propertypages/ModuleProperties.java index a0715294b07..19342e60709 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/propertypages/ModuleProperties.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/propertypages/ModuleProperties.java @@ -11,23 +11,23 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.propertypages; +package org.eclipse.cdt.debug.internal.ui.propertypages; import java.util.ArrayList; import java.util.Iterator; import org.eclipse.cdt.debug.core.model.ICModule; - + /** - * A module's properties store. + * A module's properties store. */ public class ModuleProperties { - final static public String TYPE = "type"; //$NON-NLS-1$ - final static public String CPU = "cpu"; //$NON-NLS-1$ - final static public String BASE_ADDRESS = "baseAddress"; //$NON-NLS-1$ - final static public String SIZE = "size"; //$NON-NLS-1$ - final static public String SYMBOLS_LOADED = "symbolsLoaded"; //$NON-NLS-1$ - final static public String SYMBOLS_FILE = "symbolsFile"; //$NON-NLS-1$ + final static public String TYPE = "type"; //$NON-NLS-1$ + final static public String CPU = "cpu"; //$NON-NLS-1$ + final static public String BASE_ADDRESS = "baseAddress"; //$NON-NLS-1$ + final static public String SIZE = "size"; //$NON-NLS-1$ + final static public String SYMBOLS_LOADED = "symbolsLoaded"; //$NON-NLS-1$ + final static public String SYMBOLS_FILE = "symbolsFile"; //$NON-NLS-1$ public class Property { @@ -37,7 +37,7 @@ public class ModuleProperties { /** * Constructor for Property. */ - public Property( String key, Object value ) { + public Property(String key, Object value) { fKey = key; fValue = value; } @@ -53,9 +53,9 @@ public class ModuleProperties { @Override public String toString() { String result = ""; //$NON-NLS-1$ - if ( getKey() != null ) + if (getKey() != null) result += getKey(); - if ( getValue() != null ) { + if (getValue() != null) { result += "="; //$NON-NLS-1$ result += getValue().toString(); } @@ -67,36 +67,36 @@ public class ModuleProperties { private boolean fIsDirty = false; - static ModuleProperties create( ICModule module ) { - return new ModuleProperties( module ); + static ModuleProperties create(ICModule module) { + return new ModuleProperties(module); } - /** - * Constructor for ModuleProperties. + /** + * Constructor for ModuleProperties. */ - private ModuleProperties( ICModule module ) { - fProperties = new ArrayList<>( 10 ); - fProperties.add( new Property( TYPE, Integer.valueOf(module.getType()) ) ); - fProperties.add( new Property( CPU, module.getCPU() ) ); - fProperties.add( new Property( BASE_ADDRESS, module.getBaseAddress() ) ); - fProperties.add( new Property( SIZE, Long.valueOf( module.getSize() ) ) ); - fProperties.add( new Property( SYMBOLS_LOADED, Boolean.valueOf( module.areSymbolsLoaded() ) ) ); - fProperties.add( new Property( SYMBOLS_FILE, module.getSymbolsFileName() ) ); + private ModuleProperties(ICModule module) { + fProperties = new ArrayList<>(10); + fProperties.add(new Property(TYPE, Integer.valueOf(module.getType()))); + fProperties.add(new Property(CPU, module.getCPU())); + fProperties.add(new Property(BASE_ADDRESS, module.getBaseAddress())); + fProperties.add(new Property(SIZE, Long.valueOf(module.getSize()))); + fProperties.add(new Property(SYMBOLS_LOADED, Boolean.valueOf(module.areSymbolsLoaded()))); + fProperties.add(new Property(SYMBOLS_FILE, module.getSymbolsFileName())); } public Property[] getProperties() { - return fProperties.toArray( new Property[fProperties.size()] ); + return fProperties.toArray(new Property[fProperties.size()]); } - public Object getProperty( String key ) { - return find( key ).getValue(); + public Object getProperty(String key) { + return find(key).getValue(); } - public void setProperty( String key, Object value ) { - Property p = find( key ); - if ( !p.getValue().equals( value ) ) { - fProperties.set( fProperties.indexOf( p ), new Property( key, value ) ); - setDirty( true ); + public void setProperty(String key, Object value) { + Property p = find(key); + if (!p.getValue().equals(value)) { + fProperties.set(fProperties.indexOf(p), new Property(key, value)); + setDirty(true); } } @@ -108,18 +108,18 @@ public class ModuleProperties { fProperties.clear(); } - private void setDirty( boolean dirty ) { + private void setDirty(boolean dirty) { fIsDirty = dirty; } - private Property find( String key ) { + private Property find(String key) { Iterator<Property> it = fProperties.iterator(); - while( it.hasNext() ) { + while (it.hasNext()) { Property p = it.next(); - if ( p.getKey().equals( key ) ) { + if (p.getKey().equals(key)) { return p; } } - throw new IllegalArgumentException( key ); + throw new IllegalArgumentException(key); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/propertypages/ModulePropertyPage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/propertypages/ModulePropertyPage.java index 4b9e97f6d5b..a8d337fa4be 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/propertypages/ModulePropertyPage.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/propertypages/ModulePropertyPage.java @@ -11,7 +11,7 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.propertypages; +package org.eclipse.cdt.debug.internal.ui.propertypages; import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.debug.core.CDIDebugModel; @@ -58,25 +58,25 @@ public class ModulePropertyPage extends PropertyPage { * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) */ @Override - protected Control createContents( Composite parent ) { + protected Control createContents(Composite parent) { noDefaultAndApplyButton(); - Composite composite = new Composite( parent, SWT.NONE ); + Composite composite = new Composite(parent, SWT.NONE); Font font = parent.getFont(); - composite.setFont( font ); + composite.setFont(font); GridLayout topLayout = new GridLayout(); topLayout.numColumns = 2; - composite.setLayout( topLayout ); - composite.setLayoutData( new GridData( GridData.FILL_BOTH ) ); - - createFields( composite ); + composite.setLayout(topLayout); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + + createFields(composite); initializeFields(); - setValid( true ); + setValid(true); return composite; } protected ICModule getModule() { - return (ICModule)getElement(); + return (ICModule) getElement(); } /* (non-Javadoc) @@ -84,153 +84,156 @@ public class ModulePropertyPage extends PropertyPage { */ @Override public boolean performOk() { - if ( getModuleProperties() != null && getModuleProperties().isDirty() ) { - final IPath path = (IPath)getModuleProperties().getProperty( ModuleProperties.SYMBOLS_FILE ); - final ICModule module = getModule(); - if ( module != null ) { - - DebugPlugin.getDefault().asyncExec( - new Runnable() { - @Override - public void run() { - try { - module.setSymbolsFileName( path ); - } - catch( DebugException e ) { - failed( PropertyPageMessages.getString( "ModulePropertyPage.15" ), e ); //$NON-NLS-1$ - } - } - } ); + if (getModuleProperties() != null && getModuleProperties().isDirty()) { + final IPath path = (IPath) getModuleProperties().getProperty(ModuleProperties.SYMBOLS_FILE); + final ICModule module = getModule(); + if (module != null) { + + DebugPlugin.getDefault().asyncExec(new Runnable() { + @Override + public void run() { + try { + module.setSymbolsFileName(path); + } catch (DebugException e) { + failed(PropertyPageMessages.getString("ModulePropertyPage.15"), e); //$NON-NLS-1$ + } + } + }); } } return super.performOk(); } protected ModuleProperties getModuleProperties() { - if ( fProperties == null ) { - fProperties = ModuleProperties.create( getModule() ); + if (fProperties == null) { + fProperties = ModuleProperties.create(getModule()); } return fProperties; } - protected void failed( String message, Throwable e ) { - MultiStatus ms = new MultiStatus( CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, message, null ); - ms.add( new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, e.getMessage(), null ) ); - CDebugUtils.error( ms, getModule() ); + protected void failed(String message, Throwable e) { + MultiStatus ms = new MultiStatus(CDIDebugModel.getPluginIdentifier(), + ICDebugInternalConstants.STATUS_CODE_ERROR, message, null); + ms.add(new Status(IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), + ICDebugInternalConstants.STATUS_CODE_ERROR, e.getMessage(), null)); + CDebugUtils.error(ms, getModule()); } - private void createFields( Composite parent ) { - fTypeField = createField( parent, PropertyPageMessages.getString( "ModulePropertyPage.0" ) ); //$NON-NLS-1$ - fCPUField = createField( parent, PropertyPageMessages.getString( "ModulePropertyPage.4" ) ); //$NON-NLS-1$ - fBaseAddressField = createField( parent, PropertyPageMessages.getString( "ModulePropertyPage.6" ) ); //$NON-NLS-1$ - fSizeField = createField( parent, PropertyPageMessages.getString( "ModulePropertyPage.8" ) ); //$NON-NLS-1$ - fSymbolsField = createField( parent, PropertyPageMessages.getString( "ModulePropertyPage.10" ) ); //$NON-NLS-1$ - createSymbolsFileField( parent ); + private void createFields(Composite parent) { + fTypeField = createField(parent, PropertyPageMessages.getString("ModulePropertyPage.0")); //$NON-NLS-1$ + fCPUField = createField(parent, PropertyPageMessages.getString("ModulePropertyPage.4")); //$NON-NLS-1$ + fBaseAddressField = createField(parent, PropertyPageMessages.getString("ModulePropertyPage.6")); //$NON-NLS-1$ + fSizeField = createField(parent, PropertyPageMessages.getString("ModulePropertyPage.8")); //$NON-NLS-1$ + fSymbolsField = createField(parent, PropertyPageMessages.getString("ModulePropertyPage.10")); //$NON-NLS-1$ + createSymbolsFileField(parent); } - private Label createField( Composite parent, String label ) { + private Label createField(Composite parent, String label) { Font font = parent.getFont(); - Label l = new Label( parent, SWT.LEFT ); - l.setText( label ); - GridData gd = new GridData( GridData.HORIZONTAL_ALIGN_FILL ); - l.setLayoutData( gd ); - l.setFont( font ); - Label v = new Label( parent, SWT.LEFT ); - gd = new GridData( GridData.HORIZONTAL_ALIGN_FILL ); - v.setLayoutData( gd ); - v.setFont( font ); + Label l = new Label(parent, SWT.LEFT); + l.setText(label); + GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); + l.setLayoutData(gd); + l.setFont(font); + Label v = new Label(parent, SWT.LEFT); + gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); + v.setLayoutData(gd); + v.setFont(font); return v; } - private void createSymbolsFileField( Composite parent ) { + private void createSymbolsFileField(Composite parent) { Font font = parent.getFont(); // Separator - Label l = new Label( parent, SWT.LEFT ); - GridData gd = new GridData( GridData.FILL_HORIZONTAL ); + Label l = new Label(parent, SWT.LEFT); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; - l.setLayoutData( gd ); + l.setLayoutData(gd); - l = new Label( parent, SWT.LEFT ); - l.setText( PropertyPageMessages.getString( "ModulePropertyPage.13" ) ); //$NON-NLS-1$ - gd = new GridData( GridData.FILL_HORIZONTAL ); + l = new Label(parent, SWT.LEFT); + l.setText(PropertyPageMessages.getString("ModulePropertyPage.13")); //$NON-NLS-1$ + gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; - l.setLayoutData( gd ); - l.setFont( font ); - Composite composite = new Composite( parent, SWT.NONE ); - composite.setFont( font ); + l.setLayoutData(gd); + l.setFont(font); + Composite composite = new Composite(parent, SWT.NONE); + composite.setFont(font); GridLayout layout = new GridLayout(); layout.numColumns = 5; - composite.setLayout( layout ); - gd = new GridData( GridData.FILL_BOTH ); + composite.setLayout(layout); + gd = new GridData(GridData.FILL_BOTH); gd.horizontalSpan = 2; - composite.setLayoutData( gd ); + composite.setLayoutData(gd); // Text - fSymbolsFileField = new Text( composite, SWT.SINGLE | SWT.BORDER ); - gd = new GridData( GridData.FILL_HORIZONTAL ); + fSymbolsFileField = new Text(composite, SWT.SINGLE | SWT.BORDER); + gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 4; - fSymbolsFileField.setLayoutData( gd ); - - fBrowseButton = new Button( composite, SWT.PUSH ); - fBrowseButton.setText( PropertyPageMessages.getString( "ModulePropertyPage.3" ) ); //$NON-NLS-1$ - fBrowseButton.addSelectionListener( - new SelectionListener() { - - @Override - public void widgetSelected( SelectionEvent e ) { - FileDialog dialog = new FileDialog( fBrowseButton.getShell() ); - dialog.setFileName( ((IPath)getModuleProperties().getProperty( ModuleProperties.SYMBOLS_FILE )).toOSString() ); - String fn = dialog.open(); - if ( fn != null ) { - IPath path = new Path( fn ); - fSymbolsFileField.setText( path.toOSString() ); - getModuleProperties().setProperty( ModuleProperties.SYMBOLS_FILE, path ); - } + fSymbolsFileField.setLayoutData(gd); + + fBrowseButton = new Button(composite, SWT.PUSH); + fBrowseButton.setText(PropertyPageMessages.getString("ModulePropertyPage.3")); //$NON-NLS-1$ + fBrowseButton.addSelectionListener(new SelectionListener() { + + @Override + public void widgetSelected(SelectionEvent e) { + FileDialog dialog = new FileDialog(fBrowseButton.getShell()); + dialog.setFileName( + ((IPath) getModuleProperties().getProperty(ModuleProperties.SYMBOLS_FILE)).toOSString()); + String fn = dialog.open(); + if (fn != null) { + IPath path = new Path(fn); + fSymbolsFileField.setText(path.toOSString()); + getModuleProperties().setProperty(ModuleProperties.SYMBOLS_FILE, path); } + } - @Override - public void widgetDefaultSelected( SelectionEvent e ) { - } - } ); + @Override + public void widgetDefaultSelected(SelectionEvent e) { + } + }); } private void initializeFields() { // Type - Integer type = (Integer)getModuleProperties().getProperty( ModuleProperties.TYPE ); - String value = PropertyPageMessages.getString( "ModulePropertyPage.16" ); //$NON-NLS-1$ - if ( type.intValue() == ICModule.EXECUTABLE ) { - value = PropertyPageMessages.getString( "ModulePropertyPage.1" ); //$NON-NLS-1$ + Integer type = (Integer) getModuleProperties().getProperty(ModuleProperties.TYPE); + String value = PropertyPageMessages.getString("ModulePropertyPage.16"); //$NON-NLS-1$ + if (type.intValue() == ICModule.EXECUTABLE) { + value = PropertyPageMessages.getString("ModulePropertyPage.1"); //$NON-NLS-1$ } - if ( type.intValue() == ICModule.SHARED_LIBRARY ) { - value = PropertyPageMessages.getString( "ModulePropertyPage.2" ); //$NON-NLS-1$ + if (type.intValue() == ICModule.SHARED_LIBRARY) { + value = PropertyPageMessages.getString("ModulePropertyPage.2"); //$NON-NLS-1$ } - fTypeField.setText( value ); + fTypeField.setText(value); // CPU - String cpu = (String)getModuleProperties().getProperty( ModuleProperties.CPU ); - value = ( cpu != null ) ? cpu : PropertyPageMessages.getString( "ModulePropertyPage.5" ); //$NON-NLS-1$ - fCPUField.setText( value ); - + String cpu = (String) getModuleProperties().getProperty(ModuleProperties.CPU); + value = (cpu != null) ? cpu : PropertyPageMessages.getString("ModulePropertyPage.5"); //$NON-NLS-1$ + fCPUField.setText(value); + // Base address - IAddress address = (IAddress)getModuleProperties().getProperty( ModuleProperties.BASE_ADDRESS ); - value = ( address != null && !address.isZero() ) ? address.toHexAddressString() : PropertyPageMessages.getString( "ModulePropertyPage.7" ); //$NON-NLS-1$ - fBaseAddressField.setText( value ); + IAddress address = (IAddress) getModuleProperties().getProperty(ModuleProperties.BASE_ADDRESS); + value = (address != null && !address.isZero()) ? address.toHexAddressString() + : PropertyPageMessages.getString("ModulePropertyPage.7"); //$NON-NLS-1$ + fBaseAddressField.setText(value); // Size - Long size = (Long)getModuleProperties().getProperty( ModuleProperties.SIZE ); - value = ( size != null && size.longValue() > 0 ) ? size.toString() : PropertyPageMessages.getString( "ModulePropertyPage.9" ); //$NON-NLS-1$ - fSizeField.setText( value ); + Long size = (Long) getModuleProperties().getProperty(ModuleProperties.SIZE); + value = (size != null && size.longValue() > 0) ? size.toString() + : PropertyPageMessages.getString("ModulePropertyPage.9"); //$NON-NLS-1$ + fSizeField.setText(value); // Symbols flag - Boolean loaded = (Boolean)getModuleProperties().getProperty( ModuleProperties.SYMBOLS_LOADED ); - value = ( loaded != null && loaded.booleanValue() ) ? PropertyPageMessages.getString( "ModulePropertyPage.11" ) : PropertyPageMessages.getString( "ModulePropertyPage.12" ); //$NON-NLS-1$ //$NON-NLS-2$ - fSymbolsField.setText( value ); - + Boolean loaded = (Boolean) getModuleProperties().getProperty(ModuleProperties.SYMBOLS_LOADED); + value = (loaded != null && loaded.booleanValue()) ? PropertyPageMessages.getString("ModulePropertyPage.11") //$NON-NLS-1$ + : PropertyPageMessages.getString("ModulePropertyPage.12"); //$NON-NLS-1$ + fSymbolsField.setText(value); + // Symbols file: - IPath path = (IPath)getModuleProperties().getProperty( ModuleProperties.SYMBOLS_FILE ); - value = ( path != null ) ? path.toOSString() : PropertyPageMessages.getString( "ModulePropertyPage.14" ); //$NON-NLS-1$ - fSymbolsFileField.setText( value ); + IPath path = (IPath) getModuleProperties().getProperty(ModuleProperties.SYMBOLS_FILE); + value = (path != null) ? path.toOSString() : PropertyPageMessages.getString("ModulePropertyPage.14"); //$NON-NLS-1$ + fSymbolsFileField.setText(value); } /* (non-Javadoc) @@ -238,7 +241,7 @@ public class ModulePropertyPage extends PropertyPage { */ @Override public void dispose() { - if ( getModuleProperties() != null ) { + if (getModuleProperties() != null) { getModuleProperties().dispose(); } super.dispose(); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/propertypages/PropertyPageMessages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/propertypages/PropertyPageMessages.java index 97af1addea4..8077d976adc 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/propertypages/PropertyPageMessages.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/propertypages/PropertyPageMessages.java @@ -20,16 +20,15 @@ public class PropertyPageMessages { private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.propertypages.PropertyPageMessages"; //$NON-NLS-1$ - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); private PropertyPageMessages() { } - public static String getString( String key ) { + public static String getString(String key) { try { - return RESOURCE_BUNDLE.getString( key ); - } - catch( MissingResourceException e ) { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { return '!' + key + '!'; } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/propertypages/SignalPropertyPage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/propertypages/SignalPropertyPage.java index 7437fa247f6..3399623be0d 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/propertypages/SignalPropertyPage.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/propertypages/SignalPropertyPage.java @@ -11,7 +11,7 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.propertypages; +package org.eclipse.cdt.debug.internal.ui.propertypages; import org.eclipse.cdt.debug.core.CDIDebugModel; import org.eclipse.cdt.debug.core.CDebugUtils; @@ -34,7 +34,7 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.ui.dialogs.PropertyPage; import com.ibm.icu.text.MessageFormat; - + /** * The property page for a signal. */ @@ -47,52 +47,51 @@ public class SignalPropertyPage extends PropertyPage { * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) */ @Override - protected Control createContents( Composite parent ) { + protected Control createContents(Composite parent) { noDefaultAndApplyButton(); - Composite composite = new Composite( parent, SWT.NONE ); + Composite composite = new Composite(parent, SWT.NONE); Font font = parent.getFont(); - composite.setFont( font ); - composite.setLayout( new GridLayout() ); - composite.setLayoutData( new GridData( GridData.FILL_BOTH ) ); + composite.setFont(font); + composite.setLayout(new GridLayout()); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); // Create description field try { String description = getSignal().getDescription(); - Label label = new Label( composite, SWT.WRAP ); - label.setText( MessageFormat.format( PropertyPageMessages.getString( "SignalPropertyPage.0" ), new Object[] { description } ) ); //$NON-NLS-1$ - GridData data = new GridData( GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER ); - data.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH ); - label.setLayoutData( data ); - label.setFont( font ); - } - catch( DebugException e1 ) { + Label label = new Label(composite, SWT.WRAP); + label.setText(MessageFormat.format(PropertyPageMessages.getString("SignalPropertyPage.0"), //$NON-NLS-1$ + new Object[] { description })); + GridData data = new GridData( + GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER); + data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); + label.setLayoutData(data); + label.setFont(font); + } catch (DebugException e1) { } // Create pass button try { boolean pass = getSignal().isPassEnabled(); - fPassButton = new SelectionButtonDialogField( SWT.CHECK ); - fPassButton.setLabelText( PropertyPageMessages.getString( "SignalPropertyPage.1" ) ); //$NON-NLS-1$ - fPassButton.setSelection( pass ); - fPassButton.setEnabled( getSignal().canModify() ); - fPassButton.doFillIntoGrid( composite, 1 ); - } - catch( DebugException e ) { + fPassButton = new SelectionButtonDialogField(SWT.CHECK); + fPassButton.setLabelText(PropertyPageMessages.getString("SignalPropertyPage.1")); //$NON-NLS-1$ + fPassButton.setSelection(pass); + fPassButton.setEnabled(getSignal().canModify()); + fPassButton.doFillIntoGrid(composite, 1); + } catch (DebugException e) { } // Create stop button try { boolean stop = getSignal().isStopEnabled(); - fStopButton = new SelectionButtonDialogField( SWT.CHECK ); - fStopButton.setLabelText( PropertyPageMessages.getString( "SignalPropertyPage.2" ) ); //$NON-NLS-1$ - fStopButton.setSelection( stop ); - fStopButton.setEnabled( getSignal().canModify() ); - fStopButton.doFillIntoGrid( composite, 1 ); - } - catch( DebugException e ) { + fStopButton = new SelectionButtonDialogField(SWT.CHECK); + fStopButton.setLabelText(PropertyPageMessages.getString("SignalPropertyPage.2")); //$NON-NLS-1$ + fStopButton.setSelection(stop); + fStopButton.setEnabled(getSignal().canModify()); + fStopButton.doFillIntoGrid(composite, 1); + } catch (DebugException e) { } - setValid( true ); + setValid(true); return composite; } @@ -105,7 +104,7 @@ public class SignalPropertyPage extends PropertyPage { } public ICSignal getSignal() { - return (ICSignal)getElement(); + return (ICSignal) getElement(); } /* (non-Javadoc) @@ -114,38 +113,37 @@ public class SignalPropertyPage extends PropertyPage { @Override public boolean performOk() { boolean result = super.performOk(); - if ( result ) { - DebugPlugin.getDefault().asyncExec( - new Runnable() { - @Override - public void run() { - if ( !getSignal().canModify() ) - return; - if ( getPassButton() != null ) { - try { - getSignal().setPassEnabled( getPassButton().isSelected() ); - } - catch( DebugException e ) { - failed( PropertyPageMessages.getString( "SignalPropertyPage.5" ), e ); //$NON-NLS-1$ - } - } - if ( getStopButton() != null ) { - try { - getSignal().setStopEnabled( getStopButton().isSelected() ); - } - catch( DebugException e ) { - failed( PropertyPageMessages.getString( "SignalPropertyPage.5" ), e ); //$NON-NLS-1$ - } - } + if (result) { + DebugPlugin.getDefault().asyncExec(new Runnable() { + @Override + public void run() { + if (!getSignal().canModify()) + return; + if (getPassButton() != null) { + try { + getSignal().setPassEnabled(getPassButton().isSelected()); + } catch (DebugException e) { + failed(PropertyPageMessages.getString("SignalPropertyPage.5"), e); //$NON-NLS-1$ + } + } + if (getStopButton() != null) { + try { + getSignal().setStopEnabled(getStopButton().isSelected()); + } catch (DebugException e) { + failed(PropertyPageMessages.getString("SignalPropertyPage.5"), e); //$NON-NLS-1$ } - } ); + } + } + }); } return result; } - protected void failed( String message, Throwable e ) { - MultiStatus ms = new MultiStatus( CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, message, null ); - ms.add( new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, e.getMessage(), null ) ); - CDebugUtils.error( ms, getSignal() ); + protected void failed(String message, Throwable e) { + MultiStatus ms = new MultiStatus(CDIDebugModel.getPluginIdentifier(), + ICDebugInternalConstants.STATUS_CODE_ERROR, message, null); + ms.add(new Status(IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), + ICDebugInternalConstants.STATUS_CODE_ERROR, e.getMessage(), null)); + CDebugUtils.error(ms, getSignal()); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/AddContainerAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/AddContainerAction.java index e97b90b1a9b..850375787c3 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/AddContainerAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/AddContainerAction.java @@ -11,8 +11,8 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.sourcelookup; - +package org.eclipse.cdt.debug.internal.ui.sourcelookup; + import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; import org.eclipse.jface.viewers.IStructuredSelection; @@ -23,26 +23,26 @@ import org.eclipse.jface.viewers.IStructuredSelection; */ public class AddContainerAction extends SourceContainerAction { private ISourceLookupDirector fDirector; - + public AddContainerAction() { super(SourceLookupUIMessages.AddContainerAction_0); } - + /** * Prompts for a project to add. - * + * * @see org.eclipse.jface.action.IAction#run() - */ + */ @Override public void run() { AddSourceContainerDialog dialog = new AddSourceContainerDialog(getShell(), getViewer(), fDirector); - dialog.open(); + dialog.open(); } - + public void setSourceLookupDirector(ISourceLookupDirector director) { fDirector = director; } - + /* (non-Javadoc) * @see org.eclipse.ui.actions.BaseSelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection) */ @@ -50,7 +50,7 @@ public class AddContainerAction extends SourceContainerAction { protected boolean updateSelection(IStructuredSelection selection) { if (selection == null || selection.isEmpty()) { return true; - } + } return getViewer().getTree().getSelection()[0].getParentItem() == null; } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/AddSourceContainerDialog.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/AddSourceContainerDialog.java index 7e1b83ac848..e3de03bd6a8 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/AddSourceContainerDialog.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/AddSourceContainerDialog.java @@ -11,8 +11,8 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.sourcelookup; - +package org.eclipse.cdt.debug.internal.ui.sourcelookup; + import java.util.ArrayList; import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds; import org.eclipse.debug.core.DebugPlugin; @@ -45,7 +45,7 @@ import org.eclipse.ui.PlatformUI; /** * The dialog for adding new source containers. Presents the user with a list of * source container types and allows them to select one. - * + * * @since 3.0 */ public class AddSourceContainerDialog extends TitleAreaDialog { @@ -53,34 +53,35 @@ public class AddSourceContainerDialog extends TitleAreaDialog { private SourceContainerViewer fSourceContainerViewer; private boolean fDoubleClickSelects = true; private ISourceLookupDirector fDirector; - + /** * Constructor */ - public AddSourceContainerDialog(Shell shell, SourceContainerViewer viewer, ISourceLookupDirector director) { + public AddSourceContainerDialog(Shell shell, SourceContainerViewer viewer, ISourceLookupDirector director) { super(shell); setShellStyle(getShellStyle() | SWT.RESIZE); - fSourceContainerViewer=viewer; + fSourceContainerViewer = viewer; fDirector = director; } - + /** * Creates the dialog area to display source container types that are "browseable" */ @Override - protected Control createDialogArea(Composite ancestor) { + protected Control createDialogArea(Composite ancestor) { getShell().setText(SourceLookupUIMessages.AddSourceContainerDialog_0); setTitle(SourceLookupUIMessages.AddSourceContainerDialog_1); - + Composite parent = new Composite(ancestor, SWT.NULL); - GridData gd= new GridData(GridData.FILL_BOTH); + GridData gd = new GridData(GridData.FILL_BOTH); GridLayout topLayout = new GridLayout(); topLayout.numColumns = 1; parent.setLayout(topLayout); - parent.setLayoutData(gd); - - ISourceContainerType[] types = filterTypes(DebugPlugin.getDefault().getLaunchManager().getSourceContainerTypes()); - + parent.setLayoutData(gd); + + ISourceContainerType[] types = filterTypes( + DebugPlugin.getDefault().getLaunchManager().getSourceContainerTypes()); + fViewer = new TableViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.SINGLE); final Table table = fViewer.getTable(); gd = new GridData(GridData.FILL_BOTH); @@ -95,7 +96,7 @@ public class AddSourceContainerDialog extends TitleAreaDialog { } }); } - + fViewer.setLabelProvider(new SourceContainerLabelProvider()); fViewer.setContentProvider(ArrayContentProvider.getInstance()); fViewer.setSorter(new ViewerSorter()); @@ -105,20 +106,22 @@ public class AddSourceContainerDialog extends TitleAreaDialog { ISelection selection = event.getSelection(); String desc = null; if (!selection.isEmpty()) { - ISourceContainerType type = (ISourceContainerType) ((IStructuredSelection)selection).getFirstElement(); + ISourceContainerType type = (ISourceContainerType) ((IStructuredSelection) selection) + .getFirstElement(); desc = type.getDescription(); } setMessage(desc); } }); - if (types.length != 0) { + if (types.length != 0) { fViewer.setInput(types); } Dialog.applyDialogFont(parent); - PlatformUI.getWorkbench().getHelpSystem().setHelp( getShell(), ICDebugHelpContextIds.ADD_SOURCE_CONTAINER_DIALOG ); + PlatformUI.getWorkbench().getHelpSystem().setHelp(getShell(), + ICDebugHelpContextIds.ADD_SOURCE_CONTAINER_DIALOG); return parent; - } - + } + /** * Removes types without browsers from the provided list of types. * @param types the complete list of source container types @@ -134,10 +137,10 @@ public class AddSourceContainerDialog extends TitleAreaDialog { validTypes.add(type); } } - } + } return validTypes.toArray(new ISourceContainerType[validTypes.size()]); } - + /* (non-Javadoc) * @see org.eclipse.jface.dialogs.Dialog#okPressed() */ @@ -145,7 +148,8 @@ public class AddSourceContainerDialog extends TitleAreaDialog { protected void okPressed() { // Single selection dialog, so take first item in array // there will always be a selected item since we set it with viewer.setSelection - ISourceContainerType type = (ISourceContainerType) ((StructuredSelection) fViewer.getSelection()).getFirstElement(); + ISourceContainerType type = (ISourceContainerType) ((StructuredSelection) fViewer.getSelection()) + .getFirstElement(); ISourceContainerBrowser browser = DebugUITools.getSourceContainerBrowser(type.getId()); if (browser != null) { ISourceContainer[] results = browser.addSourceContainers(getShell(), fDirector); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CProjectSourceContainerBrowser.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CProjectSourceContainerBrowser.java index af453693393..ef2ab7b4034 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CProjectSourceContainerBrowser.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CProjectSourceContainerBrowser.java @@ -33,7 +33,7 @@ import org.eclipse.ui.model.WorkbenchLabelProvider; * The browser for adding a source folder relative path source container. */ public class CProjectSourceContainerBrowser extends AbstractSourceContainerBrowser { - + /* (non-Javadoc) * @see org.eclipse.debug.internal.ui.sourcelookup.ISourceContainerBrowser#createSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.ILaunchConfiguration) */ @@ -41,27 +41,24 @@ public class CProjectSourceContainerBrowser extends AbstractSourceContainerBrows public ISourceContainer[] addSourceContainers(Shell shell, ISourceLookupDirector director) { if (director.getLaunchConfiguration() == null) { TargetProjectSourceContainerDialog dialog = new TargetProjectSourceContainerDialog(shell); - if (dialog.open() == Window.OK) { - return new ISourceContainer[] { - new CProjectSourceContainer(null, dialog.isAddReferencedProjects()) }; - } + if (dialog.open() == Window.OK) { + return new ISourceContainer[] { new CProjectSourceContainer(null, dialog.isAddReferencedProjects()) }; + } } else { Object input = ResourcesPlugin.getWorkspace().getRoot(); - IStructuredContentProvider contentProvider=new BasicContainerContentProvider(); + IStructuredContentProvider contentProvider = new BasicContainerContentProvider(); ILabelProvider labelProvider = new WorkbenchLabelProvider(); - ProjectSourceContainerDialog dialog = - new ProjectSourceContainerDialog(shell, input, contentProvider, labelProvider, - SourceLookupUIMessages.projectSelection_chooseLabel); - if (dialog.open() == Window.OK) { - ArrayList<ISourceContainer> res= new ArrayList<ISourceContainer>(); + ProjectSourceContainerDialog dialog = new ProjectSourceContainerDialog(shell, input, contentProvider, + labelProvider, SourceLookupUIMessages.projectSelection_chooseLabel); + if (dialog.open() == Window.OK) { + ArrayList<ISourceContainer> res = new ArrayList<ISourceContainer>(); for (Object element : dialog.getResult()) { if (!(element instanceof IProject)) - continue; - res.add(new CProjectSourceContainer((IProject) element, - dialog.isAddRequiredProjects())); + continue; + res.add(new CProjectSourceContainer((IProject) element, dialog.isAddRequiredProjects())); } - return res.toArray(new ISourceContainer[res.size()]); - } + return res.toArray(new ISourceContainer[res.size()]); + } } return new ISourceContainer[0]; } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CSourceNotFoundEditor.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CSourceNotFoundEditor.java index ee78e6f7646..2831032b218 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CSourceNotFoundEditor.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CSourceNotFoundEditor.java @@ -337,7 +337,7 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor { /** * Add a path mapping source locator to the global director. - * + * * @param missingPath * the compilation source path that was not found on the local * machine diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CSourceNotFoundEditorInput.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CSourceNotFoundEditorInput.java index 7b0ed1a0505..8859c50157c 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CSourceNotFoundEditorInput.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CSourceNotFoundEditorInput.java @@ -26,7 +26,7 @@ public class CSourceNotFoundEditorInput extends CommonSourceNotFoundEditorInput public String getName() { Object artifact = getArtifact(); if (artifact instanceof CSourceNotFoundElement) { - String description = ((CSourceNotFoundElement)artifact).getDescription(); + String description = ((CSourceNotFoundElement) artifact).getDescription(); if (description != null) { return description; } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CompilationDirectorySourceContainerBrowser.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CompilationDirectorySourceContainerBrowser.java index d97c0df1b3c..144ffc7f4ca 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CompilationDirectorySourceContainerBrowser.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CompilationDirectorySourceContainerBrowser.java @@ -25,7 +25,7 @@ import org.eclipse.swt.widgets.Shell; * The browser for adding a compilation directory source container. */ public class CompilationDirectorySourceContainerBrowser extends AbstractSourceContainerBrowser { - + /* (non-Javadoc) * @see org.eclipse.debug.internal.ui.sourcelookup.ISourceContainerBrowser#createSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.ILaunchConfiguration) */ @@ -36,10 +36,11 @@ public class CompilationDirectorySourceContainerBrowser extends AbstractSourceCo if (dialog.open() == Window.OK) { String directory = dialog.getDirectory(); if (directory != null) { - containers[0] = new CompilationDirectorySourceContainer(new Path(directory), dialog.isCompilationSubfolders()); - return containers; + containers[0] = new CompilationDirectorySourceContainer(new Path(directory), + dialog.isCompilationSubfolders()); + return containers; } - } + } return new ISourceContainer[0]; } @@ -48,23 +49,27 @@ public class CompilationDirectorySourceContainerBrowser extends AbstractSourceCo */ @Override public boolean canEditSourceContainers(ISourceLookupDirector director, ISourceContainer[] containers) { - return containers.length == 1 && CompilationDirectorySourceContainer.TYPE_ID.equals(containers[0].getType().getId()); + return containers.length == 1 + && CompilationDirectorySourceContainer.TYPE_ID.equals(containers[0].getType().getId()); } /* (non-Javadoc) * @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#editSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.sourcelookup.ISourceLookupDirector, org.eclipse.debug.core.sourcelookup.ISourceContainer[]) */ @Override - public ISourceContainer[] editSourceContainers(Shell shell, ISourceLookupDirector director, ISourceContainer[] containers) { - if (containers.length == 1 && CompilationDirectorySourceContainer.TYPE_ID.equals(containers[0].getType().getId()) ) { + public ISourceContainer[] editSourceContainers(Shell shell, ISourceLookupDirector director, + ISourceContainer[] containers) { + if (containers.length == 1 + && CompilationDirectorySourceContainer.TYPE_ID.equals(containers[0].getType().getId())) { CompilationDirectorySourceContainer c = (CompilationDirectorySourceContainer) containers[0]; - CompilationDirectorySourceContainerDialog dialog = - new CompilationDirectorySourceContainerDialog(shell, c.getDirectory().getPath(), c.isComposite()); + CompilationDirectorySourceContainerDialog dialog = new CompilationDirectorySourceContainerDialog(shell, + c.getDirectory().getPath(), c.isComposite()); if (dialog.open() == Window.OK) { String directory = dialog.getDirectory(); if (directory != null) { containers[0].dispose(); - return new ISourceContainer[] { new CompilationDirectorySourceContainer(new Path(directory), dialog.isCompilationSubfolders()) }; + return new ISourceContainer[] { new CompilationDirectorySourceContainer(new Path(directory), + dialog.isCompilationSubfolders()) }; } } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CompilationDirectorySourceContainerDialog.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CompilationDirectorySourceContainerDialog.java index e58ef3813bc..89a9570b15f 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CompilationDirectorySourceContainerDialog.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CompilationDirectorySourceContainerDialog.java @@ -51,14 +51,14 @@ public class CompilationDirectorySourceContainerDialog extends TitleAreaDialog { private String fDirectory; private boolean fCompilationSubfolders; - + private Text fDirText; private Button fSubfoldersButton; private boolean fNewContainer; /** * Creates a dialog to select a new file system folder. - * + * * @param shell shell */ public CompilationDirectorySourceContainerDialog(Shell shell) { @@ -69,12 +69,12 @@ public class CompilationDirectorySourceContainerDialog extends TitleAreaDialog { /** * Creates a dialog to edit file system folder. - * + * * @param shell shell * @param directory directory to edit or empty string * @param compilationSubfolders whether the 'Subdirectories are also used for compilation' * checkbox should be checked - * @param newContainer + * @param newContainer */ public CompilationDirectorySourceContainerDialog(Shell shell, String directory, boolean compilationSubfolders) { super(shell); @@ -83,7 +83,7 @@ public class CompilationDirectorySourceContainerDialog extends TitleAreaDialog { fCompilationSubfolders = compilationSubfolders; fNewContainer = false; } - + /** * Returns the result of the dialog.open() operation * @return the dialog.open() result @@ -94,7 +94,7 @@ public class CompilationDirectorySourceContainerDialog extends TitleAreaDialog { /** * Returns whether the 'Subdirectories are also used for compilation' option is selected. - * + * * @return whether the 'Subdirectories are also used for compilation' option is selected */ public boolean isCompilationSubfolders() { @@ -106,9 +106,8 @@ public class CompilationDirectorySourceContainerDialog extends TitleAreaDialog { */ @Override protected Control createDialogArea(Composite parent) { - Image image = fNewContainer ? - CDebugImages.get(IInternalCDebugUIConstants.IMG_ADD_COMP_DIR_WIZ) : - CDebugImages.get(IInternalCDebugUIConstants.IMG_EDIT_COMP_DIR_WIZ); + Image image = fNewContainer ? CDebugImages.get(IInternalCDebugUIConstants.IMG_ADD_COMP_DIR_WIZ) + : CDebugImages.get(IInternalCDebugUIConstants.IMG_EDIT_COMP_DIR_WIZ); setTitle(SourceLookupUIMessages.CompilationDirectorySourceContainerDialog_2); setMessage(SourceLookupUIMessages.CompilationDirectorySourceContainerDialog_3); setTitleImage(image); @@ -124,54 +123,54 @@ public class CompilationDirectorySourceContainerDialog extends TitleAreaDialog { composite.setLayoutData(new GridData(GridData.FILL_BOTH)); composite.setFont(font); - Composite dirComposite = new Composite(composite, SWT.NONE); - layout = new GridLayout(2, false); + Composite dirComposite = new Composite(composite, SWT.NONE); + layout = new GridLayout(2, false); dirComposite.setLayout(layout); dirComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); dirComposite.setFont(font); - Label label = new Label(dirComposite, SWT.NONE); - label.setText(SourceLookupUIMessages.CompilationDirectorySourceContainerDialog_4); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 2; - label.setLayoutData(data); - label.setFont(font); - - fDirText = new Text(dirComposite, SWT.BORDER); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 1; - fDirText.setLayoutData(data); - fDirText.setFont(font); - fDirText.addModifyListener(new ModifyListener() { + Label label = new Label(dirComposite, SWT.NONE); + label.setText(SourceLookupUIMessages.CompilationDirectorySourceContainerDialog_4); + GridData data = new GridData(GridData.FILL_HORIZONTAL); + data.horizontalSpan = 2; + label.setLayoutData(data); + label.setFont(font); + + fDirText = new Text(dirComposite, SWT.BORDER); + data = new GridData(GridData.FILL_HORIZONTAL); + data.horizontalSpan = 1; + fDirText.setLayoutData(data); + fDirText.setFont(font); + fDirText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { validate(); - } - }); - - Button button = new Button(dirComposite, SWT.PUSH); - button.setText(SourceLookupUIMessages.CompilationDirectorySourceContainerDialog_5); - data = new GridData(); - int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); - Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); - data.widthHint = Math.max(widthHint, minSize.x); - button.setLayoutData(data); - button.setFont(JFaceResources.getDialogFont()); - button.addSelectionListener(new SelectionAdapter() { - @Override + } + }); + + Button button = new Button(dirComposite, SWT.PUSH); + button.setText(SourceLookupUIMessages.CompilationDirectorySourceContainerDialog_5); + data = new GridData(); + int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); + Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); + data.widthHint = Math.max(widthHint, minSize.x); + button.setLayoutData(data); + button.setFont(JFaceResources.getDialogFont()); + button.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent event) { - browse(); - } - }); - - fSubfoldersButton = new Button(dirComposite, SWT.CHECK); - fSubfoldersButton.setText(SourceLookupUIMessages.CompilationDirectorySourceContainerDialog_6); - data = new GridData(GridData.FILL_HORIZONTAL); - data.verticalIndent = layout.verticalSpacing; // Extra vertical spacing - fSubfoldersButton.setLayoutData(data); - fSubfoldersButton.setFont(font); - - return parentComposite; + browse(); + } + }); + + fSubfoldersButton = new Button(dirComposite, SWT.CHECK); + fSubfoldersButton.setText(SourceLookupUIMessages.CompilationDirectorySourceContainerDialog_6); + data = new GridData(GridData.FILL_HORIZONTAL); + data.verticalIndent = layout.verticalSpacing; // Extra vertical spacing + fSubfoldersButton.setLayoutData(data); + fSubfoldersButton.setFont(font); + + return parentComposite; } /* (non-Javadoc) @@ -198,7 +197,8 @@ public class CompilationDirectorySourceContainerDialog extends TitleAreaDialog { fDirText.setText(fDirectory); fSubfoldersButton.setSelection(fCompilationSubfolders); validate(); - PlatformUI.getWorkbench().getHelpSystem().setHelp(c, ICDebugHelpContextIds.COMPILATION_DIRECTORY_SOURCE_CONTAINER_DIALOG); + PlatformUI.getWorkbench().getHelpSystem().setHelp(c, + ICDebugHelpContextIds.COMPILATION_DIRECTORY_SOURCE_CONTAINER_DIALOG); return c; } @@ -210,7 +210,7 @@ public class CompilationDirectorySourceContainerDialog extends TitleAreaDialog { fDirectory = fDirText.getText().trim(); fCompilationSubfolders = fSubfoldersButton.getSelection(); CDebugUIPlugin.getDefault().getDialogSettings().put(LAST_PATH_SETTING, fDirectory); - CDebugUIPlugin.getDefault().getDialogSettings().put(LAST_SUBDIR_SETTING, fCompilationSubfolders); + CDebugUIPlugin.getDefault().getDialogSettings().put(LAST_SUBDIR_SETTING, fCompilationSubfolders); super.okPressed(); } @@ -220,11 +220,11 @@ public class CompilationDirectorySourceContainerDialog extends TitleAreaDialog { last = CDebugUIPlugin.getDefault().getDialogSettings().get(LAST_PATH_SETTING); } if (last == null) { - last = ""; //$NON-NLS-1$ + last = ""; //$NON-NLS-1$ } DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.SINGLE); - dialog.setText(SourceLookupUIMessages.CompilationDirectorySourceContainerDialog_0); - dialog.setMessage(SourceLookupUIMessages.CompilationDirectorySourceContainerDialog_1); + dialog.setText(SourceLookupUIMessages.CompilationDirectorySourceContainerDialog_0); + dialog.setMessage(SourceLookupUIMessages.CompilationDirectorySourceContainerDialog_1); dialog.setFilterPath(last); String result = dialog.open(); if (result == null) { diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/DownAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/DownAction.java index 25d49c8ffb5..c227e78d44f 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/DownAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/DownAction.java @@ -7,11 +7,11 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.sourcelookup; +package org.eclipse.cdt.debug.internal.ui.sourcelookup; import java.util.List; @@ -21,8 +21,8 @@ import org.eclipse.jface.viewers.IStructuredSelection; /** * The action for sorting the order of source containers in the dialog. */ -public class DownAction extends SourceContainerAction { - +public class DownAction extends SourceContainerAction { + public DownAction() { super(SourceLookupUIMessages.DownAction_0); } @@ -49,16 +49,16 @@ public class DownAction extends SourceContainerAction { list.set(index, temp); } bottom = index; - } + } setEntries(list); } - + /** * @see SelectionListenerAction#updateSelection(IStructuredSelection) */ @Override protected boolean updateSelection(IStructuredSelection selection) { - return !selection.isEmpty() && !isIndexSelected(selection, getEntriesAsList().size() - 1) && - getViewer().getTree().getSelection()[0].getParentItem() == null; + return !selection.isEmpty() && !isIndexSelected(selection, getEntriesAsList().size() - 1) + && getViewer().getTree().getSelection()[0].getParentItem() == null; } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/EditContainerAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/EditContainerAction.java index 8faf6be6cad..424c6ba2a0a 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/EditContainerAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/EditContainerAction.java @@ -11,7 +11,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.sourcelookup; +package org.eclipse.cdt.debug.internal.ui.sourcelookup; import java.util.Iterator; import org.eclipse.debug.core.sourcelookup.ISourceContainer; @@ -28,16 +28,16 @@ public class EditContainerAction extends SourceContainerAction { private ISourceLookupDirector fDirector; private ISourceContainer[] fContainers; private ISourceContainerBrowser fBrowser; - + public EditContainerAction() { super(SourceLookupUIMessages.EditContainerAction_0); } - + /** * Prompts for a project to add. - * + * * @see org.eclipse.jface.action.IAction#run() - */ + */ @Override public void run() { ISourceContainer[] replacements = fBrowser.editSourceContainers(getShell(), fDirector, fContainers); @@ -53,11 +53,11 @@ public class EditContainerAction extends SourceContainerAction { } getViewer().setEntries(existing); } - + public void setSourceLookupDirector(ISourceLookupDirector director) { fDirector = director; } - + /* (non-Javadoc) * @see org.eclipse.ui.actions.BaseSelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection) */ @@ -66,7 +66,7 @@ public class EditContainerAction extends SourceContainerAction { if (selection == null || selection.isEmpty()) { return false; } - if (getViewer().getTree().getSelection()[0].getParentItem()==null) { + if (getViewer().getTree().getSelection()[0].getParentItem() == null) { // can only edit top level items of same type fContainers = new ISourceContainer[selection.size()]; Iterator<?> iterator = selection.iterator(); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/MappingSourceContainerDialog.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/MappingSourceContainerDialog.java index 4193a6c9305..f159ffaf904 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/MappingSourceContainerDialog.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/MappingSourceContainerDialog.java @@ -67,546 +67,539 @@ import org.eclipse.ui.PlatformUI; public class MappingSourceContainerDialog extends TitleAreaDialog { - class EntryCellModifier implements ICellModifier { - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ICellModifier#canModify(java.lang.Object, java.lang.String) - */ - @Override + class EntryCellModifier implements ICellModifier { + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ICellModifier#canModify(java.lang.Object, java.lang.String) + */ + @Override public boolean canModify(Object element, String property) { - return (CP_COMPILATION_PATH.equals(property) || CP_FILE_SYSTEM_PATH.equals(property)); - } + return (CP_COMPILATION_PATH.equals(property) || CP_FILE_SYSTEM_PATH.equals(property)); + } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ICellModifier#getValue(java.lang.Object, java.lang.String) - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ICellModifier#getValue(java.lang.Object, java.lang.String) + */ + @Override public Object getValue(Object element, String property) { - if (element instanceof MapEntrySourceContainer) { - MapEntrySourceContainer entry = (MapEntrySourceContainer)element; - if (CP_COMPILATION_PATH.equals(property)) - return entry.getBackendPathStr(); - if (CP_FILE_SYSTEM_PATH.equals(property)) - return entry.getLocalPath().toOSString(); - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object, java.lang.String, java.lang.Object) - */ - @Override + if (element instanceof MapEntrySourceContainer) { + MapEntrySourceContainer entry = (MapEntrySourceContainer) element; + if (CP_COMPILATION_PATH.equals(property)) + return entry.getBackendPathStr(); + if (CP_FILE_SYSTEM_PATH.equals(property)) + return entry.getLocalPath().toOSString(); + } + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object, java.lang.String, java.lang.Object) + */ + @Override public void modify(Object element, String property, Object value) { - MapEntrySourceContainer entry = - (element instanceof Item) ? - (MapEntrySourceContainer)((Item)element).getData() - : (MapEntrySourceContainer)element; - boolean isDirty = false; - if (CP_COMPILATION_PATH.equals(property)) { - entry.setBackendPathStr((String)value); - isDirty = true; - } - else if (CP_FILE_SYSTEM_PATH.equals(property)) { - entry.setLocalPath(new Path((String)value)); - isDirty = true; - } - if (isDirty) - refresh(); - } - } - - class DirectoryCellEditor extends DialogCellEditor { - - DirectoryCellEditor(Composite parent) { - super(parent); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(org.eclipse.swt.widgets.Control) - */ - @Override - protected Object openDialogBox(Control cellEditorWindow) { - TableItem[] selection = ((Table)cellEditorWindow.getParent()).getSelection(); - DirectoryDialog dialog = new DirectoryDialog(cellEditorWindow.getShell()); - dialog.setFilterPath(selection[0].getText(1)); - return dialog.open(); - } - } - - class EntryLabelProvider extends LabelProvider implements ITableLabelProvider { - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int) - */ - @Override + MapEntrySourceContainer entry = (element instanceof Item) + ? (MapEntrySourceContainer) ((Item) element).getData() + : (MapEntrySourceContainer) element; + boolean isDirty = false; + if (CP_COMPILATION_PATH.equals(property)) { + entry.setBackendPathStr((String) value); + isDirty = true; + } else if (CP_FILE_SYSTEM_PATH.equals(property)) { + entry.setLocalPath(new Path((String) value)); + isDirty = true; + } + if (isDirty) + refresh(); + } + } + + class DirectoryCellEditor extends DialogCellEditor { + + DirectoryCellEditor(Composite parent) { + super(parent); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(org.eclipse.swt.widgets.Control) + */ + @Override + protected Object openDialogBox(Control cellEditorWindow) { + TableItem[] selection = ((Table) cellEditorWindow.getParent()).getSelection(); + DirectoryDialog dialog = new DirectoryDialog(cellEditorWindow.getShell()); + dialog.setFilterPath(selection[0].getText(1)); + return dialog.open(); + } + } + + class EntryLabelProvider extends LabelProvider implements ITableLabelProvider { + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int) + */ + @Override public Image getColumnImage(Object element, int columnIndex) { - if (element instanceof MapEntrySourceContainer && columnIndex == 0) { - return CDebugImages.get(CDebugImages.IMG_OBJS_PATH_MAP_ENTRY); - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int) - */ - @Override + if (element instanceof MapEntrySourceContainer && columnIndex == 0) { + return CDebugImages.get(CDebugImages.IMG_OBJS_PATH_MAP_ENTRY); + } + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int) + */ + @Override public String getColumnText(Object element, int columnIndex) { - if (element instanceof MapEntrySourceContainer) { - MapEntrySourceContainer entry = (MapEntrySourceContainer)element; - if (columnIndex == 0) - return entry.getBackendPathStr(); - if (columnIndex == 1) - return entry.getLocalPath().toOSString(); - } - return null; - } - } - - // Column properties - private static final String CP_COMPILATION_PATH = "compilationPath"; //$NON-NLS-1$ - private static final String CP_FILE_SYSTEM_PATH = "fileSystemPath"; //$NON-NLS-1$ - - private MappingSourceContainer fOriginalContainer; - private MappingSourceContainer fContainer; - - private Text fNameText; - private Button fMappingWithBackendEnabledCheck; - private TableViewer fViewer; - private Button fAddButton; - private Button fRemoveButton; - private Button fUpButton; - private Button fDownButton; - - private ControlListener fTableListener; - - private boolean fIsValid = true; - - public MappingSourceContainerDialog(Shell shell, MappingSourceContainer container) { - super(shell); - fOriginalContainer = container; - fContainer = container.copy(); - fTableListener = new ControlListener() { - /* (non-Javadoc) - * @see org.eclipse.swt.events.ControlListener#controlMoved(org.eclipse.swt.events.ControlEvent) - */ - @Override + if (element instanceof MapEntrySourceContainer) { + MapEntrySourceContainer entry = (MapEntrySourceContainer) element; + if (columnIndex == 0) + return entry.getBackendPathStr(); + if (columnIndex == 1) + return entry.getLocalPath().toOSString(); + } + return null; + } + } + + // Column properties + private static final String CP_COMPILATION_PATH = "compilationPath"; //$NON-NLS-1$ + private static final String CP_FILE_SYSTEM_PATH = "fileSystemPath"; //$NON-NLS-1$ + + private MappingSourceContainer fOriginalContainer; + private MappingSourceContainer fContainer; + + private Text fNameText; + private Button fMappingWithBackendEnabledCheck; + private TableViewer fViewer; + private Button fAddButton; + private Button fRemoveButton; + private Button fUpButton; + private Button fDownButton; + + private ControlListener fTableListener; + + private boolean fIsValid = true; + + public MappingSourceContainerDialog(Shell shell, MappingSourceContainer container) { + super(shell); + fOriginalContainer = container; + fContainer = container.copy(); + fTableListener = new ControlListener() { + /* (non-Javadoc) + * @see org.eclipse.swt.events.ControlListener#controlMoved(org.eclipse.swt.events.ControlEvent) + */ + @Override public void controlMoved(ControlEvent e) { - MappingSourceContainerDialog.this.controlMoved(e); - } + MappingSourceContainerDialog.this.controlMoved(e); + } - /* (non-Javadoc) - * @see org.eclipse.swt.events.ControlListener#controlResized(org.eclipse.swt.events.ControlEvent) - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.swt.events.ControlListener#controlResized(org.eclipse.swt.events.ControlEvent) + */ + @Override public void controlResized(ControlEvent e) { - MappingSourceContainerDialog.this.controlResized(e); - } - }; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.TrayDialog#close() - */ - @Override - public boolean close() { - fViewer.getTable().removeControlListener(fTableListener); - fContainer.dispose(); - return super.close(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#isResizable() - */ - @Override - protected boolean isResizable() { - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) - */ - @Override - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - newShell.setText(SourceLookupUIMessages.PathMappingDialog_16); - newShell.setToolTipText(SourceLookupUIMessages.MappingSourceContainerDialog_0); - newShell.setImage(CDebugImages.get( CDebugImages.IMG_OBJS_PATH_MAPPING)); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#createContents(org.eclipse.swt.widgets.Composite) - */ - @Override - protected Control createContents(Composite parent) { - Control control = super.createContents(parent); - initialize(); - return control; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) - */ - @Override - protected Control createDialogArea(Composite parent) { - Composite control = (Composite)super.createDialogArea(parent); - setTitle(SourceLookupUIMessages.PathMappingDialog_0); - setTitleImage(CDebugImages.get(CDebugImages.IMG_WIZBAN_PATH_MAPPING)); - - Composite composite = new Composite(control, SWT.None); - composite.setLayout(new GridLayout(2, false)); - composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - - createNameArea(composite); - createViewer(composite); - createViewerButtonBar(composite); - createMappingWithBackendEnabledArea(composite); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(getShell(), ICDebugHelpContextIds.SOURCE_PATH_MAP_ENTRY_DIALOG); - return control; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#okPressed() - */ - @Override - protected void okPressed() { - fOriginalContainer.clear(); - fOriginalContainer.setName(fNameText.getText().trim()); - fOriginalContainer.setIsMappingWithBackendEnabled(fMappingWithBackendEnabledCheck.getSelection()); - try { - fOriginalContainer.addMapEntries((MapEntrySourceContainer[])fContainer.getSourceContainers()); - } catch (CoreException e) { - } - super.okPressed(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.TitleAreaDialog#setErrorMessage(java.lang.String) - */ - @Override - public void setErrorMessage(String newErrorMessage) { - fIsValid = (newErrorMessage == null); - super.setErrorMessage(newErrorMessage); - } - - public MappingSourceContainer getContainer() { - return fOriginalContainer; - } - - private void createNameArea(Composite parent) { - Composite composite = new Composite(parent, SWT.None); - composite.setLayout(new GridLayout(2, false)); - composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1)); - - Label label = new Label(composite, SWT.NONE); - label.setText(SourceLookupUIMessages.PathMappingDialog_12); - fNameText = new Text(composite, SWT.BORDER | SWT.SINGLE); - GridData data = new GridData(SWT.FILL, SWT.CENTER, false, false); - data.widthHint = 200; - fNameText.setLayoutData(data); - fNameText.addModifyListener(new ModifyListener() { - /* (non-Javadoc) - * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent) - */ - @Override + MappingSourceContainerDialog.this.controlResized(e); + } + }; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.TrayDialog#close() + */ + @Override + public boolean close() { + fViewer.getTable().removeControlListener(fTableListener); + fContainer.dispose(); + return super.close(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#isResizable() + */ + @Override + protected boolean isResizable() { + return true; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) + */ + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText(SourceLookupUIMessages.PathMappingDialog_16); + newShell.setToolTipText(SourceLookupUIMessages.MappingSourceContainerDialog_0); + newShell.setImage(CDebugImages.get(CDebugImages.IMG_OBJS_PATH_MAPPING)); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#createContents(org.eclipse.swt.widgets.Composite) + */ + @Override + protected Control createContents(Composite parent) { + Control control = super.createContents(parent); + initialize(); + return control; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) + */ + @Override + protected Control createDialogArea(Composite parent) { + Composite control = (Composite) super.createDialogArea(parent); + setTitle(SourceLookupUIMessages.PathMappingDialog_0); + setTitleImage(CDebugImages.get(CDebugImages.IMG_WIZBAN_PATH_MAPPING)); + + Composite composite = new Composite(control, SWT.None); + composite.setLayout(new GridLayout(2, false)); + composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + + createNameArea(composite); + createViewer(composite); + createViewerButtonBar(composite); + createMappingWithBackendEnabledArea(composite); + + PlatformUI.getWorkbench().getHelpSystem().setHelp(getShell(), + ICDebugHelpContextIds.SOURCE_PATH_MAP_ENTRY_DIALOG); + return control; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#okPressed() + */ + @Override + protected void okPressed() { + fOriginalContainer.clear(); + fOriginalContainer.setName(fNameText.getText().trim()); + fOriginalContainer.setIsMappingWithBackendEnabled(fMappingWithBackendEnabledCheck.getSelection()); + try { + fOriginalContainer.addMapEntries((MapEntrySourceContainer[]) fContainer.getSourceContainers()); + } catch (CoreException e) { + } + super.okPressed(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.TitleAreaDialog#setErrorMessage(java.lang.String) + */ + @Override + public void setErrorMessage(String newErrorMessage) { + fIsValid = (newErrorMessage == null); + super.setErrorMessage(newErrorMessage); + } + + public MappingSourceContainer getContainer() { + return fOriginalContainer; + } + + private void createNameArea(Composite parent) { + Composite composite = new Composite(parent, SWT.None); + composite.setLayout(new GridLayout(2, false)); + composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1)); + + Label label = new Label(composite, SWT.NONE); + label.setText(SourceLookupUIMessages.PathMappingDialog_12); + fNameText = new Text(composite, SWT.BORDER | SWT.SINGLE); + GridData data = new GridData(SWT.FILL, SWT.CENTER, false, false); + data.widthHint = 200; + fNameText.setLayoutData(data); + fNameText.addModifyListener(new ModifyListener() { + /* (non-Javadoc) + * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent) + */ + @Override public void modifyText(ModifyEvent e) { - } - }); - } - - private void createMappingWithBackendEnabledArea(Composite parent) { - Composite composite = new Composite(parent, SWT.None); - composite.setLayout(new GridLayout(1, false)); - composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1)); - - fMappingWithBackendEnabledCheck = new Button(composite, SWT.CHECK); - fMappingWithBackendEnabledCheck.setText(SourceLookupUIMessages.PathMappingDialog_MappingWithBackendEnabled); - fMappingWithBackendEnabledCheck.setToolTipText(SourceLookupUIMessages.PathMappingDialog_MappingWithBackendEnabledTooltip); - GridData data = new GridData(SWT.FILL, SWT.CENTER, false, false); - fMappingWithBackendEnabledCheck.setLayoutData(data); - } - - private void createViewer(Composite parent) { - Composite tableComp = new Composite(parent, SWT.NONE); - tableComp.setLayout(new GridLayout()); - tableComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - - fViewer = new TableViewer(tableComp, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); - Table table = fViewer.getTable(); - table.setLinesVisible(true); - table.setHeaderVisible(true); - GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); - data.widthHint = 500; - data.heightHint = 200; - table.setLayoutData(data); - - table.addControlListener(fTableListener); - - TableColumn nameColumn = new TableColumn(table, SWT.NULL); - nameColumn.setResizable(true); - nameColumn.setText(SourceLookupUIMessages.PathMappingDialog_1); - nameColumn.setToolTipText(SourceLookupUIMessages.MappingSourceContainerDialog_1); - - TableColumn valueColumn = new TableColumn(table, SWT.NULL); - valueColumn.setResizable(true); - valueColumn.setText(SourceLookupUIMessages.PathMappingDialog_2); - valueColumn.setToolTipText(SourceLookupUIMessages.MappingSourceContainerDialog_2); - - fViewer.setColumnProperties( - new String[] { - CP_COMPILATION_PATH, - CP_FILE_SYSTEM_PATH, - }); - - fViewer.setContentProvider(new IStructuredContentProvider() { - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) - */ - @Override + } + }); + } + + private void createMappingWithBackendEnabledArea(Composite parent) { + Composite composite = new Composite(parent, SWT.None); + composite.setLayout(new GridLayout(1, false)); + composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1)); + + fMappingWithBackendEnabledCheck = new Button(composite, SWT.CHECK); + fMappingWithBackendEnabledCheck.setText(SourceLookupUIMessages.PathMappingDialog_MappingWithBackendEnabled); + fMappingWithBackendEnabledCheck + .setToolTipText(SourceLookupUIMessages.PathMappingDialog_MappingWithBackendEnabledTooltip); + GridData data = new GridData(SWT.FILL, SWT.CENTER, false, false); + fMappingWithBackendEnabledCheck.setLayoutData(data); + } + + private void createViewer(Composite parent) { + Composite tableComp = new Composite(parent, SWT.NONE); + tableComp.setLayout(new GridLayout()); + tableComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + + fViewer = new TableViewer(tableComp, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); + Table table = fViewer.getTable(); + table.setLinesVisible(true); + table.setHeaderVisible(true); + GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); + data.widthHint = 500; + data.heightHint = 200; + table.setLayoutData(data); + + table.addControlListener(fTableListener); + + TableColumn nameColumn = new TableColumn(table, SWT.NULL); + nameColumn.setResizable(true); + nameColumn.setText(SourceLookupUIMessages.PathMappingDialog_1); + nameColumn.setToolTipText(SourceLookupUIMessages.MappingSourceContainerDialog_1); + + TableColumn valueColumn = new TableColumn(table, SWT.NULL); + valueColumn.setResizable(true); + valueColumn.setText(SourceLookupUIMessages.PathMappingDialog_2); + valueColumn.setToolTipText(SourceLookupUIMessages.MappingSourceContainerDialog_2); + + fViewer.setColumnProperties(new String[] { CP_COMPILATION_PATH, CP_FILE_SYSTEM_PATH, }); + + fViewer.setContentProvider(new IStructuredContentProvider() { + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) + */ + @Override public Object[] getElements(Object inputElement) { - if (inputElement instanceof MappingSourceContainer) { - try { - return ((MappingSourceContainer)inputElement).getSourceContainers(); - } catch (CoreException e) { - } - } - return new Object[0]; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IContentProvider#dispose() - */ - @Override + if (inputElement instanceof MappingSourceContainer) { + try { + return ((MappingSourceContainer) inputElement).getSourceContainers(); + } catch (CoreException e) { + } + } + return new Object[0]; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IContentProvider#dispose() + */ + @Override public void dispose() { - } + } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) - */ - @Override + /* (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) { - } - }); - - fViewer.setCellEditors(new CellEditor[] { - new TextCellEditor(table), - new DirectoryCellEditor(table), - }); - - fViewer.setCellModifier(new EntryCellModifier()); - - fViewer.setLabelProvider(new EntryLabelProvider()); - - fViewer.addSelectionChangedListener(new ISelectionChangedListener() { - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) - */ - @Override + } + }); + + fViewer.setCellEditors(new CellEditor[] { new TextCellEditor(table), new DirectoryCellEditor(table), }); + + fViewer.setCellModifier(new EntryCellModifier()); + + fViewer.setLabelProvider(new EntryLabelProvider()); + + fViewer.addSelectionChangedListener(new ISelectionChangedListener() { + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) + */ + @Override public void selectionChanged(SelectionChangedEvent event) { - updateViewerButtons(); - } - }); - } - - private void createViewerButtonBar(Composite parent) { - Composite buttonComp = new Composite(parent, SWT.NONE); - buttonComp.setLayout(new GridLayout()); - buttonComp.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false)); - - fAddButton = createPushButton(buttonComp, SourceLookupUIMessages.MappingSourceContainerDialog_3); - fAddButton.addSelectionListener(new SelectionAdapter() { - /* (non-Javadoc) - * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) - */ - @Override - public void widgetSelected(SelectionEvent event) { - addPathEntry(); - } - }); - - fRemoveButton = createPushButton(buttonComp, SourceLookupUIMessages.PathMappingDialog_15); - fRemoveButton.addSelectionListener(new SelectionAdapter() { - /* (non-Javadoc) - * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) - */ - @Override - public void widgetSelected(SelectionEvent event) { - removePathEntries(); - } - }); - - fUpButton = createPushButton(buttonComp, SourceLookupUIMessages.MappingSourceContainerDialog_4); - fUpButton.addSelectionListener(new SelectionAdapter() { - /* (non-Javadoc) - * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) - */ - @Override - public void widgetSelected(SelectionEvent event) { - move(true); - } - }); - - fDownButton = createPushButton(buttonComp, SourceLookupUIMessages.MappingSourceContainerDialog_5); - fDownButton.addSelectionListener(new SelectionAdapter() { - /* (non-Javadoc) - * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) - */ - @Override - public void widgetSelected(SelectionEvent event) { - move(false); - } - }); - } - - private void initialize() { - fNameText.setText(fContainer.getName()); - fNameText.selectAll(); - fMappingWithBackendEnabledCheck.setSelection(fContainer.isMappingWithBackendEnabled()); - fViewer.setInput(fContainer); - updateViewerButtons(); - } - - private Button createPushButton(Composite parent, String label) { - Button button = new Button(parent, SWT.PUSH); - button.setText(label); - GridData gd = new GridData(SWT.FILL, SWT.BEGINNING, true, false); - gd.widthHint = SWTUtil.getButtonWidthHint(button); - button.setLayoutData(gd); - return button; - } - - private MapEntrySourceContainer[] getSelectedEntries() { - List<?> list = ((IStructuredSelection)fViewer.getSelection()).toList(); - return list.toArray(new MapEntrySourceContainer[list.size()]); - } - - private void updateErrorMessage() { - setErrorMessage(null); - try { - ISourceContainer[] containers = fContainer.getSourceContainers(); - if (containers.length == 0) - return; - for (ISourceContainer c : containers) { - MapEntrySourceContainer entry = (MapEntrySourceContainer)c; - String backendPath = entry.getBackendPathStr(); - if (backendPath.isEmpty()) { - setErrorMessage(SourceLookupUIMessages.PathMappingDialog_5); - break; - } - IPath localPath = entry.getLocalPath(); - if (localPath.isEmpty()) { - setErrorMessage(SourceLookupUIMessages.PathMappingDialog_7); - break; - } - if (!localPath.toFile().exists()) { - setErrorMessage(SourceLookupUIMessages.PathMappingDialog_8); - break; - } - if (!localPath.toFile().isDirectory()) { - setErrorMessage(SourceLookupUIMessages.PathMappingDialog_9); - break; - } - if (!localPath.toFile().isAbsolute()) { - setErrorMessage(SourceLookupUIMessages.PathMappingDialog_10); - break; - } - } - } catch (CoreException e) { - // ignore - } - } - - private void updateViewerButtons() { - boolean ok = true; - boolean remove = true; - boolean up = true; - boolean down = true; - - try { - ISourceContainer[] allEntries = fContainer.getSourceContainers(); - MapEntrySourceContainer[] entries = getSelectedEntries(); - if (entries.length == 0) { - remove = false; - } - - if (entries.length != 1) { - up = false; - down = false; - } else { - up = (!entries[0].equals(allEntries[0])); - down = (!entries[0].equals(allEntries[allEntries.length - 1])); - } - - ok = (allEntries.length != 0 && fIsValid); - } catch (CoreException e) { - // ignore, shouldn't happen - } - getButton(IDialogConstants.OK_ID).setEnabled(ok); - fRemoveButton.setEnabled(remove); - fUpButton.setEnabled(up); - fDownButton.setEnabled(down); - } - - private void refresh() { - ISelection s = fViewer.getSelection(); - fViewer.refresh(); - fViewer.setSelection(s); - updateErrorMessage(); - updateViewerButtons(); - } - - void controlMoved(ControlEvent e) { - } - - void controlResized(ControlEvent e) { - // resize columns - Table table = fViewer.getTable(); - int width = table.getSize().x; - if (width > 0) { - TableColumn[] columns = table.getColumns(); - int colWidth = width / columns.length; - for (TableColumn col : columns) { - if (col.getWidth() == 0) { - col.setWidth(colWidth); - } - } - } - } - - void addPathEntry() { - MapEntrySourceContainer entry = new MapEntrySourceContainer(); - fContainer.addMapEntry(entry); - fViewer.refresh(); - fViewer.setSelection(new StructuredSelection(entry), true); - updateViewerButtons(); - fViewer.editElement(entry, 0); - } - - void removePathEntries() { - MapEntrySourceContainer[] entries = getSelectedEntries(); - fContainer.removeMapEntries(entries); - refresh(); - } - - void move(boolean up) { - MapEntrySourceContainer[] selEntries = getSelectedEntries(); - if (selEntries.length != 1) - return; - MapEntrySourceContainer entry = selEntries[0]; - try { - ISourceContainer[] containers = fContainer.getSourceContainers(); - List<MapEntrySourceContainer> list = new ArrayList<MapEntrySourceContainer>(containers.length); - for (ISourceContainer container : containers) { - list.add(((MapEntrySourceContainer)container).copy()); - } - int index = list.indexOf(entry); - list.remove(index); - index = (up) ? index - 1 : index + 1; - list.add(index, entry); - fContainer.clear(); - fContainer.addMapEntries(list.toArray(new MapEntrySourceContainer[list.size()])); - refresh(); - } catch (CoreException e) { - } catch (IndexOutOfBoundsException e) { - } - } + updateViewerButtons(); + } + }); + } + + private void createViewerButtonBar(Composite parent) { + Composite buttonComp = new Composite(parent, SWT.NONE); + buttonComp.setLayout(new GridLayout()); + buttonComp.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false)); + + fAddButton = createPushButton(buttonComp, SourceLookupUIMessages.MappingSourceContainerDialog_3); + fAddButton.addSelectionListener(new SelectionAdapter() { + /* (non-Javadoc) + * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) + */ + @Override + public void widgetSelected(SelectionEvent event) { + addPathEntry(); + } + }); + + fRemoveButton = createPushButton(buttonComp, SourceLookupUIMessages.PathMappingDialog_15); + fRemoveButton.addSelectionListener(new SelectionAdapter() { + /* (non-Javadoc) + * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) + */ + @Override + public void widgetSelected(SelectionEvent event) { + removePathEntries(); + } + }); + + fUpButton = createPushButton(buttonComp, SourceLookupUIMessages.MappingSourceContainerDialog_4); + fUpButton.addSelectionListener(new SelectionAdapter() { + /* (non-Javadoc) + * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) + */ + @Override + public void widgetSelected(SelectionEvent event) { + move(true); + } + }); + + fDownButton = createPushButton(buttonComp, SourceLookupUIMessages.MappingSourceContainerDialog_5); + fDownButton.addSelectionListener(new SelectionAdapter() { + /* (non-Javadoc) + * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) + */ + @Override + public void widgetSelected(SelectionEvent event) { + move(false); + } + }); + } + + private void initialize() { + fNameText.setText(fContainer.getName()); + fNameText.selectAll(); + fMappingWithBackendEnabledCheck.setSelection(fContainer.isMappingWithBackendEnabled()); + fViewer.setInput(fContainer); + updateViewerButtons(); + } + + private Button createPushButton(Composite parent, String label) { + Button button = new Button(parent, SWT.PUSH); + button.setText(label); + GridData gd = new GridData(SWT.FILL, SWT.BEGINNING, true, false); + gd.widthHint = SWTUtil.getButtonWidthHint(button); + button.setLayoutData(gd); + return button; + } + + private MapEntrySourceContainer[] getSelectedEntries() { + List<?> list = ((IStructuredSelection) fViewer.getSelection()).toList(); + return list.toArray(new MapEntrySourceContainer[list.size()]); + } + + private void updateErrorMessage() { + setErrorMessage(null); + try { + ISourceContainer[] containers = fContainer.getSourceContainers(); + if (containers.length == 0) + return; + for (ISourceContainer c : containers) { + MapEntrySourceContainer entry = (MapEntrySourceContainer) c; + String backendPath = entry.getBackendPathStr(); + if (backendPath.isEmpty()) { + setErrorMessage(SourceLookupUIMessages.PathMappingDialog_5); + break; + } + IPath localPath = entry.getLocalPath(); + if (localPath.isEmpty()) { + setErrorMessage(SourceLookupUIMessages.PathMappingDialog_7); + break; + } + if (!localPath.toFile().exists()) { + setErrorMessage(SourceLookupUIMessages.PathMappingDialog_8); + break; + } + if (!localPath.toFile().isDirectory()) { + setErrorMessage(SourceLookupUIMessages.PathMappingDialog_9); + break; + } + if (!localPath.toFile().isAbsolute()) { + setErrorMessage(SourceLookupUIMessages.PathMappingDialog_10); + break; + } + } + } catch (CoreException e) { + // ignore + } + } + + private void updateViewerButtons() { + boolean ok = true; + boolean remove = true; + boolean up = true; + boolean down = true; + + try { + ISourceContainer[] allEntries = fContainer.getSourceContainers(); + MapEntrySourceContainer[] entries = getSelectedEntries(); + if (entries.length == 0) { + remove = false; + } + + if (entries.length != 1) { + up = false; + down = false; + } else { + up = (!entries[0].equals(allEntries[0])); + down = (!entries[0].equals(allEntries[allEntries.length - 1])); + } + + ok = (allEntries.length != 0 && fIsValid); + } catch (CoreException e) { + // ignore, shouldn't happen + } + getButton(IDialogConstants.OK_ID).setEnabled(ok); + fRemoveButton.setEnabled(remove); + fUpButton.setEnabled(up); + fDownButton.setEnabled(down); + } + + private void refresh() { + ISelection s = fViewer.getSelection(); + fViewer.refresh(); + fViewer.setSelection(s); + updateErrorMessage(); + updateViewerButtons(); + } + + void controlMoved(ControlEvent e) { + } + + void controlResized(ControlEvent e) { + // resize columns + Table table = fViewer.getTable(); + int width = table.getSize().x; + if (width > 0) { + TableColumn[] columns = table.getColumns(); + int colWidth = width / columns.length; + for (TableColumn col : columns) { + if (col.getWidth() == 0) { + col.setWidth(colWidth); + } + } + } + } + + void addPathEntry() { + MapEntrySourceContainer entry = new MapEntrySourceContainer(); + fContainer.addMapEntry(entry); + fViewer.refresh(); + fViewer.setSelection(new StructuredSelection(entry), true); + updateViewerButtons(); + fViewer.editElement(entry, 0); + } + + void removePathEntries() { + MapEntrySourceContainer[] entries = getSelectedEntries(); + fContainer.removeMapEntries(entries); + refresh(); + } + + void move(boolean up) { + MapEntrySourceContainer[] selEntries = getSelectedEntries(); + if (selEntries.length != 1) + return; + MapEntrySourceContainer entry = selEntries[0]; + try { + ISourceContainer[] containers = fContainer.getSourceContainers(); + List<MapEntrySourceContainer> list = new ArrayList<MapEntrySourceContainer>(containers.length); + for (ISourceContainer container : containers) { + list.add(((MapEntrySourceContainer) container).copy()); + } + int index = list.indexOf(entry); + list.remove(index); + index = (up) ? index - 1 : index + 1; + list.add(index, entry); + fContainer.clear(); + fContainer.addMapEntries(list.toArray(new MapEntrySourceContainer[list.size()])); + refresh(); + } catch (CoreException e) { + } catch (IndexOutOfBoundsException e) { + } + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/NewMappingSourceContainerBrowser.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/NewMappingSourceContainerBrowser.java index 0f3ef3b2bfd..ff2b7e565fb 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/NewMappingSourceContainerBrowser.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/NewMappingSourceContainerBrowser.java @@ -21,41 +21,42 @@ import org.eclipse.jface.window.Window; import org.eclipse.swt.widgets.Shell; public class NewMappingSourceContainerBrowser extends AbstractSourceContainerBrowser { - private static final String MAPPING = SourceLookupUIMessages.MappingSourceContainerBrowser_0; + private static final String MAPPING = SourceLookupUIMessages.MappingSourceContainerBrowser_0; - /* (non-Javadoc) - * @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#addSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.sourcelookup.ISourceLookupDirector) - */ - @Override - public ISourceContainer[] addSourceContainers(Shell shell, ISourceLookupDirector director) { - MappingSourceContainerDialog dialog = - new MappingSourceContainerDialog(shell, new MappingSourceContainer(MAPPING)); - if (dialog.open() == Window.OK) { - return new ISourceContainer[] { dialog.getContainer() }; - } - return new ISourceContainer[0]; - } + /* (non-Javadoc) + * @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#addSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.sourcelookup.ISourceLookupDirector) + */ + @Override + public ISourceContainer[] addSourceContainers(Shell shell, ISourceLookupDirector director) { + MappingSourceContainerDialog dialog = new MappingSourceContainerDialog(shell, + new MappingSourceContainer(MAPPING)); + if (dialog.open() == Window.OK) { + return new ISourceContainer[] { dialog.getContainer() }; + } + return new ISourceContainer[0]; + } - /* (non-Javadoc) - * @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#canEditSourceContainers(org.eclipse.debug.core.sourcelookup.ISourceLookupDirector, org.eclipse.debug.core.sourcelookup.ISourceContainer[]) - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#canEditSourceContainers(org.eclipse.debug.core.sourcelookup.ISourceLookupDirector, org.eclipse.debug.core.sourcelookup.ISourceContainer[]) + */ + @Override public boolean canEditSourceContainers(ISourceLookupDirector director, ISourceContainer[] containers) { - return (containers.length == 1 && containers[0] instanceof MappingSourceContainer); - } + return (containers.length == 1 && containers[0] instanceof MappingSourceContainer); + } - /* (non-Javadoc) - * @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#editSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.sourcelookup.ISourceLookupDirector, org.eclipse.debug.core.sourcelookup.ISourceContainer[]) - */ - @Override - public ISourceContainer[] editSourceContainers(Shell shell, ISourceLookupDirector director, ISourceContainer[] containers) { - if (containers.length == 1 && containers[0] instanceof MappingSourceContainer) { - MappingSourceContainerDialog dialog = - new MappingSourceContainerDialog(shell, (MappingSourceContainer)containers[0]); - if (dialog.open() == Window.OK) { - return new ISourceContainer[] { dialog.getContainer() }; - } - } - return new ISourceContainer[0]; - } + /* (non-Javadoc) + * @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#editSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.sourcelookup.ISourceLookupDirector, org.eclipse.debug.core.sourcelookup.ISourceContainer[]) + */ + @Override + public ISourceContainer[] editSourceContainers(Shell shell, ISourceLookupDirector director, + ISourceContainer[] containers) { + if (containers.length == 1 && containers[0] instanceof MappingSourceContainer) { + MappingSourceContainerDialog dialog = new MappingSourceContainerDialog(shell, + (MappingSourceContainer) containers[0]); + if (dialog.open() == Window.OK) { + return new ISourceContainer[] { dialog.getContainer() }; + } + } + return new ISourceContainer[0]; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/RemoveAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/RemoveAction.java index a578d121de2..8fab39f42b3 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/RemoveAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/RemoveAction.java @@ -7,12 +7,12 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.sourcelookup; - +package org.eclipse.cdt.debug.internal.ui.sourcelookup; + import java.util.List; import org.eclipse.debug.core.sourcelookup.ISourceContainer; @@ -28,7 +28,7 @@ public class RemoveAction extends SourceContainerAction { /** * Removes all selected entries. - * + * * @see IAction#run() */ @Override @@ -38,7 +38,7 @@ public class RemoveAction extends SourceContainerAction { list.removeAll(targets); setEntries(list); } - + /** * @see SelectionListenerAction#updateSelection(IStructuredSelection) */ diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerAction.java index abb566d71f1..950e36da6f7 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerAction.java @@ -7,11 +7,12 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.sourcelookup; +package org.eclipse.cdt.debug.internal.ui.sourcelookup; + import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -34,18 +35,18 @@ public abstract class SourceContainerAction extends SelectionListenerAction { private Button fButton; //the shell used to realize this action's dialog (if any) private Shell fShell; - + /** * The constructor for the action * @param label the label for the action's button */ public SourceContainerAction(String label) { - super(label); + super(label); } - + /** * Sets the viewer on which this action operates. - * + * * @param viewer the viewer on which this action operates */ public void setViewer(SourceContainerViewer viewer) { @@ -58,20 +59,20 @@ public abstract class SourceContainerAction extends SelectionListenerAction { update(); } } - + /** * Returns the viewer on which this action operates. - * + * * @return the viewer on which this action operates */ protected SourceContainerViewer getViewer() { return fViewer; } - + /** * Returns the selected items in the list, in the order they are * displayed. - * + * * @return targets for an action */ protected List<ISourceContainer> getOrderedSelection() { @@ -86,7 +87,7 @@ public abstract class SourceContainerAction extends SelectionListenerAction { } return targets; } - + /** * Returns a list (copy) of the entries in the viewer */ @@ -98,7 +99,7 @@ public abstract class SourceContainerAction extends SelectionListenerAction { } return list; } - + /** * Updates the entries to the entries in the given list */ @@ -107,7 +108,7 @@ public abstract class SourceContainerAction extends SelectionListenerAction { // update all selection listeners getViewer().setSelection(getViewer().getSelection()); } - + /** * Returns whether the item at the given index in the list * (visually) is selected. @@ -126,7 +127,7 @@ public abstract class SourceContainerAction extends SelectionListenerAction { } return false; } - + /** * Sets the button that invokes this action */ @@ -139,7 +140,7 @@ public abstract class SourceContainerAction extends SelectionListenerAction { } }); } - + /** * @see IAction#setEnabled(boolean) */ @@ -150,14 +151,14 @@ public abstract class SourceContainerAction extends SelectionListenerAction { fButton.setEnabled(enabled); } } - + /** * Updates the enabled state. */ protected void update() { selectionChanged((IStructuredSelection) getViewer().getSelection()); } - + /** * Returns the shell used to realize this action's dialog (if any). */ @@ -167,11 +168,11 @@ public abstract class SourceContainerAction extends SelectionListenerAction { } return fShell; } - + /** * Sets the shell used to realize this action's dialog (if any). */ public void setShell(Shell shell) { fShell = shell; - } + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerAdapterFactory.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerAdapterFactory.java index b30bc96131c..616280c29b5 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerAdapterFactory.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerAdapterFactory.java @@ -11,11 +11,11 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.sourcelookup; +package org.eclipse.cdt.debug.internal.ui.sourcelookup; import org.eclipse.core.runtime.IAdapterFactory; import org.eclipse.ui.model.IWorkbenchAdapter; - + /** * Adapter factory for CDT source containers. */ @@ -32,6 +32,6 @@ public class SourceContainerAdapterFactory implements IAdapterFactory { @Override public Class<?>[] getAdapterList() { - return new Class[]{ IWorkbenchAdapter.class }; + return new Class[] { IWorkbenchAdapter.class }; } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerLabelProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerLabelProvider.java index 7a452fe83e1..2b92e1dbe4e 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerLabelProvider.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerLabelProvider.java @@ -11,7 +11,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.sourcelookup; +package org.eclipse.cdt.debug.internal.ui.sourcelookup; import org.eclipse.debug.core.sourcelookup.ISourceContainer; import org.eclipse.debug.core.sourcelookup.ISourceContainerType; @@ -26,7 +26,7 @@ import org.eclipse.ui.model.WorkbenchLabelProvider; */ public class SourceContainerLabelProvider extends LabelProvider { private ILabelProvider fLabelProvider = null; - + /* (non-Javadoc) * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object) */ @@ -44,13 +44,13 @@ public class SourceContainerLabelProvider extends LabelProvider { // next consult contributed image image = DebugUITools.getSourceContainerImage(type.getId()); } - } + } if (image != null) { return image; } return super.getImage(element); } - + /* (non-Javadoc) * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) */ @@ -60,7 +60,7 @@ public class SourceContainerLabelProvider extends LabelProvider { String label = getWorkbenchLabelProvider().getText(element); if (label == null || label.length() == 0) { if (element instanceof ISourceContainer) { - return ((ISourceContainer) element).getName(); + return ((ISourceContainer) element).getName(); } else if (element instanceof ISourceContainerType) { return ((ISourceContainerType) element).getName(); } @@ -69,14 +69,14 @@ public class SourceContainerLabelProvider extends LabelProvider { } return super.getText(element); } - + private ILabelProvider getWorkbenchLabelProvider() { if (fLabelProvider == null) { fLabelProvider = new WorkbenchLabelProvider(); } return fLabelProvider; } - + /* (non-Javadoc) * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() */ diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerViewer.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerViewer.java index 1194f3d9e7c..51a26be6e93 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerViewer.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerViewer.java @@ -11,7 +11,7 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.sourcelookup; +package org.eclipse.cdt.debug.internal.ui.sourcelookup; import java.util.ArrayList; import java.util.List; @@ -37,7 +37,7 @@ public class SourceContainerViewer extends TreeViewer { * The source container entries displayed in this viewer */ protected List<ISourceContainer> fEntries = new ArrayList<ISourceContainer>(); - + class ContentProvider implements ITreeContentProvider { /** * @see IStructuredContentProvider#getElements(Object) @@ -46,33 +46,33 @@ public class SourceContainerViewer extends TreeViewer { public Object[] getElements(Object inputElement) { return getEntries(); } - + /** * @see IContentProvider#dispose() */ @Override public void dispose() { } - + /** * @see IContentProvider#inputChanged(Viewer, Object, Object) */ @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } - - /** + + /** * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) */ @Override public Object[] getChildren(Object parentElement) { try { - return ((ISourceContainer)parentElement).getSourceContainers(); + return ((ISourceContainer) parentElement).getSourceContainers(); } catch (CoreException e) { return new Object[0]; } } - + /** * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object) */ @@ -80,16 +80,16 @@ public class SourceContainerViewer extends TreeViewer { public Object getParent(Object element) { return null; } - + /** * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object) */ @Override public boolean hasChildren(Object element) { - return ((ISourceContainer)element).isComposite(); + return ((ISourceContainer) element).isComposite(); } } - + /** * Creates a runtime classpath viewer with the given parent. * @@ -100,12 +100,12 @@ public class SourceContainerViewer extends TreeViewer { super(parent); setContentProvider(new ContentProvider()); SourceContainerLabelProvider lp = new SourceContainerLabelProvider(); - setLabelProvider(lp); - } - + setLabelProvider(lp); + } + /** - * Sets the entries in this viewer - * + * Sets the entries in this viewer + * * @param entries source container entries */ public void setEntries(ISourceContainer[] entries) { @@ -117,39 +117,39 @@ public class SourceContainerViewer extends TreeViewer { if (getInput() == null) { setInput(fEntries); //select first item in list - if (!fEntries.isEmpty() && fEntries.get(0)!=null) - setSelection(new StructuredSelection(fEntries.get(0))); + if (!fEntries.isEmpty() && fEntries.get(0) != null) + setSelection(new StructuredSelection(fEntries.get(0))); } else { refresh(); } } - + /** * Returns the entries in this viewer - * + * * @return the entries in this viewer */ public ISourceContainer[] getEntries() { return fEntries.toArray(new ISourceContainer[fEntries.size()]); } - + /** * Adds the given entries to the list. If there is no selection - * in the list, the entries are added at the end of the list, + * in the list, the entries are added at the end of the list, * otherwise the new entries are added before the (first) selected * entry. The new entries are selected. - * + * * @param entries additions */ public void addEntries(ISourceContainer[] entries) { - IStructuredSelection sel = (IStructuredSelection)getSelection(); + IStructuredSelection sel = (IStructuredSelection) getSelection(); if (sel.isEmpty()) { for (int i = 0; i < entries.length; i++) { if (!fEntries.contains(entries[i])) { fEntries.add(entries[i]); } } - } else { + } else { int index = fEntries.indexOf(sel.getFirstElement()); for (int i = 0; i < entries.length; i++) { if (!fEntries.contains(entries[i])) { @@ -157,13 +157,13 @@ public class SourceContainerViewer extends TreeViewer { index++; } } - } - - if (!fEntries.isEmpty() && fEntries.get(0)!=null) + } + + if (!fEntries.isEmpty() && fEntries.get(0) != null) setSelection(new StructuredSelection(fEntries.get(0))); refresh(); - } - + } + /** * Enables/disables this viewer. Note the control is not disabled, since * we still want the user to be able to scroll if required to see the @@ -173,18 +173,18 @@ public class SourceContainerViewer extends TreeViewer { fEnabled = enabled; // fire selection change to update actions setSelection(getSelection()); - } - + } + /** * Returns whether this viewer is enabled */ public boolean isEnabled() { return fEnabled; - } - + } + /** * Returns the index of an equivalent entry, or -1 if none. - * + * * @return the index of an equivalent entry, or -1 if none */ public int indexOf(ISourceContainer entry) { diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerWorkbenchAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerWorkbenchAdapter.java index b21f0abcf5d..57066a57395 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerWorkbenchAdapter.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceContainerWorkbenchAdapter.java @@ -11,7 +11,7 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.sourcelookup; +package org.eclipse.cdt.debug.internal.ui.sourcelookup; import java.io.File; import org.eclipse.cdt.core.CCorePlugin; @@ -26,7 +26,7 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.model.IWorkbenchAdapter; - + /** * Workbench adapter for CDT source containers. */ @@ -81,10 +81,10 @@ public class SourceContainerWorkbenchAdapter implements IWorkbenchAdapter { @Override public String getLabel(Object o) { if (o instanceof MappingSourceContainer) { - return SourceLookupUIMessages.SourceContainerWorkbenchAdapter_0 + ((MappingSourceContainer)o).getName(); + return SourceLookupUIMessages.SourceContainerWorkbenchAdapter_0 + ((MappingSourceContainer) o).getName(); } if (o instanceof MapEntrySourceContainer) { - return ((MapEntrySourceContainer)o).getName(); + return ((MapEntrySourceContainer) o).getName(); } return null; } @@ -107,7 +107,7 @@ public class SourceContainerWorkbenchAdapter implements IWorkbenchAdapter { if (path.getDevice() != null) { buffer.append(path.getDevice()); } - for(int i = 0; i < segments.length - 1; i++) { + for (int i = 0; i < segments.length - 1; i++) { buffer.append(File.separatorChar); buffer.append(segments[i]); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceDisplayAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceDisplayAdapter.java index 426a32231fe..2a323180e77 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceDisplayAdapter.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceDisplayAdapter.java @@ -35,285 +35,284 @@ import org.eclipse.ui.progress.UIJob; public class SourceDisplayAdapter implements ISourceDisplay { - class DelegatingStackFrame implements IStackFrame { - private ICStackFrame fDelegate; - - DelegatingStackFrame(ICStackFrame delegate) { - super(); - fDelegate = delegate; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.IStackFrame#getCharEnd() - */ - @Override + class DelegatingStackFrame implements IStackFrame { + private ICStackFrame fDelegate; + + DelegatingStackFrame(ICStackFrame delegate) { + super(); + fDelegate = delegate; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IStackFrame#getCharEnd() + */ + @Override public int getCharEnd() throws DebugException { - return fDelegate.getCharEnd(); - } + return fDelegate.getCharEnd(); + } - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.IStackFrame#getCharStart() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IStackFrame#getCharStart() + */ + @Override public int getCharStart() throws DebugException { - return fDelegate.getCharStart(); - } + return fDelegate.getCharStart(); + } - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.IStackFrame#getLineNumber() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IStackFrame#getLineNumber() + */ + @Override public int getLineNumber() throws DebugException { - return fDelegate.getLineNumber(); - } + return fDelegate.getLineNumber(); + } - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.IStackFrame#getName() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IStackFrame#getName() + */ + @Override public String getName() throws DebugException { - return fDelegate.getName(); - } + return fDelegate.getName(); + } - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.IStackFrame#getRegisterGroups() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IStackFrame#getRegisterGroups() + */ + @Override public IRegisterGroup[] getRegisterGroups() throws DebugException { - return fDelegate.getRegisterGroups(); - } + return fDelegate.getRegisterGroups(); + } - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.IStackFrame#getThread() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IStackFrame#getThread() + */ + @Override public IThread getThread() { - return fDelegate.getThread(); - } + return fDelegate.getThread(); + } - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.IStackFrame#getVariables() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IStackFrame#getVariables() + */ + @Override public IVariable[] getVariables() throws DebugException { - return fDelegate.getVariables(); - } + return fDelegate.getVariables(); + } - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.IStackFrame#hasRegisterGroups() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IStackFrame#hasRegisterGroups() + */ + @Override public boolean hasRegisterGroups() throws DebugException { - return fDelegate.hasRegisterGroups(); - } + return fDelegate.hasRegisterGroups(); + } - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.IStackFrame#hasVariables() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IStackFrame#hasVariables() + */ + @Override public boolean hasVariables() throws DebugException { - return fDelegate.hasVariables(); - } + return fDelegate.hasVariables(); + } - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.IDebugElement#getDebugTarget() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IDebugElement#getDebugTarget() + */ + @Override public IDebugTarget getDebugTarget() { - return fDelegate.getDebugTarget(); - } + return fDelegate.getDebugTarget(); + } - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.IDebugElement#getLaunch() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IDebugElement#getLaunch() + */ + @Override public ILaunch getLaunch() { - return fDelegate.getLaunch(); - } + return fDelegate.getLaunch(); + } - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier() + */ + @Override public String getModelIdentifier() { - return fDelegate.getModelIdentifier(); - } + return fDelegate.getModelIdentifier(); + } - @SuppressWarnings("unchecked") + @SuppressWarnings("unchecked") @Override public <T> T getAdapter(Class<T> adapter) { - if (ICStackFrame.class.equals(adapter)) - return (T) fDelegate; - return fDelegate.getAdapter(adapter); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.IStep#canStepInto() - */ - @Override + if (ICStackFrame.class.equals(adapter)) + return (T) fDelegate; + return fDelegate.getAdapter(adapter); + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IStep#canStepInto() + */ + @Override public boolean canStepInto() { - return fDelegate.canStepInto(); - } + return fDelegate.canStepInto(); + } - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.IStep#canStepOver() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IStep#canStepOver() + */ + @Override public boolean canStepOver() { - return fDelegate.canStepOver(); - } + return fDelegate.canStepOver(); + } - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.IStep#canStepReturn() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IStep#canStepReturn() + */ + @Override public boolean canStepReturn() { - return fDelegate.canStepReturn(); - } + return fDelegate.canStepReturn(); + } - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.IStep#isStepping() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IStep#isStepping() + */ + @Override public boolean isStepping() { - return fDelegate.isStepping(); - } + return fDelegate.isStepping(); + } - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.IStep#stepInto() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IStep#stepInto() + */ + @Override public void stepInto() throws DebugException { - fDelegate.stepInto(); - } + fDelegate.stepInto(); + } - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.IStep#stepOver() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IStep#stepOver() + */ + @Override public void stepOver() throws DebugException { - fDelegate.stepOver(); - } + fDelegate.stepOver(); + } - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.IStep#stepReturn() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IStep#stepReturn() + */ + @Override public void stepReturn() throws DebugException { - fDelegate.stepReturn(); - } + fDelegate.stepReturn(); + } - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.ISuspendResume#canResume() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.ISuspendResume#canResume() + */ + @Override public boolean canResume() { - return fDelegate.canResume(); - } + return fDelegate.canResume(); + } - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend() + */ + @Override public boolean canSuspend() { - return fDelegate.canSuspend(); - } + return fDelegate.canSuspend(); + } - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.ISuspendResume#isSuspended() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.ISuspendResume#isSuspended() + */ + @Override public boolean isSuspended() { - return fDelegate.isSuspended(); - } + return fDelegate.isSuspended(); + } - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.ISuspendResume#resume() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.ISuspendResume#resume() + */ + @Override public void resume() throws DebugException { - fDelegate.resume(); - } + fDelegate.resume(); + } - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.ISuspendResume#suspend() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.ISuspendResume#suspend() + */ + @Override public void suspend() throws DebugException { - fDelegate.suspend(); - } + fDelegate.suspend(); + } - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.ITerminate#canTerminate() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.ITerminate#canTerminate() + */ + @Override public boolean canTerminate() { - return fDelegate.canTerminate(); - } + return fDelegate.canTerminate(); + } - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.ITerminate#isTerminated() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.ITerminate#isTerminated() + */ + @Override public boolean isTerminated() { - return fDelegate.isTerminated(); - } + return fDelegate.isTerminated(); + } - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.ITerminate#terminate() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.ITerminate#terminate() + */ + @Override public void terminate() throws DebugException { - fDelegate.terminate(); - } - } - - /* (non-Javadoc) - * @see org.eclipse.debug.ui.sourcelookup.ISourceDisplay#displaySource(java.lang.Object, org.eclipse.ui.IWorkbenchPage, boolean) - */ - @Override + fDelegate.terminate(); + } + } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.sourcelookup.ISourceDisplay#displaySource(java.lang.Object, org.eclipse.ui.IWorkbenchPage, boolean) + */ + @Override public void displaySource(Object element, IWorkbenchPage page, boolean forceSourceLookup) { - if (element instanceof ICStackFrame) { - ICStackFrame frame = (ICStackFrame)element; - if (isDisplayDisassembly(frame, page)) { - displayDisassembly(page, frame); - } else { - DelegatingStackFrame delegatingFrame = new DelegatingStackFrame((ICStackFrame)element); - ISourceDisplay sd = Platform.getAdapterManager().getAdapter(delegatingFrame, ISourceDisplay.class); - if (sd != null) - sd.displaySource(element, page, forceSourceLookup); - } - } - } - - private boolean isDisplayDisassembly(ICStackFrame frame, IWorkbenchPage page) { - // always go to the disassembly window if it is already open - IEditorPart editor = getDisassemblyEditorManager().findEditor(page, frame); - return (editor != null); - } - - protected DisassemblyEditorManager getDisassemblyEditorManager() { - return CDebugUIPlugin.getDefault().getDisassemblyEditorManager(); - } - - private void displayDisassembly(final IWorkbenchPage page, final Object debugContext) { - Job uijob = new UIJob("Display Disassembly Job") { //$NON-NLS-1$ - /* (non-Javadoc) - * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) - */ - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - try { - getDisassemblyEditorManager().openEditor(page, debugContext); - } - catch(DebugException e) { - return e.getStatus(); - } - return Status.OK_STATUS; - } - - }; - uijob.setSystem(true); - uijob.schedule(); - } + if (element instanceof ICStackFrame) { + ICStackFrame frame = (ICStackFrame) element; + if (isDisplayDisassembly(frame, page)) { + displayDisassembly(page, frame); + } else { + DelegatingStackFrame delegatingFrame = new DelegatingStackFrame((ICStackFrame) element); + ISourceDisplay sd = Platform.getAdapterManager().getAdapter(delegatingFrame, ISourceDisplay.class); + if (sd != null) + sd.displaySource(element, page, forceSourceLookup); + } + } + } + + private boolean isDisplayDisassembly(ICStackFrame frame, IWorkbenchPage page) { + // always go to the disassembly window if it is already open + IEditorPart editor = getDisassemblyEditorManager().findEditor(page, frame); + return (editor != null); + } + + protected DisassemblyEditorManager getDisassemblyEditorManager() { + return CDebugUIPlugin.getDefault().getDisassemblyEditorManager(); + } + + private void displayDisassembly(final IWorkbenchPage page, final Object debugContext) { + Job uijob = new UIJob("Display Disassembly Job") { //$NON-NLS-1$ + /* (non-Javadoc) + * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + public IStatus runInUIThread(IProgressMonitor monitor) { + try { + getDisassemblyEditorManager().openEditor(page, debugContext); + } catch (DebugException e) { + return e.getStatus(); + } + return Status.OK_STATUS; + } + + }; + uijob.setSystem(true); + uijob.schedule(); + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceFoldersRelativePathSourceContainerBrowser.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceFoldersRelativePathSourceContainerBrowser.java index 3b5d1018e1b..74df270f32d 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceFoldersRelativePathSourceContainerBrowser.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceFoldersRelativePathSourceContainerBrowser.java @@ -33,7 +33,7 @@ import org.eclipse.ui.model.WorkbenchLabelProvider; * The browser for adding a source folder relative path source container. */ public class SourceFoldersRelativePathSourceContainerBrowser extends AbstractSourceContainerBrowser { - + /* (non-Javadoc) * @see org.eclipse.debug.internal.ui.sourcelookup.ISourceContainerBrowser#createSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.ILaunchConfiguration) */ @@ -41,27 +41,26 @@ public class SourceFoldersRelativePathSourceContainerBrowser extends AbstractSou public ISourceContainer[] addSourceContainers(Shell shell, ISourceLookupDirector director) { if (director.getLaunchConfiguration() == null) { TargetProjectSourceContainerDialog dialog = new TargetProjectSourceContainerDialog(shell); - if (dialog.open() == Window.OK) { + if (dialog.open() == Window.OK) { return new ISourceContainer[] { - new SourceFoldersRelativePathSourceContainer(null, dialog.isAddReferencedProjects()) }; - } + new SourceFoldersRelativePathSourceContainer(null, dialog.isAddReferencedProjects()) }; + } } else { Object input = ResourcesPlugin.getWorkspace().getRoot(); - IStructuredContentProvider contentProvider=new BasicContainerContentProvider(); + IStructuredContentProvider contentProvider = new BasicContainerContentProvider(); ILabelProvider labelProvider = new WorkbenchLabelProvider(); - ProjectSourceContainerDialog dialog = - new ProjectSourceContainerDialog(shell, input, contentProvider, labelProvider, - SourceLookupUIMessages.projectSelection_chooseLabel); - if (dialog.open() == Window.OK) { - ArrayList<ISourceContainer> res= new ArrayList<ISourceContainer>(); + ProjectSourceContainerDialog dialog = new ProjectSourceContainerDialog(shell, input, contentProvider, + labelProvider, SourceLookupUIMessages.projectSelection_chooseLabel); + if (dialog.open() == Window.OK) { + ArrayList<ISourceContainer> res = new ArrayList<ISourceContainer>(); for (Object element : dialog.getResult()) { if (!(element instanceof IProject)) - continue; + continue; res.add(new SourceFoldersRelativePathSourceContainer((IProject) element, dialog.isAddRequiredProjects())); } - return res.toArray(new ISourceContainer[res.size()]); - } + return res.toArray(new ISourceContainer[res.size()]); + } } return new ISourceContainer[0]; } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/TargetProjectSourceContainerDialog.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/TargetProjectSourceContainerDialog.java index bff90733228..3c275b9d9bc 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/TargetProjectSourceContainerDialog.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/TargetProjectSourceContainerDialog.java @@ -31,11 +31,11 @@ import org.eclipse.ui.dialogs.SelectionDialog; public class TargetProjectSourceContainerDialog extends SelectionDialog { private boolean fAddReferencedProjects; - public TargetProjectSourceContainerDialog(Shell parentShell) { - super(parentShell); - setTitle(SourceLookupUIMessages.TargetProjectSourceContainerDialog_title); - setMessage(SourceLookupUIMessages.TargetProjectSourceContainerDialog_description); - } + public TargetProjectSourceContainerDialog(Shell parentShell) { + super(parentShell); + setTitle(SourceLookupUIMessages.TargetProjectSourceContainerDialog_title); + setMessage(SourceLookupUIMessages.TargetProjectSourceContainerDialog_description); + } /** * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) @@ -43,15 +43,15 @@ public class TargetProjectSourceContainerDialog extends SelectionDialog { @Override protected Control createDialogArea(Composite parent) { Font font = parent.getFont(); - - // Page group - Composite composite = (Composite) super.createDialogArea(parent); - initializeDialogUnits(composite); - createMessageArea(composite); + // Page group + Composite composite = (Composite) super.createDialogArea(parent); + initializeDialogUnits(composite); + + createMessageArea(composite); final Button addRequired = new Button(composite, SWT.CHECK); - addRequired.setText(SourceLookupUIMessages.TargetProjectSourceContainerDialog_referencedLabel); + addRequired.setText(SourceLookupUIMessages.TargetProjectSourceContainerDialog_referencedLabel); addRequired.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { @@ -59,17 +59,17 @@ public class TargetProjectSourceContainerDialog extends SelectionDialog { } }); addRequired.setSelection(fAddReferencedProjects); - addRequired.setFont(font); - + addRequired.setFont(font); + PlatformUI.getWorkbench().getHelpSystem().setHelp(getShell(), ICDebugHelpContextIds.ADD_TARGET_PROJECT_CONTAINER_DIALOG); - applyDialogFont(composite); + applyDialogFont(composite); return composite; } /** * Returns whether the user has selected to add referenced projects. - * + * * @return whether the user has selected to add referenced projects */ public boolean isAddReferencedProjects() { diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/UpAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/UpAction.java index 85b3a6f7b33..288ba46741e 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/UpAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/UpAction.java @@ -7,29 +7,29 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.sourcelookup; - +package org.eclipse.cdt.debug.internal.ui.sourcelookup; + import java.util.List; import org.eclipse.debug.core.sourcelookup.ISourceContainer; import org.eclipse.jface.viewers.IStructuredSelection; /** - * The action used to move source containers up in the list + * The action used to move source containers up in the list */ public class UpAction extends SourceContainerAction { - + public UpAction() { super(SourceLookupUIMessages.UpAction_0); } /** * Moves all selected entries up one position (if possible). - * + * * @see IAction#run() */ @Override @@ -50,16 +50,17 @@ public class UpAction extends SourceContainerAction { list.set(index, temp); } top = index; - } + } setEntries(list); } - + /** * @see SelectionListenerAction#updateSelection(IStructuredSelection) */ @Override protected boolean updateSelection(IStructuredSelection selection) { //check that something is selected, it's not first in the list, and it is a root tree node. - return !selection.isEmpty() && !isIndexSelected(selection, 0) && getViewer().getTree().getSelection()[0].getParentItem()==null; + return !selection.isEmpty() && !isIndexSelected(selection, 0) + && getViewer().getTree().getSelection()[0].getParentItem() == null; } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/AbstractDebugEventHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/AbstractDebugEventHandler.java index 4333bce23f6..96c0ac019a6 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/AbstractDebugEventHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/AbstractDebugEventHandler.java @@ -13,7 +13,6 @@ *******************************************************************************/ package org.eclipse.cdt.debug.internal.ui.views; - import org.eclipse.debug.core.DebugEvent; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.IDebugEventSetListener; @@ -32,20 +31,20 @@ import org.eclipse.ui.PlatformUI; * Handles debug events, updating a view and viewer. */ public abstract class AbstractDebugEventHandler implements IDebugEventSetListener { - + /** * This event handler's view */ private AbstractDebugView fView; - + /** * Constructs an event handler for the given view. - * + * * @param view debug view */ public AbstractDebugEventHandler(AbstractDebugView view) { setView(view); - DebugPlugin plugin= DebugPlugin.getDefault(); + DebugPlugin plugin = DebugPlugin.getDefault(); plugin.addDebugEventListener(this); } @@ -53,13 +52,13 @@ public abstract class AbstractDebugEventHandler implements IDebugEventSetListene * Returns the active workbench page or <code>null</code> if none. */ protected IWorkbenchPage getActivePage() { - IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window == null) { return null; } return window.getActivePage(); } - + /** * @see IDebugEventSetListener#handleDebugEvents(DebugEvent[]) */ @@ -68,7 +67,7 @@ public abstract class AbstractDebugEventHandler implements IDebugEventSetListene if (!isAvailable()) { return; } - Runnable r= new Runnable() { + Runnable r = new Runnable() { @Override public void run() { if (isAvailable()) { @@ -81,7 +80,7 @@ public abstract class AbstractDebugEventHandler implements IDebugEventSetListene }; getView().asyncExec(r); } - + /** * Updates this view for the given debug events. Unlike * doHandleDebugEvents(DebugEvent[]) which is only called if the view is @@ -91,21 +90,21 @@ public abstract class AbstractDebugEventHandler implements IDebugEventSetListene */ protected void updateForDebugEvents(DebugEvent[] events) { } - + /** * Implementation specific handling of debug events. * Subclasses should override. */ - protected abstract void doHandleDebugEvents(DebugEvent[] events); - + protected abstract void doHandleDebugEvents(DebugEvent[] events); + /** - * Helper method for inserting the given element in the tree viewer - + * Helper method for inserting the given element in the tree viewer - * must be called in UI thread */ protected void insert(Object element) { TreeViewer viewer = getTreeViewer(); if (isAvailable() && viewer != null) { - Object parent= ((ITreeContentProvider)viewer.getContentProvider()).getParent(element); + Object parent = ((ITreeContentProvider) viewer.getContentProvider()).getParent(element); // a parent can be null for a debug target or process that has not yet been associated // with a launch if (parent != null) { @@ -116,7 +115,7 @@ public abstract class AbstractDebugEventHandler implements IDebugEventSetListene } /** - * Helper method to remove the given element from the tree viewer - + * Helper method to remove the given element from the tree viewer - * must be called in UI thread. */ protected void remove(Object element) { @@ -133,7 +132,7 @@ public abstract class AbstractDebugEventHandler implements IDebugEventSetListene protected void labelChanged(Object element) { if (isAvailable()) { getView().showViewer(); - getStructuredViewer().update(element, new String[] {IBasicPropertyConstants.P_TEXT}); + getStructuredViewer().update(element, new String[] { IBasicPropertyConstants.P_TEXT }); } } @@ -142,20 +141,20 @@ public abstract class AbstractDebugEventHandler implements IDebugEventSetListene */ protected void refresh(Object element) { if (isAvailable()) { - getView().showViewer(); - getStructuredViewer().refresh(element); + getView().showViewer(); + getStructuredViewer().refresh(element); } } - + /** * Refresh the viewer - must be called in UI thread. */ public void refresh() { if (isAvailable()) { - getView().showViewer(); - getStructuredViewer().refresh(); + getView().showViewer(); + getStructuredViewer().refresh(); } - } + } /** * Helper method to select and reveal the given element - must be called in UI thread @@ -165,28 +164,28 @@ public abstract class AbstractDebugEventHandler implements IDebugEventSetListene getViewer().setSelection(new StructuredSelection(element), true); } } - + /** * De-registers this event handler from the debug model. */ public void dispose() { - DebugPlugin plugin= DebugPlugin.getDefault(); + DebugPlugin plugin = DebugPlugin.getDefault(); plugin.removeDebugEventListener(this); } - + /** * Returns the view this event handler is * updating. - * + * * @return debug view */ protected AbstractDebugView getView() { return this.fView; } - + /** * Sets the view this event handler is updating. - * + * * @param view debug view */ private void setView(AbstractDebugView view) { @@ -194,63 +193,63 @@ public abstract class AbstractDebugEventHandler implements IDebugEventSetListene } /** - * Returns the viewer this event handler is + * Returns the viewer this event handler is * updating. - * + * * @return viewer - */ + */ protected Viewer getViewer() { return getView().getViewer(); } - + /** * Returns this event handler's viewer as a tree * viewer or <code>null</code> if none. - * + * * @return this event handler's viewer as a tree * viewer or <code>null</code> if none */ protected TreeViewer getTreeViewer() { if (getViewer() instanceof TreeViewer) { - return (TreeViewer)getViewer(); - } + return (TreeViewer) getViewer(); + } return null; } /** * Returns this event handler's viewer as a structured * viewer or <code>null</code> if none. - * + * * @return this event handler's viewer as a structured * viewer or <code>null</code> if none */ protected StructuredViewer getStructuredViewer() { if (getViewer() instanceof StructuredViewer) { - return (StructuredViewer)getViewer(); - } + return (StructuredViewer) getViewer(); + } return null; } - + /** * Returns whether this event handler's viewer is * currently available. - * + * * @return whether this event handler's viewer is * currently available */ protected boolean isAvailable() { return getView().isAvailable(); } - + /** * Returns whether this event handler's view is currently visible. - * + * * @return whether this event handler's view is currently visible */ protected boolean isViewVisible() { - return getView().isVisible(); - } - + return getView().isVisible(); + } + /** * Called when this event handler's view becomes visible. Default behavior * is to refresh the view. @@ -258,7 +257,7 @@ public abstract class AbstractDebugEventHandler implements IDebugEventSetListene protected void viewBecomesVisible() { refresh(); } - + /** * Called when this event handler's view becomes hidden. Default behavior is * to do nothing. Subclasses may override. diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/AbstractDebugEventHandlerView.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/AbstractDebugEventHandlerView.java index 6fcbac46965..e485208e6d0 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/AbstractDebugEventHandlerView.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/AbstractDebugEventHandlerView.java @@ -13,7 +13,6 @@ *******************************************************************************/ package org.eclipse.cdt.debug.internal.ui.views; - import org.eclipse.debug.ui.AbstractDebugView; import org.eclipse.jface.action.IStatusLineManager; @@ -30,22 +29,22 @@ public abstract class AbstractDebugEventHandlerView extends AbstractDebugView { /** * Sets the event handler for this view - * + * * @param eventHandler event handler */ protected void setEventHandler(AbstractDebugEventHandler eventHandler) { this.fEventHandler = eventHandler; } - + /** * Returns the event handler for this view - * + * * @return The event handler for this view */ protected AbstractDebugEventHandler getEventHandler() { return this.fEventHandler; - } - + } + /** * @see IWorkbenchPart#dispose() */ @@ -54,9 +53,9 @@ public abstract class AbstractDebugEventHandlerView extends AbstractDebugView { super.dispose(); if (getEventHandler() != null) { getEventHandler().dispose(); - } + } } - + /** * @see org.eclipse.debug.ui.AbstractDebugView#becomesHidden() */ @@ -74,9 +73,9 @@ public abstract class AbstractDebugEventHandlerView extends AbstractDebugView { super.becomesVisible(); getEventHandler().viewBecomesVisible(); } - + protected void clearStatusLine() { - IStatusLineManager manager = getViewSite().getActionBars().getStatusLineManager(); + IStatusLineManager manager = getViewSite().getActionBars().getStatusLineManager(); manager.setErrorMessage(null); manager.setMessage(null); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/IDebugExceptionHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/IDebugExceptionHandler.java index 5b1a454ce5f..1e6b832c4ec 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/IDebugExceptionHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/IDebugExceptionHandler.java @@ -14,15 +14,15 @@ package org.eclipse.cdt.debug.internal.ui.views; import org.eclipse.debug.core.DebugException; - + /** * A plugable exception handler. */ public interface IDebugExceptionHandler { /** * Handles the given debug exception. - * + * * @param e debug exception */ - public abstract void handleException( DebugException e ); + public abstract void handleException(DebugException e); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/debuggerconsole/ConsoleMessages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/debuggerconsole/ConsoleMessages.java index 8991225df47..f63d43d8a73 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/debuggerconsole/ConsoleMessages.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/debuggerconsole/ConsoleMessages.java @@ -16,12 +16,12 @@ public class ConsoleMessages extends NLS { public static String ConsoleMessages_no_console; public static String ConsoleDropDownAction_name; public static String ConsoleDropDownAction_description; - + static { // initialize resource bundle NLS.initializeMessages(ConsoleMessages.class.getName(), ConsoleMessages.class); } - + private ConsoleMessages() { } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/debuggerconsole/DebuggerConsoleDropDownAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/debuggerconsole/DebuggerConsoleDropDownAction.java index 86d0ac18705..a1f8ffe91bb 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/debuggerconsole/DebuggerConsoleDropDownAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/debuggerconsole/DebuggerConsoleDropDownAction.java @@ -95,7 +95,7 @@ public class DebuggerConsoleDropDownAction extends Action implements IMenuCreato private void addActionToMenu(Menu parent, Action action, int accelerator) { if (accelerator < 10) { - StringBuffer label= new StringBuffer(); + StringBuffer label = new StringBuffer(); //add the numerical accelerator label.append('&'); label.append(accelerator); @@ -103,7 +103,7 @@ public class DebuggerConsoleDropDownAction extends Action implements IMenuCreato label.append(action.getText()); action.setText(label.toString()); } - ActionContributionItem item= new ActionContributionItem(action); + ActionContributionItem item = new ActionContributionItem(action); item.fill(parent, -1); } @@ -118,7 +118,7 @@ public class DebuggerConsoleDropDownAction extends Action implements IMenuCreato break; } } - int next = idx+1; + int next = idx + 1; if (next >= consoles.length) { next = 0; } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/debuggerconsole/DebuggerConsoleManager.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/debuggerconsole/DebuggerConsoleManager.java index 9fcbe73d6e2..6b274de6c0b 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/debuggerconsole/DebuggerConsoleManager.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/debuggerconsole/DebuggerConsoleManager.java @@ -54,16 +54,16 @@ public class DebuggerConsoleManager implements IDebuggerConsoleManager { /** A list of all known consoles */ private ArrayList<IDebuggerConsole> fConsoleList = new ArrayList<>(); - + /** A list of listeners registered for notifications of changes to consoles */ private ListenerList<IConsoleListener> fConsoleListeners = new ListenerList<>(); - + /** A list of registered console page participants */ private List<ConsolePageParticipantExtension> fPageParticipants; private OpenDebuggerConsoleViewJob fOpenDebuggerConsoleViewJob = new OpenDebuggerConsoleViewJob(); private ShowDebuggerConsoleViewJob fShowDebuggerConsoleViewJob = new ShowDebuggerConsoleViewJob(); - + @Override public void addConsoleListener(IConsoleListener listener) { fConsoleListeners.add(listener); @@ -76,16 +76,16 @@ public class DebuggerConsoleManager implements IDebuggerConsoleManager { @Override public IDebuggerConsole[] getConsoles() { - synchronized (fConsoleList) { - return fConsoleList.toArray(new IDebuggerConsole[fConsoleList.size()]); - } + synchronized (fConsoleList) { + return fConsoleList.toArray(new IDebuggerConsole[fConsoleList.size()]); + } } - + @Override public void addConsole(IDebuggerConsole console) { - synchronized (fConsoleList) { - fConsoleList.add(console); - } + synchronized (fConsoleList) { + fConsoleList.add(console); + } for (IConsoleListener listener : fConsoleListeners) { listener.consolesAdded(new IConsole[] { console }); } @@ -93,9 +93,9 @@ public class DebuggerConsoleManager implements IDebuggerConsoleManager { @Override public void removeConsole(IDebuggerConsole console) { - synchronized (fConsoleList) { - fConsoleList.remove(console); - } + synchronized (fConsoleList) { + fConsoleList.remove(console); + } for (IConsoleListener listener : fConsoleListeners) { listener.consolesRemoved(new IConsole[] { console }); } @@ -132,14 +132,14 @@ public class DebuggerConsoleManager implements IDebuggerConsoleManager { // Without this richer EvaluationContext, the information about // plugin activation is not available and all that can be checked is // the type of console. - IEvaluationContext context = DebugUIPlugin.createEvaluationContext(console); - Expression expression = getEnablementExpression(); - if (expression != null){ - EvaluationResult evaluationResult = expression.evaluate(context); - return evaluationResult == EvaluationResult.TRUE; - } - return true; - } + IEvaluationContext context = DebugUIPlugin.createEvaluationContext(console); + Expression expression = getEnablementExpression(); + if (expression != null) { + EvaluationResult evaluationResult = expression.evaluate(context); + return evaluationResult == EvaluationResult.TRUE; + } + return true; + } }; fPageParticipants.add(extension); } @@ -167,14 +167,14 @@ public class DebuggerConsoleManager implements IDebuggerConsoleManager { @Override public IStatus runInUIThread(IProgressMonitor monitor) { - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window != null) { - IWorkbenchPage page = window.getActivePage(); - if (page != null) { - boolean consoleFound = false; + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window != null) { + IWorkbenchPage page = window.getActivePage(); + if (page != null) { + boolean consoleFound = false; IViewPart view = page.findView(DebuggerConsoleView.DEBUGGER_CONSOLE_VIEW_ID); if (view != null) { - DebuggerConsoleView consoleView = (DebuggerConsoleView)view; + DebuggerConsoleView consoleView = (DebuggerConsoleView) view; boolean consoleVisible = page.isPartVisible(consoleView); if (consoleVisible) { consoleFound = true; @@ -184,21 +184,19 @@ public class DebuggerConsoleManager implements IDebuggerConsoleManager { if (!consoleFound) { try { - DebuggerConsoleView consoleView = - (DebuggerConsoleView)page.showView(DebuggerConsoleView.DEBUGGER_CONSOLE_VIEW_ID, - null, - IWorkbenchPage.VIEW_CREATE); + DebuggerConsoleView consoleView = (DebuggerConsoleView) page.showView( + DebuggerConsoleView.DEBUGGER_CONSOLE_VIEW_ID, null, IWorkbenchPage.VIEW_CREATE); page.bringToTop(consoleView); } catch (PartInitException e) { CDebugUIPlugin.log(e); } } - } - } + } + } return Status.OK_STATUS; } } - + private class OpenDebuggerConsoleViewJob extends WorkbenchJob { OpenDebuggerConsoleViewJob() { super("Open GDB Console View"); //$NON-NLS-1$ @@ -208,23 +206,22 @@ public class DebuggerConsoleManager implements IDebuggerConsoleManager { @Override public IStatus runInUIThread(IProgressMonitor monitor) { - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window != null) { - IWorkbenchPage page = window.getActivePage(); - if (page != null) { - IViewPart view = page.findView(DebuggerConsoleView.DEBUGGER_CONSOLE_VIEW_ID); - if (view == null || !page.isPartVisible(view)) { - try { - page.showView(DebuggerConsoleView.DEBUGGER_CONSOLE_VIEW_ID, - null, - IWorkbenchPage.VIEW_CREATE); - } catch (PartInitException e) { - CDebugUIPlugin.log(e); - } + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window != null) { + IWorkbenchPage page = window.getActivePage(); + if (page != null) { + IViewPart view = page.findView(DebuggerConsoleView.DEBUGGER_CONSOLE_VIEW_ID); + if (view == null || !page.isPartVisible(view)) { + try { + page.showView(DebuggerConsoleView.DEBUGGER_CONSOLE_VIEW_ID, null, + IWorkbenchPage.VIEW_CREATE); + } catch (PartInitException e) { + CDebugUIPlugin.log(e); } - } - } - return Status.OK_STATUS; + } + } + } + return Status.OK_STATUS; } } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/debuggerconsole/DebuggerConsoleView.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/debuggerconsole/DebuggerConsoleView.java index 4852dfcdc1e..18040b411d4 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/debuggerconsole/DebuggerConsoleView.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/debuggerconsole/DebuggerConsoleView.java @@ -50,23 +50,23 @@ import org.eclipse.ui.part.PageSwitcher; /** * The Debugger console view shows different {@link IDebuggerConsole}. - * + * * This class extends {@link IConsoleView} to allow it to easily display * consoles of type {@link IOConsole}. - * + * * @see {@link IDebuggerConsoleManager} */ -public class DebuggerConsoleView extends PageBookView +public class DebuggerConsoleView extends PageBookView implements IConsoleView, IDebuggerConsoleView, IConsoleListener, IPropertyChangeListener, IPartListener2 { public static final String DEBUGGER_CONSOLE_VIEW_ID = "org.eclipse.cdt.debug.ui.debuggerConsoleView"; //$NON-NLS-1$ - public static final String DROP_DOWN_ACTION_ID = DEBUGGER_CONSOLE_VIEW_ID + ".DebuggerConsoleDropDownAction"; //$NON-NLS-1$ + public static final String DROP_DOWN_ACTION_ID = DEBUGGER_CONSOLE_VIEW_ID + ".DebuggerConsoleDropDownAction"; //$NON-NLS-1$ /** * Stack of consoles in MRU order */ private List<IDebuggerConsole> fStack = new ArrayList<>(); - + /** The console being displayed, or <code>null</code> if none */ private IDebuggerConsole fActiveConsole; @@ -84,7 +84,7 @@ public class DebuggerConsoleView extends PageBookView * Map of consoles to array of page participants */ private Map<IDebuggerConsole, ListenerList<IConsolePageParticipant>> fConsoleToPageParticipants = new HashMap<>(); - + /** * Whether this view is active */ @@ -99,7 +99,7 @@ public class DebuggerConsoleView extends PageBookView // create pages for existing consoles IConsole[] consoles = getConsoleManager().getConsoles(); consolesAdded(consoles); - + // add as a listener for new consoles getConsoleManager().addConsoleListener(this); // register for part events @@ -110,7 +110,7 @@ public class DebuggerConsoleView extends PageBookView @Override protected PageRec doCreatePage(IWorkbenchPart dummyPart) { - DebuggerConsoleWorkbenchPart part = (DebuggerConsoleWorkbenchPart)dummyPart; + DebuggerConsoleWorkbenchPart part = (DebuggerConsoleWorkbenchPart) dummyPart; IDebuggerConsole console = fPartToConsole.get(part); IPageBookViewPage page = console.createDebuggerPage(this); initPage(page); @@ -118,26 +118,28 @@ public class DebuggerConsoleView extends PageBookView console.addPropertyChangeListener(this); // initialize page participants - IConsolePageParticipant[] consoleParticipants = ((DebuggerConsoleManager)getConsoleManager()).getPageParticipants(console); + IConsolePageParticipant[] consoleParticipants = ((DebuggerConsoleManager) getConsoleManager()) + .getPageParticipants(console); final ListenerList<IConsolePageParticipant> participants = new ListenerList<>(); for (int i = 0; i < consoleParticipants.length; i++) { participants.add(consoleParticipants[i]); } fConsoleToPageParticipants.put(console, participants); for (IConsolePageParticipant participant : participants) { - SafeRunner.run(new ISafeRunnable() { + SafeRunner.run(new ISafeRunnable() { @Override public void run() throws Exception { participant.init(page, console); } + @Override public void handleException(Throwable exception) { CDebugUIPlugin.log(exception); participants.remove(participant); } }); - } - + } + return new PageRec(dummyPart, page); } @@ -210,7 +212,7 @@ public class DebuggerConsoleView extends PageBookView fStack.add(0, fActiveConsole); activateParticipants(fActiveConsole); } - + updateTitle(); } @@ -225,22 +227,23 @@ public class DebuggerConsoleView extends PageBookView final ListenerList<IConsolePageParticipant> listeners = getParticipants(console); if (listeners != null) { for (IConsolePageParticipant participant : listeners) { - SafeRunner.run(new ISafeRunnable() { + SafeRunner.run(new ISafeRunnable() { @Override public void run() throws Exception { participant.activated(); } + @Override public void handleException(Throwable exception) { CDebugUIPlugin.log(exception); listeners.remove(participant); } }); - } + } } } } - + /** * Returns the page participants registered for the given console, or * <code>null</code> @@ -303,10 +306,10 @@ public class DebuggerConsoleView extends PageBookView fConsoleToPart.remove(console); console.removePropertyChangeListener(this); - - if (fPartToConsole.isEmpty()) { - fActiveConsole = null; - } + + if (fPartToConsole.isEmpty()) { + fActiveConsole = null; + } } @Override @@ -336,7 +339,8 @@ public class DebuggerConsoleView extends PageBookView IDebuggerConsole[] allConsoles = getConsoleManager().getConsoles(); for (IDebuggerConsole registered : allConsoles) { if (registered.equals(console)) { - DebuggerConsoleWorkbenchPart part = new DebuggerConsoleWorkbenchPart(registered, getSite()); + DebuggerConsoleWorkbenchPart part = new DebuggerConsoleWorkbenchPart(registered, + getSite()); fConsoleToPart.put(registered, part); fPartToConsole.put(part, registered); // Must call partActivated() to create the page @@ -391,12 +395,12 @@ public class DebuggerConsoleView extends PageBookView // Already displayed return; } - + DebuggerConsoleWorkbenchPart part = fConsoleToPart.get(console); if (part != null) { partActivated(part); // let the console know it's being activated - fActiveConsole.consoleSelected(); + fActiveConsole.consoleSelected(); } } @@ -421,24 +425,24 @@ public class DebuggerConsoleView extends PageBookView /** * Initialize the PageSwitcher. * The page switcher is triggered using a keyboard shortcut - * configured in the user's eclipse and allows to switch + * configured in the user's eclipse and allows to switch * pages using a popup. */ private void initPageSwitcher() { new PageSwitcher(this) { @Override public void activatePage(Object page) { - display((IDebuggerConsole)page); + display((IDebuggerConsole) page); } @Override public ImageDescriptor getImageDescriptor(Object page) { - return ((IDebuggerConsole)page).getImageDescriptor(); + return ((IDebuggerConsole) page).getImageDescriptor(); } @Override public String getName(Object page) { - return ((IDebuggerConsole)page).getName(); + return ((IDebuggerConsole) page).getName(); } @Override @@ -472,7 +476,7 @@ public class DebuggerConsoleView extends PageBookView @Override public void display(IConsole console) { if (console instanceof IDebuggerConsole) { - display((IDebuggerConsole)console); + display((IDebuggerConsole) console); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/debuggerconsole/DebuggerConsoleWorkbenchPart.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/debuggerconsole/DebuggerConsoleWorkbenchPart.java index e936ed4ecbd..a152578e71e 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/debuggerconsole/DebuggerConsoleWorkbenchPart.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/debuggerconsole/DebuggerConsoleWorkbenchPart.java @@ -27,8 +27,8 @@ public class DebuggerConsoleWorkbenchPart implements IWorkbenchPart { @Override public boolean equals(Object obj) { - return (obj instanceof DebuggerConsoleWorkbenchPart) && - fConsole.equals(((DebuggerConsoleWorkbenchPart)obj).fConsole); + return (obj instanceof DebuggerConsoleWorkbenchPart) + && fConsole.equals(((DebuggerConsoleWorkbenchPart) obj).fConsole); } @Override diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/debuggerconsole/DebuggerShowConsoleAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/debuggerconsole/DebuggerShowConsoleAction.java index 2801eab1a65..f4eabd18d34 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/debuggerconsole/DebuggerShowConsoleAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/debuggerconsole/DebuggerShowConsoleAction.java @@ -34,7 +34,7 @@ public class DebuggerShowConsoleAction extends Action { */ public static void showConsole(IDebuggerConsole console, DebuggerConsoleView consoleView) { if (!console.equals(consoleView.getCurrentConsole())) { - consoleView.display(console); + consoleView.display(console); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/BaseViewer.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/BaseViewer.java index e9e6cee7fee..f378051450a 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/BaseViewer.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/BaseViewer.java @@ -54,7 +54,7 @@ abstract class BaseViewer extends TreeViewer { setComparator(getViewerComparator(selector)); getTree().setSortColumn((TreeColumn) e.getSource()); getTree().setSortDirection(column_sort_order[selector] == ExecutablesView.ASCENDING ? SWT.UP : SWT.DOWN); - column_sort_order[selector] *= -1; + column_sort_order[selector] *= -1; } } @@ -62,9 +62,9 @@ abstract class BaseViewer extends TreeViewer { public BaseViewer(ExecutablesView view, Composite parent, int style) { super(parent, style); executablesView = view; - + // default all columns sort order to ascending - for (int i=0; i<NUM_COLUMNS; i++) { + for (int i = 0; i < NUM_COLUMNS; i++) { column_sort_order[i] = ExecutablesView.ASCENDING; } } @@ -85,9 +85,9 @@ abstract class BaseViewer extends TreeViewer { protected void saveColumnSettings(Preferences preferences) { Tree tree = getTree(); - + // save the column order - StringBuilder columnOrder = new StringBuilder(); + StringBuilder columnOrder = new StringBuilder(); for (int index : tree.getColumnOrder()) { columnOrder.append(","); //$NON-NLS-1$ columnOrder.append(Integer.toString(index)); @@ -98,17 +98,17 @@ abstract class BaseViewer extends TreeViewer { // save which column was sorted and in which direction TreeColumn sortedColumn = tree.getSortColumn(); - for (int i=0; i<tree.getColumnCount(); i++) { + for (int i = 0; i < tree.getColumnCount(); i++) { if (sortedColumn.equals(tree.getColumn(i))) { preferences.setValue(getSortedColumnIndexKey(), i); preferences.setValue(getSortedColumnDirectionKey(), tree.getSortDirection()); break; } } - + // save the visible state of each columns (1 is visible, 0 is not) String visibleColumns = ""; //$NON-NLS-1$ - for (int i=0; i<tree.getColumnCount(); i++) { + for (int i = 0; i < tree.getColumnCount(); i++) { if (tree.getColumn(i).getWidth() > 0) { visibleColumns += ",1"; //$NON-NLS-1$ } else { @@ -119,7 +119,7 @@ abstract class BaseViewer extends TreeViewer { visibleColumns = visibleColumns.substring(1); preferences.setValue(getVisibleColumnsKey(), visibleColumns); } - + protected void restoreColumnSettings(Preferences preferences) { Tree tree = getTree(); @@ -128,12 +128,12 @@ abstract class BaseViewer extends TreeViewer { if (columnOrder.length() > 0) { String[] columns = columnOrder.split(","); //$NON-NLS-1$ int[] columnNumbers = new int[columns.length]; - for (int i=0; i<columns.length; i++) { + for (int i = 0; i < columns.length; i++) { columnNumbers[i] = Integer.parseInt(columns[i]); } tree.setColumnOrder(columnNumbers); } - + // restore the sorted column int sortedColumnIndex = preferences.getInt(getSortedColumnIndexKey()); int sortedColumnDirection = preferences.getInt(getSortedColumnDirectionKey()); @@ -143,29 +143,30 @@ abstract class BaseViewer extends TreeViewer { setComparator(getViewerComparator(sortedColumnIndex)); // remember the sort order for the column - column_sort_order[sortedColumnIndex] = sortedColumnDirection == SWT.UP ? ExecutablesView.ASCENDING : ExecutablesView.DESCENDING; - + column_sort_order[sortedColumnIndex] = sortedColumnDirection == SWT.UP ? ExecutablesView.ASCENDING + : ExecutablesView.DESCENDING; + // restore the visible state of each columns (1 is visible, 0 is not) String visibleColumns = preferences.getString(getVisibleColumnsKey()); if (visibleColumns.length() <= 0) { visibleColumns = getDefaultVisibleColumnsValue(); } String[] columns = visibleColumns.split(","); //$NON-NLS-1$ - for (int i=0; i<columns.length; i++) { + for (int i = 0; i < columns.length; i++) { if (columns[i].equals("0")) { //$NON-NLS-1$ tree.getColumn(i).setWidth(0); } } } - + abstract protected ViewerComparator getViewerComparator(int sortType); - + abstract protected String getColumnOrderKey(); - + abstract protected String getSortedColumnIndexKey(); - + abstract protected String getSortedColumnDirectionKey(); - + abstract protected String getVisibleColumnsKey(); abstract protected String getDefaultVisibleColumnsValue(); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesContentProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesContentProvider.java index 058ca560f36..d0725b1aafd 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesContentProvider.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesContentProvider.java @@ -34,7 +34,8 @@ import org.eclipse.ui.progress.WorkbenchJob; import com.ibm.icu.text.DateFormat; -class ExecutablesContentProvider extends ColumnLabelProvider implements IStructuredContentProvider, ITreeContentProvider, IExecutablesChangeListener { +class ExecutablesContentProvider extends ColumnLabelProvider + implements IStructuredContentProvider, ITreeContentProvider, IExecutablesChangeListener { final private TreeViewer viewer; @@ -98,7 +99,8 @@ class ExecutablesContentProvider extends ColumnLabelProvider implements IStructu IPath path = exe.getPath(); if (path != null && path.toFile().exists()) { long modified = path.toFile().lastModified(); - cellText = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(new Date(modified)); + cellText = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT) + .format(new Date(modified)); } cell.setImage(null); } else if (cell.getColumnIndex() == 5) { @@ -134,7 +136,7 @@ class ExecutablesContentProvider extends ColumnLabelProvider implements IStructu public IStatus runInUIThread(IProgressMonitor monitor) { viewer.refresh(null); if (viewer instanceof BaseViewer) { - ((BaseViewer)viewer).packColumns(); + ((BaseViewer) viewer).packColumns(); } return Status.OK_STATUS; } @@ -146,8 +148,8 @@ class ExecutablesContentProvider extends ColumnLabelProvider implements IStructu */ @Override public void executablesChanged(List<Executable> executables) { - // Our concern is only if the list of executables changed. The - // content provider for the source files viewer will care about + // Our concern is only if the list of executables changed. The + // content provider for the source files viewer will care about // whether the Executables themselves change } }
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesView.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesView.java index 25c7b1df10c..89ff4a8bd94 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesView.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesView.java @@ -69,7 +69,7 @@ import org.eclipse.ui.progress.WorkbenchJob; * the ExecutablesManager. This view has two subviews: one that shows the list * of executables and another that shows the list of source files in the * selected executable. - * + * */ public class ExecutablesView extends ViewPart { @@ -130,8 +130,10 @@ public class ExecutablesView extends ViewPart { * names and should not be localized. Display names are set when the columns * are created in the sub views. */ - private String[] columnNames = { Messages.ExecutablesView_ExeName, Messages.ExecutablesView_ExeProject, Messages.ExecutablesView_ExeLocation, Messages.ExecutablesView_ExeSize, Messages.ExecutablesView_ExeData, - Messages.ExecutablesView_ExeType, Messages.ExecutablesView_SrcName, Messages.ExecutablesView_SrcLocation, Messages.ExecutablesView_SrcOrgLocation, Messages.ExecutablesView_SrcSize, Messages.ExecutablesView_SrcDate, + private String[] columnNames = { Messages.ExecutablesView_ExeName, Messages.ExecutablesView_ExeProject, + Messages.ExecutablesView_ExeLocation, Messages.ExecutablesView_ExeSize, Messages.ExecutablesView_ExeData, + Messages.ExecutablesView_ExeType, Messages.ExecutablesView_SrcName, Messages.ExecutablesView_SrcLocation, + Messages.ExecutablesView_SrcOrgLocation, Messages.ExecutablesView_SrcSize, Messages.ExecutablesView_SrcDate, Messages.ExecutablesView_SrcType }; /** @@ -151,7 +153,7 @@ public class ExecutablesView extends ViewPart { /* * (non-Javadoc) - * + * * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) */ @Override @@ -161,7 +163,7 @@ public class ExecutablesView extends ViewPart { /* * (non-Javadoc) - * + * * @see org.eclipse.jface.viewers.IContentProvider#dispose() */ @Override @@ -170,7 +172,7 @@ public class ExecutablesView extends ViewPart { /* * (non-Javadoc) - * + * * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, * java.lang.Object, java.lang.Object) */ @@ -197,13 +199,14 @@ public class ExecutablesView extends ViewPart { /* * (non-Javadoc) - * + * * @see org.eclipse.jface.action.Action#run() */ @Override public void run() { - ListSelectionDialog dialog = new ListSelectionDialog(ExecutablesView.this.getExecutablesViewer().getTree().getShell(), this, - new ColumnContentProvider(), new ColumnLabelProvider(), Messages.ExecutablesView_SelectColumns); + ListSelectionDialog dialog = new ListSelectionDialog( + ExecutablesView.this.getExecutablesViewer().getTree().getShell(), this, new ColumnContentProvider(), + new ColumnLabelProvider(), Messages.ExecutablesView_SelectColumns); PlatformUI.getWorkbench().getHelpSystem().setHelp(this, CONFIGURE_COLUMNS_DIALOG); String[] visibleColumns = getVisibleColumns(); List<String> initialSelection = new ArrayList<String>(visibleColumns.length); @@ -239,13 +242,13 @@ public class ExecutablesView extends ViewPart { private Action configureColumnsAction; private IMemento memento; - + private IStructuredSelection oldSelection; private ISelectionProvider focusedViewer; /** * Create contents of the Executables View - * + * * @param parent */ @Override @@ -261,10 +264,11 @@ public class ExecutablesView extends ViewPart { sourceFilesViewer = new SourceFilesViewer(this, sashForm, SWT.BORDER | SWT.MULTI); executablesViewer.getTree().addFocusListener(new FocusListener() { - + @Override - public void focusLost(FocusEvent e) {} - + public void focusLost(FocusEvent e) { + } + @Override public void focusGained(FocusEvent e) { focusedViewer = executablesViewer; @@ -272,35 +276,35 @@ public class ExecutablesView extends ViewPart { }); sourceFilesViewer.getTree().addFocusListener(new FocusListener() { - + @Override - public void focusLost(FocusEvent e) {} - + public void focusLost(FocusEvent e) { + } + @Override public void focusGained(FocusEvent e) { focusedViewer = sourceFilesViewer; } }); - + ExecutablesView.this.getViewSite().setSelectionProvider(new ISelectionProvider() { - + @Override public void setSelection(ISelection selection) { getFocusedViewer().setSelection(selection); } - + @Override - public void removeSelectionChangedListener( - ISelectionChangedListener listener) { + public void removeSelectionChangedListener(ISelectionChangedListener listener) { executablesViewer.removeSelectionChangedListener(listener); sourceFilesViewer.removeSelectionChangedListener(listener); } - + @Override public ISelection getSelection() { return getFocusedViewer().getSelection(); } - + @Override public void addSelectionChangedListener(ISelectionChangedListener listener) { executablesViewer.addSelectionChangedListener(listener); @@ -337,9 +341,8 @@ public class ExecutablesView extends ViewPart { public void selectionChanged(SelectionChangedEvent event) { ISelection newSelection = event.getSelection(); if (newSelection instanceof IStructuredSelection) { - - if (oldSelection == null || !oldSelection.equals(newSelection)) - { + + if (oldSelection == null || !oldSelection.equals(newSelection)) { // update the remove action removeAction.setEnabled(!newSelection.isEmpty()); @@ -348,7 +351,7 @@ public class ExecutablesView extends ViewPart { final Object firstElement = ((IStructuredSelection) newSelection).getFirstElement(); sourceFilesViewer.setInput(firstElement); - + oldSelection = (IStructuredSelection) newSelection; } } @@ -409,70 +412,70 @@ public class ExecutablesView extends ViewPart { importAction = createImportAction(); toolBarManager.add(importAction); - + removeAction = createRemoveAction(); toolBarManager.add(removeAction); configureColumnsAction = createConfigureColumnsAction(); toolBarManager.add(configureColumnsAction); - + copyAction = createCopyAction(); - bars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction ); + bars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction); } private Action createCopyAction() { Action action = new Action("Copy") { //$NON-NLS-1$ - + }; return action; - + } - + private Action createRemoveAction() { Action action = new Action(Messages.ExecutablesView_Remove) { - + @Override - public void run() { + public void run() { ISelection selection = getExecutablesViewer().getSelection(); - if (selection instanceof IStructuredSelection) - { - Object[] selectedObjects = ((IStructuredSelection)selection).toArray(); + if (selection instanceof IStructuredSelection) { + Object[] selectedObjects = ((IStructuredSelection) selection).toArray(); ArrayList<Executable> selectedExes = new ArrayList<Executable>(); for (Object object : selectedObjects) { if (object instanceof Executable) - selectedExes.add((Executable) object); + selectedExes.add((Executable) object); } final Executable[] selectedExesArray = selectedExes.toArray(new Executable[selectedExes.size()]); - - boolean confirm = MessageDialog.openConfirm(getSite().getShell(), Messages.ExecutablesView_ConfirmRemoveExe, Messages.ExecutablesView_ConfirmRemoveSelected); - - if (confirm) - { + + boolean confirm = MessageDialog.openConfirm(getSite().getShell(), + Messages.ExecutablesView_ConfirmRemoveExe, Messages.ExecutablesView_ConfirmRemoveSelected); + + if (confirm) { Job removeJob = new WorkbenchJob(Messages.ExecutablesView_RemoveExes) { - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - IStatus result = ExecutablesManager.getExecutablesManager().removeExecutables(selectedExesArray, monitor); - if (result.getSeverity() != IStatus.OK) - { + @Override + public IStatus runInUIThread(IProgressMonitor monitor) { + IStatus result = ExecutablesManager.getExecutablesManager() + .removeExecutables(selectedExesArray, monitor); + if (result.getSeverity() != IStatus.OK) { StringBuilder message = new StringBuilder(result.getMessage()); if (result.isMultiStatus()) { IStatus[] children = result.getChildren(); for (int i = 0; i < children.length && i < 6; i++) { message.append(SEPARATOR); - message.append(children[i].getMessage()); + message.append(children[i].getMessage()); } } - MessageDialog.openWarning(getSite().getShell(), Messages.ExecutablesView_RemoveExes, message.toString()); + MessageDialog.openWarning(getSite().getShell(), Messages.ExecutablesView_RemoveExes, + message.toString()); } return result; } }; - removeJob.schedule(); + removeJob.schedule(); } } - + } }; action.setToolTipText(Messages.ExecutablesView_RemoveSelectedExes); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesViewCopyHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesViewCopyHandler.java index 04d14e10af8..30de71a8c02 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesViewCopyHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesViewCopyHandler.java @@ -57,10 +57,10 @@ public class ExecutablesViewCopyHandler extends AbstractHandler { } if (selection instanceof IStructuredSelection) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - PrintStream ps = new PrintStream(baos); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + PrintStream ps = new PrintStream(baos); - Iterator<?> iter = ((IStructuredSelection) selection).iterator(); + Iterator<?> iter = ((IStructuredSelection) selection).iterator(); while (iter.hasNext()) { Object obj = iter.next(); if (obj instanceof Executable) { @@ -73,15 +73,14 @@ public class ExecutablesViewCopyHandler extends AbstractHandler { ps.println(obj.toString()); } - ps.flush(); - try { + ps.flush(); + try { baos.flush(); } catch (IOException e) { throw new ExecutionException("", e); //$NON-NLS-1$ } Clipboard cp = getClipboard(); - cp.setContents(new Object[] { baos.toString().trim() }, - new Transfer[] { TextTransfer.getInstance() }); + cp.setContents(new Object[] { baos.toString().trim() }, new Transfer[] { TextTransfer.getInstance() }); } return null; diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesViewer.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesViewer.java index 19a6b609c8d..6f1733c6337 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesViewer.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesViewer.java @@ -42,7 +42,6 @@ public class ExecutablesViewer extends BaseViewer { private static final String P_COLUMN_SORT_DIRECTION_KEY_EXE = "columnSortDirectionKeyEXE"; //$NON-NLS-1$ private static final String P_VISIBLE_COLUMNS_KEY_EXE = "visibleColumnsKeyEXE"; //$NON-NLS-1$ - /** * Handles dropping executable files into the view */ @@ -103,7 +102,8 @@ public class ExecutablesViewer extends BaseViewer { }; popupMenuManager.addMenuListener(listener); popupMenuManager.setRemoveAllWhenShown(true); - getExecutablesView().getSite().registerContextMenu(popupMenuManager, this.getExecutablesView().getSite().getSelectionProvider()); + getExecutablesView().getSite().registerContextMenu(popupMenuManager, + this.getExecutablesView().getSite().getSelectionProvider()); Menu menu = popupMenuManager.createContextMenu(getTree()); getTree().setMenu(menu); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/SourceFilesContentProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/SourceFilesContentProvider.java index 15ebc9e24a9..9f705186f90 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/SourceFilesContentProvider.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/SourceFilesContentProvider.java @@ -41,34 +41,34 @@ public class SourceFilesContentProvider extends CElementContentProvider implemen static class QuickParseJob extends Job { final Executable executable; ITranslationUnit[] tus; - + public QuickParseJob(Executable executable) { - super (Messages.SourceFilesContentProvider_ReadingDebugSymbolInformationLabel - + executable.getName()); + super(Messages.SourceFilesContentProvider_ReadingDebugSymbolInformationLabel + executable.getName()); this.executable = executable; } - + @Override protected IStatus run(IProgressMonitor monitor) { - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "Quick parsing of executable for source files has begun (" + this + ')'); //$NON-NLS-1$ - + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().trace(null, "Quick parsing of executable for source files has begun (" + this + ')'); //$NON-NLS-1$ + // Ask the Executable for its source files. This could take a while... ITranslationUnit[] mytus = executable.getSourceFiles(monitor); - + IStatus status; if (!monitor.isCanceled()) { tus = mytus; status = Status.OK_STATUS; - } - else { + } else { status = Status.CANCEL_STATUS; } - - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "Quick parsing of executable has finished, status is " + status); //$NON-NLS-1$ + + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().trace(null, "Quick parsing of executable has finished, status is " + status); //$NON-NLS-1$ return status; } } - + /** * The collection of running file parsing jobs. Each executable file (not * object) can independently be parsed, and these parses can happen @@ -78,40 +78,40 @@ public class SourceFilesContentProvider extends CElementContentProvider implemen * first one is canceled. We cancel the first one, remove it from this list, * schedule a new one, then add that to the list. It's safe to assume the * canceled one will complete before the new one. - * - * <p> This collection must be accessed only from the UI thread + * + * <p> This collection must be accessed only from the UI thread */ private Map<IPath, QuickParseJob> pathToJobMap = new HashMap<IPath, SourceFilesContentProvider.QuickParseJob>(); - + /** those executables for which we asked the question and got a result. * NOTE: this contains a duplicate of into in Executable, because we can't * guarantee or check whether Executable still has the info itself. */ - private static class TUData{ + private static class TUData { /** Constructor used when search completes successfully */ public TUData(ITranslationUnit[] tus, long timestamp) { this.tus = tus; this.timestamp = timestamp; } - + /** Constructor used when search is canceled */ public TUData() { this.canceled = true; } - + ITranslationUnit[] tus; - /** IResource.getModificationStamp value of when this data was last updated */ + /** IResource.getModificationStamp value of when this data was last updated */ long timestamp; - + boolean canceled; } /** - * The cached file info. Key is the path of the executable. This collection must be accessed only on the UI thread. + * The cached file info. Key is the path of the executable. This collection must be accessed only on the UI thread. */ private Map<IPath, TUData> fetchedExecutables = new HashMap<IPath, TUData>(); private final SourceFilesViewer viewer; - + public SourceFilesContentProvider(SourceFilesViewer viewer) { super(true, true); this.viewer = viewer; @@ -134,12 +134,12 @@ public class SourceFilesContentProvider extends CElementContentProvider implemen }.schedule(); super.dispose(); } - + @Override public boolean hasChildren(Object element) { if (element instanceof ITranslationUnit) { - TranslationUnitInfo info = SourceFilesViewer.fetchTranslationUnitInfo( - (Executable) viewer.getInput(), element); + TranslationUnitInfo info = SourceFilesViewer.fetchTranslationUnitInfo((Executable) viewer.getInput(), + element); if (info != null && !info.exists) return false; } @@ -151,12 +151,13 @@ public class SourceFilesContentProvider extends CElementContentProvider implemen */ @Override public Object[] getElements(Object inputElement) { - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().traceEntry(null, inputElement); - + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().traceEntry(null, inputElement); + if (inputElement instanceof Executable) { final Executable executable = (Executable) inputElement; final IPath exePath = executable.getPath(); - + // look for a job that is currently fetching this info QuickParseJob job; job = pathToJobMap.get(exePath); @@ -167,7 +168,7 @@ public class SourceFilesContentProvider extends CElementContentProvider implemen // create a background job to look for the sources but don't start it yet job = new QuickParseJob(executable); pathToJobMap.put(exePath, job); - + // See if we have the result cached for this executable. If so // return that. It's also possible that the most resent search was // canceled @@ -175,7 +176,7 @@ public class SourceFilesContentProvider extends CElementContentProvider implemen TUData tud = fetchedExecutables.get(exePath); if (tud != null) { if (tud.canceled) - cachedResult = new String[]{Messages.SourceFilesContentProvider_Canceled}; + cachedResult = new String[] { Messages.SourceFilesContentProvider_Canceled }; else cachedResult = tud.tus; } @@ -183,24 +184,24 @@ public class SourceFilesContentProvider extends CElementContentProvider implemen pathToJobMap.remove(exePath); // removed the unused search job return cachedResult; } - + // Schedule the job; once it finishes, update the viewer final QuickParseJob theJob = job; job.addJobChangeListener(new JobChangeAdapter() { @Override public void done(final IJobChangeEvent event) { - new WorkbenchJob("refreshing source files viewer"){ //$NON-NLS-1$ + new WorkbenchJob("refreshing source files viewer") { //$NON-NLS-1$ @Override public IStatus runInUIThread(IProgressMonitor monitor) { if (event.getResult().isOK()) { - fetchedExecutables.put(exePath, new TUData(theJob.tus, theJob.executable.getResource().getModificationStamp())); - } - else { + fetchedExecutables.put(exePath, + new TUData(theJob.tus, theJob.executable.getResource().getModificationStamp())); + } else { fetchedExecutables.put(exePath, new TUData()); } pathToJobMap.values().remove(theJob); - + refreshViewer(executable); return Status.OK_STATUS; } @@ -209,14 +210,13 @@ public class SourceFilesContentProvider extends CElementContentProvider implemen }); job.schedule(); - + // show the user a string that lets him know we're searching return new String[] { Messages.SourceFilesContentProvider_Refreshing }; } return new Object[] {}; } - /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.executables.IExecutablesChangeListener#executablesListChanged() */ @@ -225,14 +225,14 @@ public class SourceFilesContentProvider extends CElementContentProvider implemen // we react via IExecutablesChangeListener2 methods } - /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.executables.IExecutablesChangeListener#executablesChanged(java.util.List) */ @Override public void executablesChanged(final List<Executable> executables) { - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().traceEntry(null, executables); - + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().traceEntry(null, executables); + new WorkbenchJob("Refreshing viewer") { //$NON-NLS-1$ @Override public IStatus runInUIThread(IProgressMonitor monitor) { @@ -241,12 +241,13 @@ public class SourceFilesContentProvider extends CElementContentProvider implemen fetchedExecutables.remove(exePath); QuickParseJob job = pathToJobMap.get(exePath); if (job != null) { - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "Cancelling QuickParseJob: " + job); //$NON-NLS-1$ + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().trace(null, "Cancelling QuickParseJob: " + job); //$NON-NLS-1$ job.cancel(); pathToJobMap.remove(exePath); } } - + if (!viewer.getControl().isDisposed()) { // See if our current input is one of the executables that has changed. for (Executable executable : executables) { @@ -254,7 +255,7 @@ public class SourceFilesContentProvider extends CElementContentProvider implemen // Executable.equals() is not a simple reference // check. Two Executable objects are equal if they // represent the same file on disk. I.e., our input - // object might not be one of the instances on the + // object might not be one of the instances on the // changed-list, but for sure the file on disk has // changed. Now, the manager that called this // listener has already told the Executable @@ -266,7 +267,7 @@ public class SourceFilesContentProvider extends CElementContentProvider implemen // tell that Executable to flush its source file // cache so that refreshing the viewer will cause a // fresh fetch of the source file information. - Executable execInput = (Executable)fInput; + Executable execInput = (Executable) fInput; if (executable != execInput) { execInput.setRefreshSourceFiles(true); } @@ -277,23 +278,22 @@ public class SourceFilesContentProvider extends CElementContentProvider implemen } return Status.OK_STATUS; } - + }.schedule(); } - + /* (non-Javadoc) * @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, final Object newInput) { super.inputChanged(viewer, oldInput, newInput); - + new WorkbenchJob("Refreshing viewer") { //$NON-NLS-1$ @Override public IStatus runInUIThread(IProgressMonitor monitor) { // pack because the quick parse job won't run - if (newInput instanceof Executable - && fetchedExecutables.containsKey(((Executable) newInput).getPath())) + if (newInput instanceof Executable && fetchedExecutables.containsKey(((Executable) newInput).getPath())) SourceFilesContentProvider.this.viewer.packColumns(); return Status.OK_STATUS; } @@ -305,8 +305,9 @@ public class SourceFilesContentProvider extends CElementContentProvider implemen */ @Override public void executablesAdded(final List<Executable> executables) { - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().traceEntry(null, executables); - + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().traceEntry(null, executables); + // Throw out our cached translation units for the executable *file* but // only if the file hasn't changed. Executable objects come and go // independently of the file on disk. @@ -321,7 +322,7 @@ public class SourceFilesContentProvider extends CElementContentProvider implemen fetchedExecutables.remove(exePath); } } - + if (!viewer.getControl().isDisposed()) { // See if current viewer input is one of the executables that // was added. If so, this is likely an exec that was rebuilt @@ -336,13 +337,15 @@ public class SourceFilesContentProvider extends CElementContentProvider implemen // message in the viewer table. for (Executable executable : executables) { if (executable.equals(fInput)) { - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "refreshing viewer; added executable is our current input"); //$NON-NLS-1$ - refreshViewer((Executable)fInput); + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().trace(null, + "refreshing viewer; added executable is our current input"); //$NON-NLS-1$ + refreshViewer((Executable) fInput); break; } } } - + return Status.OK_STATUS; } }.schedule(); @@ -353,8 +356,9 @@ public class SourceFilesContentProvider extends CElementContentProvider implemen */ @Override public void executablesRemoved(final List<Executable> executables) { - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().traceEntry(null, executables); - + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().traceEntry(null, executables); + // The fact that the Executable was removed from the workspace doesn't // mean we need to throw out the source file info we've cached. If a // project is closed then reopened, we are able to reuse the info as @@ -367,7 +371,8 @@ public class SourceFilesContentProvider extends CElementContentProvider implemen final IPath exePath = exec.getPath(); QuickParseJob job = pathToJobMap.get(exePath); if (job != null) { - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "Cancelling QuickParseJob: " + job); //$NON-NLS-1$ + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().trace(null, "Cancelling QuickParseJob: " + job); //$NON-NLS-1$ job.cancel(); pathToJobMap.remove(exePath); } @@ -380,20 +385,20 @@ public class SourceFilesContentProvider extends CElementContentProvider implemen /** * Restarts a parse of the current input (Executable) if and only if its * last search was canceled. The viewer is refresh accordingly. - * + * * <p> * Must be called on the UI thread - * + * */ public void restartCanceledExecutableParse() { assert Display.getCurrent() != null; - + Object input = viewer.getInput(); if (input instanceof Executable) { - final Executable executable = (Executable)input; + final Executable executable = (Executable) input; final IPath exePath = executable.getPath(); - // Ignore restart if there's an ongoing search. + // Ignore restart if there's an ongoing search. QuickParseJob job; job = pathToJobMap.get(exePath); if (job != null) { @@ -416,15 +421,15 @@ public class SourceFilesContentProvider extends CElementContentProvider implemen job.addJobChangeListener(new JobChangeAdapter() { @Override public void done(final IJobChangeEvent event) { - - new WorkbenchJob("refreshing source files viewer"){ //$NON-NLS-1$ + + new WorkbenchJob("refreshing source files viewer") { //$NON-NLS-1$ @Override public IStatus runInUIThread(IProgressMonitor monitor) { // Update the model with the search results if (event.getResult().isOK()) { - fetchedExecutables.put(exePath, new TUData(theJob.tus, theJob.executable.getResource().getModificationStamp())); - } - else { + fetchedExecutables.put(exePath, + new TUData(theJob.tus, theJob.executable.getResource().getModificationStamp())); + } else { // The search job apparently always completes // successfully or it was canceled (failure was // not a considered outcome). If it was canceled, @@ -432,7 +437,7 @@ public class SourceFilesContentProvider extends CElementContentProvider implemen fetchedExecutables.put(exePath, new TUData()); } pathToJobMap.values().remove(theJob); - + refreshViewer(executable); return Status.OK_STATUS; } @@ -448,12 +453,12 @@ public class SourceFilesContentProvider extends CElementContentProvider implemen refreshViewer(executable); } } - + /** * Utility method to invoke a viewer refresh for the given element * @param input the Executable to show content for - * - * <p> Must be called on the UI thread + * + * <p> Must be called on the UI thread */ private void refreshViewer(Executable input) { if (!viewer.getControl().isDisposed()) { @@ -464,4 +469,3 @@ public class SourceFilesContentProvider extends CElementContentProvider implemen } } } - diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/SourceFilesLabelProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/SourceFilesLabelProvider.java index 8db62a88b90..4939bee2e57 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/SourceFilesLabelProvider.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/SourceFilesLabelProvider.java @@ -44,13 +44,14 @@ public class SourceFilesLabelProvider extends TreeColumnViewerLabelProvider impl public SourceFilesLabelProvider(SourceFilesViewer viewer) { super(new CElementLabelProvider()); this.viewer = viewer; - + // brute-force clear the cache when executables change ExecutablesManager.getExecutablesManager().addExecutablesChangeListener(this); viewer.getControl().addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { - ExecutablesManager.getExecutablesManager().removeExecutablesChangeListener(SourceFilesLabelProvider.this); + ExecutablesManager.getExecutablesManager() + .removeExecutablesChangeListener(SourceFilesLabelProvider.this); } }); } @@ -64,13 +65,14 @@ public class SourceFilesLabelProvider extends TreeColumnViewerLabelProvider impl if (element instanceof ITranslationUnit) { tuInfo = SourceFilesViewer.fetchTranslationUnitInfo((Executable) viewer.getInput(), element); } - + int orgColumnIndex = cell.getColumnIndex(); if (orgColumnIndex == 0) { if (element instanceof String) { cell.setText((String) element); - Font italicFont = resourceManager.createFont(FontDescriptor.createFrom(viewer.getTree().getFont()).setStyle(SWT.ITALIC)); + Font italicFont = resourceManager + .createFont(FontDescriptor.createFrom(viewer.getTree().getFont()).setStyle(SWT.ITALIC)); cell.setFont(italicFont); } else { cell.setFont(viewer.getTree().getFont()); @@ -109,8 +111,8 @@ public class SourceFilesLabelProvider extends TreeColumnViewerLabelProvider impl cell.setText(null); if (tuInfo != null) { if (tuInfo.exists) { - String dateTimeString = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format( - new Date(tuInfo.lastModified)); + String dateTimeString = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT) + .format(new Date(tuInfo.lastModified)); cell.setText(dateTimeString); } } @@ -146,4 +148,3 @@ public class SourceFilesLabelProvider extends TreeColumnViewerLabelProvider impl } } -
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/SourceFilesViewer.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/SourceFilesViewer.java index 2fecf75cf9e..1282953c88a 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/SourceFilesViewer.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/SourceFilesViewer.java @@ -72,13 +72,13 @@ public class SourceFilesViewer extends BaseViewer { private static final String P_COLUMN_SORT_DIRECTION_KEY_SF = "columnSortDirectionKeySF"; //$NON-NLS-1$ private static final String P_VISIBLE_COLUMNS_KEY_SF = "visibleColumnsKeySF"; //$NON-NLS-1$ - TreeColumn originalLocationColumn; private Tree sourceFilesTree; - /** Tradeoff expensiveness of checking filesystem against likelihood + /** Tradeoff expensiveness of checking filesystem against likelihood * that files will be added/removed/changed in the given time period */ static final long FILE_CHECK_DELTA = 30 * 1000; - private static LRUCache<Object, TranslationUnitInfo> translationUnitInfoCache = new LRUCache<Object, TranslationUnitInfo>(1024); + private static LRUCache<Object, TranslationUnitInfo> translationUnitInfoCache = new LRUCache<Object, TranslationUnitInfo>( + 1024); public SourceFilesViewer(ExecutablesView view, Composite parent, int style) { super(view, parent, style); @@ -98,8 +98,8 @@ public class SourceFilesViewer extends BaseViewer { openSourceFile(event); } }); - - ExecutablesManager.getExecutablesManager().addExecutablesChangeListener(new IExecutablesChangeListener(){ + + ExecutablesManager.getExecutablesManager().addExecutablesChangeListener(new IExecutablesChangeListener() { @Override public void executablesListChanged() { // this doesn't directly affect us @@ -109,12 +109,13 @@ public class SourceFilesViewer extends BaseViewer { public void executablesChanged(List<Executable> executables) { // TODO: be more selective; we don't know what TUs go with which executables yet flushTranslationUnitCache(); - - // Note that we don't invoke a viewer refresh. Our content - // provider needs to also be listening for this notification. - // It's up to him to invoke a refresh on us if the model has + + // Note that we don't invoke a viewer refresh. Our content + // provider needs to also be listening for this notification. + // It's up to him to invoke a refresh on us if the model has // been affected by the Executable change - }}); + } + }); } private void openSourceFile(OpenEvent event) { @@ -207,7 +208,8 @@ public class SourceFilesViewer extends BaseViewer { Executable exe = (Executable) getInput(); String originalLocation1 = exe.getOriginalLocation(entry1); String originalLocation2 = exe.getOriginalLocation(entry2); - return getComparator().compare(originalLocation1, originalLocation2) * column_sort_order[ExecutablesView.ORG_LOCATION]; + return getComparator().compare(originalLocation1, originalLocation2) + * column_sort_order[ExecutablesView.ORG_LOCATION]; } return super.compare(viewer, e1, e2); } @@ -246,18 +248,18 @@ public class SourceFilesViewer extends BaseViewer { if (!(element instanceof ITranslationUnit)) { return null; } - + ITranslationUnit tu = (ITranslationUnit) element; long now = System.currentTimeMillis(); TranslationUnitInfo info; - + synchronized (translationUnitInfoCache) { info = (TranslationUnitInfo) translationUnitInfoCache.get(element); } if (info == null || info.nextCheckTimestamp <= now) { if (info == null) info = new TranslationUnitInfo(); - + info.location = tu.getLocation(); if (info.location != null) { // A source file with a non-absolute path has no local context; @@ -265,26 +267,25 @@ public class SourceFilesViewer extends BaseViewer { // java.io.File would be wrong since that class makes arbitrary // assumptions about where the file should be locally. See // similar comment in Executable.getSourceFiles() - if (Util.isNativeAbsolutePath(info.location.toOSString()) ) { + if (Util.isNativeAbsolutePath(info.location.toOSString())) { File file = info.location.toFile(); info.exists = file.exists(); if (info.exists) { info.fileLength = file.length(); info.lastModified = file.lastModified(); - } - else { + } else { info.fileLength = 0; info.lastModified = 0; } - } - else { + } else { info.exists = false; info.fileLength = 0; info.lastModified = 0; } - + info.originalLocation = new Path(executable.getOriginalLocation(tu)); - info.originalExists = Util.isNativeAbsolutePath(info.originalLocation.toOSString()) && info.originalLocation.toFile().exists(); + info.originalExists = Util.isNativeAbsolutePath(info.originalLocation.toOSString()) + && info.originalLocation.toFile().exists(); } else { info.exists = false; info.fileLength = 0; @@ -292,9 +293,9 @@ public class SourceFilesViewer extends BaseViewer { info.originalExists = false; info.originalLocation = null; } - + info.nextCheckTimestamp = System.currentTimeMillis() + FILE_CHECK_DELTA; - + synchronized (translationUnitInfoCache) { translationUnitInfoCache.put(element, info); } @@ -303,13 +304,13 @@ public class SourceFilesViewer extends BaseViewer { } /** - * + * */ static void flushTranslationUnitCache() { synchronized (translationUnitInfoCache) { translationUnitInfoCache.flush(); } - + } /** @@ -318,11 +319,11 @@ public class SourceFilesViewer extends BaseViewer { * canceled. If it wasn't canceled, this is a no-op. */ public void restartCanceledExecutableParse() { - SourceFilesContentProvider provider = (SourceFilesContentProvider)getContentProvider(); + SourceFilesContentProvider provider = (SourceFilesContentProvider) getContentProvider(); if (provider != null) { provider.restartCanceledExecutableParse(); } - + } }
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/AddMemoryBlockDialog.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/AddMemoryBlockDialog.java index fe130c7ece3..ef9b1eaed00 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/AddMemoryBlockDialog.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/AddMemoryBlockDialog.java @@ -38,12 +38,12 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; /** - * Dialog CDT puts up when adding a memory monitor to the memory view for a - * debug target that supports memory spaces. + * Dialog CDT puts up when adding a memory monitor to the memory view for a + * debug target that supports memory spaces. * <p> * It differs from the platform one in that you can enter an expression or * an address + memory space pair. - * + * * @since 3.2 */ public class AddMemoryBlockDialog extends TrayDialog implements ModifyListener, SelectionListener { @@ -56,8 +56,8 @@ public class AddMemoryBlockDialog extends TrayDialog implements ModifyListener, private Button fExpressionRadio; private String fAddress; private String fMemorySpace; - private boolean fEnteredExpression; // basically, which of the two radio buttons was selected when OK was hit - + private boolean fEnteredExpression; // basically, which of the two radio buttons was selected when OK was hit + /** The memory spaces to expose. Given to use at instantiation time. */ final private String[] fMemorySpaces; @@ -70,7 +70,7 @@ public class AddMemoryBlockDialog extends TrayDialog implements ModifyListener, private static List<String> sAddressHistory = new ArrayList<String>(); private static List<String> sExpressionHistory = new ArrayList<String>(); - + private static boolean sDefaultToExpression = true; public AddMemoryBlockDialog(Shell parentShell, String[] memorySpaces) { @@ -90,13 +90,11 @@ public class AddMemoryBlockDialog extends TrayDialog implements ModifyListener, */ @Override protected Control createDialogArea(Composite parent) { - PlatformUI.getWorkbench().getHelpSystem().setHelp( - parent, - IDebugUIConstants.PLUGIN_ID - + ".MonitorMemoryBlockDialog_context"); //$NON-NLS-1$ + PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, + IDebugUIConstants.PLUGIN_ID + ".MonitorMemoryBlockDialog_context"); //$NON-NLS-1$ // The button bar will work better if we make the parent composite - // a single column grid layout. For the widgets we add, we want a + // a single column grid layout. For the widgets we add, we want a // a two-column grid, so we just create a sub composite for that. GridLayout gridLayout = new GridLayout(); parent.setLayout(gridLayout); @@ -108,7 +106,7 @@ public class AddMemoryBlockDialog extends TrayDialog implements ModifyListener, composite.setLayout(gridLayout); gridData = new GridData(GridData.FILL_BOTH); composite.setLayoutData(gridData); - parent = composite; // for all our widgets, the two-column composite is the real parent + parent = composite; // for all our widgets, the two-column composite is the real parent fExpressionRadio = new Button(parent, SWT.RADIO); final int radioButtonWidth = fExpressionRadio.computeSize(SWT.DEFAULT, SWT.DEFAULT).x; @@ -117,7 +115,7 @@ public class AddMemoryBlockDialog extends TrayDialog implements ModifyListener, gridData.horizontalSpan = 2; fExpressionRadio.setLayoutData(gridData); fExpressionRadio.addSelectionListener(this); - + fExpressionInput = new Combo(parent, SWT.BORDER); gridData = new GridData(GridData.FILL_HORIZONTAL); gridData.horizontalSpan = 2; @@ -133,15 +131,15 @@ public class AddMemoryBlockDialog extends TrayDialog implements ModifyListener, fMemorySpaceInput = new Combo(parent, SWT.BORDER | SWT.READ_ONLY); gridData = new GridData(); - gridData.horizontalIndent = radioButtonWidth; + gridData.horizontalIndent = radioButtonWidth; fMemorySpaceInput.setLayoutData(gridData); fMemorySpaceInput.addSelectionListener(this); fMemorySpaceInput.setItems(fMemorySpaces); - + // Try to persist the mem space selection from one invocation of the // dialog to the next - String memSpaceSelection = null; + String memSpaceSelection = null; if (fPreviousMemorySpaceSelection != null) { String[] items = fMemorySpaceInput.getItems(); for (String item : items) { @@ -152,8 +150,7 @@ public class AddMemoryBlockDialog extends TrayDialog implements ModifyListener, } if (memSpaceSelection != null) { fMemorySpaceInput.setText(memSpaceSelection); - } - else { + } else { fMemorySpaceInput.select(0); // the n/a entry } @@ -161,25 +158,25 @@ public class AddMemoryBlockDialog extends TrayDialog implements ModifyListener, gridData = new GridData(GridData.FILL_HORIZONTAL); GC gc = new GC(fAddressInput); FontMetrics fm = gc.getFontMetrics(); - // Give enough room for a 64 bit hex address (25 is a guess at the combobox selector) + // Give enough room for a 64 bit hex address (25 is a guess at the combobox selector) gridData.minimumWidth = 18 * fm.getAverageCharWidth() + 25; gc.dispose(); fAddressInput.setLayoutData(gridData); fAddressInput.addModifyListener(this); fAddressInput.addVerifyListener(new VerifyListener() { - // limit entry to hex or decimal + // limit entry to hex or decimal @Override public void verifyText(VerifyEvent e) { e.doit = false; - final char c = e.character; - if (Character.isDigit(c) || ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F') || - c == 'x' || Character.isISOControl(e.character)) { + final char c = e.character; + if (Character.isDigit(c) || ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F') || c == 'x' + || Character.isISOControl(e.character)) { e.doit = true; } } }); - // add the history into the combo boxes + // add the history into the combo boxes String[] history = getHistory(sExpressionHistory); for (int i = 0; i < history.length; i++) fExpressionInput.add(history[i]); @@ -194,13 +191,12 @@ public class AddMemoryBlockDialog extends TrayDialog implements ModifyListener, fExpressionRadio.setSelection(true); fAddressRadio.setSelection(false); fExpressionInput.setFocus(); - } - else { + } else { fAddressRadio.setSelection(false); fAddressRadio.setSelection(true); fAddressInput.setFocus(); } - + return parent; } @@ -223,7 +219,7 @@ public class AddMemoryBlockDialog extends TrayDialog implements ModifyListener, fExpression = fExpressionInput.getText(); fAddress = fAddressInput.getText(); fMemorySpace = fMemorySpaceInput.getText(); - + // add to HISTORY list; add to the platform dialog's for the expression if (fExpression.length() > 0) addHistory(sExpressionHistory, fExpression); @@ -231,7 +227,7 @@ public class AddMemoryBlockDialog extends TrayDialog implements ModifyListener, addHistory(sAddressHistory, fAddress); fEnteredExpression = fExpressionRadio.getSelection(); - + fPreviousMemorySpaceSelection = fMemorySpace; super.okPressed(); } @@ -242,9 +238,8 @@ public class AddMemoryBlockDialog extends TrayDialog implements ModifyListener, @Override public void modifyText(ModifyEvent e) { // if user enters text into either the address field or the expression one, automatically - // select its associated radio button (and deselect the other, these are mutually exclusive) - if (e.widget == fAddressInput || - e.widget == fExpressionInput) { + // select its associated radio button (and deselect the other, these are mutually exclusive) + if (e.widget == fAddressInput || e.widget == fExpressionInput) { fAddressRadio.setSelection(e.widget != fExpressionInput); fExpressionRadio.setSelection(e.widget == fExpressionInput); @@ -275,16 +270,16 @@ public class AddMemoryBlockDialog extends TrayDialog implements ModifyListener, public boolean enteredExpression() { return fEnteredExpression; } - - private static void addHistory(List<String> list, String item) { + + private static void addHistory(List<String> list, String item) { if (!list.contains(item)) list.add(0, item); if (list.size() > 5) - list.remove(list.size()-1); + list.remove(list.size() - 1); } - - private static String[] getHistory(List<String> list) { + + private static String[] getHistory(List<String> list) { return list.toArray(new String[list.size()]); } @@ -294,7 +289,7 @@ public class AddMemoryBlockDialog extends TrayDialog implements ModifyListener, @Override public void widgetDefaultSelected(SelectionEvent e) { // TODO Auto-generated method stub - + } /* (non-Javadoc) @@ -302,19 +297,18 @@ public class AddMemoryBlockDialog extends TrayDialog implements ModifyListener, */ @Override public void widgetSelected(SelectionEvent e) { - // if user selects a memory space, select its associated radio button (and deselect the - // other, these are mutually exclusive) + // if user selects a memory space, select its associated radio button (and deselect the + // other, these are mutually exclusive) if (e.widget == fExpressionRadio) { fExpressionRadio.setSelection(true); fAddressRadio.setSelection(false); fExpressionInput.setFocus(); - } - else { + } else { fExpressionRadio.setSelection(false); fAddressRadio.setSelection(true); fAddressInput.setFocus(); } - + sDefaultToExpression = (e.widget == fExpressionInput); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/AddMemoryBlocks.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/AddMemoryBlocks.java index caa0759ea18..23b105cfc63 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/AddMemoryBlocks.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/AddMemoryBlocks.java @@ -55,33 +55,36 @@ import org.eclipse.ui.progress.UIJob; /** * Adds memory blocks to the Memory view. - * + * * <p> - * CDT adapter logic will link us to a CMemoryBlockRetrievalExtension + * CDT adapter logic will link us to a CMemoryBlockRetrievalExtension * if and only if the CDI backend support memory spaces. When this is the case, * the platform will call us to add a memory monitor to the Memory view. We - * must put up a dialog, handle the user input, create the memory blocks - * with default renderings and add them to the view. - * + * must put up a dialog, handle the user input, create the memory blocks + * with default renderings and add them to the view. + * * <p> * @since 3.2 * */ public class AddMemoryBlocks implements IAddMemoryBlocksTarget { - + /** Request object used to get the memory spaces */ - private static class GetMemorySpacesRequest extends CRequest implements IMemorySpaceAwareMemoryBlockRetrieval.GetMemorySpacesRequest { - String [] fMemorySpaces = new String[0]; + private static class GetMemorySpacesRequest extends CRequest + implements IMemorySpaceAwareMemoryBlockRetrieval.GetMemorySpacesRequest { + String[] fMemorySpaces = new String[0]; + @Override public String[] getMemorySpaces() { return fMemorySpaces; } + @Override public void setMemorySpaces(String[] memorySpaceIds) { fMemorySpaces = memorySpaceIds; } } - + /* (non-Javadoc) * @see org.eclipse.debug.ui.actions.IAddMemoryBlocksTarget#addMemoryBlocks(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) */ @@ -92,15 +95,14 @@ public class AddMemoryBlocks implements IAddMemoryBlocksTarget { assert false : "unexpected kind of view part"; //$NON-NLS-1$ return; } - final IMemoryRenderingSite renderingSite = (IMemoryRenderingSite)part; + final IMemoryRenderingSite renderingSite = (IMemoryRenderingSite) part; final IAdaptable debugViewElement = DebugUITools.getDebugContext(); - IMemoryBlockRetrieval retrieval = debugViewElement.getAdapter(IMemoryBlockRetrieval.class); if (retrieval == null && debugViewElement instanceof IDebugElement) { // Added logic for CDI (which is based on the standard debug model) - retrieval = ((IDebugElement)debugViewElement).getDebugTarget(); + retrieval = ((IDebugElement) debugViewElement).getDebugTarget(); } // If the backend doesn't support memory spaces, use the standard @@ -109,8 +111,8 @@ public class AddMemoryBlocks implements IAddMemoryBlocksTarget { invokePlatformAction(renderingSite); return; } - final IMemorySpaceAwareMemoryBlockRetrieval msRetrieval = (IMemorySpaceAwareMemoryBlockRetrieval)retrieval; - + final IMemorySpaceAwareMemoryBlockRetrieval msRetrieval = (IMemorySpaceAwareMemoryBlockRetrieval) retrieval; + // We still don't really know if this session actually involves any // memory spaces. Finding out is not trivial since it requires an // asynchronous call. @@ -118,17 +120,17 @@ public class AddMemoryBlocks implements IAddMemoryBlocksTarget { Job job = new Job("update memory space choices") { //$NON-NLS-1$ @Override protected IStatus run(IProgressMonitor monitor) { - msRetrieval.getMemorySpaces(context, new GetMemorySpacesRequest(){ + msRetrieval.getMemorySpaces(context, new GetMemorySpacesRequest() { @Override public void done() { - runOnUIThread(new Runnable(){ + runOnUIThread(new Runnable() { @Override public void run() { if (isSuccess()) { String[] memorySpaces = getMemorySpaces(); - // We shouldn't be using the custom dialog - // if there are none or only one memory + // We shouldn't be using the custom dialog + // if there are none or only one memory // spaces involved. // https://bugs.eclipse.org/bugs/show_bug.cgi?id=309032#c50 if (memorySpaces.length >= 2) { @@ -137,10 +139,11 @@ public class AddMemoryBlocks implements IAddMemoryBlocksTarget { } } - // If we get here, then the custom dialog isn't + // If we get here, then the custom dialog isn't // necessary. Use the standard (platform) one invokePlatformAction(renderingSite); - }}); + } + }); } }); return Status.OK_STATUS; @@ -149,10 +152,10 @@ public class AddMemoryBlocks implements IAddMemoryBlocksTarget { job.setSystem(true); job.schedule(); } - + /** * Invoke the platform's Add Memory Block action. - * + * * @param site the rendering site */ void invokePlatformAction(IMemoryRenderingSite site) { @@ -161,17 +164,20 @@ public class AddMemoryBlocks implements IAddMemoryBlocksTarget { PlatformAction(IMemoryRenderingSite site) { super(site); } - @Override + + @Override protected void dispose() { super.dispose(); } - }; + } + ; PlatformAction action = new PlatformAction(site); action.run(); action.dispose(); } - private void doAddMemoryBlocks(final IMemoryRenderingSite renderingSite, final Object context, final IMemorySpaceAwareMemoryBlockRetrieval retrieval, String[] memorySpaces) { + private void doAddMemoryBlocks(final IMemoryRenderingSite renderingSite, final Object context, + final IMemorySpaceAwareMemoryBlockRetrieval retrieval, String[] memorySpaces) { Shell shell = CDebugUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(); // create dialog to ask for expression/address to block @@ -215,8 +221,7 @@ public class AddMemoryBlocks implements IAddMemoryBlocksTarget { } @Override - public boolean canAddMemoryBlocks(IWorkbenchPart part, ISelection selection) - throws CoreException { + public boolean canAddMemoryBlocks(IWorkbenchPart part, ISelection selection) throws CoreException { return true; } @@ -225,8 +230,8 @@ public class AddMemoryBlocks implements IAddMemoryBlocksTarget { return (IDebugUIConstants.ID_MEMORY_VIEW.equals(part.getSite().getId())); } - // In order to avoid duplicating the addMemoryBlocks method--one - // version for expressions, one for memory-space+address, we pass in a + // In order to avoid duplicating the addMemoryBlocks method--one + // version for expressions, one for memory-space+address, we pass in a // an opaque parameter and let the logic within addMemoryBlocks // differentiate where needed via isinstanceof @@ -234,8 +239,7 @@ public class AddMemoryBlocks implements IAddMemoryBlocksTarget { } class AddressAndSpaceHolder extends ParamHolder { - public AddressAndSpaceHolder(final String[] addresses, - final String memorySpace) { + public AddressAndSpaceHolder(final String[] addresses, final String memorySpace) { this.addresses = addresses; this.memorySpace = memorySpace; } @@ -253,11 +257,11 @@ public class AddMemoryBlocks implements IAddMemoryBlocksTarget { public String[] expressions; } - private void addMemoryBlocks(Object context, - IMemorySpaceAwareMemoryBlockRetrieval memRetrieval, + private void addMemoryBlocks(Object context, IMemorySpaceAwareMemoryBlockRetrieval memRetrieval, final ParamHolder params, IMemoryRenderingSite memRendSite) { - final String[] addrsOrExprs = (params instanceof AddressAndSpaceHolder) ? ((AddressAndSpaceHolder) params).addresses + final String[] addrsOrExprs = (params instanceof AddressAndSpaceHolder) + ? ((AddressAndSpaceHolder) params).addresses : ((ExpressionsHolder) params).expressions; for (int i = 0; i < addrsOrExprs.length; i++) { @@ -269,13 +273,10 @@ public class AddMemoryBlocks implements IAddMemoryBlocksTarget { IMemoryBlockExtension memBlock; if (params instanceof AddressAndSpaceHolder) - memBlock = memRetrieval.getMemoryBlock( - addrOrExpr, - context, + memBlock = memRetrieval.getMemoryBlock(addrOrExpr, context, ((AddressAndSpaceHolder) params).memorySpace); else - memBlock = memRetrieval.getExtendedMemoryBlock(addrOrExpr, - context); + memBlock = memRetrieval.getExtendedMemoryBlock(addrOrExpr, context); // add block to memory block manager if (memBlock != null) { @@ -286,40 +287,34 @@ public class AddMemoryBlocks implements IAddMemoryBlocksTarget { addDefaultRenderings(memBlock, memRendSite); } else { // open error if it failed to retrieve a memory block - openError(Messages.AddMemBlocks_title, - Messages.AddMemBlocks_noMemoryBlock, - null); + openError(Messages.AddMemBlocks_title, Messages.AddMemBlocks_noMemoryBlock, null); } } catch (DebugException e1) { - openError(Messages.AddMemBlocks_title, - Messages.AddMemBlocks_failed, e1); + openError(Messages.AddMemBlocks_title, Messages.AddMemBlocks_failed, e1); } catch (NumberFormatException e2) { String message = Messages.AddMemBlocks_failed + "\n" + Messages.AddMemBlocks_input_invalid; //$NON-NLS-1$ - openError(Messages.AddMemBlocks_title, message, - null); + openError(Messages.AddMemBlocks_title, message, null); } } } - private void addDefaultRenderings(IMemoryBlock memoryBlock, - IMemoryRenderingSite memRendSite) { + private void addDefaultRenderings(IMemoryBlock memoryBlock, IMemoryRenderingSite memRendSite) { // This method was mostly lifted from the platform's AddMemoryBlockAction - IMemoryRenderingType primaryType = DebugUITools.getMemoryRenderingManager().getPrimaryRenderingType( - memoryBlock); - IMemoryRenderingType renderingTypes[] = DebugUITools.getMemoryRenderingManager().getDefaultRenderingTypes( - memoryBlock); + IMemoryRenderingType primaryType = DebugUITools.getMemoryRenderingManager() + .getPrimaryRenderingType(memoryBlock); + IMemoryRenderingType renderingTypes[] = DebugUITools.getMemoryRenderingManager() + .getDefaultRenderingTypes(memoryBlock); // create primary rendering try { if (primaryType != null) { - createRenderingInContainer(memoryBlock, memRendSite, - primaryType, IDebugUIConstants.ID_RENDERING_VIEW_PANE_1); + createRenderingInContainer(memoryBlock, memRendSite, primaryType, + IDebugUIConstants.ID_RENDERING_VIEW_PANE_1); } else if (renderingTypes.length > 0) { primaryType = renderingTypes[0]; - createRenderingInContainer(memoryBlock, memRendSite, - renderingTypes[0], + createRenderingInContainer(memoryBlock, memRendSite, renderingTypes[0], IDebugUIConstants.ID_RENDERING_VIEW_PANE_1); } } catch (CoreException e1) { @@ -334,8 +329,7 @@ public class AddMemoryBlocks implements IAddMemoryBlocksTarget { create = false; } if (create) - createRenderingInContainer(memoryBlock, memRendSite, - renderingTypes[i], + createRenderingInContainer(memoryBlock, memRendSite, renderingTypes[i], IDebugUIConstants.ID_RENDERING_VIEW_PANE_2); } catch (CoreException e) { CDebugUIPlugin.log(e); @@ -343,9 +337,8 @@ public class AddMemoryBlocks implements IAddMemoryBlocksTarget { } } - private void createRenderingInContainer(IMemoryBlock memoryBlock, - IMemoryRenderingSite memRendSite, IMemoryRenderingType primaryType, - String paneId) throws CoreException { + private void createRenderingInContainer(IMemoryBlock memoryBlock, IMemoryRenderingSite memRendSite, + IMemoryRenderingType primaryType, String paneId) throws CoreException { // This method was mostly lifted from the platform's AddMemoryBlockAction @@ -361,9 +354,8 @@ public class AddMemoryBlocks implements IAddMemoryBlocksTarget { * @param message * @param e */ - static public void openError (final String title, final String message, final Exception e) - { - UIJob uiJob = new UIJob("open error"){ //$NON-NLS-1$ + static public void openError(final String title, final String message, final Exception e) { + UIJob uiJob = new UIJob("open error") { //$NON-NLS-1$ @Override public IStatus runInUIThread(IProgressMonitor monitor) { @@ -374,19 +366,17 @@ public class AddMemoryBlocks implements IAddMemoryBlocksTarget { Shell shell = CDebugUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(); - MessageDialog.openError( - shell, - title, - message + "\n" + detail); //$NON-NLS-1$ + MessageDialog.openError(shell, title, message + "\n" + detail); //$NON-NLS-1$ return Status.OK_STATUS; - }}; - uiJob.setSystem(true); - uiJob.schedule(); + } + }; + uiJob.setSystem(true); + uiJob.schedule(); } private static Object getContextSelectionForPart(IWorkbenchPart part) { - IDebugContextService contextService = DebugUITools.getDebugContextManager().getContextService( - part.getSite().getWorkbenchWindow()); + IDebugContextService contextService = DebugUITools.getDebugContextManager() + .getContextService(part.getSite().getWorkbenchWindow()); ISelection debugContext = contextService.getActiveContext(getPartId(part)); if (debugContext == null) { @@ -399,7 +389,7 @@ public class AddMemoryBlocks implements IAddMemoryBlocksTarget { return null; } - + private static String getPartId(IWorkbenchPart part) { if (part instanceof IViewPart) { IViewSite site = (IViewSite) part.getSite(); @@ -408,27 +398,27 @@ public class AddMemoryBlocks implements IAddMemoryBlocksTarget { return part.getSite().getId(); } } + /** * Execute runnable on UI thread if the current thread is not an UI thread. * Otherwise execute it directly. - * + * * @param runnable * the runnable to execute */ - private void runOnUIThread(final Runnable runnable) { + private void runOnUIThread(final Runnable runnable) { if (Display.getCurrent() != null) { runnable.run(); - } - else { - UIJob job = new UIJob("Memory Browser UI Job"){ //$NON-NLS-1$ + } else { + UIJob job = new UIJob("Memory Browser UI Job") { //$NON-NLS-1$ @Override public IStatus runInUIThread(IProgressMonitor monitor) { runnable.run(); return Status.OK_STATUS; - }}; + } + }; job.setSystem(true); job.schedule(); } } } - diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/Messages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/Messages.java index 32bfade48fa..2b54b842fd4 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/Messages.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/Messages.java @@ -21,7 +21,7 @@ public class Messages extends NLS { public static String AddMemBlockDlg_enterExpression; public static String AddMemBlockDlg_or; public static String AddMemBlockDlg_MonitorMemory; - + public static String AddMemBlocks_title; public static String AddMemBlocks_noMemoryBlock; public static String AddMemBlocks_failed; diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModuleContentProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModuleContentProvider.java index bab2eaa9c11..a1450b40287 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModuleContentProvider.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModuleContentProvider.java @@ -12,7 +12,7 @@ * ARM - Initial API and implementation * Wind River Systems - adapted to work with platform Modules view (bug 210558) *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.views.modules; +package org.eclipse.cdt.debug.internal.ui.views.modules; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.IBinary; @@ -34,51 +34,48 @@ public class ModuleContentProvider extends ElementContentProvider { * @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#getChildCount(java.lang.Object, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate) */ @Override - protected int getChildCount( Object element, IPresentationContext context, IViewerUpdate monitor ) throws CoreException { - return getAllChildren( element, context ).length; + protected int getChildCount(Object element, IPresentationContext context, IViewerUpdate monitor) + throws CoreException { + return getAllChildren(element, context).length; } /* (non-Javadoc) * @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#getChildren(java.lang.Object, int, int, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate) */ @Override - protected Object[] getChildren( Object parent, int index, int length, IPresentationContext context, IViewerUpdate monitor ) throws CoreException { - return getElements( getAllChildren( parent, context ), index, length ); + protected Object[] getChildren(Object parent, int index, int length, IPresentationContext context, + IViewerUpdate monitor) throws CoreException { + return getElements(getAllChildren(parent, context), index, length); } /* (non-Javadoc) * @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#supportsContextId(java.lang.String) */ @Override - protected boolean supportsContextId( String id ) { - return IDebugUIConstants.ID_MODULE_VIEW.equals( id ); + protected boolean supportsContextId(String id) { + return IDebugUIConstants.ID_MODULE_VIEW.equals(id); } - - protected Object[] getAllChildren( Object parent, IPresentationContext context ) throws CoreException { - if ( parent instanceof IModuleRetrieval ) { - return ((IModuleRetrieval)parent).getModules(); - } - else if ( parent instanceof ICThread || parent instanceof ICStackFrame ) { - IModuleRetrieval mr = ((IAdaptable)parent).getAdapter( IModuleRetrieval.class ); - if ( mr != null ) { + + protected Object[] getAllChildren(Object parent, IPresentationContext context) throws CoreException { + if (parent instanceof IModuleRetrieval) { + return ((IModuleRetrieval) parent).getModules(); + } else if (parent instanceof ICThread || parent instanceof ICStackFrame) { + IModuleRetrieval mr = ((IAdaptable) parent).getAdapter(IModuleRetrieval.class); + if (mr != null) { return mr.getModules(); } - } - else if ( parent instanceof ICModule ) { - IBinary binary = ((ICModule)parent).getAdapter( IBinary.class ); - if ( binary != null ) { + } else if (parent instanceof ICModule) { + IBinary binary = ((ICModule) parent).getAdapter(IBinary.class); + if (binary != null) { try { return binary.getChildren(); - } - catch( CModelException e ) { + } catch (CModelException e) { } } - } - else if ( parent instanceof IParent ) { + } else if (parent instanceof IParent) { try { - return ((IParent)parent).getChildren(); - } - catch( CModelException e ) { + return ((IParent) parent).getChildren(); + } catch (CModelException e) { } } return EMPTY; diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModuleDetailPane.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModuleDetailPane.java index 703a0927039..03acaf51829 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModuleDetailPane.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModuleDetailPane.java @@ -65,504 +65,511 @@ import org.eclipse.ui.progress.WorkbenchJob; import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds; /** - * + * */ -public class ModuleDetailPane extends AbstractDetailPane implements IAdaptable, IPropertyChangeListener{ - - /** - * These are the IDs for the actions in the context menu - */ - protected static final String DETAIL_COPY_ACTION = ActionFactory.COPY.getId() + ".SourceDetailPane"; //$NON-NLS-1$ - protected static final String DETAIL_SELECT_ALL_ACTION = IDebugView.SELECT_ALL_ACTION + ".SourceDetailPane"; //$NON-NLS-1$ - - /** - * The ID, name and description of this pane are stored in constants so that the class - * does not have to be instantiated to access them. - */ - public static final String ID = "ModuleDetailPane"; //$NON-NLS-1$ - public static final String NAME = "Module Viewer"; - public static final String DESCRIPTION = "A detail pane that is based on a source viewer. Displays as text and has actions for assigning values, content assist and text modifications."; - - - /** - * Job to compute the details for a selection - */ - class DetailJob extends Job { - - private Object fElement; - // whether a result was collected - private IProgressMonitor fMonitor; - - public DetailJob(Object element) { - super("compute module details"); //$NON-NLS-1$ - setSystem(true); - fElement = element; - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) - */ - @Override +public class ModuleDetailPane extends AbstractDetailPane implements IAdaptable, IPropertyChangeListener { + + /** + * These are the IDs for the actions in the context menu + */ + protected static final String DETAIL_COPY_ACTION = ActionFactory.COPY.getId() + ".SourceDetailPane"; //$NON-NLS-1$ + protected static final String DETAIL_SELECT_ALL_ACTION = IDebugView.SELECT_ALL_ACTION + ".SourceDetailPane"; //$NON-NLS-1$ + + /** + * The ID, name and description of this pane are stored in constants so that the class + * does not have to be instantiated to access them. + */ + public static final String ID = "ModuleDetailPane"; //$NON-NLS-1$ + public static final String NAME = "Module Viewer"; + public static final String DESCRIPTION = "A detail pane that is based on a source viewer. Displays as text and has actions for assigning values, content assist and text modifications."; + + /** + * Job to compute the details for a selection + */ + class DetailJob extends Job { + + private Object fElement; + // whether a result was collected + private IProgressMonitor fMonitor; + + public DetailJob(Object element) { + super("compute module details"); //$NON-NLS-1$ + setSystem(true); + fElement = element; + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override protected IStatus run(IProgressMonitor monitor) { - fMonitor = monitor; - - String detail = ""; //$NON-NLS-1$ - if ( fElement instanceof ICModule ) { - detail = getModuleDetail( ((ICModule)fElement) ); - } - if ( fElement instanceof ICElement ) { - detail = fElement.toString(); - } - - detailComputed(detail); - return Status.OK_STATUS; - } - - private void detailComputed(final String result) { - if (!fMonitor.isCanceled()) { - WorkbenchJob setDetail = new WorkbenchJob("set details") { //$NON-NLS-1$ - @Override + fMonitor = monitor; + + String detail = ""; //$NON-NLS-1$ + if (fElement instanceof ICModule) { + detail = getModuleDetail(((ICModule) fElement)); + } + if (fElement instanceof ICElement) { + detail = fElement.toString(); + } + + detailComputed(detail); + return Status.OK_STATUS; + } + + private void detailComputed(final String result) { + if (!fMonitor.isCanceled()) { + WorkbenchJob setDetail = new WorkbenchJob("set details") { //$NON-NLS-1$ + @Override public IStatus runInUIThread(IProgressMonitor monitor) { - if (!fMonitor.isCanceled()) { - getDetailDocument().set(result); - } - return Status.OK_STATUS; - } - }; - setDetail.setSystem(true); - setDetail.schedule(); - } - } - - } - - private String getModuleDetail( ICModule module ) { - StringBuilder sb = new StringBuilder(); - - // Type - String type = null; - switch( module.getType() ) { - case ICModule.EXECUTABLE: - type = ModulesMessages.getString( "ModulesView.1" ); //$NON-NLS-1$ - break; - case ICModule.SHARED_LIBRARY: - type = ModulesMessages.getString( "ModulesView.2" ); //$NON-NLS-1$ - break; - } - if ( type != null ) { - sb.append( ModulesMessages.getString( "ModulesView.3" ) ); //$NON-NLS-1$ - sb.append( type ); - sb.append( '\n' ); - } - - // Symbols flag - sb.append( ModulesMessages.getString( "ModulesView.4" ) ); //$NON-NLS-1$ - sb.append( ( module.areSymbolsLoaded() ) ? ModulesMessages.getString( "ModulesView.5" ) : ModulesMessages.getString( "ModulesView.6" ) ); //$NON-NLS-1$ //$NON-NLS-2$ - sb.append( '\n' ); - - // Symbols file - sb.append( ModulesMessages.getString( "ModulesView.7" ) ); //$NON-NLS-1$ - sb.append( module.getSymbolsFileName().toOSString() ); - sb.append( '\n' ); - - // CPU - String cpu = module.getCPU(); - if ( cpu != null ) { - sb.append( ModulesMessages.getString( "ModulesView.8" ) ); //$NON-NLS-1$ - sb.append( cpu ); - sb.append( '\n' ); - } - - // Base address - IAddress baseAddress = module.getBaseAddress(); - if ( !baseAddress.isZero() ) { - sb.append( ModulesMessages.getString( "ModulesView.9" ) ); //$NON-NLS-1$ - sb.append( baseAddress.toHexAddressString() ); - sb.append( '\n' ); - } - - // Size - long size = module.getSize(); - if ( size > 0 ) { - sb.append( ModulesMessages.getString( "ModulesView.10" ) ); //$NON-NLS-1$ - sb.append( size ); - sb.append( '\n' ); - } - - return sb.toString(); - } - - - /** - * The source viewer in which the computed string detail - * of selected modules will be displayed. - */ - private SourceViewer fSourceViewer; - - /** - * Variables used to create the detailed information for a selection - */ - private IDocument fDetailDocument; - private DetailJob fDetailJob = null; - - /* (non-Javadoc) - * @see org.eclipse.debug.ui.IDetailPane#createControl(org.eclipse.swt.widgets.Composite) - */ - @Override + if (!fMonitor.isCanceled()) { + getDetailDocument().set(result); + } + return Status.OK_STATUS; + } + }; + setDetail.setSystem(true); + setDetail.schedule(); + } + } + + } + + private String getModuleDetail(ICModule module) { + StringBuilder sb = new StringBuilder(); + + // Type + String type = null; + switch (module.getType()) { + case ICModule.EXECUTABLE: + type = ModulesMessages.getString("ModulesView.1"); //$NON-NLS-1$ + break; + case ICModule.SHARED_LIBRARY: + type = ModulesMessages.getString("ModulesView.2"); //$NON-NLS-1$ + break; + } + if (type != null) { + sb.append(ModulesMessages.getString("ModulesView.3")); //$NON-NLS-1$ + sb.append(type); + sb.append('\n'); + } + + // Symbols flag + sb.append(ModulesMessages.getString("ModulesView.4")); //$NON-NLS-1$ + sb.append((module.areSymbolsLoaded()) ? ModulesMessages.getString("ModulesView.5") //$NON-NLS-1$ + : ModulesMessages.getString("ModulesView.6")); //$NON-NLS-1$ + sb.append('\n'); + + // Symbols file + sb.append(ModulesMessages.getString("ModulesView.7")); //$NON-NLS-1$ + sb.append(module.getSymbolsFileName().toOSString()); + sb.append('\n'); + + // CPU + String cpu = module.getCPU(); + if (cpu != null) { + sb.append(ModulesMessages.getString("ModulesView.8")); //$NON-NLS-1$ + sb.append(cpu); + sb.append('\n'); + } + + // Base address + IAddress baseAddress = module.getBaseAddress(); + if (!baseAddress.isZero()) { + sb.append(ModulesMessages.getString("ModulesView.9")); //$NON-NLS-1$ + sb.append(baseAddress.toHexAddressString()); + sb.append('\n'); + } + + // Size + long size = module.getSize(); + if (size > 0) { + sb.append(ModulesMessages.getString("ModulesView.10")); //$NON-NLS-1$ + sb.append(size); + sb.append('\n'); + } + + return sb.toString(); + } + + /** + * The source viewer in which the computed string detail + * of selected modules will be displayed. + */ + private SourceViewer fSourceViewer; + + /** + * Variables used to create the detailed information for a selection + */ + private IDocument fDetailDocument; + private DetailJob fDetailJob = null; + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.IDetailPane#createControl(org.eclipse.swt.widgets.Composite) + */ + @Override public Control createControl(Composite parent) { - - createSourceViewer(parent); - - if (isInView()){ - createViewSpecificComponents(); - createActions(); - CDebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this); - JFaceResources.getFontRegistry().addListener(this); - } - - return fSourceViewer.getControl(); - } - - /** - * Creates the source viewer in the given parent composite - * - * @param parent Parent composite to create the source viewer in - */ - private void createSourceViewer(Composite parent) { - - // Create & configure a SourceViewer - fSourceViewer = new SourceViewer(parent, null, SWT.V_SCROLL | SWT.H_SCROLL); - fSourceViewer.setDocument(getDetailDocument()); - fSourceViewer.getTextWidget().setFont(JFaceResources.getFont(IInternalCDebugUIConstants.DETAIL_PANE_FONT)); - fSourceViewer.setEditable(false); - PlatformUI.getWorkbench().getHelpSystem().setHelp(fSourceViewer.getTextWidget(), ICDebugHelpContextIds.MODULES_DETAIL_PANE); - Control control = fSourceViewer.getControl(); - GridData gd = new GridData(GridData.FILL_BOTH); - control.setLayoutData(gd); - } - - /** - * Creates listeners and other components that should only be added to the - * source viewer when this detail pane is inside a view. - */ - private void createViewSpecificComponents(){ - - // Add a document listener so actions get updated when the document changes - getDetailDocument().addDocumentListener(new IDocumentListener() { - @Override - public void documentAboutToBeChanged(DocumentEvent event) {} - @Override + + createSourceViewer(parent); + + if (isInView()) { + createViewSpecificComponents(); + createActions(); + CDebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this); + JFaceResources.getFontRegistry().addListener(this); + } + + return fSourceViewer.getControl(); + } + + /** + * Creates the source viewer in the given parent composite + * + * @param parent Parent composite to create the source viewer in + */ + private void createSourceViewer(Composite parent) { + + // Create & configure a SourceViewer + fSourceViewer = new SourceViewer(parent, null, SWT.V_SCROLL | SWT.H_SCROLL); + fSourceViewer.setDocument(getDetailDocument()); + fSourceViewer.getTextWidget().setFont(JFaceResources.getFont(IInternalCDebugUIConstants.DETAIL_PANE_FONT)); + fSourceViewer.setEditable(false); + PlatformUI.getWorkbench().getHelpSystem().setHelp(fSourceViewer.getTextWidget(), + ICDebugHelpContextIds.MODULES_DETAIL_PANE); + Control control = fSourceViewer.getControl(); + GridData gd = new GridData(GridData.FILL_BOTH); + control.setLayoutData(gd); + } + + /** + * Creates listeners and other components that should only be added to the + * source viewer when this detail pane is inside a view. + */ + private void createViewSpecificComponents() { + + // Add a document listener so actions get updated when the document changes + getDetailDocument().addDocumentListener(new IDocumentListener() { + @Override + public void documentAboutToBeChanged(DocumentEvent event) { + } + + @Override public void documentChanged(DocumentEvent event) { - updateSelectionDependentActions(); - } - }); - - // Add the selection listener so selection dependent actions get updated. - fSourceViewer.getSelectionProvider().addSelectionChangedListener(new ISelectionChangedListener() { - @Override + updateSelectionDependentActions(); + } + }); + + // Add the selection listener so selection dependent actions get updated. + fSourceViewer.getSelectionProvider().addSelectionChangedListener(new ISelectionChangedListener() { + @Override public void selectionChanged(SelectionChangedEvent event) { - updateSelectionDependentActions(); - } - }); - - // Add a focus listener to update actions when details area gains focus - fSourceViewer.getControl().addFocusListener(new FocusAdapter() { - @Override + updateSelectionDependentActions(); + } + }); + + // Add a focus listener to update actions when details area gains focus + fSourceViewer.getControl().addFocusListener(new FocusAdapter() { + @Override public void focusGained(FocusEvent e) { - - getViewSite().setSelectionProvider(fSourceViewer.getSelectionProvider()); - - setGlobalAction(IDebugView.SELECT_ALL_ACTION, getAction(DETAIL_SELECT_ALL_ACTION)); - setGlobalAction(IDebugView.COPY_ACTION, getAction(DETAIL_COPY_ACTION)); - - getViewSite().getActionBars().updateActionBars(); - } - - @Override + + getViewSite().setSelectionProvider(fSourceViewer.getSelectionProvider()); + + setGlobalAction(IDebugView.SELECT_ALL_ACTION, getAction(DETAIL_SELECT_ALL_ACTION)); + setGlobalAction(IDebugView.COPY_ACTION, getAction(DETAIL_COPY_ACTION)); + + getViewSite().getActionBars().updateActionBars(); + } + + @Override public void focusLost(FocusEvent e) { - - getViewSite().setSelectionProvider(null); - - setGlobalAction(IDebugView.SELECT_ALL_ACTION, null); - setGlobalAction(IDebugView.CUT_ACTION, null); - setGlobalAction(IDebugView.COPY_ACTION, null); - setGlobalAction(IDebugView.PASTE_ACTION, null); - setGlobalAction(IDebugView.FIND_ACTION, null); - - getViewSite().getActionBars().updateActionBars(); - - } - }); - - // Add a context menu to the detail area - createDetailContextMenu(fSourceViewer.getTextWidget()); - } - - /** - * Creates the actions to add to the context menu - */ - private void createActions() { - - TextViewerAction textAction= new TextViewerAction(fSourceViewer, ITextOperationTarget.SELECT_ALL); - textAction.configureAction("Select &All", "", ""); //$NON-NLS-2$ //$NON-NLS-3$ - textAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.SELECT_ALL); - PlatformUI.getWorkbench().getHelpSystem().setHelp(textAction, ICDebugHelpContextIds.MODULE_DETAIL_PANE_SELECT_ALL_ACTION); - setAction(DETAIL_SELECT_ALL_ACTION, textAction); - - textAction= new TextViewerAction(fSourceViewer, ITextOperationTarget.COPY); - textAction.configureAction("&Copy", "", ""); //$NON-NLS-2$ //$NON-NLS-3$ - textAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.COPY); - PlatformUI.getWorkbench().getHelpSystem().setHelp(textAction, ICDebugHelpContextIds.MODULE_DETAIL_PANE_COPY_ACTION); - setAction(DETAIL_COPY_ACTION, textAction); - - setSelectionDependantAction(DETAIL_COPY_ACTION); - - updateSelectionDependentActions(); - } - - /** - * Create the context menu particular to the detail pane. Note that anyone - * wishing to contribute an action to this menu must use - * <code>ICDebugUIConstants.MODULES_VIEW_DETAIL_ID</code> as the - * <code>targetID</code> in the extension XML. - */ - protected void createDetailContextMenu(Control menuControl) { - MenuManager menuMgr= new MenuManager(); - menuMgr.setRemoveAllWhenShown(true); - menuMgr.addMenuListener(new IMenuListener() { - @Override + + getViewSite().setSelectionProvider(null); + + setGlobalAction(IDebugView.SELECT_ALL_ACTION, null); + setGlobalAction(IDebugView.CUT_ACTION, null); + setGlobalAction(IDebugView.COPY_ACTION, null); + setGlobalAction(IDebugView.PASTE_ACTION, null); + setGlobalAction(IDebugView.FIND_ACTION, null); + + getViewSite().getActionBars().updateActionBars(); + + } + }); + + // Add a context menu to the detail area + createDetailContextMenu(fSourceViewer.getTextWidget()); + } + + /** + * Creates the actions to add to the context menu + */ + private void createActions() { + + TextViewerAction textAction = new TextViewerAction(fSourceViewer, ITextOperationTarget.SELECT_ALL); + textAction.configureAction("Select &All", "", ""); //$NON-NLS-2$ //$NON-NLS-3$ + textAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.SELECT_ALL); + PlatformUI.getWorkbench().getHelpSystem().setHelp(textAction, + ICDebugHelpContextIds.MODULE_DETAIL_PANE_SELECT_ALL_ACTION); + setAction(DETAIL_SELECT_ALL_ACTION, textAction); + + textAction = new TextViewerAction(fSourceViewer, ITextOperationTarget.COPY); + textAction.configureAction("&Copy", "", ""); //$NON-NLS-2$ //$NON-NLS-3$ + textAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.COPY); + PlatformUI.getWorkbench().getHelpSystem().setHelp(textAction, + ICDebugHelpContextIds.MODULE_DETAIL_PANE_COPY_ACTION); + setAction(DETAIL_COPY_ACTION, textAction); + + setSelectionDependantAction(DETAIL_COPY_ACTION); + + updateSelectionDependentActions(); + } + + /** + * Create the context menu particular to the detail pane. Note that anyone + * wishing to contribute an action to this menu must use + * <code>ICDebugUIConstants.MODULES_VIEW_DETAIL_ID</code> as the + * <code>targetID</code> in the extension XML. + */ + protected void createDetailContextMenu(Control menuControl) { + MenuManager menuMgr = new MenuManager(); + menuMgr.setRemoveAllWhenShown(true); + menuMgr.addMenuListener(new IMenuListener() { + @Override public void menuAboutToShow(IMenuManager mgr) { - fillDetailContextMenu(mgr); - } - }); - Menu menu= menuMgr.createContextMenu(menuControl); - menuControl.setMenu(menu); - - getViewSite().registerContextMenu(ICDebugUIConstants.MODULES_VIEW_DETAIL_ID, menuMgr, fSourceViewer.getSelectionProvider()); - - } - - /** - * Adds items to the detail pane's context menu including any extension defined - * actions. - * - * @param menu The menu to add the item to. - */ - protected void fillDetailContextMenu(IMenuManager menu) { - - menu.add(new Separator(ICDebugUIConstants.MODULES_GROUP)); - menu.add(new Separator()); - menu.add(getAction(DETAIL_COPY_ACTION)); - menu.add(getAction(DETAIL_SELECT_ALL_ACTION)); - menu.add(new Separator()); - menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); - - } - - /* (non-Javadoc) - * @see org.eclipse.debug.ui.IDetailPane#display(org.eclipse.jface.viewers.IStructuredSelection) - */ - @Override + fillDetailContextMenu(mgr); + } + }); + Menu menu = menuMgr.createContextMenu(menuControl); + menuControl.setMenu(menu); + + getViewSite().registerContextMenu(ICDebugUIConstants.MODULES_VIEW_DETAIL_ID, menuMgr, + fSourceViewer.getSelectionProvider()); + + } + + /** + * Adds items to the detail pane's context menu including any extension defined + * actions. + * + * @param menu The menu to add the item to. + */ + protected void fillDetailContextMenu(IMenuManager menu) { + + menu.add(new Separator(ICDebugUIConstants.MODULES_GROUP)); + menu.add(new Separator()); + menu.add(getAction(DETAIL_COPY_ACTION)); + menu.add(getAction(DETAIL_SELECT_ALL_ACTION)); + menu.add(new Separator()); + menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); + + } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.IDetailPane#display(org.eclipse.jface.viewers.IStructuredSelection) + */ + @Override public void display(IStructuredSelection selection) { - - if (selection == null){ - clearSourceViewer(); - return; - } - - if (isInView()){ - fSourceViewer.setEditable(true); - } - - if (selection.isEmpty()){ - clearSourceViewer(); - return; - } - - Object firstElement = selection.getFirstElement(); - if (firstElement != null && firstElement instanceof IDebugElement) { - String modelID = ((IDebugElement)firstElement).getModelIdentifier(); - } - - synchronized (this) { - if (fDetailJob != null) { - fDetailJob.cancel(); - } - fDetailJob = new DetailJob(selection.getFirstElement()); - fDetailJob.schedule(); - } - - } - - /* (non-Javadoc) - * @see org.eclipse.debug.ui.IDetailPane#setFocus() - */ - @Override - public boolean setFocus(){ - if (fSourceViewer != null){ - fSourceViewer.getTextWidget().setFocus(); - return true; - } - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.views.variables.details.AbstractDetailPane#dispose() - */ - @Override - public void dispose(){ - super.dispose(); - - if (fDetailJob != null) fDetailJob.cancel(); - if (fSourceViewer != null && fSourceViewer.getControl() != null) fSourceViewer.getControl().dispose(); - - if (isInView()){ - CDebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this); - JFaceResources.getFontRegistry().removeListener(this); - } - } - - /* (non-Javadoc) - * @see org.eclipse.debug.ui.IDetailPane#getDescription() - */ - @Override + + if (selection == null) { + clearSourceViewer(); + return; + } + + if (isInView()) { + fSourceViewer.setEditable(true); + } + + if (selection.isEmpty()) { + clearSourceViewer(); + return; + } + + Object firstElement = selection.getFirstElement(); + if (firstElement != null && firstElement instanceof IDebugElement) { + String modelID = ((IDebugElement) firstElement).getModelIdentifier(); + } + + synchronized (this) { + if (fDetailJob != null) { + fDetailJob.cancel(); + } + fDetailJob = new DetailJob(selection.getFirstElement()); + fDetailJob.schedule(); + } + + } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.IDetailPane#setFocus() + */ + @Override + public boolean setFocus() { + if (fSourceViewer != null) { + fSourceViewer.getTextWidget().setFocus(); + return true; + } + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.views.variables.details.AbstractDetailPane#dispose() + */ + @Override + public void dispose() { + super.dispose(); + + if (fDetailJob != null) + fDetailJob.cancel(); + if (fSourceViewer != null && fSourceViewer.getControl() != null) + fSourceViewer.getControl().dispose(); + + if (isInView()) { + CDebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this); + JFaceResources.getFontRegistry().removeListener(this); + } + } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.IDetailPane#getDescription() + */ + @Override public String getDescription() { - return DESCRIPTION; - } + return DESCRIPTION; + } - /* (non-Javadoc) - * @see org.eclipse.debug.ui.IDetailPane#getID() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.debug.ui.IDetailPane#getID() + */ + @Override public String getID() { - return ID; - } + return ID; + } - /* (non-Javadoc) - * @see org.eclipse.debug.ui.IDetailPane#getName() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.debug.ui.IDetailPane#getName() + */ + @Override public String getName() { - return NAME; - } - - @SuppressWarnings("unchecked") + return NAME; + } + + @SuppressWarnings("unchecked") @Override public <T> T getAdapter(Class<T> required) { - if (ITextViewer.class.equals(required)) { - return (T) fSourceViewer; - } - return null; - } - - /** - * Lazily instantiate and return a Document for the detail pane text viewer. - */ - protected IDocument getDetailDocument() { - if (fDetailDocument == null) { - fDetailDocument = new Document(); - } - return fDetailDocument; - } - - /** - * Clears the source viewer, removes all text. - */ - protected void clearSourceViewer(){ - if (fDetailJob != null) { - fDetailJob.cancel(); - } - fDetailDocument.set(""); //$NON-NLS-1$ - fSourceViewer.setEditable(false); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) - */ - @Override + if (ITextViewer.class.equals(required)) { + return (T) fSourceViewer; + } + return null; + } + + /** + * Lazily instantiate and return a Document for the detail pane text viewer. + */ + protected IDocument getDetailDocument() { + if (fDetailDocument == null) { + fDetailDocument = new Document(); + } + return fDetailDocument; + } + + /** + * Clears the source viewer, removes all text. + */ + protected void clearSourceViewer() { + if (fDetailJob != null) { + fDetailJob.cancel(); + } + fDetailDocument.set(""); //$NON-NLS-1$ + fSourceViewer.setEditable(false); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) + */ + @Override public void propertyChange(PropertyChangeEvent event) { - String propertyName= event.getProperty(); - if (propertyName.equals(IInternalCDebugUIConstants.DETAIL_PANE_FONT)) { - fSourceViewer.getTextWidget().setFont(JFaceResources.getFont(IInternalCDebugUIConstants.DETAIL_PANE_FONT)); - } - - } - - /** - * Wrapper class that wraps around an IFindReplaceTarget. Allows the detail pane to scroll - * to text selected by the find/replace action. The source viewer treats the text as a single - * line, even when the text is wrapped onto several lines so the viewer will not scroll properly - * on it's own. See bug 178106. - */ - class FindReplaceTargetWrapper implements IFindReplaceTarget{ - - private IFindReplaceTarget fTarget; - - /** - * Constructor - * - * @param target find/replace target this class will wrap around. - */ - public FindReplaceTargetWrapper(IFindReplaceTarget target){ - fTarget = target; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.text.IFindReplaceTarget#canPerformFind() - */ - @Override + String propertyName = event.getProperty(); + if (propertyName.equals(IInternalCDebugUIConstants.DETAIL_PANE_FONT)) { + fSourceViewer.getTextWidget().setFont(JFaceResources.getFont(IInternalCDebugUIConstants.DETAIL_PANE_FONT)); + } + + } + + /** + * Wrapper class that wraps around an IFindReplaceTarget. Allows the detail pane to scroll + * to text selected by the find/replace action. The source viewer treats the text as a single + * line, even when the text is wrapped onto several lines so the viewer will not scroll properly + * on it's own. See bug 178106. + */ + class FindReplaceTargetWrapper implements IFindReplaceTarget { + + private IFindReplaceTarget fTarget; + + /** + * Constructor + * + * @param target find/replace target this class will wrap around. + */ + public FindReplaceTargetWrapper(IFindReplaceTarget target) { + fTarget = target; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.text.IFindReplaceTarget#canPerformFind() + */ + @Override public boolean canPerformFind() { - return fTarget.canPerformFind(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.text.IFindReplaceTarget#findAndSelect(int, java.lang.String, boolean, boolean, boolean) - */ - @Override - public int findAndSelect(int widgetOffset, String findString, boolean searchForward, boolean caseSensitive, boolean wholeWord) { - int position = fTarget.findAndSelect(widgetOffset, findString, searchForward, caseSensitive, wholeWord); - // Explicitly tell the widget to show the selection because the viewer thinks the text is all on one line, even if wrapping is turned on. - if (fSourceViewer != null){ - StyledText text = fSourceViewer.getTextWidget(); - if(text != null && !text.isDisposed()) { - text.showSelection(); - } - } - return position; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.text.IFindReplaceTarget#getSelection() - */ - @Override + return fTarget.canPerformFind(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.text.IFindReplaceTarget#findAndSelect(int, java.lang.String, boolean, boolean, boolean) + */ + @Override + public int findAndSelect(int widgetOffset, String findString, boolean searchForward, boolean caseSensitive, + boolean wholeWord) { + int position = fTarget.findAndSelect(widgetOffset, findString, searchForward, caseSensitive, wholeWord); + // Explicitly tell the widget to show the selection because the viewer thinks the text is all on one line, even if wrapping is turned on. + if (fSourceViewer != null) { + StyledText text = fSourceViewer.getTextWidget(); + if (text != null && !text.isDisposed()) { + text.showSelection(); + } + } + return position; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.text.IFindReplaceTarget#getSelection() + */ + @Override public Point getSelection() { - return fTarget.getSelection(); - } + return fTarget.getSelection(); + } - /* (non-Javadoc) - * @see org.eclipse.jface.text.IFindReplaceTarget#getSelectionText() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.jface.text.IFindReplaceTarget#getSelectionText() + */ + @Override public String getSelectionText() { - return fTarget.getSelectionText(); - } + return fTarget.getSelectionText(); + } - /* (non-Javadoc) - * @see org.eclipse.jface.text.IFindReplaceTarget#isEditable() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.jface.text.IFindReplaceTarget#isEditable() + */ + @Override public boolean isEditable() { - return fTarget.isEditable(); - } + return fTarget.isEditable(); + } - /* (non-Javadoc) - * @see org.eclipse.jface.text.IFindReplaceTarget#replaceSelection(java.lang.String) - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.jface.text.IFindReplaceTarget#replaceSelection(java.lang.String) + */ + @Override public void replaceSelection(String text) { - fTarget.replaceSelection(text); - } - } - -} + fTarget.replaceSelection(text); + } + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModuleDetailPaneFactory.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModuleDetailPaneFactory.java index c1059e263ee..d7c47d48b6b 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModuleDetailPaneFactory.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModuleDetailPaneFactory.java @@ -27,7 +27,7 @@ import org.eclipse.jface.viewers.IStructuredSelection; public class ModuleDetailPaneFactory implements IDetailPaneFactory { public static final String MODULE_DETAIL_PANE_ID = ModuleDetailPane.ID; - + /* (non-Javadoc) * @see org.eclipse.debug.internal.ui.views.variables.IDetailsFactory#createDetailsArea(java.lang.String) */ @@ -42,7 +42,7 @@ public class ModuleDetailPaneFactory implements IDetailPaneFactory { possibleIDs.add(ModuleDetailPane.ID); return possibleIDs; } - + /* (non-Javadoc) * @see org.eclipse.debug.ui.IDetailPaneFactory#getDefaultDetailPane(java.util.Set, org.eclipse.jface.viewers.IStructuredSelection) */ @@ -57,19 +57,18 @@ public class ModuleDetailPaneFactory implements IDetailPaneFactory { */ @Override public String getDetailPaneName(String id) { - if (id.equals(ModuleDetailPane.ID)){ + if (id.equals(ModuleDetailPane.ID)) { return ModuleDetailPane.NAME; } return null; } - /* (non-Javadoc) * @see org.eclipse.debug.internal.ui.views.variables.IDetailsFactory#getDescription(java.lang.String) */ @Override public String getDetailPaneDescription(String id) { - if (id.equals(ModuleDetailPane.ID)){ + if (id.equals(ModuleDetailPane.ID)) { return ModuleDetailPane.DESCRIPTION; } return null; diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModuleLabelProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModuleLabelProvider.java index 9bcad3aaa40..9e7bf13cc4f 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModuleLabelProvider.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModuleLabelProvider.java @@ -28,7 +28,7 @@ import org.eclipse.jface.viewers.TreePath; import org.eclipse.ui.model.IWorkbenchAdapter; /** - * org.eclipse.cdt.debug.internal.ui.views.modules.CElementLabelProvider: + * org.eclipse.cdt.debug.internal.ui.views.modules.CElementLabelProvider: * //TODO Add description. */ public class ModuleLabelProvider extends ElementLabelProvider { @@ -37,16 +37,18 @@ public class ModuleLabelProvider extends ElementLabelProvider { * @see org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider#getLabel(org.eclipse.jface.viewers.TreePath, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, java.lang.String) */ @Override - protected String getLabel( TreePath elementPath, IPresentationContext presentationContext, String columnId ) throws CoreException { + protected String getLabel(TreePath elementPath, IPresentationContext presentationContext, String columnId) + throws CoreException { Object element = elementPath.getLastSegment(); - if ( element instanceof ICModule && presentationContext instanceof DebugModelPresentationContext ) { - IDebugModelPresentation presentation = ((DebugModelPresentationContext)presentationContext).getModelPresentation(); - return presentation.getText( element ); + if (element instanceof ICModule && presentationContext instanceof DebugModelPresentationContext) { + IDebugModelPresentation presentation = ((DebugModelPresentationContext) presentationContext) + .getModelPresentation(); + return presentation.getText(element); } - if ( element instanceof IAdaptable ) { - IWorkbenchAdapter adapter = (((IAdaptable)element).getAdapter( IWorkbenchAdapter.class )); - if ( adapter != null ) - return adapter.getLabel( element ); + if (element instanceof IAdaptable) { + IWorkbenchAdapter adapter = (((IAdaptable) element).getAdapter(IWorkbenchAdapter.class)); + if (adapter != null) + return adapter.getLabel(element); } return ""; //$NON-NLS-1$ } @@ -55,28 +57,29 @@ public class ModuleLabelProvider extends ElementLabelProvider { * @see org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider#getImageDescriptor(org.eclipse.jface.viewers.TreePath, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, java.lang.String) */ @Override - protected ImageDescriptor getImageDescriptor( TreePath elementPath, IPresentationContext presentationContext, String columnId ) throws CoreException { + protected ImageDescriptor getImageDescriptor(TreePath elementPath, IPresentationContext presentationContext, + String columnId) throws CoreException { Object element = elementPath.getLastSegment(); - if ( element instanceof ICModule ) { - ICModule module = (ICModule)element; - switch( module.getType() ) { - case ICModule.EXECUTABLE: - if ( module.areSymbolsLoaded() ) { - return CDebugImages.DESC_OBJS_EXECUTABLE_WITH_SYMBOLS; - } - return CDebugImages.DESC_OBJS_EXECUTABLE; - case ICModule.SHARED_LIBRARY: - if ( module.areSymbolsLoaded() ) { - return CDebugImages.DESC_OBJS_SHARED_LIBRARY_WITH_SYMBOLS; - } - return CDebugImages.DESC_OBJS_SHARED_LIBRARY; + if (element instanceof ICModule) { + ICModule module = (ICModule) element; + switch (module.getType()) { + case ICModule.EXECUTABLE: + if (module.areSymbolsLoaded()) { + return CDebugImages.DESC_OBJS_EXECUTABLE_WITH_SYMBOLS; + } + return CDebugImages.DESC_OBJS_EXECUTABLE; + case ICModule.SHARED_LIBRARY: + if (module.areSymbolsLoaded()) { + return CDebugImages.DESC_OBJS_SHARED_LIBRARY_WITH_SYMBOLS; + } + return CDebugImages.DESC_OBJS_SHARED_LIBRARY; } } - if ( element instanceof ICElement ) { - IWorkbenchAdapter adapter = (((IAdaptable)element).getAdapter( IWorkbenchAdapter.class )); - if ( adapter != null ) - return adapter.getImageDescriptor( element ); + if (element instanceof ICElement) { + IWorkbenchAdapter adapter = (((IAdaptable) element).getAdapter(IWorkbenchAdapter.class)); + if (adapter != null) + return adapter.getImageDescriptor(element); } - return super.getImageDescriptor( elementPath, presentationContext, columnId ); + return super.getImageDescriptor(elementPath, presentationContext, columnId); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesMessages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesMessages.java index 660c60e6ad2..6a915a4a28c 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesMessages.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesMessages.java @@ -23,17 +23,16 @@ public class ModulesMessages { private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.views.modules.ModulesMessages";//$NON-NLS-1$ - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); private ModulesMessages() { } - public static String getString( String key ) { + public static String getString(String key) { // TODO Auto-generated method stub try { - return RESOURCE_BUNDLE.getString( key ); - } - catch( MissingResourceException e ) { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { return '!' + key + '!'; } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesViewEventHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesViewEventHandler.java index fc575c743da..149d4ced7e8 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesViewEventHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesViewEventHandler.java @@ -11,7 +11,7 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.views.modules; +package org.eclipse.cdt.debug.internal.ui.views.modules; import org.eclipse.cdt.debug.core.model.ICModule; import org.eclipse.cdt.debug.core.model.IModuleRetrieval; @@ -21,7 +21,7 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta; import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta; import org.eclipse.debug.internal.ui.viewers.provisional.AbstractModelProxy; import org.eclipse.debug.internal.ui.viewers.update.DebugEventHandler; - + /** * Comment for . */ @@ -29,11 +29,11 @@ public class ModulesViewEventHandler extends DebugEventHandler { private IModuleRetrieval fModuleRetrieval; - /** - * Constructor for ModulesViewEventHandler. + /** + * Constructor for ModulesViewEventHandler. */ - public ModulesViewEventHandler( AbstractModelProxy proxy, IModuleRetrieval moduleRetrieval ) { - super( proxy ); + public ModulesViewEventHandler(AbstractModelProxy proxy, IModuleRetrieval moduleRetrieval) { + super(proxy); fModuleRetrieval = moduleRetrieval; } @@ -41,10 +41,9 @@ public class ModulesViewEventHandler extends DebugEventHandler { * @see org.eclipse.debug.internal.ui.viewers.update.DebugEventHandler#handlesEvent(org.eclipse.debug.core.DebugEvent) */ @Override - protected boolean handlesEvent( DebugEvent event ) { - if ( event.getKind() == DebugEvent.CREATE || - event.getKind() == DebugEvent.TERMINATE || - event.getKind() == DebugEvent.CHANGE ) + protected boolean handlesEvent(DebugEvent event) { + if (event.getKind() == DebugEvent.CREATE || event.getKind() == DebugEvent.TERMINATE + || event.getKind() == DebugEvent.CHANGE) return true; return false; } @@ -53,24 +52,23 @@ public class ModulesViewEventHandler extends DebugEventHandler { * @see org.eclipse.debug.internal.ui.viewers.update.DebugEventHandler#handleChange(org.eclipse.debug.core.DebugEvent) */ @Override - protected void handleChange( DebugEvent event ) { - if ( event.getSource() instanceof ICModule ) - fireDelta( (ICModule)event.getSource(), IModelDelta.STATE ); + protected void handleChange(DebugEvent event) { + if (event.getSource() instanceof ICModule) + fireDelta((ICModule) event.getSource(), IModelDelta.STATE); } /* (non-Javadoc) * @see org.eclipse.debug.internal.ui.viewers.update.DebugEventHandler#handleCreate(org.eclipse.debug.core.DebugEvent) */ @Override - protected void handleCreate( DebugEvent event ) { + protected void handleCreate(DebugEvent event) { Object source = event.getSource(); - if ( source instanceof IDebugTarget ) { - refreshRoot( event ); - } - else if ( source instanceof ICModule ) { - if ( accept( (ICModule)source ) ) { - ICModule module = (ICModule)source; - fireDelta( module, IModelDelta.ADDED ); + if (source instanceof IDebugTarget) { + refreshRoot(event); + } else if (source instanceof ICModule) { + if (accept((ICModule) source)) { + ICModule module = (ICModule) source; + fireDelta(module, IModelDelta.ADDED); } } } @@ -79,20 +77,19 @@ public class ModulesViewEventHandler extends DebugEventHandler { * @see org.eclipse.debug.internal.ui.viewers.update.DebugEventHandler#handleTerminate(org.eclipse.debug.core.DebugEvent) */ @Override - protected void handleTerminate( DebugEvent event ) { + protected void handleTerminate(DebugEvent event) { Object source = event.getSource(); - if ( source instanceof IDebugTarget ) { - refreshRoot( event ); - } - else if ( source instanceof ICModule ) { - fireDelta( (ICModule)source, IModelDelta.REMOVED ); + if (source instanceof IDebugTarget) { + refreshRoot(event); + } else if (source instanceof ICModule) { + fireDelta((ICModule) source, IModelDelta.REMOVED); } } - private void fireDelta( ICModule module, int flags ) { - ModelDelta root = new ModelDelta( fModuleRetrieval, IModelDelta.NO_CHANGE ); - root.addNode( module, flags ); - fireDelta( root ); + private void fireDelta(ICModule module, int flags) { + ModelDelta root = new ModelDelta(fModuleRetrieval, IModelDelta.NO_CHANGE); + root.addNode(module, flags); + fireDelta(root); } /* (non-Javadoc) @@ -104,7 +101,7 @@ public class ModulesViewEventHandler extends DebugEventHandler { fModuleRetrieval = null; } - private boolean accept( ICModule module ) { - return fModuleRetrieval.equals( module.getAdapter( IModuleRetrieval.class ) ); + private boolean accept(ICModule module) { + return fModuleRetrieval.equals(module.getAdapter(IModuleRetrieval.class)); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesViewModelProxy.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesViewModelProxy.java index 79aa5585c81..1fca5a999e3 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesViewModelProxy.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesViewModelProxy.java @@ -11,12 +11,12 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.views.modules; +package org.eclipse.cdt.debug.internal.ui.views.modules; import org.eclipse.cdt.debug.core.model.IModuleRetrieval; import org.eclipse.debug.internal.ui.viewers.update.DebugEventHandler; import org.eclipse.debug.internal.ui.viewers.update.EventHandlerModelProxy; - + /** * Default update for modules view. */ @@ -24,10 +24,10 @@ public class ModulesViewModelProxy extends EventHandlerModelProxy { private IModuleRetrieval fModuleRetrieval; - /** - * Constructor for ModulesViewModelProxy. + /** + * Constructor for ModulesViewModelProxy. */ - public ModulesViewModelProxy( IModuleRetrieval moduleRetrieval ) { + public ModulesViewModelProxy(IModuleRetrieval moduleRetrieval) { super(); fModuleRetrieval = moduleRetrieval; } @@ -37,7 +37,7 @@ public class ModulesViewModelProxy extends EventHandlerModelProxy { */ @Override protected DebugEventHandler[] createEventHandlers() { - return new DebugEventHandler[] { new ModulesViewEventHandler( this, fModuleRetrieval ) }; + return new DebugEventHandler[] { new ModulesViewEventHandler(this, fModuleRetrieval) }; } /* (non-Javadoc) diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/FlexibleSignalsView.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/FlexibleSignalsView.java index 2fd0f20767e..9987d10bd60 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/FlexibleSignalsView.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/FlexibleSignalsView.java @@ -51,7 +51,8 @@ import org.eclipse.ui.progress.IWorkbenchSiteProgressService; /** * A Signals view based on flexible hierarchy. */ -public class FlexibleSignalsView extends AbstractDebugView implements IViewerUpdateListener, IDebugContextListener, IModelChangedListener { +public class FlexibleSignalsView extends AbstractDebugView + implements IViewerUpdateListener, IDebugContextListener, IModelChangedListener { private PresentationContext fPresentationContext; @@ -65,7 +66,7 @@ public class FlexibleSignalsView extends AbstractDebugView implements IViewerUpd @Override public void viewerInputComplete(IViewerInputUpdate update) { if (!update.isCanceled()) { - viewerInputUpdateComplete(update); + viewerInputUpdateComplete(update); } } }; @@ -92,31 +93,31 @@ public class FlexibleSignalsView extends AbstractDebugView implements IViewerUpd } return fModelPresentation; } - + protected TreeModelViewer createTreeViewer(Composite parent) { int style = getViewerStyle(); - fPresentationContext = new DebugModelPresentationContext(getPresentationContextId(), this, fModelPresentation); + fPresentationContext = new DebugModelPresentationContext(getPresentationContextId(), this, fModelPresentation); final TreeModelViewer variablesViewer = new TreeModelViewer(parent, style, fPresentationContext); - - variablesViewer.getPresentationContext().addPropertyChangeListener( - new IPropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent event) { - if (IPresentationContext.PROPERTY_COLUMNS.equals(event.getProperty())) { - IAction action = getAction("ShowTypeNames"); //$NON-NLS-1$ - if (action != null) { - action.setEnabled(event.getNewValue() == null); - } - } + + variablesViewer.getPresentationContext().addPropertyChangeListener(new IPropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent event) { + if (IPresentationContext.PROPERTY_COLUMNS.equals(event.getProperty())) { + IAction action = getAction("ShowTypeNames"); //$NON-NLS-1$ + if (action != null) { + action.setEnabled(event.getNewValue() == null); } - }); - - DebugUITools.getDebugContextManager().getContextService(getSite().getWorkbenchWindow()).addDebugContextListener(this); + } + } + }); + + DebugUITools.getDebugContextManager().getContextService(getSite().getWorkbenchWindow()) + .addDebugContextListener(this); return variablesViewer; } protected void viewerInputUpdateComplete(IViewerInputUpdate update) { - setViewerInput(update.getInputElement()); + setViewerInput(update.getInputElement()); } /** @@ -124,38 +125,38 @@ public class FlexibleSignalsView extends AbstractDebugView implements IViewerUpd * @param context the object context */ protected void setViewerInput(Object context) { - Object current = getViewer().getInput(); - - if (current == null && context == null) { - return; - } + Object current = getViewer().getInput(); - if (current != null && current.equals(context)) { - return; - } - - showViewer(); - getViewer().setInput(context); + if (current == null && context == null) { + return; + } + + if (current != null && current.equals(context)) { + return; + } + + showViewer(); + getViewer().setInput(context); } /** * Returns the presentation context id for this view. - * + * * @return context id */ protected String getPresentationContextId() { return ICDebugUIConstants.ID_SIGNALS_VIEW; } - + /** * Returns the style bits for the viewer. - * + * * @return SWT style */ protected int getViewerStyle() { return SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.VIRTUAL | SWT.FULL_SELECTION; } - + @Override protected void createActions() { } @@ -167,7 +168,7 @@ public class FlexibleSignalsView extends AbstractDebugView implements IViewerUpd @Override protected void fillContextMenu(IMenuManager menu) { - menu.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) ); + menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); updateObjects(); } @@ -180,11 +181,10 @@ public class FlexibleSignalsView extends AbstractDebugView implements IViewerUpd */ @Override public void viewerUpdatesBegin() { - IWorkbenchSiteProgressService progressService = - getSite().getAdapter(IWorkbenchSiteProgressService.class); - if (progressService != null) { - progressService.incrementBusy(); - } + IWorkbenchSiteProgressService progressService = getSite().getAdapter(IWorkbenchSiteProgressService.class); + if (progressService != null) { + progressService.incrementBusy(); + } } /* @@ -192,11 +192,10 @@ public class FlexibleSignalsView extends AbstractDebugView implements IViewerUpd */ @Override public void viewerUpdatesComplete() { - IWorkbenchSiteProgressService progressService = - getSite().getAdapter(IWorkbenchSiteProgressService.class); - if (progressService != null) { - progressService.decrementBusy(); - } + IWorkbenchSiteProgressService progressService = getSite().getAdapter(IWorkbenchSiteProgressService.class); + if (progressService != null) { + progressService.decrementBusy(); + } } /* @@ -240,11 +239,11 @@ public class FlexibleSignalsView extends AbstractDebugView implements IViewerUpd return; } if (selection instanceof IStructuredSelection) { - Object source = ((IStructuredSelection)selection).getFirstElement(); + Object source = ((IStructuredSelection) selection).getFirstElement(); fInputService.resolveViewerInput(source); } } - + /* * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IModelChangedListener#modelChanged(org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta, org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxy) */ diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/FlexibleSignalsViewEventHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/FlexibleSignalsViewEventHandler.java index bfc4fab3de6..787d57b7746 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/FlexibleSignalsViewEventHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/FlexibleSignalsViewEventHandler.java @@ -12,7 +12,7 @@ * QNX Software Systems - Initial API and implementation * Wind River Systems - flexible hierarchy Signals view (bug 338908) *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.views.signals; +package org.eclipse.cdt.debug.internal.ui.views.signals; import org.eclipse.cdt.debug.core.model.ICSignal; import org.eclipse.debug.core.DebugEvent; @@ -21,67 +21,63 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta; import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta; import org.eclipse.debug.internal.ui.viewers.provisional.AbstractModelProxy; import org.eclipse.debug.internal.ui.viewers.update.DebugEventHandler; - + /** */ public class FlexibleSignalsViewEventHandler extends DebugEventHandler { private Object fTarget; - /** - * Constructor for SignalsViewEventHandler. + /** + * Constructor for SignalsViewEventHandler. */ - public FlexibleSignalsViewEventHandler( AbstractModelProxy proxy, Object target ) { - super( proxy ); + public FlexibleSignalsViewEventHandler(AbstractModelProxy proxy, Object target) { + super(proxy); fTarget = target; } @Override - protected boolean handlesEvent( DebugEvent event ) { + protected boolean handlesEvent(DebugEvent event) { int kind = event.getKind(); - if ( kind == DebugEvent.CREATE || - kind == DebugEvent.TERMINATE || - kind == DebugEvent.CHANGE || - kind == DebugEvent.SUSPEND) + if (kind == DebugEvent.CREATE || kind == DebugEvent.TERMINATE || kind == DebugEvent.CHANGE + || kind == DebugEvent.SUSPEND) return true; return false; } @Override - protected void handleChange( DebugEvent event ) { - if ( event.getSource() instanceof ICSignal ) - fireDelta( (ICSignal)event.getSource(), IModelDelta.STATE ); + protected void handleChange(DebugEvent event) { + if (event.getSource() instanceof ICSignal) + fireDelta((ICSignal) event.getSource(), IModelDelta.STATE); } @Override - protected void handleCreate( DebugEvent event ) { + protected void handleCreate(DebugEvent event) { Object source = event.getSource(); - if ( source instanceof IDebugTarget ) { - refreshRoot( event ); - } - else if ( source instanceof ICSignal ) { - if ( accept( (ICSignal)source ) ) { - ICSignal signal = (ICSignal)source; - fireDelta( signal, IModelDelta.ADDED ); + if (source instanceof IDebugTarget) { + refreshRoot(event); + } else if (source instanceof ICSignal) { + if (accept((ICSignal) source)) { + ICSignal signal = (ICSignal) source; + fireDelta(signal, IModelDelta.ADDED); } } } @Override - protected void handleTerminate( DebugEvent event ) { + protected void handleTerminate(DebugEvent event) { Object source = event.getSource(); - if ( source instanceof IDebugTarget ) { - refreshRoot( event ); - } - else if ( source instanceof ICSignal ) { - fireDelta( (ICSignal)source, IModelDelta.REMOVED ); + if (source instanceof IDebugTarget) { + refreshRoot(event); + } else if (source instanceof ICSignal) { + fireDelta((ICSignal) source, IModelDelta.REMOVED); } } - private void fireDelta( ICSignal signal, int flags ) { - ModelDelta root = new ModelDelta( fTarget, IModelDelta.NO_CHANGE ); - root.addNode( signal, flags ); - fireDelta( root ); + private void fireDelta(ICSignal signal, int flags) { + ModelDelta root = new ModelDelta(fTarget, IModelDelta.NO_CHANGE); + root.addNode(signal, flags); + fireDelta(root); } @Override @@ -90,7 +86,7 @@ public class FlexibleSignalsViewEventHandler extends DebugEventHandler { fTarget = null; } - private boolean accept( ICSignal signal ) { - return fTarget.equals( signal.getDebugTarget() ); + private boolean accept(ICSignal signal) { + return fTarget.equals(signal.getDebugTarget()); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/SignalLabelProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/SignalLabelProvider.java index db8ee2d7689..cbf6b43d14f 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/SignalLabelProvider.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/SignalLabelProvider.java @@ -41,8 +41,8 @@ public class SignalLabelProvider extends ElementLabelProvider { } @Override - protected ImageDescriptor getImageDescriptor(TreePath elementPath, IPresentationContext presentationContext, String columnId) - throws CoreException { + protected ImageDescriptor getImageDescriptor(TreePath elementPath, IPresentationContext presentationContext, + String columnId) throws CoreException { Object element = elementPath.getLastSegment(); if (element instanceof ICSignal) { String[] columns = presentationContext.getColumns(); @@ -61,11 +61,9 @@ public class SignalLabelProvider extends ElementLabelProvider { case 0: return ((ICSignal) element).getName(); case 1: - return (((ICSignal) element).isPassEnabled()) ? SignalsViewer.YES_VALUE - : SignalsViewer.NO_VALUE; + return (((ICSignal) element).isPassEnabled()) ? SignalsViewer.YES_VALUE : SignalsViewer.NO_VALUE; case 2: - return (((ICSignal) element).isStopEnabled()) ? SignalsViewer.YES_VALUE - : SignalsViewer.NO_VALUE; + return (((ICSignal) element).isStopEnabled()) ? SignalsViewer.YES_VALUE : SignalsViewer.NO_VALUE; case 3: return ((ICSignal) element).getDescription(); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/SignalsMessages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/SignalsMessages.java index 68c568708c0..5ae8e6a30e2 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/SignalsMessages.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/SignalsMessages.java @@ -20,15 +20,15 @@ public class SignalsMessages { private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.views.signals.SignalsMessages";//$NON-NLS-1$ - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); private SignalsMessages() { } - public static String getString( String key ) { + public static String getString(String key) { try { - return RESOURCE_BUNDLE.getString( key ); - } catch( MissingResourceException e ) { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { return '!' + key + '!'; } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/SignalsViewColumnPresentation.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/SignalsViewColumnPresentation.java index f2758951a82..35b98199b8b 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/SignalsViewColumnPresentation.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/SignalsViewColumnPresentation.java @@ -25,81 +25,73 @@ import org.eclipse.jface.resource.ImageDescriptor; */ public class SignalsViewColumnPresentation implements IColumnPresentation { - private static final String PREFIX = CDebugUIPlugin.PLUGIN_ID + "."; //$NON-NLS-1$ - - public static final String ID = PREFIX + "signalsViewColumnPresentationId"; //$NON-NLS-1$ - - private static final String COLUMN_ID_NAME = VariableColumnPresentation.COLUMN_VARIABLE_NAME; - private static final String COLUMN_ID_PASS = PREFIX + "signalsColumn.pass"; //$NON-NLS-1$ - private static final String COLUMN_ID_STOP = PREFIX + "signalsColumn.stop"; //$NON-NLS-1$ - private static final String COLUMN_ID_DESC = PREFIX + "signalsColumn.desc"; //$NON-NLS-1$ - - private static final String CL_NAME = SignalsMessages.getString( "SignalsViewer.4" ); //$NON-NLS-1$ - private static final String CL_PASS = SignalsMessages.getString( "SignalsViewer.5" ); //$NON-NLS-1$ - private static final String CL_SUSPEND = SignalsMessages.getString( "SignalsViewer.6" ); //$NON-NLS-1$ - private static final String CL_DESCRIPTION = SignalsMessages.getString( "SignalsViewer.7" ); //$NON-NLS-1$ - - private static final String[] ALL_COLUMNS = new String[] { - COLUMN_ID_NAME, - COLUMN_ID_PASS, - COLUMN_ID_STOP, - COLUMN_ID_DESC - }; - - private static final String[] INITIAL_COLUMNS = new String[] { - COLUMN_ID_NAME, - COLUMN_ID_PASS, - COLUMN_ID_STOP, - COLUMN_ID_DESC - }; - - @Override - public void init( IPresentationContext context ) { - } - - @Override + private static final String PREFIX = CDebugUIPlugin.PLUGIN_ID + "."; //$NON-NLS-1$ + + public static final String ID = PREFIX + "signalsViewColumnPresentationId"; //$NON-NLS-1$ + + private static final String COLUMN_ID_NAME = VariableColumnPresentation.COLUMN_VARIABLE_NAME; + private static final String COLUMN_ID_PASS = PREFIX + "signalsColumn.pass"; //$NON-NLS-1$ + private static final String COLUMN_ID_STOP = PREFIX + "signalsColumn.stop"; //$NON-NLS-1$ + private static final String COLUMN_ID_DESC = PREFIX + "signalsColumn.desc"; //$NON-NLS-1$ + + private static final String CL_NAME = SignalsMessages.getString("SignalsViewer.4"); //$NON-NLS-1$ + private static final String CL_PASS = SignalsMessages.getString("SignalsViewer.5"); //$NON-NLS-1$ + private static final String CL_SUSPEND = SignalsMessages.getString("SignalsViewer.6"); //$NON-NLS-1$ + private static final String CL_DESCRIPTION = SignalsMessages.getString("SignalsViewer.7"); //$NON-NLS-1$ + + private static final String[] ALL_COLUMNS = new String[] { COLUMN_ID_NAME, COLUMN_ID_PASS, COLUMN_ID_STOP, + COLUMN_ID_DESC }; + + private static final String[] INITIAL_COLUMNS = new String[] { COLUMN_ID_NAME, COLUMN_ID_PASS, COLUMN_ID_STOP, + COLUMN_ID_DESC }; + + @Override + public void init(IPresentationContext context) { + } + + @Override public void dispose() { - } + } - @Override + @Override public String[] getAvailableColumns() { - return ALL_COLUMNS; - } + return ALL_COLUMNS; + } - @Override + @Override public String[] getInitialColumns() { - return INITIAL_COLUMNS; - } - - @Override - public String getHeader( String id ) { - if ( COLUMN_ID_NAME.equals( id ) ) { - return CL_NAME; - } - if ( COLUMN_ID_PASS.equals( id ) ) { - return CL_PASS; - } - if ( COLUMN_ID_STOP.equals( id ) ) { - return CL_SUSPEND; - } - if ( COLUMN_ID_DESC.equals( id ) ) { - return CL_DESCRIPTION; - } - return null; - } - - @Override - public ImageDescriptor getImageDescriptor( String id ) { - return null; - } - - @Override + return INITIAL_COLUMNS; + } + + @Override + public String getHeader(String id) { + if (COLUMN_ID_NAME.equals(id)) { + return CL_NAME; + } + if (COLUMN_ID_PASS.equals(id)) { + return CL_PASS; + } + if (COLUMN_ID_STOP.equals(id)) { + return CL_SUSPEND; + } + if (COLUMN_ID_DESC.equals(id)) { + return CL_DESCRIPTION; + } + return null; + } + + @Override + public ImageDescriptor getImageDescriptor(String id) { + return null; + } + + @Override public String getId() { - return ID; - } + return ID; + } - @Override + @Override public boolean isOptional() { - return true; - } + return true; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/SignalsViewEventHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/SignalsViewEventHandler.java index ca8f34eb3d2..02349bb3653 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/SignalsViewEventHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/SignalsViewEventHandler.java @@ -20,7 +20,6 @@ import org.eclipse.debug.core.DebugEvent; import org.eclipse.debug.core.model.IDebugTarget; import org.eclipse.debug.ui.AbstractDebugView; - /** * Updates the signals view. * @@ -30,33 +29,33 @@ public class SignalsViewEventHandler extends AbstractDebugEventHandler { /** * Constructs a new event handler on the given view - * + * * @param view signals view */ - public SignalsViewEventHandler( AbstractDebugView view ) { - super( view ); + public SignalsViewEventHandler(AbstractDebugView view) { + super(view); } /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandler#doHandleDebugEvents(org.eclipse.debug.core.DebugEvent[]) */ @Override - protected void doHandleDebugEvents( DebugEvent[] events ) { - for( int i = 0; i < events.length; i++ ) { + protected void doHandleDebugEvents(DebugEvent[] events) { + for (int i = 0; i < events.length; i++) { DebugEvent event = events[i]; - switch( event.getKind() ) { - case DebugEvent.CREATE: - case DebugEvent.TERMINATE: - if ( event.getSource() instanceof IDebugTarget || event.getSource() instanceof ICSignal ) - refresh(); - break; - case DebugEvent.SUSPEND: + switch (event.getKind()) { + case DebugEvent.CREATE: + case DebugEvent.TERMINATE: + if (event.getSource() instanceof IDebugTarget || event.getSource() instanceof ICSignal) refresh(); - break; - case DebugEvent.CHANGE: - if ( event.getSource() instanceof ICSignal ) - refresh( event.getSource() ); - break; + break; + case DebugEvent.SUSPEND: + refresh(); + break; + case DebugEvent.CHANGE: + if (event.getSource() instanceof ICSignal) + refresh(event.getSource()); + break; } } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/SignalsViewModelProxy.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/SignalsViewModelProxy.java index 852a9babfd3..1910b5c3719 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/SignalsViewModelProxy.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/SignalsViewModelProxy.java @@ -12,11 +12,11 @@ * QNX Software Systems - Initial API and implementation * Wind River Systems - flexible hierarchy Signals view (bug 338908) *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.views.signals; +package org.eclipse.cdt.debug.internal.ui.views.signals; import org.eclipse.debug.internal.ui.viewers.update.DebugEventHandler; import org.eclipse.debug.internal.ui.viewers.update.EventHandlerModelProxy; - + /** * Default update for Signals view. */ @@ -24,17 +24,17 @@ public class SignalsViewModelProxy extends EventHandlerModelProxy { private Object fTarget; - /** - * Constructor for SignalesViewModelProxy. + /** + * Constructor for SignalesViewModelProxy. */ - public SignalsViewModelProxy( Object target ) { + public SignalsViewModelProxy(Object target) { super(); fTarget = target; } @Override protected DebugEventHandler[] createEventHandlers() { - return new DebugEventHandler[] { new FlexibleSignalsViewEventHandler( this, fTarget ) }; + return new DebugEventHandler[] { new FlexibleSignalsViewEventHandler(this, fTarget) }; } @Override diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/SignalsViewer.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/SignalsViewer.java index c7541f74e92..eb7232ca0f4 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/SignalsViewer.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/signals/SignalsViewer.java @@ -23,7 +23,6 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; - /** * Signals viewer. * @@ -32,8 +31,8 @@ import org.eclipse.swt.widgets.TableColumn; public class SignalsViewer extends TableViewer { // String constants - protected static final String YES_VALUE = SignalsMessages.getString( "SignalsViewer.8" ); //$NON-NLS-1$ - protected static final String NO_VALUE = SignalsMessages.getString( "SignalsViewer.9" ); //$NON-NLS-1$ + protected static final String YES_VALUE = SignalsMessages.getString("SignalsViewer.8"); //$NON-NLS-1$ + protected static final String NO_VALUE = SignalsMessages.getString("SignalsViewer.9"); //$NON-NLS-1$ // Column properties private static final String CP_NAME = "name"; //$NON-NLS-1$ @@ -42,46 +41,46 @@ public class SignalsViewer extends TableViewer { private static final String CP_DESCRIPTION = "description"; //$NON-NLS-1$ // Column labels - private static final String CL_NAME = SignalsMessages.getString( "SignalsViewer.4" ); //$NON-NLS-1$ - private static final String CL_PASS = SignalsMessages.getString( "SignalsViewer.5" ); //$NON-NLS-1$ - private static final String CL_SUSPEND = SignalsMessages.getString( "SignalsViewer.6" ); //$NON-NLS-1$ - private static final String CL_DESCRIPTION = SignalsMessages.getString( "SignalsViewer.7" ); //$NON-NLS-1$ + private static final String CL_NAME = SignalsMessages.getString("SignalsViewer.4"); //$NON-NLS-1$ + private static final String CL_PASS = SignalsMessages.getString("SignalsViewer.5"); //$NON-NLS-1$ + private static final String CL_SUSPEND = SignalsMessages.getString("SignalsViewer.6"); //$NON-NLS-1$ + private static final String CL_DESCRIPTION = SignalsMessages.getString("SignalsViewer.7"); //$NON-NLS-1$ /** * Constructor for SignalsViewer - * + * * @param parent * @param style */ - public SignalsViewer( Composite parent, int style ) { - super( parent, style ); + public SignalsViewer(Composite parent, int style) { + super(parent, style); Table table = getTable(); - table.setLinesVisible( true ); - table.setHeaderVisible( true ); - table.setLayoutData( new GridData( GridData.FILL_BOTH ) ); + table.setLinesVisible(true); + table.setHeaderVisible(true); + table.setLayoutData(new GridData(GridData.FILL_BOTH)); // Create the table columns - new TableColumn( table, SWT.NULL ); - new TableColumn( table, SWT.NULL ); - new TableColumn( table, SWT.NULL ); - new TableColumn( table, SWT.NULL ); + new TableColumn(table, SWT.NULL); + new TableColumn(table, SWT.NULL); + new TableColumn(table, SWT.NULL); + new TableColumn(table, SWT.NULL); TableColumn[] columns = table.getColumns(); - columns[0].setResizable( true ); - columns[1].setResizable( true ); - columns[2].setResizable( true ); - columns[3].setResizable( true ); + columns[0].setResizable(true); + columns[1].setResizable(true); + columns[2].setResizable(true); + columns[3].setResizable(true); - columns[0].setText( CL_NAME ); - columns[1].setText( CL_PASS ); - columns[2].setText( CL_SUSPEND ); - columns[3].setText( CL_DESCRIPTION ); + columns[0].setText(CL_NAME); + columns[1].setText(CL_PASS); + columns[2].setText(CL_SUSPEND); + columns[3].setText(CL_DESCRIPTION); - PixelConverter pc = new PixelConverter( parent ); - columns[0].setWidth( pc.convertWidthInCharsToPixels( 20 ) ); - columns[1].setWidth( pc.convertWidthInCharsToPixels( 15 ) ); - columns[2].setWidth( pc.convertWidthInCharsToPixels( 15 ) ); - columns[3].setWidth( pc.convertWidthInCharsToPixels( 50 ) ); + PixelConverter pc = new PixelConverter(parent); + columns[0].setWidth(pc.convertWidthInCharsToPixels(20)); + columns[1].setWidth(pc.convertWidthInCharsToPixels(15)); + columns[2].setWidth(pc.convertWidthInCharsToPixels(15)); + columns[3].setWidth(pc.convertWidthInCharsToPixels(50)); - setColumnProperties( new String[]{ CP_NAME, CP_PASS, CP_SUSPEND, CP_DESCRIPTION } ); + setColumnProperties(new String[] { CP_NAME, CP_PASS, CP_SUSPEND, CP_DESCRIPTION }); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/AbstractCDebuggerPage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/AbstractCDebuggerPage.java index c7bbc8281f9..24bf8b8eba0 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/AbstractCDebuggerPage.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/AbstractCDebuggerPage.java @@ -11,61 +11,61 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.ui; +package org.eclipse.cdt.debug.ui; import org.eclipse.core.runtime.ListenerList; import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; - + /** * Common function for debugger pages. * @since 3.1 */ -abstract public class AbstractCDebuggerPage extends AbstractLaunchConfigurationTab - implements ICDebuggerPage, ICDebuggerPageExtension { +abstract public class AbstractCDebuggerPage extends AbstractLaunchConfigurationTab + implements ICDebuggerPage, ICDebuggerPageExtension { private String fDebuggerID = null; private ListenerList<IContentChangeListener> fContentListeners; - public AbstractCDebuggerPage() { - super(); - fContentListeners = new ListenerList<>(); - } + public AbstractCDebuggerPage() { + super(); + fContentListeners = new ListenerList<>(); + } @Override public void init(String debuggerID) { fDebuggerID = debuggerID; } - @Override - public void dispose() { - fContentListeners.clear(); - super.dispose(); - } + @Override + public void dispose() { + fContentListeners.clear(); + super.dispose(); + } @Override public String getDebuggerIdentifier() { return fDebuggerID; } - /** @since 7.0 */ - @Override + /** @since 7.0 */ + @Override public void addContentChangeListener(IContentChangeListener listener) { - fContentListeners.add(listener); - } + fContentListeners.add(listener); + } - /** @since 7.0 */ - @Override + /** @since 7.0 */ + @Override public void removeContentChangeListener(IContentChangeListener listener) { - fContentListeners.remove(listener); - } + fContentListeners.remove(listener); + } - /** - * Notifies the registered listeners that the page's content has changed. - * - * @since 7.0 - */ - protected void contentChanged() { - for (IContentChangeListener listener : fContentListeners) - listener.contentChanged(); - } + /** + * Notifies the registered listeners that the page's content has changed. + * + * @since 7.0 + */ + protected void contentChanged() { + for (IContentChangeListener listener : fContentListeners) + listener.contentChanged(); + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java index 2f0095fb20b..bba7b4c9c8c 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java @@ -78,7 +78,7 @@ public class CDebugUIPlugin extends AbstractUIPlugin { public static final String CDEBUGGER_PAGE_EXTENSION_POINT_ID = "CDebuggerPage"; //$NON-NLS-1$ public static final String DEBUGGER_PAGE_ELEMENT = "debuggerPage"; //$NON-NLS-1$ - + //The shared instance. private static CDebugUIPlugin plugin; @@ -86,9 +86,9 @@ public class CDebugUIPlugin extends AbstractUIPlugin { private CDebugImageDescriptorRegistry fImageDescriptorRegistry; - private DisassemblyEditorManager fDisassemblyEditorManager; - - private static IDebuggerConsoleManager fDebuggerConsoleManager; + private DisassemblyEditorManager fDisassemblyEditorManager; + + private static IDebuggerConsoleManager fDebuggerConsoleManager; /** * The constructor. @@ -123,8 +123,9 @@ public class CDebugUIPlugin extends AbstractUIPlugin { * Returns the a color based on the type of output. Valid types: * <li>CHANGED_REGISTER_RGB</li> */ - public static Color getPreferenceColor( String type ) { - return ColorManager.getDefault().getColor( PreferenceConverter.getColor( getDefault().getPreferenceStore(), type ) ); + public static Color getPreferenceColor(String type) { + return ColorManager.getDefault() + .getColor(PreferenceConverter.getColor(getDefault().getPreferenceStore(), type)); } public static CDebugModelPresentation getDebugModelPresentation() { @@ -133,89 +134,91 @@ public class CDebugUIPlugin extends AbstractUIPlugin { /** * Logs the specified status with this plug-in's log. - * + * * @param status * status to log */ - public static void log( IStatus status ) { - getDefault().getLog().log( status ); + public static void log(IStatus status) { + getDefault().getLog().log(status); } /** * Logs an internal error with the specified throwable - * + * * @param e * the exception to be logged */ - public static void log( Throwable e ) { - log( new Status( IStatus.ERROR, getUniqueIdentifier(), IInternalCDebugUIConstants.INTERNAL_ERROR, "Internal Error", e ) ); //$NON-NLS-1$ + public static void log(Throwable e) { + log(new Status(IStatus.ERROR, getUniqueIdentifier(), IInternalCDebugUIConstants.INTERNAL_ERROR, + "Internal Error", e)); //$NON-NLS-1$ } /** * Logs an internal error with the specified message. - * + * * @param message * the error message to log */ - public static void logErrorMessage( String message ) { - log( new Status( IStatus.ERROR, getUniqueIdentifier(), IInternalCDebugUIConstants.INTERNAL_ERROR, message, null ) ); + public static void logErrorMessage(String message) { + log(new Status(IStatus.ERROR, getUniqueIdentifier(), IInternalCDebugUIConstants.INTERNAL_ERROR, message, null)); } - public ICDebuggerPage getDebuggerPage( String debuggerID ) throws CoreException { - if ( fDebuggerPageMap == null ) { + public ICDebuggerPage getDebuggerPage(String debuggerID) throws CoreException { + if (fDebuggerPageMap == null) { initializeDebuggerPageMap(); } - IConfigurationElement configElement = fDebuggerPageMap.get( debuggerID ); + IConfigurationElement configElement = fDebuggerPageMap.get(debuggerID); ICDebuggerPage tab = null; - if ( configElement != null ) { - Object o = configElement.createExecutableExtension( "class" ); //$NON-NLS-1$ - if ( o instanceof ICDebuggerPage ) { - tab = (ICDebuggerPage)o; - tab.init( debuggerID ); - } - else if ( o instanceof ILaunchConfigurationTab ) { - tab = new CDebuggerPageAdapter( (ILaunchConfigurationTab)o ); - tab.init( debuggerID ); + if (configElement != null) { + Object o = configElement.createExecutableExtension("class"); //$NON-NLS-1$ + if (o instanceof ICDebuggerPage) { + tab = (ICDebuggerPage) o; + tab.init(debuggerID); + } else if (o instanceof ILaunchConfigurationTab) { + tab = new CDebuggerPageAdapter((ILaunchConfigurationTab) o); + tab.init(debuggerID); } } return tab; } protected void initializeDebuggerPageMap() { - fDebuggerPageMap = new HashMap<String, IConfigurationElement>( 10 ); - IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint( PLUGIN_ID, CDEBUGGER_PAGE_EXTENSION_POINT_ID ); + fDebuggerPageMap = new HashMap<String, IConfigurationElement>(10); + IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(PLUGIN_ID, + CDEBUGGER_PAGE_EXTENSION_POINT_ID); IConfigurationElement[] infos = extensionPoint.getConfigurationElements(); - for( int i = 0; i < infos.length; i++ ) { + for (int i = 0; i < infos.length; i++) { IConfigurationElement info = infos[i]; if (info.getName().equals(DEBUGGER_PAGE_ELEMENT)) { - String id = info.getAttribute( "debuggerID" ); //$NON-NLS-1$ + String id = info.getAttribute("debuggerID"); //$NON-NLS-1$ if (id != null) { - fDebuggerPageMap.put( id, info ); + fDebuggerPageMap.put(id, info); } } } } - public static void errorDialog( String message, IStatus status ) { - log( status ); + public static void errorDialog(String message, IStatus status) { + log(status); Shell shell = getActiveWorkbenchShell(); - if ( shell != null ) { - ErrorDialog.openError( shell, UIMessages.getString( "CDebugUIPlugin.0" ), message, status ); //$NON-NLS-1$ + if (shell != null) { + ErrorDialog.openError(shell, UIMessages.getString("CDebugUIPlugin.0"), message, status); //$NON-NLS-1$ } } - public static void errorDialog( String message, Throwable t ) { - log( t ); + public static void errorDialog(String message, Throwable t) { + log(t); Shell shell = getActiveWorkbenchShell(); - if ( shell != null ) { - IStatus status = new Status( IStatus.ERROR, getUniqueIdentifier(), IInternalCDebugUIConstants.INTERNAL_ERROR, t.getMessage(), null ); - ErrorDialog.openError( shell, UIMessages.getString( "CDebugUIPlugin.0" ), message, status ); //$NON-NLS-1$ + if (shell != null) { + IStatus status = new Status(IStatus.ERROR, getUniqueIdentifier(), IInternalCDebugUIConstants.INTERNAL_ERROR, + t.getMessage(), null); + ErrorDialog.openError(shell, UIMessages.getString("CDebugUIPlugin.0"), message, status); //$NON-NLS-1$ } } /** * Returns the active workbench window - * + * * @return the active workbench window */ public static IWorkbenchWindow getActiveWorkbenchWindow() { @@ -224,7 +227,7 @@ public class CDebugUIPlugin extends AbstractUIPlugin { public static IWorkbenchPage getActivePage() { IWorkbenchWindow w = getActiveWorkbenchWindow(); - if ( w != null ) { + if (w != null) { return w.getActivePage(); } return null; @@ -241,8 +244,7 @@ public class CDebugUIPlugin extends AbstractUIPlugin { if (windows.length > 0) { return windows[0].getShell(); } - } - else { + } else { return window.getShell(); } return null; @@ -255,7 +257,7 @@ public class CDebugUIPlugin extends AbstractUIPlugin { public static Display getStandardDisplay() { Display display; display = Display.getCurrent(); - if ( display == null ) + if (display == null) display = Display.getDefault(); return display; } @@ -264,7 +266,7 @@ public class CDebugUIPlugin extends AbstractUIPlugin { * Returns the image descriptor registry used for this plugin. */ public static CDebugImageDescriptorRegistry getImageDescriptorRegistry() { - if ( getDefault().fImageDescriptorRegistry == null ) { + if (getDefault().fImageDescriptorRegistry == null) { getDefault().fImageDescriptorRegistry = new CDebugImageDescriptorRegistry(); } return getDefault().fImageDescriptorRegistry; @@ -287,17 +289,17 @@ public class CDebugUIPlugin extends AbstractUIPlugin { /* * (non-Javadoc) - * + * * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) */ @Override - public void start( BundleContext context ) throws Exception { - super.start( context ); - fDisassemblyEditorManager = new DisassemblyEditorManager(); - CDebugCorePlugin.getDefault().addCBreakpointListener( CBreakpointUpdater.getInstance() ); - + public void start(BundleContext context) throws Exception { + super.start(context); + fDisassemblyEditorManager = new DisassemblyEditorManager(); + CDebugCorePlugin.getDefault().addCBreakpointListener(CBreakpointUpdater.getInstance()); + fDebuggerConsoleManager = new DebuggerConsoleManager(); - + WorkbenchJob wjob = new WorkbenchJob("Initializing CDT Debug UI") { //$NON-NLS-1$ @Override public IStatus runInUIThread(IProgressMonitor monitor) { @@ -310,42 +312,42 @@ public class CDebugUIPlugin extends AbstractUIPlugin { private void startupInUIThread() { ViewIDCounterManager.getInstance().init(); - + // We contribute actions to the platform's Variables view with a // criteria to enable only when this plugin is loaded. This can lead to // some edge cases with broken behavior (273306). The solution is to // force a selection change notification after we get loaded. IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows(); for (IWorkbenchWindow window : windows) { - IWorkbenchPage[] pages = window.getPages(); - for (IWorkbenchPage page : pages) { - IViewReference viewRef = page.findViewReference(IDebugUIConstants.ID_VARIABLE_VIEW); - if (viewRef != null) { - IViewPart part = viewRef.getView(false); - if (part instanceof IDebugView) { - Viewer viewer = ((IDebugView)part).getViewer(); - if (viewer != null) { - viewer.setSelection(viewer.getSelection()); - } - } - } - } + IWorkbenchPage[] pages = window.getPages(); + for (IWorkbenchPage page : pages) { + IViewReference viewRef = page.findViewReference(IDebugUIConstants.ID_VARIABLE_VIEW); + if (viewRef != null) { + IViewPart part = viewRef.getView(false); + if (part instanceof IDebugView) { + Viewer viewer = ((IDebugView) part).getViewer(); + if (viewer != null) { + viewer.setSelection(viewer.getSelection()); + } + } + } + } } } /* * (non-Javadoc) - * + * * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) */ @Override - public void stop( BundleContext context ) throws Exception { - CDebugCorePlugin.getDefault().removeCBreakpointListener( CBreakpointUpdater.getInstance() ); - fDisassemblyEditorManager.dispose(); - if ( fImageDescriptorRegistry != null ) { + public void stop(BundleContext context) throws Exception { + CDebugCorePlugin.getDefault().removeCBreakpointListener(CBreakpointUpdater.getInstance()); + fDisassemblyEditorManager.dispose(); + if (fImageDescriptorRegistry != null) { fImageDescriptorRegistry.dispose(); } - super.stop( context ); + super.stop(context); } /** @@ -358,13 +360,13 @@ public class CDebugUIPlugin extends AbstractUIPlugin { return EditorsUI.getSharedTextColors(); } - public DisassemblyEditorManager getDisassemblyEditorManager() { - return fDisassemblyEditorManager; - } - + public DisassemblyEditorManager getDisassemblyEditorManager() { + return fDisassemblyEditorManager; + } + /** * Returns an image descriptor for the image file at the given plug-in relative path - * + * * @param path * the path * @return the image descriptor @@ -374,7 +376,7 @@ public class CDebugUIPlugin extends AbstractUIPlugin { } /** - * + * * @param key - key is usually plug-in relative path to image like icons/xxx.gif * @return Image loaded from key location or from registry cache, it will be stored in plug-in registry and disposed when plug-in unloads */ @@ -383,7 +385,7 @@ public class CDebugUIPlugin extends AbstractUIPlugin { Image image = registry.get(key); if (image == null) { ImageDescriptor descriptor = imageDescriptorFromPlugin(PLUGIN_ID, key); - if (descriptor==null) { + if (descriptor == null) { ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages(); return sharedImages.getImage(key); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/ICDebugUIConstants.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/ICDebugUIConstants.java index a448b8fb83e..012fddbc867 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/ICDebugUIConstants.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/ICDebugUIConstants.java @@ -30,72 +30,72 @@ public interface ICDebugUIConstants { */ public static final String ID_EXECUTABLES_VIEW = PREFIX + "executablesView"; //$NON-NLS-1$ - /** - * Disassembly view identifier (value <code>"org.eclipse.cdt.debug.ui.DisassemblyView"</code>). - * @deprecated As of CDT 7.0 replaced by the DSF Disassembly view ("org.eclipse.cdt.dsf.debug.ui.disassembly.view") - */ - @Deprecated - public static final String ID_DISASSEMBLY_VIEW = PREFIX + "DisassemblyView"; //$NON-NLS-1$ - - /** - * Disassembly view identifier (value <code>"org.eclipse.cdt.dsf.debug.ui.disassembly.view"</code>). - * @since 7.0 - */ - public static final String ID_DSF_DISASSEMBLY_VIEW = "org.eclipse.cdt.dsf.debug.ui.disassembly.view"; //$NON-NLS-1$ - - /** - * Signals view identifier (value <code>"org.eclipse.cdt.debug.ui.SignalsView"</code>). - * @since 6.0 - */ - public static final String ID_SIGNALS_VIEW = PREFIX + "SignalsView"; //$NON-NLS-1$ - - /** - * Deafult disassembly editor identifier (value <code>"org.eclipse.cdt.debug.ui.disassemblyEditor"</code>). - */ - public static final String ID_DEFAULT_DISASSEMBLY_EDITOR = PREFIX + "disassemblyEditor"; //$NON-NLS-1$ + /** + * Disassembly view identifier (value <code>"org.eclipse.cdt.debug.ui.DisassemblyView"</code>). + * @deprecated As of CDT 7.0 replaced by the DSF Disassembly view ("org.eclipse.cdt.dsf.debug.ui.disassembly.view") + */ + @Deprecated + public static final String ID_DISASSEMBLY_VIEW = PREFIX + "DisassemblyView"; //$NON-NLS-1$ + + /** + * Disassembly view identifier (value <code>"org.eclipse.cdt.dsf.debug.ui.disassembly.view"</code>). + * @since 7.0 + */ + public static final String ID_DSF_DISASSEMBLY_VIEW = "org.eclipse.cdt.dsf.debug.ui.disassembly.view"; //$NON-NLS-1$ + + /** + * Signals view identifier (value <code>"org.eclipse.cdt.debug.ui.SignalsView"</code>). + * @since 6.0 + */ + public static final String ID_SIGNALS_VIEW = PREFIX + "SignalsView"; //$NON-NLS-1$ + + /** + * Deafult disassembly editor identifier (value <code>"org.eclipse.cdt.debug.ui.disassemblyEditor"</code>). + */ + public static final String ID_DEFAULT_DISASSEMBLY_EDITOR = PREFIX + "disassemblyEditor"; //$NON-NLS-1$ /** * Id for the popup menu associated with the detail (text viewer) part of the Modules view */ public static final String MODULES_VIEW_DETAIL_ID = PREFIX + "ModulesView.detail"; //$NON-NLS-1$ - /** + /** * Identifier for an empty group preceeding a * format group in a menu (value <code>"emptyFormatGroup"</code>). */ public static final String EMPTY_FORMAT_GROUP = "emptyFormatGroup"; //$NON-NLS-1$ - + /** * Identifier for a format group in a menu (value <code>"formatGroup"</code>). */ public static final String FORMAT_GROUP = "formatGroup"; //$NON-NLS-1$ - /** + /** * Identifier for an empty group preceeding a * refresh group in a menu (value <code>"emptyRefreshGroup"</code>). */ public static final String EMPTY_REFRESH_GROUP = "emptyRefreshGroup"; //$NON-NLS-1$ - + /** * Identifier for a refresh group in a menu (value <code>"refreshGroup" * </code>). */ public static final String REFRESH_GROUP = "refreshGroup"; //$NON-NLS-1$ - /** + /** * Identifier for an empty group preceeding a * modules group in a menu (value <code>"emptyModulesGroup"</code>). */ public static final String EMPTY_MODULES_GROUP = "emptyModulesGroup"; //$NON-NLS-1$ - + /** * Identifier for a shared libraries group in a menu (value <code>"modulesGroup"</code>). */ public static final String MODULES_GROUP = "modulesGroup"; //$NON-NLS-1$ - + /** * Editor ID for the CSourceNotFoundEditor. */ public static final String CSOURCENOTFOUND_EDITOR_ID = PREFIX + "SourceNotFoundEditor"; //$NON-NLS-1$ - + } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/ICDebuggerPage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/ICDebuggerPage.java index be93e5eca92..cb7f1603eea 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/ICDebuggerPage.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/ICDebuggerPage.java @@ -11,26 +11,26 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.ui; +package org.eclipse.cdt.debug.ui; import org.eclipse.debug.ui.ILaunchConfigurationTab; - + /** - * Interface for debugger pages contributed via the "CDebuggerPage" + * Interface for debugger pages contributed via the "CDebuggerPage" * extension point. - * + * * @since 3.1 */ public interface ICDebuggerPage extends ILaunchConfigurationTab { /** - * Allows the page to initialize itself after being created. - * This lifecycle method is called after the page has been created + * Allows the page to initialize itself after being created. + * This lifecycle method is called after the page has been created * and before any other method of the page is called. - * + * * @param debuggerID the identifier of the debugger this page is created for. */ - public void init( String debuggerID ); + public void init(String debuggerID); /** * Returns the identifier of the debugger this page is associated with. diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/ICDebuggerPageExtension.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/ICDebuggerPageExtension.java index 6354bf8ab05..591b85d14d8 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/ICDebuggerPageExtension.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/ICDebuggerPageExtension.java @@ -15,30 +15,30 @@ package org.eclipse.cdt.debug.ui; /** * This interface extension allows the registration of content listeners. - * Page implementors can use it to notify parents of changes in + * Page implementors can use it to notify parents of changes in * the page content which will force the parent tab to recalculate its size. - * + * * @since 7.0 */ public interface ICDebuggerPageExtension extends ICDebuggerPage { - /** - * @since 7.0 - */ - public interface IContentChangeListener { + /** + * @since 7.0 + */ + public interface IContentChangeListener { - void contentChanged(); - } + void contentChanged(); + } - /** - * Adds a listener to this page. This method has no effect - * if the same listener is already registered. - */ - void addContentChangeListener( IContentChangeListener listener ); + /** + * Adds a listener to this page. This method has no effect + * if the same listener is already registered. + */ + void addContentChangeListener(IContentChangeListener listener); - /** - * Removes a listener from this list. Has no effect if - * the same listener was not already registered. - */ - void removeContentChangeListener( IContentChangeListener listener ); + /** + * Removes a listener from this list. Has no effect if + * the same listener was not already registered. + */ + void removeContentChangeListener(IContentChangeListener listener); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/IPinProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/IPinProvider.java index c09197f522d..77e93167813 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/IPinProvider.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/IPinProvider.java @@ -12,7 +12,7 @@ * Patrick Chuong (Texas Instruments) - Pin and Clone Supports (331781) * Patrick Chuong (Texas Instruments) - Add support for icon overlay in the debug view (Bug 334566) *****************************************************************/ -package org.eclipse.cdt.debug.ui; +package org.eclipse.cdt.debug.ui; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.ISelection; @@ -21,14 +21,14 @@ import org.eclipse.ui.IWorkbenchPart; /** * Debug element that wants to enable pin capability should be adaptable to this interface. * <br><br> - * When the user presses the 'Pin' action in a view that supports debug context pinning, the + * When the user presses the 'Pin' action in a view that supports debug context pinning, the * DebugEventFilterService calls the <code>pin</code> method with the selected debug context. * If more than one debug context is selected, the <code>pin</code> method is called multiple times. * The <code>pin</code> method should return a handle for the pinned debug context and when - * there is a debug context change event generated by the debug context manager, + * there is a debug context change event generated by the debug context manager, * <code>isPinnedTo</code> will be call by the DebugEventFilterService to determine whether the * debug context in question is pinned to the handle returned by the <code>pin</code> method. - * + * * @since 7.1 */ public interface IPinProvider { @@ -39,119 +39,118 @@ public interface IPinProvider { /** * Default number of color count. */ - final int DEFAULT_COLOR_COUNT = 3; - + final int DEFAULT_COLOR_COUNT = 3; + /** * An undefined color */ int UNDEFINED = -1; - + /** * Green color (Default) */ int GREEN = 0; - + /** * Red color */ int RED = 1; - + /** * Blue color */ int BLUE = 2; - + /** * Returns the overlay pin color. The overlay pin will be used to decorate the debug view for an element that * is pinned to a view. - * + * * @return one of the overlay colors */ int getOverlayColor(); - + /** - * Returns the toolbar pin action image description to use when the view is pinned, can be <code>null</code>. + * Returns the toolbar pin action image description to use when the view is pinned, can be <code>null</code>. * If <code>null</code>, then the default image description will be used. - * + * * @return the icon descriptor */ ImageDescriptor getToolbarIconDescriptor(); } - + /** - * Pin element handler interface. + * Pin element handler interface. */ public interface IPinElementHandle { /** * Returns the debug context for this handle. - * + * * @return the debug context */ Object getDebugContext(); - + /** * Returns the label that will be used in the pinned view's description. - * + * * @return the handle label */ String getLabel(); - + /** * Returns color descriptor for this element. - * + * * @return the color descriptor, can be <code>null</code> */ IPinElementColorDescriptor getPinElementColorDescriptor(); } - + /** - * A callback interface that can be used by an IPinProvider to indicate + * A callback interface that can be used by an IPinProvider to indicate * that the model has changed for a pinned view and that the view must be * refreshed. * - * @noimplement This interface is not intended to be implemented by clients. + * @noimplement This interface is not intended to be implemented by clients. */ public interface IPinModelListener { /** * Model changed handler that will cause the view to update. - * + * * @param newSelection the new selection, if {@code null} the view will blank out. - * + * */ void modelChanged(ISelection newSelection); } /** * Returns whether the debug context is pinnable. - * + * * @param part the workbench part * @param debugContext the debug context in question * @return true if the debug context is pinnable */ boolean isPinnable(IWorkbenchPart part, Object debugContext); - + /** * Pin the debug context and returns a handle for the pinned debug context. - * + * * @param part the workbench part * @param debugContext the debug context to pin to * @return a handle for the pinned debug context */ IPinElementHandle pin(IWorkbenchPart part, Object debugContext, IPinModelListener listener); - + /** * Unpin the debug context for the given pin handle. - * + * * @param part the workbench part * @param handle the handle for the pinned debug context */ void unpin(IWorkbenchPart part, IPinElementHandle handle); - - + /** * Returns true if the debug context belongs to the handle. If returning true, - * then the debug context change event will be delegated to the view. - * + * then the debug context change event will be delegated to the view. + * * @param debugContext the debug context in question * @param handle an existing pinned debug context handle * @return true to delegate debug context change event to the view diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/PinElementHandle.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/PinElementHandle.java index 963203432b8..6a109dcadb3 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/PinElementHandle.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/PinElementHandle.java @@ -20,14 +20,14 @@ import org.eclipse.core.runtime.PlatformObject; /** * A class that encapsulates the pin element handle and implements <code>IPinHandleLableProvider</code>. - * + * * @since 7.1 */ public class PinElementHandle extends PlatformObject implements IPinElementHandle { private Object fDebugContext; private String fLabel; private IPinElementColorDescriptor fColorDescriptor; - + public PinElementHandle(Object debugContext, String label, IPinElementColorDescriptor colorDescriptor) { fDebugContext = debugContext; fLabel = label; @@ -41,17 +41,17 @@ public class PinElementHandle extends PlatformObject implements IPinElementHandl @Override public synchronized Object getDebugContext() { return fDebugContext; - } - + } + /** * Sets the debug context. - * + * * @param debugContext the new debug context */ public synchronized void setDebugContext(Object debugContext) { fDebugContext = debugContext; } - + /* * (non-Javadoc) * @see org.eclipse.cdt.debug.core.IPinProvider.IHandleLabelProvider#getLabel() @@ -60,7 +60,7 @@ public class PinElementHandle extends PlatformObject implements IPinElementHandl public String getLabel() { return fLabel; } - + /* * (non-Javadoc) * @see org.eclipse.cdt.debug.ui.IPinProvider.IPinElementHandle#getPinElementColorDescriptor() @@ -69,7 +69,7 @@ public class PinElementHandle extends PlatformObject implements IPinElementHandl public IPinElementColorDescriptor getPinElementColorDescriptor() { return fColorDescriptor; } - + /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/UIMessages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/UIMessages.java index 94c099371f4..4dc44e3153a 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/UIMessages.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/UIMessages.java @@ -20,16 +20,15 @@ public class UIMessages { private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.ui.UIMessages";//$NON-NLS-1$ - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); private UIMessages() { } - public static String getString( String key ) { + public static String getString(String key) { try { - return RESOURCE_BUNDLE.getString( key ); - } - catch( MissingResourceException e ) { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { return '!' + key + '!'; } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionDialog.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionDialog.java index ac14f348dae..bfab3bf9d8f 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionDialog.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionDialog.java @@ -139,7 +139,8 @@ public class ActionDialog extends Dialog { combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); // - IExtension[] actionExtensions = CDebugCorePlugin.getDefault().getBreakpointActionManager().getBreakpointActionExtensions(); + IExtension[] actionExtensions = CDebugCorePlugin.getDefault().getBreakpointActionManager() + .getBreakpointActionExtensions(); breakpointActions = new IBreakpointAction[actionExtensions.length]; actionPages = new IBreakpointActionPage[actionExtensions.length]; @@ -147,7 +148,8 @@ public class ActionDialog extends Dialog { if (actionExtensions.length > 0) { - String lastTypeName = CDebugUIPlugin.getDefault().getPreferenceStore().getString(ACTION_DIALOG_LAST_SELECTED); + String lastTypeName = CDebugUIPlugin.getDefault().getPreferenceStore() + .getString(ACTION_DIALOG_LAST_SELECTED); if (breakpointAction != null) { lastTypeName = breakpointAction.getTypeName(); @@ -207,7 +209,8 @@ public class ActionDialog extends Dialog { @Override protected void okPressed() { if (originalAction == null) - CDebugUIPlugin.getDefault().getPreferenceStore().setValue(ACTION_DIALOG_LAST_SELECTED, breakpointAction.getTypeName()); + CDebugUIPlugin.getDefault().getPreferenceStore().setValue(ACTION_DIALOG_LAST_SELECTED, + breakpointAction.getTypeName()); String newName = actionNameTextWidget.getText(); if (originalAction == null || !originalAction.getName().equals(newName)) { actionName = CDebugCorePlugin.getDefault().getBreakpointActionManager().makeUniqueActionName(newName); @@ -226,7 +229,8 @@ public class ActionDialog extends Dialog { int elementCount = 0; IConfigurationElement selectedElement = null; - IExtension[] actionExtensions = CDebugCorePlugin.getDefault().getBreakpointActionManager().getBreakpointActionExtensions(); + IExtension[] actionExtensions = CDebugCorePlugin.getDefault().getBreakpointActionManager() + .getBreakpointActionExtensions(); for (int i = 0; i < actionExtensions.length && selectedElement == null; i++) { IConfigurationElement[] elements = actionExtensions[i].getConfigurationElements(); @@ -250,7 +254,8 @@ public class ActionDialog extends Dialog { actionPage = actionPages[selectedTypeIndex]; } if (actionComposites[selectedTypeIndex] == null) { - Composite actionComposite = actionPages[selectedTypeIndex].createComposite(breakpointAction, actionArea, SWT.NONE); + Composite actionComposite = actionPages[selectedTypeIndex].createComposite(breakpointAction, actionArea, + SWT.NONE); actionComposites[selectedTypeIndex] = actionComposite; } actionName = breakpointAction.getName(); @@ -263,7 +268,8 @@ public class ActionDialog extends Dialog { public IExtension[] getBreakpointActionPageExtensions() { if (breakpointActionPageExtensions == null) { - IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CDebugUIPlugin.PLUGIN_ID, BREAKPOINT_ACTION_PAGE_EXTENSION_POINT_ID); + IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CDebugUIPlugin.PLUGIN_ID, + BREAKPOINT_ACTION_PAGE_EXTENSION_POINT_ID); if (point == null) breakpointActionPageExtensions = new IExtension[0]; else { @@ -304,16 +310,15 @@ public class ActionDialog extends Dialog { gd.horizontalIndent = FieldDecorationRegistry.getDefault().getMaximumDecorationWidth(); control.setLayoutData(gd); - final ControlDecoration decoration = new ControlDecoration(control, SWT.TOP | SWT.LEFT, parent ); + final ControlDecoration decoration = new ControlDecoration(control, SWT.TOP | SWT.LEFT, parent); decoration.hide(); control.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { String name = control.getText(); if (name.trim().isEmpty()) { - decoration.setImage( - FieldDecorationRegistry.getDefault().getFieldDecoration( - FieldDecorationRegistry.DEC_ERROR).getImage()); + decoration.setImage(FieldDecorationRegistry.getDefault() + .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage()); decoration.setDescriptionText(Messages.getString("ActionDialog.ErrEmptyName")); //$NON-NLS-1$ decoration.show(); } else { diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionsList.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionsList.java index 4c8d7bcd387..56ee5588a58 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionsList.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionsList.java @@ -116,7 +116,7 @@ public class ActionsList extends Composite { /** * Remove an action from the list - * + * * @since 7.0 */ public void removeAction(IBreakpointAction action) { @@ -185,7 +185,8 @@ public class ActionsList extends Composite { while (tok.hasMoreTokens()) { String actionName = tok.nextToken(); - IBreakpointAction action = CDebugCorePlugin.getDefault().getBreakpointActionManager().findBreakpointAction(actionName); + IBreakpointAction action = CDebugCorePlugin.getDefault().getBreakpointActionManager() + .findBreakpointAction(actionName); if (action != null) { final TableItem tableItem = new TableItem(table, SWT.NONE); tableItem.setText(0, action.getName()); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionsPreferencePage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionsPreferencePage.java index 0d9b703ffbf..c431e3f8866 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionsPreferencePage.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionsPreferencePage.java @@ -54,8 +54,8 @@ public class ActionsPreferencePage extends PreferencePage implements IWorkbenchP actionsList.HandleDeleteButton(); } }); - - String helpContextID = CDebugUIPlugin.PLUGIN_ID + "." + contextHelpID; //$NON-NLS-1$ + + String helpContextID = CDebugUIPlugin.PLUGIN_ID + "." + contextHelpID; //$NON-NLS-1$ PlatformUI.getWorkbench().getHelpSystem().setHelp(super.getControl(), helpContextID); return container; diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionsPropertyPage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionsPropertyPage.java index cb4dca68b95..0d4767e3420 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionsPropertyPage.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionsPropertyPage.java @@ -112,7 +112,7 @@ public class ActionsPropertyPage extends PropertyPage { /** * Clean up attached actions that were just deleted from the GlobalActionList - * + * * @since 7.0 */ protected void HandleDeleteButton() { @@ -144,7 +144,8 @@ public class ActionsPropertyPage extends PropertyPage { public boolean performOk() { try { CDebugCorePlugin.getDefault().getBreakpointActionManager().saveActionData(); - breakpointMarker.setAttribute(BreakpointActionManager.BREAKPOINT_ACTION_ATTRIBUTE, actionsList.getActionNames()); + breakpointMarker.setAttribute(BreakpointActionManager.BREAKPOINT_ACTION_ATTRIBUTE, + actionsList.getActionNames()); } catch (CoreException e) { } return super.performOk(); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandAction.java index 11c803030c2..cb8cd86c7ba 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandAction.java @@ -54,8 +54,7 @@ public class CLICommandAction extends AbstractBreakpointAction { } } else return new Status(IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), - IInternalCDebugUIConstants.INTERNAL_ERROR, - Messages.getString("CLICommandAction.NoSupport"), null); //$NON-NLS-1$ + IInternalCDebugUIConstants.INTERNAL_ERROR, Messages.getString("CLICommandAction.NoSupport"), null); //$NON-NLS-1$ return monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS; } @@ -84,7 +83,7 @@ public class CLICommandAction extends AbstractBreakpointAction { rootElement.setAttribute(COMMAND_ATT, command); doc.appendChild(rootElement); return DebugPlugin.serializeDocument(doc); - } catch (DOMException | CoreException e) { + } catch (DOMException | CoreException e) { CDebugUIPlugin.log(e); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandActionPage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandActionPage.java index adebc47eb84..90c7331651a 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandActionPage.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/CLICommandActionPage.java @@ -21,8 +21,7 @@ import org.eclipse.swt.widgets.Composite; /** * @since 8.0 */ -public class CLICommandActionPage extends PlatformObject implements - IBreakpointActionPage { +public class CLICommandActionPage extends PlatformObject implements IBreakpointActionPage { private CLICommandAction cliCommandAction; private CLICommandActionComposite editor; diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ExternalToolAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ExternalToolAction.java index 152e6960a9f..b664c08d21a 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ExternalToolAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ExternalToolAction.java @@ -51,27 +51,27 @@ public class ExternalToolAction extends AbstractBreakpointAction { private String externalToolName = ""; //$NON-NLS-1$ - @Override - public IStatus execute(final IBreakpoint breakpoint, final IAdaptable context, final IProgressMonitor monitor) { - Job uiJob = new WorkbenchJob("ExternalToolAction") { //$NON-NLS-1$ - { - setPriority(INTERACTIVE); - } - - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - return executeInUIThread(breakpoint, context, monitor); - } - }; - uiJob.schedule(); - try { - uiJob.join(); - } catch (InterruptedException e) { - return Status.CANCEL_STATUS; - } - return uiJob.getResult(); - } - + @Override + public IStatus execute(final IBreakpoint breakpoint, final IAdaptable context, final IProgressMonitor monitor) { + Job uiJob = new WorkbenchJob("ExternalToolAction") { //$NON-NLS-1$ + { + setPriority(INTERACTIVE); + } + + @Override + public IStatus runInUIThread(IProgressMonitor monitor) { + return executeInUIThread(breakpoint, context, monitor); + } + }; + uiJob.schedule(); + try { + uiJob.join(); + } catch (InterruptedException e) { + return Status.CANCEL_STATUS; + } + return uiJob.getResult(); + } + private IStatus executeInUIThread(IBreakpoint breakpoint, IAdaptable context, IProgressMonitor monitor) { IStatus errorStatus = null; ILaunchManager lcm = DebugPlugin.getDefault().getLaunchManager(); @@ -86,19 +86,24 @@ public class ExternalToolAction extends AbstractBreakpointAction { } } if (!launched) { - String errorMsg = MessageFormat.format(Messages.getString("ExternalToolAction.error.0"), new Object[] { externalToolName }); //$NON-NLS-1$ - errorStatus = new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, errorMsg, null); + String errorMsg = MessageFormat.format(Messages.getString("ExternalToolAction.error.0"), //$NON-NLS-1$ + new Object[] { externalToolName }); + errorStatus = new Status(IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), + ICDebugInternalConstants.STATUS_CODE_ERROR, errorMsg, null); } - + } catch (CoreException e) { errorStatus = e.getStatus(); } catch (Exception e) { - errorStatus = new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, e.getMessage(), e ); + errorStatus = new Status(IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), + ICDebugInternalConstants.STATUS_CODE_ERROR, e.getMessage(), e); } - + if (errorStatus != null) { - String errorMsg = MessageFormat.format(Messages.getString("ExternalToolAction.error.1"), new Object[] { externalToolName }); //$NON-NLS-1$ - MultiStatus ms = new MultiStatus( CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, errorMsg, null ); + String errorMsg = MessageFormat.format(Messages.getString("ExternalToolAction.error.1"), //$NON-NLS-1$ + new Object[] { externalToolName }); + MultiStatus ms = new MultiStatus(CDIDebugModel.getPluginIdentifier(), + ICDebugInternalConstants.STATUS_CODE_ERROR, errorMsg, null); ms.add(errorStatus); return ms; } @@ -161,7 +166,8 @@ public class ExternalToolAction extends AbstractBreakpointAction { @Override public String getSummary() { - return MessageFormat.format(Messages.getString("ExternalToolAction.Summary"), new Object[] { externalToolName }); //$NON-NLS-1$ + return MessageFormat.format(Messages.getString("ExternalToolAction.Summary"), //$NON-NLS-1$ + new Object[] { externalToolName }); } @Override diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ExternalToolActionComposite.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ExternalToolActionComposite.java index 5d5218ec9d9..e2ad2fc20e4 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ExternalToolActionComposite.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ExternalToolActionComposite.java @@ -53,7 +53,7 @@ public class ExternalToolActionComposite extends Composite { /** * Creates a new plug-in contribution for the given type - * + * * @param type * the launch configuration type */ @@ -63,7 +63,7 @@ public class ExternalToolActionComposite extends Composite { /* * (non-Javadoc) - * + * * @see org.eclipse.ui.IPluginContribution#getLocalId() */ @Override @@ -73,7 +73,7 @@ public class ExternalToolActionComposite extends Composite { /* * (non-Javadoc) - * + * * @see org.eclipse.ui.IPluginContribution#getPluginId() */ @Override @@ -124,7 +124,7 @@ public class ExternalToolActionComposite extends Composite { /** * Create the composite - * + * * @param parent * @param style * @param page @@ -151,7 +151,8 @@ public class ExternalToolActionComposite extends Composite { public void widgetSelected(SelectionEvent e) { ILaunchConfiguration[] lcs = getLaunchConfigurations(); - LaunchConfigurationSelectionDialog dlg = new LaunchConfigurationSelectionDialog(externalToolActionComposite, lcs); + LaunchConfigurationSelectionDialog dlg = new LaunchConfigurationSelectionDialog( + externalToolActionComposite, lcs); dlg.setTitle(Messages.getString("ExternalToolActionComposite.DialogTitle")); //$NON-NLS-1$ dlg.setMessage(Messages.getString("ExternalToolActionComposite.DialogMessage")); //$NON-NLS-1$ if (lcs.length > 0) { @@ -173,7 +174,8 @@ public class ExternalToolActionComposite extends Composite { if (dlg.open() == Window.OK) { Object[] selectedTool = dlg.getResult(); if (selectedTool.length > 0 && selectedTool[0] instanceof ILaunchConfiguration) { - externalToolActionComposite.setExternalToolName(((ILaunchConfiguration) selectedTool[0]).getName()); + externalToolActionComposite + .setExternalToolName(((ILaunchConfiguration) selectedTool[0]).getName()); } } @@ -186,7 +188,8 @@ public class ExternalToolActionComposite extends Composite { externalToolsButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - DebugUITools.openLaunchConfigurationDialogOnGroup(externalToolActionComposite.getShell(), new StructuredSelection(), "org.eclipse.ui.externaltools.launchGroup"); //$NON-NLS-1$ + DebugUITools.openLaunchConfigurationDialogOnGroup(externalToolActionComposite.getShell(), + new StructuredSelection(), "org.eclipse.ui.externaltools.launchGroup"); //$NON-NLS-1$ browseButton.setEnabled(getLaunchConfigurations().length > 0); } }); @@ -221,7 +224,8 @@ public class ExternalToolActionComposite extends Composite { } catch (CoreException e) { } if (type != null) { - if (!priv && type.supportsMode(ILaunchManager.RUN_MODE) && equalCategories(type.getCategory(), "org.eclipse.ui.externaltools") //$NON-NLS-1$ + if (!priv && type.supportsMode(ILaunchManager.RUN_MODE) + && equalCategories(type.getCategory(), "org.eclipse.ui.externaltools") //$NON-NLS-1$ && !WorkbenchActivityHelper.filterItem(new LaunchConfigurationTypeContribution(type))) onlyExternalTools.add(launchConfigurations[i]); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/GlobalActionsList.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/GlobalActionsList.java index 8e6c2294b6c..319ba219ff4 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/GlobalActionsList.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/GlobalActionsList.java @@ -75,7 +75,8 @@ public class GlobalActionsList extends Composite { summaryTableColumn.setWidth(120); summaryTableColumn.setText(Messages.getString("GlobalActionsList.2")); //$NON-NLS-1$ - for (IBreakpointAction element : CDebugCorePlugin.getDefault().getBreakpointActionManager().getBreakpointActions()) { + for (IBreakpointAction element : CDebugCorePlugin.getDefault().getBreakpointActionManager() + .getBreakpointActions()) { final TableItem tableItem = new TableItem(table, SWT.NONE); tableItem.setText(0, element.getName()); tableItem.setText(1, element.getTypeName()); @@ -102,7 +103,8 @@ public class GlobalActionsList extends Composite { } }); newButton.setText(Messages.getString("GlobalActionsList.4")); //$NON-NLS-1$ - newButton.setEnabled(CDebugCorePlugin.getDefault().getBreakpointActionManager().getBreakpointActionExtensions().length > 0); + newButton.setEnabled( + CDebugCorePlugin.getDefault().getBreakpointActionManager().getBreakpointActionExtensions().length > 0); editButton = new Button(this, SWT.NONE); editButton.setText(Messages.getString("GlobalActionsList.5")); //$NON-NLS-1$ diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/IBreakpointActionPage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/IBreakpointActionPage.java index 79e9e2d2376..b3f8557b0a1 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/IBreakpointActionPage.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/IBreakpointActionPage.java @@ -17,7 +17,7 @@ import org.eclipse.cdt.debug.core.breakpointactions.IBreakpointAction; import org.eclipse.swt.widgets.Composite; /** - * + * * THIS INTERFACE IS PROVISIONAL AND WILL CHANGE IN THE FUTURE * PLUG-INS USING THIS INTERFACE WILL NEED * TO BE REVISED TO WORK WITH FUTURE VERSIONS OF CDT. diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/LogAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/LogAction.java index 8ebae9c9188..51f5aa990bc 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/LogAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/LogAction.java @@ -78,8 +78,10 @@ public class LogAction extends AbstractBreakpointAction { stream.println(logMessage); stream.close(); } catch (Exception e) { - String errorMsg = MessageFormat.format(Messages.getString("LogAction.error.0"), new Object[] {getSummary()}); //$NON-NLS-1$ - result = new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, errorMsg, e ); + String errorMsg = MessageFormat.format(Messages.getString("LogAction.error.0"), //$NON-NLS-1$ + new Object[] { getSummary() }); + result = new Status(IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), + ICDebugInternalConstants.STATUS_CODE_ERROR, errorMsg, e); } return result; } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/PreferenceInitializer.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/PreferenceInitializer.java index 4ccf3916c93..f44cf7cb480 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/PreferenceInitializer.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/PreferenceInitializer.java @@ -24,7 +24,7 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer { /* * (non-Javadoc) - * + * * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() */ @Override diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ResumeAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ResumeAction.java index 8e4884406d1..805bd98dff3 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ResumeAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ResumeAction.java @@ -45,9 +45,9 @@ import org.xml.sax.helpers.DefaultHandler; public class ResumeAction extends AbstractBreakpointAction { final static int INCRIMENT_MSEC = 100; - + int pauseTime = 0; - + /* * (non-Javadoc) * @see org.eclipse.cdt.debug.core.breakpointactions.IBreakpointAction#execute(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.runtime.IAdaptable, org.eclipse.core.runtime.IProgressMonitor) @@ -55,39 +55,43 @@ public class ResumeAction extends AbstractBreakpointAction { @Override public IStatus execute(IBreakpoint breakpoint, IAdaptable context, IProgressMonitor monitor) { IStatus errorStatus = null; - long endTime = System.currentTimeMillis() + getPauseTime()*1000; + long endTime = System.currentTimeMillis() + getPauseTime() * 1000; IResumeActionEnabler enabler = context.getAdapter(IResumeActionEnabler.class); if (enabler != null) { try { - monitor.beginTask(getName(), getPauseTime()*1000/INCRIMENT_MSEC); - + monitor.beginTask(getName(), getPauseTime() * 1000 / INCRIMENT_MSEC); + long currentTime = System.currentTimeMillis(); - while (!monitor.isCanceled() && currentTime < endTime ){ - monitor.setTaskName(MessageFormat.format(Messages.getString("ResumeAction.SummaryResumeTime"), new Object[] { Long.valueOf((endTime - currentTime)/1000) })); //$NON-NLS-1$) - monitor.worked(1); - Thread.sleep(INCRIMENT_MSEC); - currentTime = System.currentTimeMillis(); - } - + while (!monitor.isCanceled() && currentTime < endTime) { + monitor.setTaskName(MessageFormat.format(Messages.getString("ResumeAction.SummaryResumeTime"), //$NON-NLS-1$ + new Object[] { Long.valueOf((endTime - currentTime) / 1000) })); //) + monitor.worked(1); + Thread.sleep(INCRIMENT_MSEC); + currentTime = System.currentTimeMillis(); + } + if (!monitor.isCanceled()) { - monitor.setTaskName( Messages.getString("ResumeAction.SummaryImmediately")); //$NON-NLS-1$) + monitor.setTaskName(Messages.getString("ResumeAction.SummaryImmediately")); //$NON-NLS-1$) enabler.resume(); } monitor.worked(1); } catch (Exception e) { - errorStatus = new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, e.getMessage(), e ); + errorStatus = new Status(IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), + ICDebugInternalConstants.STATUS_CODE_ERROR, e.getMessage(), e); } } else - errorStatus = new Status( IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), IInternalCDebugUIConstants.INTERNAL_ERROR, Messages.getString("ResumeAction.error.0"), null ); //$NON-NLS-1$ - + errorStatus = new Status(IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), + IInternalCDebugUIConstants.INTERNAL_ERROR, Messages.getString("ResumeAction.error.0"), null); //$NON-NLS-1$ + if (errorStatus != null) { - MultiStatus ms = new MultiStatus( CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, Messages.getString("ResumeAction.error.1"), null ); //$NON-NLS-1$ - ms.add( errorStatus); - errorStatus = ms; + MultiStatus ms = new MultiStatus(CDIDebugModel.getPluginIdentifier(), + ICDebugInternalConstants.STATUS_CODE_ERROR, Messages.getString("ResumeAction.error.1"), null); //$NON-NLS-1$ + ms.add(errorStatus); + errorStatus = ms; } else { errorStatus = monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS; - } + } return errorStatus; } @@ -147,7 +151,8 @@ public class ResumeAction extends AbstractBreakpointAction { public String getSummary() { if (pauseTime == 0) return Messages.getString("ResumeAction.SummaryImmediately"); //$NON-NLS-1$ - return MessageFormat.format(Messages.getString("ResumeAction.SummaryResumeTime"), new Object[] { Integer.valueOf(pauseTime) }); //$NON-NLS-1$ + return MessageFormat.format(Messages.getString("ResumeAction.SummaryResumeTime"), //$NON-NLS-1$ + new Object[] { Integer.valueOf(pauseTime) }); } @Override diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ResumeActionComposite.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ResumeActionComposite.java index 1bf020f59db..d61a287d1bf 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ResumeActionComposite.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ResumeActionComposite.java @@ -26,7 +26,7 @@ public class ResumeActionComposite extends Composite { /** * Create the composite - * + * * @param parent * @param style */ @@ -41,8 +41,7 @@ public class ResumeActionComposite extends Composite { pauseTime = new Text(this, SWT.BORDER); pauseTime.setText(Integer.toString(page.getResumeAction().getPauseTime())); - - + final GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false); gridData.widthHint = 35; pauseTime.setLayoutData(gridData); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ReverseDebugAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ReverseDebugAction.java index 4452f71a237..42847abdad9 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ReverseDebugAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ReverseDebugAction.java @@ -41,20 +41,19 @@ import org.w3c.dom.Element; import org.xml.sax.InputSource; import org.xml.sax.helpers.DefaultHandler; - /** * Implements the reverse debug breakpoint action - * + * *@since 7.3 */ -public class ReverseDebugAction extends AbstractBreakpointAction{ +public class ReverseDebugAction extends AbstractBreakpointAction { /** * The available reverse debug action modes: enable, disable and toggle. */ - public static enum REVERSE_DEBUG_ACTIONS_ENUM { - + public static enum REVERSE_DEBUG_ACTIONS_ENUM { + ENABLE, DISABLE, TOGGLE; - + /** * @param index * @return the enum value for the given index @@ -63,8 +62,9 @@ public class ReverseDebugAction extends AbstractBreakpointAction{ return REVERSE_DEBUG_ACTIONS_ENUM.values()[index]; } }; + private REVERSE_DEBUG_ACTIONS_ENUM fOperation; - + /** * @return the currently configured reverse debug mode, for this BP action */ @@ -83,7 +83,7 @@ public class ReverseDebugAction extends AbstractBreakpointAction{ @Override public IStatus execute(IBreakpoint breakpoint, IAdaptable context, IProgressMonitor monitor) { IStatus errorStatus = null; - + IReverseDebugEnabler enabler = context.getAdapter(IReverseDebugEnabler.class); if (enabler != null) { try { @@ -98,18 +98,20 @@ public class ReverseDebugAction extends AbstractBreakpointAction{ enabler.disable(); break; } - + } catch (Exception e) { - errorStatus = new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, e.getMessage(), e ); + errorStatus = new Status(IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), + ICDebugInternalConstants.STATUS_CODE_ERROR, e.getMessage(), e); } - } - else - errorStatus = new Status( IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), IInternalCDebugUIConstants.INTERNAL_ERROR, Messages.getString("ReverseDebugAction.error.0"), null ); //$NON-NLS-1$ + } else + errorStatus = new Status(IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), + IInternalCDebugUIConstants.INTERNAL_ERROR, Messages.getString("ReverseDebugAction.error.0"), null); //$NON-NLS-1$ if (errorStatus != null) { - MultiStatus ms = new MultiStatus( CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, Messages.getString("ReverseDebugAction.error.1"), null ); //$NON-NLS-1$ - ms.add( errorStatus); - errorStatus = ms; + MultiStatus ms = new MultiStatus(CDIDebugModel.getPluginIdentifier(), + ICDebugInternalConstants.STATUS_CODE_ERROR, Messages.getString("ReverseDebugAction.error.1"), null); //$NON-NLS-1$ + ms.add(errorStatus); + errorStatus = ms; } else { errorStatus = monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS; } @@ -172,14 +174,14 @@ public class ReverseDebugAction extends AbstractBreakpointAction{ @Override public String getDefaultName() { - return Messages.getString("ReverseDebugAction.UntitledName"); //$NON-NLS-1$ + return Messages.getString("ReverseDebugAction.UntitledName"); //$NON-NLS-1$ } @Override public String getSummary() { // get translated operation - String operation = Messages.getString("ReverseDebugAction."+fOperation.toString().toLowerCase()); //$NON-NLS-1$ - + String operation = Messages.getString("ReverseDebugAction." + fOperation.toString().toLowerCase()); //$NON-NLS-1$ + return operation + " " + Messages.getString("ReverseDebugAction.Summary"); //$NON-NLS-1$ //$NON-NLS-2$ } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ReverseDebugActionComposite.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ReverseDebugActionComposite.java index f903f4e16e8..bd8989c2795 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ReverseDebugActionComposite.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ReverseDebugActionComposite.java @@ -21,34 +21,33 @@ import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; - /** * @since 7.3 */ -public class ReverseDebugActionComposite extends Composite { +public class ReverseDebugActionComposite extends Composite { private Combo combo; - + public ReverseDebugActionComposite(Composite parent, int style, ReverseDebugActionPage page) { super(parent, style); final GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 3; setLayout(gridLayout); - + final Label reverseDebugActionLabel = new Label(this, SWT.NONE); reverseDebugActionLabel.setText(Messages.getString("ReverseDebugActionComposite.label")); //$NON-NLS-1$ - + // combo widget that lets the user select which reverse debug action to set combo = new Combo(this, SWT.READ_ONLY); combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); - + // add the available reverse debug actions to the combo drop-down list - for(REVERSE_DEBUG_ACTIONS_ENUM elem : REVERSE_DEBUG_ACTIONS_ENUM.values()) { + for (REVERSE_DEBUG_ACTIONS_ENUM elem : REVERSE_DEBUG_ACTIONS_ENUM.values()) { String option = elem.toString().toLowerCase(); - combo.add(Messages.getString("ReverseDebugAction."+option)); //$NON-NLS-1$ + combo.add(Messages.getString("ReverseDebugAction." + option)); //$NON-NLS-1$ } combo.select(0); } - + /** * @return The currently selected reverse debug action */ @@ -57,5 +56,5 @@ public class ReverseDebugActionComposite extends Composite { return REVERSE_DEBUG_ACTIONS_ENUM.getValue(index); } - + } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ReverseDebugActionPage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ReverseDebugActionPage.java index 70fc3218b58..7a67f5a989f 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ReverseDebugActionPage.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ReverseDebugActionPage.java @@ -20,8 +20,8 @@ import org.eclipse.swt.widgets.Composite; /** *@since 7.3 */ -public class ReverseDebugActionPage extends PlatformObject implements IBreakpointActionPage{ - +public class ReverseDebugActionPage extends PlatformObject implements IBreakpointActionPage { + private ReverseDebugActionComposite reverseDebugActionComposite; private ReverseDebugAction reverseDebugAction; @@ -35,8 +35,7 @@ public class ReverseDebugActionPage extends PlatformObject implements IBreakpoin } @Override - public Composite createComposite(IBreakpointAction action, - Composite composite, int style) { + public Composite createComposite(IBreakpointAction action, Composite composite, int style) { reverseDebugAction = (ReverseDebugAction) action; reverseDebugActionComposite = new ReverseDebugActionComposite(composite, style, this); return reverseDebugActionComposite; diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundAction.java index 5efbd1326c3..5a9ec18a185 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundAction.java @@ -88,7 +88,7 @@ public class SoundAction extends AbstractBreakpointAction { } } - + if (soundFile.exists()) { new SoundPlayer().start(); } @@ -102,8 +102,10 @@ public class SoundAction extends AbstractBreakpointAction { @Override public IStatus execute(IBreakpoint breakpoint, IAdaptable context, IProgressMonitor monitor) { if (soundFile == null || !soundFile.exists()) { - String errorMsg = MessageFormat.format(Messages.getString("SoundAction.error.0"), new Object[] {getSummary()}); //$NON-NLS-1$ - return new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, errorMsg, null); + String errorMsg = MessageFormat.format(Messages.getString("SoundAction.error.0"), //$NON-NLS-1$ + new Object[] { getSummary() }); + return new Status(IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), + ICDebugInternalConstants.STATUS_CODE_ERROR, errorMsg, null); } playSoundFile(soundFile); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundActionComposite.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundActionComposite.java index 24971f79e08..5d4a7388de4 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundActionComposite.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundActionComposite.java @@ -45,7 +45,7 @@ public class SoundActionComposite extends Composite { /** * Create the composite - * + * * @param parent * @param style * @param page diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AbstractToggleBreakpointAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AbstractToggleBreakpointAdapter.java index 930cd54f483..ece1362f9ab 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AbstractToggleBreakpointAdapter.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AbstractToggleBreakpointAdapter.java @@ -94,609 +94,598 @@ import org.eclipse.ui.texteditor.SimpleMarkerAnnotation; /** * Base class for toggle adapter to create/remove CDT breakpoints. Clients may * extend this class to gather additional data prior to creating the breakpoints. - * + * * @since 7.2 */ -abstract public class AbstractToggleBreakpointAdapter - implements IToggleBreakpointsTargetExtension2, IToggleBreakpointsTargetCExtension -{ - - - @Override - public boolean canToggleBreakpointsWithEvent(IWorkbenchPart part, ISelection selection, Event event) { - return canToggleBreakpoints(part, selection); - } - - @Override - public void toggleBreakpointsWithEvent(IWorkbenchPart part, ISelection selection, Event event) throws CoreException { - if(event != null && (event.stateMask & SWT.MOD2) > 0) { - if (toggleBreakpointEnable(part)) { - return; - } - } - else { - boolean interactive = event != null && (event.stateMask & SWT.MOD1) > 0; - updateBreakpoints(true, interactive, part, selection); - } - } - - @Override - public void toggleLineBreakpoints( IWorkbenchPart part, ISelection selection ) throws CoreException { - updateLineBreakpoints(true, false, part, selection); - } +abstract public class AbstractToggleBreakpointAdapter + implements IToggleBreakpointsTargetExtension2, IToggleBreakpointsTargetCExtension { + + @Override + public boolean canToggleBreakpointsWithEvent(IWorkbenchPart part, ISelection selection, Event event) { + return canToggleBreakpoints(part, selection); + } + + @Override + public void toggleBreakpointsWithEvent(IWorkbenchPart part, ISelection selection, Event event) + throws CoreException { + if (event != null && (event.stateMask & SWT.MOD2) > 0) { + if (toggleBreakpointEnable(part)) { + return; + } + } else { + boolean interactive = event != null && (event.stateMask & SWT.MOD1) > 0; + updateBreakpoints(true, interactive, part, selection); + } + } + + @Override + public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException { + updateLineBreakpoints(true, false, part, selection); + } @Override - public boolean canToggleLineBreakpoints( IWorkbenchPart part, ISelection selection ) { + public boolean canToggleLineBreakpoints(IWorkbenchPart part, ISelection selection) { return (selection instanceof ITextSelection); } - @Override - public void toggleMethodBreakpoints( IWorkbenchPart part, ISelection selection ) throws CoreException { - ICElement element = getCElementFromSelection( part, selection ); - if ( element instanceof IFunction || element instanceof IMethod) { - updateMethodBreakpoints(true, false, part, (IDeclaration)element); - } - } - @Override - public boolean canToggleMethodBreakpoints( IWorkbenchPart part, ISelection selection ) { - ICElement element = getCElementFromSelection( part, selection ); + public void toggleMethodBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException { + ICElement element = getCElementFromSelection(part, selection); + if (element instanceof IFunction || element instanceof IMethod) { + updateMethodBreakpoints(true, false, part, (IDeclaration) element); + } + } + + @Override + public boolean canToggleMethodBreakpoints(IWorkbenchPart part, ISelection selection) { + ICElement element = getCElementFromSelection(part, selection); return (element instanceof IFunction || element instanceof IMethod); } - @Override - public void toggleWatchpoints( IWorkbenchPart part, ISelection selection ) throws CoreException { - IVariable variable = getVariableFromSelection( part, selection ); - if ( variable != null ) { - updateVariableWatchpoint(true, false, part, variable); - } - IRepositionableMemoryRendering rendering = getMemoryRendering(part, selection); - if (rendering != null) { - updateMemoryWatchpoint(true, false, part, rendering); - } - - - } + @Override + public void toggleWatchpoints(IWorkbenchPart part, ISelection selection) throws CoreException { + IVariable variable = getVariableFromSelection(part, selection); + if (variable != null) { + updateVariableWatchpoint(true, false, part, variable); + } + IRepositionableMemoryRendering rendering = getMemoryRendering(part, selection); + if (rendering != null) { + updateMemoryWatchpoint(true, false, part, rendering); + } + + } @Override - public boolean canToggleWatchpoints( IWorkbenchPart part, ISelection selection ) { - return getVariableFromSelection( part, selection ) != null || - getMemoryRendering(part, selection) != null || - getWatchpointTarget(part, selection) != null; + public boolean canToggleWatchpoints(IWorkbenchPart part, ISelection selection) { + return getVariableFromSelection(part, selection) != null || getMemoryRendering(part, selection) != null + || getWatchpointTarget(part, selection) != null; } @Override - public boolean canToggleBreakpoints( IWorkbenchPart part, ISelection selection ) { - return ( canToggleLineBreakpoints( part, selection ) - || canToggleWatchpoints( part, selection ) - || canToggleMethodBreakpoints( part, selection ) ); + public boolean canToggleBreakpoints(IWorkbenchPart part, ISelection selection) { + return (canToggleLineBreakpoints(part, selection) || canToggleWatchpoints(part, selection) + || canToggleMethodBreakpoints(part, selection)); } @Override - public void toggleBreakpoints( IWorkbenchPart part, ISelection selection ) throws CoreException { - updateBreakpoints(true, false, part, selection); + public void toggleBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException { + updateBreakpoints(true, false, part, selection); } @Override public boolean canCreateLineBreakpointsInteractive(IWorkbenchPart part, ISelection selection) { - return canToggleLineBreakpoints( part, selection ) && !hasBreakpoint( part ); + return canToggleLineBreakpoints(part, selection) && !hasBreakpoint(part); } - + @Override public void createLineBreakpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException { - updateLineBreakpoints(false, true, part, selection); + updateLineBreakpoints(false, true, part, selection); } - + @Override public boolean canCreateWatchpointsInteractive(IWorkbenchPart part, ISelection selection) { - return canToggleWatchpoints(part, selection) && !hasWatchpoint(part, selection); + return canToggleWatchpoints(part, selection) && !hasWatchpoint(part, selection); } - + @Override public void createWatchpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException { - ICElement element = getCElementFromSelection( part, selection ); - if (element instanceof IVariable) { - updateVariableWatchpoint(false, true, part, (IVariable)element); - return; - } - - IRepositionableMemoryRendering rendering = getMemoryRendering(part, selection); - if (rendering != null) { - updateMemoryWatchpoint(false, true, part, rendering); - return; - } - - ICWatchpointTarget watchpointTarget = getWatchpointTarget(part, selection); - if (watchpointTarget != null) { - updateTargetWatchpoint(false, true, part, watchpointTarget); - return; - } - - String text = ""; //$NON-NLS-1$ - if (selection instanceof ITextSelection) { - text = ((ITextSelection)selection).getText(); - } - createWatchpoint(true, part, null, ResourcesPlugin.getWorkspace().getRoot(), -1, -1, -1, text, null, "0"); //$NON-NLS-1$ + ICElement element = getCElementFromSelection(part, selection); + if (element instanceof IVariable) { + updateVariableWatchpoint(false, true, part, (IVariable) element); + return; + } + + IRepositionableMemoryRendering rendering = getMemoryRendering(part, selection); + if (rendering != null) { + updateMemoryWatchpoint(false, true, part, rendering); + return; + } + + ICWatchpointTarget watchpointTarget = getWatchpointTarget(part, selection); + if (watchpointTarget != null) { + updateTargetWatchpoint(false, true, part, watchpointTarget); + return; + } + + String text = ""; //$NON-NLS-1$ + if (selection instanceof ITextSelection) { + text = ((ITextSelection) selection).getText(); + } + createWatchpoint(true, part, null, ResourcesPlugin.getWorkspace().getRoot(), -1, -1, -1, text, null, "0"); //$NON-NLS-1$ } @Override public boolean canCreateEventBreakpointsInteractive(IWorkbenchPart part, ISelection selection) { - return true; + return true; } @Override public void createEventBreakpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException { String type = ""; //$NON-NLS-1$ String arg = ""; //$NON-NLS-1$ - createEventBreakpoint( true, part, ResourcesPlugin.getWorkspace().getRoot(), type, arg ); + createEventBreakpoint(true, part, ResourcesPlugin.getWorkspace().getRoot(), type, arg); } @Override public boolean canCreateFunctionBreakpointInteractive(IWorkbenchPart part, ISelection selection) { - return canToggleMethodBreakpoints(part, selection) && !hasMethodBreakpoints(part, selection); + return canToggleMethodBreakpoints(part, selection) && !hasMethodBreakpoints(part, selection); } - + @Override public void createFunctionBreakpointInteractive(IWorkbenchPart part, ISelection selection) throws CoreException { - ICElement element = getCElementFromSelection( part, selection ); - if ( element instanceof IFunction || element instanceof IMethod ) { - updateMethodBreakpoints(false, true, part, (IDeclaration)element); - } else { - String text = ""; //$NON-NLS-1$ - if (selection instanceof ITextSelection) { - text = ((ITextSelection)selection).getText(); - } - createFunctionBreakpoint(true, part, null, ResourcesPlugin.getWorkspace().getRoot(), text, -1, -1, -1); - } - } - - private boolean hasBreakpoint(IWorkbenchPart part) { - if (part instanceof ITextEditor) { - ITextEditor textEditor = (ITextEditor) part; - IVerticalRulerInfo rulerInfo = textEditor.getAdapter(IVerticalRulerInfo.class); - IBreakpoint breakpoint = CDebugUIUtils.getBreakpointFromEditor(textEditor, rulerInfo); - return breakpoint != null; - } - return false; - } - - private boolean hasWatchpoint(IWorkbenchPart part, ISelection selection) { - ICElement element = getCElementFromSelection( part, selection ); - if (element instanceof IVariable) { - IVariable variable = (IVariable) element; - String sourceHandle = getSourceHandle(variable ); - IResource resource = getElementResource(variable); - String expression = getVariableName(variable); - try { - return null != findWatchpoint(sourceHandle, resource, expression); - } catch (CoreException e) { - DebugPlugin.log(e); - } - } - return false; - } - - private boolean hasMethodBreakpoints(IWorkbenchPart part, ISelection selection) { - ICElement element = getCElementFromSelection( part, selection ); - if ( element instanceof IFunction || element instanceof IMethod ) { - IDeclaration declaration = (IDeclaration) element; - String sourceHandle = getSourceHandle(declaration); - IResource resource = getElementResource(declaration); - String functionName = (declaration instanceof IFunction) ? - getFunctionName((IFunction) declaration) - : getMethodName((IMethod) declaration); - try { - return null != findFunctionBreakpoint(sourceHandle, resource, functionName); - } catch (CoreException e) { - DebugPlugin.log(e); - } - } - return false; - } - - /** - * Updates the breakpoint for given part and selection. - * Depending on the flags and on whether a breakpoint exists, this method - * executes the toggle action. - * - * @param toggle Whether the toggle action is requested. If - * true and the breakpoint currently exists, it will cause the - * toggle action to either remove breakpoint or edit its properties. - * Otherwise a new breakpoint will be created. - * @param interactive If true the toggle adapter should open a dialog before - * creating a breakpoint, or open a properties dialog on an existing - * breakpoint. - * @param part Workbench part where the toggle action is to be executed. - * @param selection Current selection on which the toggle action is to be - * executed. - * @throws CoreException Any error in creating or editing the breakpoint. - */ - private void updateBreakpoints(boolean toggle, boolean interactive, IWorkbenchPart part, ISelection selection ) throws CoreException { - if ( canToggleLineBreakpoints( part, selection ) ) { - updateLineBreakpoints(toggle, interactive, part, selection); - } - else { - ICElement element = getCElementFromSelection( part, selection ); - if ( element instanceof IFunction || element instanceof IMethod ) { - updateMethodBreakpoints(toggle, interactive, part, (IDeclaration)element); - } - else if ( element instanceof IVariable ) { - updateVariableWatchpoint(toggle, interactive, part, (IVariable)element); - } - } - } - - private void updateLineBreakpoints(boolean toggle, boolean interactive, IWorkbenchPart part, ISelection selection) - throws CoreException { - String errorMessage = null; - if (part instanceof ITextEditor) { - ITextEditor textEditor = (ITextEditor) part; - IEditorInput input = textEditor.getEditorInput(); - if (input == null) { - errorMessage = ActionMessages.getString("ToggleBreakpointAdapter.Empty_editor_1"); //$NON-NLS-1$ - } else { - IDocument document = textEditor.getDocumentProvider().getDocument(input); - if (document == null) { - errorMessage = ActionMessages.getString("ToggleBreakpointAdapter.Missing_document_1"); //$NON-NLS-1$ - } else { - IResource resource = getResource(textEditor); - if (resource == null) { - errorMessage = ActionMessages.getString("ToggleBreakpointAdapter.Missing_resource_1"); //$NON-NLS-1$ - } else { - int lineNumber = ((ITextSelection) selection).getStartLine() + 1; - if (lineNumber == -1) { - errorMessage = ActionMessages.getString("ToggleBreakpointAdapter.Invalid_line_1"); //$NON-NLS-1$ - } else { - String sourceHandle = getSourceHandle(input); - if (interactive && !toggle) { - createLineBreakpoint(true, part, sourceHandle, resource, lineNumber); - } else { - ICLineBreakpoint breakpoint = findLineBreakpoint(sourceHandle, resource, lineNumber); - if (breakpoint != null) { - if (interactive) { - CDebugUIUtils.editBreakpointProperties(part, breakpoint); - } else { - DebugPlugin.getDefault().getBreakpointManager() - .removeBreakpoint(breakpoint, true); - } - } else { - createLineBreakpoint(interactive, part, sourceHandle, resource, lineNumber); - } - } - return; - } - } - } - } - } else if (interactive && !toggle) { - createLineBreakpoint(true, part, null, ResourcesPlugin.getWorkspace().getRoot(), -1); - return; - } else { - errorMessage = ActionMessages.getString("RunToLineAdapter.Operation_is_not_supported_1"); //$NON-NLS-1$ - } - throw new CoreException(new Status(IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), - IInternalCDebugUIConstants.INTERNAL_ERROR, errorMessage, null)); - } - - private void updateMethodBreakpoints(boolean toggle, boolean interactive, IWorkbenchPart part, - IDeclaration declaration) throws CoreException { - String sourceHandle = getSourceHandle(declaration); - IResource resource = getElementResource(declaration); - String functionName = (declaration instanceof IFunction) ? getFunctionName((IFunction) declaration) - : getMethodName((IMethod) declaration); - ICFunctionBreakpoint breakpoint = findFunctionBreakpoint(sourceHandle, resource, functionName); - if (toggle && breakpoint != null) { - if (interactive) { - CDebugUIUtils.editBreakpointProperties(part, breakpoint); - } else { - DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(breakpoint, true); - } - } else { - int lineNumber = -1; - int charStart = -1; - int charEnd = -1; - try { - ISourceRange sourceRange = declaration.getSourceRange(); - if (sourceRange != null) { - charStart = sourceRange.getStartPos(); - charEnd = charStart + sourceRange.getLength(); - if (charEnd <= 0) { - charStart = -1; - charEnd = -1; - } - lineNumber = sourceRange.getStartLine(); - } - } catch (CModelException e) { - DebugPlugin.log(e); - } - createFunctionBreakpoint(interactive, part, sourceHandle, resource, functionName, charStart, charEnd, - lineNumber); - } - } - - /** - * Updates a watchpoint. Depending on the flags and on whether a breakpoint - * exists, this method executes the toggle action. - * - * @param toggle - * Whether the toggle action is requested. If true and the - * breakpoint currently exists, it will cause the toggle action - * to either remove breakpoint or edit its properties. Otherwise - * a new breakpoint will be created. - * @param interactive - * If true the toggle adapter should open a dialog before - * creating a breakpoint, or open a properties dialog on an - * existing breakpoint. - * @param part - * Workbench part where the toggle action is to be executed. - * @param selection - * Variable on which to execute the toggle action. - * @throws CoreException - * Any error in creating or editing the breakpoint. - */ - private void updateVariableWatchpoint(boolean toggle, boolean interactive, IWorkbenchPart part, IVariable variable) - throws CoreException { - String sourceHandle = getSourceHandle(variable); - IResource resource = getElementResource(variable); - String expression = getVariableName(variable); - ICWatchpoint watchpoint = findWatchpoint(sourceHandle, resource, expression); - if (toggle && watchpoint != null) { - if (interactive) { - CDebugUIUtils.editBreakpointProperties(part, watchpoint); - } else { - DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(watchpoint, true); - } - } else { - int lineNumber = -1; - int charStart = -1; - int charEnd = -1; - try { - ISourceRange sourceRange = variable.getSourceRange(); - if (sourceRange != null) { - charStart = sourceRange.getStartPos(); - charEnd = charStart + sourceRange.getLength(); - if (charEnd <= 0) { - charStart = -1; - charEnd = -1; - } - lineNumber = sourceRange.getStartLine(); - } - } catch (CModelException e) { - CDebugUIPlugin.log(e); - } - createWatchpoint(interactive, part, sourceHandle, resource, charStart, charEnd, lineNumber, expression, null, "0"); //$NON-NLS-1$ - } - } - - private void updateMemoryWatchpoint(boolean toggle, boolean interactive, IWorkbenchPart part, - IRepositionableMemoryRendering rendering) throws CoreException - { - int addressableSize = 1; - IMemoryBlock memblock = rendering.getMemoryBlock(); - if (memblock instanceof IMemoryBlockExtension) { - try { - addressableSize = ((IMemoryBlockExtension)memblock).getAddressableSize(); - } catch (DebugException e) { - CDebugUIPlugin.log(e); - } - } - - String memorySpace = getMemorySpace(rendering.getMemoryBlock(), null); - String address = getSelectedAddress(rendering.getSelectedAddress(), ""); //$NON-NLS-1$ - String range = getRange(rendering.getSelectedAsBytes(), addressableSize, "1"); //$NON-NLS-1$ - - createWatchpoint(interactive, part, "", ResourcesPlugin.getWorkspace().getRoot(), -1, -1, -1, address, //$NON-NLS-1$ - memorySpace, range); - } - - private String getMemorySpace(IMemoryBlock memBlock, String def) { - // XXX: In pre-CDI removal this retrieved memory space from CMemoryBlockExtension - if (memBlock != null && memBlock instanceof IMemorySpaceAwareMemoryBlock) { - return ((IMemorySpaceAwareMemoryBlock) memBlock).getMemorySpaceID(); - } - return def; - } - - private String getSelectedAddress(BigInteger selectedAddress, String def) { - if (selectedAddress != null) { - return "0x" + selectedAddress.toString(16); //$NON-NLS-1$ - } - return def; - } - - private String getRange(MemoryByte[] selectedBytes, int addressableSize, String def) { - if (selectedBytes != null && selectedBytes.length > 0) { - return Integer.toString(selectedBytes.length / addressableSize); - } - return def; - } - - private void updateTargetWatchpoint(boolean toggle, final boolean interactive, final IWorkbenchPart part, - ICWatchpointTarget watchpointTarget) throws CoreException - { - String _expr = watchpointTarget.getExpression(); - if (_expr == null) { - _expr = ""; //$NON-NLS-1$ - } - final String expr = _expr; - - // Getting the size of the variable/expression is an asynchronous - // operation...or at least the API is (the CDI implementation reacts - // synchronously) - - class GetSizeRequest extends CRequest implements ICWatchpointTarget.GetSizeRequest { - int fSize = -1; - @Override - public int getSize() { - return fSize; - } - @Override - public void setSize(int size) { - fSize = size; - } - - @Override - public void done() { - int _size = 0; - if (isSuccess()) { - // Now that we have the size, put up a dialog to create the watchpoint - _size = getSize(); - assert _size > 0 : "unexpected variale/expression size"; //$NON-NLS-1$ - } - final int size = _size; - - WorkbenchJob job = new WorkbenchJob("open watchpoint dialog") { //$NON-NLS-1$ - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - try { - createWatchpoint(interactive, part, "", ResourcesPlugin.getWorkspace().getRoot(), //$NON-NLS-1$ - -1, -1, -1, expr, null, Integer.toString(size)); - } catch (CoreException e) { - return e.getStatus(); - } - return Status.OK_STATUS; - } - }; - job.setSystem(true); - job.schedule(); - } - }; - - watchpointTarget.getSize(new GetSizeRequest()); - - } - + ICElement element = getCElementFromSelection(part, selection); + if (element instanceof IFunction || element instanceof IMethod) { + updateMethodBreakpoints(false, true, part, (IDeclaration) element); + } else { + String text = ""; //$NON-NLS-1$ + if (selection instanceof ITextSelection) { + text = ((ITextSelection) selection).getText(); + } + createFunctionBreakpoint(true, part, null, ResourcesPlugin.getWorkspace().getRoot(), text, -1, -1, -1); + } + } + + private boolean hasBreakpoint(IWorkbenchPart part) { + if (part instanceof ITextEditor) { + ITextEditor textEditor = (ITextEditor) part; + IVerticalRulerInfo rulerInfo = textEditor.getAdapter(IVerticalRulerInfo.class); + IBreakpoint breakpoint = CDebugUIUtils.getBreakpointFromEditor(textEditor, rulerInfo); + return breakpoint != null; + } + return false; + } + + private boolean hasWatchpoint(IWorkbenchPart part, ISelection selection) { + ICElement element = getCElementFromSelection(part, selection); + if (element instanceof IVariable) { + IVariable variable = (IVariable) element; + String sourceHandle = getSourceHandle(variable); + IResource resource = getElementResource(variable); + String expression = getVariableName(variable); + try { + return null != findWatchpoint(sourceHandle, resource, expression); + } catch (CoreException e) { + DebugPlugin.log(e); + } + } + return false; + } + + private boolean hasMethodBreakpoints(IWorkbenchPart part, ISelection selection) { + ICElement element = getCElementFromSelection(part, selection); + if (element instanceof IFunction || element instanceof IMethod) { + IDeclaration declaration = (IDeclaration) element; + String sourceHandle = getSourceHandle(declaration); + IResource resource = getElementResource(declaration); + String functionName = (declaration instanceof IFunction) ? getFunctionName((IFunction) declaration) + : getMethodName((IMethod) declaration); + try { + return null != findFunctionBreakpoint(sourceHandle, resource, functionName); + } catch (CoreException e) { + DebugPlugin.log(e); + } + } + return false; + } + + /** + * Updates the breakpoint for given part and selection. + * Depending on the flags and on whether a breakpoint exists, this method + * executes the toggle action. + * + * @param toggle Whether the toggle action is requested. If + * true and the breakpoint currently exists, it will cause the + * toggle action to either remove breakpoint or edit its properties. + * Otherwise a new breakpoint will be created. + * @param interactive If true the toggle adapter should open a dialog before + * creating a breakpoint, or open a properties dialog on an existing + * breakpoint. + * @param part Workbench part where the toggle action is to be executed. + * @param selection Current selection on which the toggle action is to be + * executed. + * @throws CoreException Any error in creating or editing the breakpoint. + */ + private void updateBreakpoints(boolean toggle, boolean interactive, IWorkbenchPart part, ISelection selection) + throws CoreException { + if (canToggleLineBreakpoints(part, selection)) { + updateLineBreakpoints(toggle, interactive, part, selection); + } else { + ICElement element = getCElementFromSelection(part, selection); + if (element instanceof IFunction || element instanceof IMethod) { + updateMethodBreakpoints(toggle, interactive, part, (IDeclaration) element); + } else if (element instanceof IVariable) { + updateVariableWatchpoint(toggle, interactive, part, (IVariable) element); + } + } + } + + private void updateLineBreakpoints(boolean toggle, boolean interactive, IWorkbenchPart part, ISelection selection) + throws CoreException { + String errorMessage = null; + if (part instanceof ITextEditor) { + ITextEditor textEditor = (ITextEditor) part; + IEditorInput input = textEditor.getEditorInput(); + if (input == null) { + errorMessage = ActionMessages.getString("ToggleBreakpointAdapter.Empty_editor_1"); //$NON-NLS-1$ + } else { + IDocument document = textEditor.getDocumentProvider().getDocument(input); + if (document == null) { + errorMessage = ActionMessages.getString("ToggleBreakpointAdapter.Missing_document_1"); //$NON-NLS-1$ + } else { + IResource resource = getResource(textEditor); + if (resource == null) { + errorMessage = ActionMessages.getString("ToggleBreakpointAdapter.Missing_resource_1"); //$NON-NLS-1$ + } else { + int lineNumber = ((ITextSelection) selection).getStartLine() + 1; + if (lineNumber == -1) { + errorMessage = ActionMessages.getString("ToggleBreakpointAdapter.Invalid_line_1"); //$NON-NLS-1$ + } else { + String sourceHandle = getSourceHandle(input); + if (interactive && !toggle) { + createLineBreakpoint(true, part, sourceHandle, resource, lineNumber); + } else { + ICLineBreakpoint breakpoint = findLineBreakpoint(sourceHandle, resource, lineNumber); + if (breakpoint != null) { + if (interactive) { + CDebugUIUtils.editBreakpointProperties(part, breakpoint); + } else { + DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(breakpoint, + true); + } + } else { + createLineBreakpoint(interactive, part, sourceHandle, resource, lineNumber); + } + } + return; + } + } + } + } + } else if (interactive && !toggle) { + createLineBreakpoint(true, part, null, ResourcesPlugin.getWorkspace().getRoot(), -1); + return; + } else { + errorMessage = ActionMessages.getString("RunToLineAdapter.Operation_is_not_supported_1"); //$NON-NLS-1$ + } + throw new CoreException(new Status(IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), + IInternalCDebugUIConstants.INTERNAL_ERROR, errorMessage, null)); + } + + private void updateMethodBreakpoints(boolean toggle, boolean interactive, IWorkbenchPart part, + IDeclaration declaration) throws CoreException { + String sourceHandle = getSourceHandle(declaration); + IResource resource = getElementResource(declaration); + String functionName = (declaration instanceof IFunction) ? getFunctionName((IFunction) declaration) + : getMethodName((IMethod) declaration); + ICFunctionBreakpoint breakpoint = findFunctionBreakpoint(sourceHandle, resource, functionName); + if (toggle && breakpoint != null) { + if (interactive) { + CDebugUIUtils.editBreakpointProperties(part, breakpoint); + } else { + DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(breakpoint, true); + } + } else { + int lineNumber = -1; + int charStart = -1; + int charEnd = -1; + try { + ISourceRange sourceRange = declaration.getSourceRange(); + if (sourceRange != null) { + charStart = sourceRange.getStartPos(); + charEnd = charStart + sourceRange.getLength(); + if (charEnd <= 0) { + charStart = -1; + charEnd = -1; + } + lineNumber = sourceRange.getStartLine(); + } + } catch (CModelException e) { + DebugPlugin.log(e); + } + createFunctionBreakpoint(interactive, part, sourceHandle, resource, functionName, charStart, charEnd, + lineNumber); + } + } + /** - * Returns the C model element at the given selection. - * @param part Workbench part where the selection is. - * @param selection Selection in part. - * @return C model element if found. - */ - protected ICElement getCElementFromSelection( IWorkbenchPart part, ISelection selection ) { - if ( selection instanceof ITextSelection ) { - ITextSelection textSelection = (ITextSelection)selection; - String text = textSelection.getText(); - if ( text != null ) { - if ( part instanceof ITextEditor ) { - ICElement editorElement = CDTUITools.getEditorInputCElement( ((ITextEditor)part).getEditorInput() ); - if ( editorElement instanceof ITranslationUnit ) { - ITranslationUnit tu = (ITranslationUnit)editorElement; - try { - if ( tu.isStructureKnown() && tu.isConsistent() ) { - return tu.getElementAtOffset( textSelection.getOffset() ); - } - } - catch( CModelException exc ) { - // ignored on purpose - } - } - } - else { - IResource resource = getResource( part ); - if ( resource instanceof IFile ) { - ITranslationUnit tu = getTranslationUnit( (IFile)resource ); - if ( tu != null ) { - try { - ICElement element = tu.getElement( text.trim() ); - if ( element == null ) { - element = tu.getElementAtLine( textSelection.getStartLine() ); - } - return element; - } - catch( CModelException e ) { - } - } - } - } - } - } - else if ( selection instanceof IStructuredSelection ) { - IStructuredSelection ss = (IStructuredSelection)selection; - if ( ss.size() == 1 ) { - Object object = ss.getFirstElement(); - if ( object instanceof ICElement ) { - return (ICElement)object; - } - } - } - return null; - } - - /** - * Returns the variable object at the given selection. - * Returns the C model element at the given selection. - * @param part Workbench part where the selection is. - * @param selection Selection in part. - * @return C model variable, if found. - */ - protected IVariable getVariableFromSelection( IWorkbenchPart part, ISelection selection ) { - ICElement element = getCElementFromSelection( part, selection ); - if ( element instanceof IVariable ) { - return (IVariable)element; + * Updates a watchpoint. Depending on the flags and on whether a breakpoint + * exists, this method executes the toggle action. + * + * @param toggle + * Whether the toggle action is requested. If true and the + * breakpoint currently exists, it will cause the toggle action + * to either remove breakpoint or edit its properties. Otherwise + * a new breakpoint will be created. + * @param interactive + * If true the toggle adapter should open a dialog before + * creating a breakpoint, or open a properties dialog on an + * existing breakpoint. + * @param part + * Workbench part where the toggle action is to be executed. + * @param selection + * Variable on which to execute the toggle action. + * @throws CoreException + * Any error in creating or editing the breakpoint. + */ + private void updateVariableWatchpoint(boolean toggle, boolean interactive, IWorkbenchPart part, IVariable variable) + throws CoreException { + String sourceHandle = getSourceHandle(variable); + IResource resource = getElementResource(variable); + String expression = getVariableName(variable); + ICWatchpoint watchpoint = findWatchpoint(sourceHandle, resource, expression); + if (toggle && watchpoint != null) { + if (interactive) { + CDebugUIUtils.editBreakpointProperties(part, watchpoint); + } else { + DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(watchpoint, true); + } + } else { + int lineNumber = -1; + int charStart = -1; + int charEnd = -1; + try { + ISourceRange sourceRange = variable.getSourceRange(); + if (sourceRange != null) { + charStart = sourceRange.getStartPos(); + charEnd = charStart + sourceRange.getLength(); + if (charEnd <= 0) { + charStart = -1; + charEnd = -1; + } + lineNumber = sourceRange.getStartLine(); + } + } catch (CModelException e) { + CDebugUIPlugin.log(e); + } + createWatchpoint(interactive, part, sourceHandle, resource, charStart, charEnd, lineNumber, expression, + null, "0"); //$NON-NLS-1$ + } + } + + private void updateMemoryWatchpoint(boolean toggle, boolean interactive, IWorkbenchPart part, + IRepositionableMemoryRendering rendering) throws CoreException { + int addressableSize = 1; + IMemoryBlock memblock = rendering.getMemoryBlock(); + if (memblock instanceof IMemoryBlockExtension) { + try { + addressableSize = ((IMemoryBlockExtension) memblock).getAddressableSize(); + } catch (DebugException e) { + CDebugUIPlugin.log(e); + } + } + + String memorySpace = getMemorySpace(rendering.getMemoryBlock(), null); + String address = getSelectedAddress(rendering.getSelectedAddress(), ""); //$NON-NLS-1$ + String range = getRange(rendering.getSelectedAsBytes(), addressableSize, "1"); //$NON-NLS-1$ + + createWatchpoint(interactive, part, "", ResourcesPlugin.getWorkspace().getRoot(), -1, -1, -1, address, //$NON-NLS-1$ + memorySpace, range); + } + + private String getMemorySpace(IMemoryBlock memBlock, String def) { + // XXX: In pre-CDI removal this retrieved memory space from CMemoryBlockExtension + if (memBlock != null && memBlock instanceof IMemorySpaceAwareMemoryBlock) { + return ((IMemorySpaceAwareMemoryBlock) memBlock).getMemorySpaceID(); + } + return def; + } + + private String getSelectedAddress(BigInteger selectedAddress, String def) { + if (selectedAddress != null) { + return "0x" + selectedAddress.toString(16); //$NON-NLS-1$ + } + return def; + } + + private String getRange(MemoryByte[] selectedBytes, int addressableSize, String def) { + if (selectedBytes != null && selectedBytes.length > 0) { + return Integer.toString(selectedBytes.length / addressableSize); + } + return def; + } + + private void updateTargetWatchpoint(boolean toggle, final boolean interactive, final IWorkbenchPart part, + ICWatchpointTarget watchpointTarget) throws CoreException { + String _expr = watchpointTarget.getExpression(); + if (_expr == null) { + _expr = ""; //$NON-NLS-1$ + } + final String expr = _expr; + + // Getting the size of the variable/expression is an asynchronous + // operation...or at least the API is (the CDI implementation reacts + // synchronously) + + class GetSizeRequest extends CRequest implements ICWatchpointTarget.GetSizeRequest { + int fSize = -1; + + @Override + public int getSize() { + return fSize; + } + + @Override + public void setSize(int size) { + fSize = size; + } + + @Override + public void done() { + int _size = 0; + if (isSuccess()) { + // Now that we have the size, put up a dialog to create the watchpoint + _size = getSize(); + assert _size > 0 : "unexpected variale/expression size"; //$NON-NLS-1$ + } + final int size = _size; + + WorkbenchJob job = new WorkbenchJob("open watchpoint dialog") { //$NON-NLS-1$ + @Override + public IStatus runInUIThread(IProgressMonitor monitor) { + try { + createWatchpoint(interactive, part, "", ResourcesPlugin.getWorkspace().getRoot(), //$NON-NLS-1$ + -1, -1, -1, expr, null, Integer.toString(size)); + } catch (CoreException e) { + return e.getStatus(); + } + return Status.OK_STATUS; + } + }; + job.setSystem(true); + job.schedule(); + } + } + ; + + watchpointTarget.getSize(new GetSizeRequest()); + + } + + /** + * Returns the C model element at the given selection. + * @param part Workbench part where the selection is. + * @param selection Selection in part. + * @return C model element if found. + */ + protected ICElement getCElementFromSelection(IWorkbenchPart part, ISelection selection) { + if (selection instanceof ITextSelection) { + ITextSelection textSelection = (ITextSelection) selection; + String text = textSelection.getText(); + if (text != null) { + if (part instanceof ITextEditor) { + ICElement editorElement = CDTUITools.getEditorInputCElement(((ITextEditor) part).getEditorInput()); + if (editorElement instanceof ITranslationUnit) { + ITranslationUnit tu = (ITranslationUnit) editorElement; + try { + if (tu.isStructureKnown() && tu.isConsistent()) { + return tu.getElementAtOffset(textSelection.getOffset()); + } + } catch (CModelException exc) { + // ignored on purpose + } + } + } else { + IResource resource = getResource(part); + if (resource instanceof IFile) { + ITranslationUnit tu = getTranslationUnit((IFile) resource); + if (tu != null) { + try { + ICElement element = tu.getElement(text.trim()); + if (element == null) { + element = tu.getElementAtLine(textSelection.getStartLine()); + } + return element; + } catch (CModelException e) { + } + } + } + } + } + } else if (selection instanceof IStructuredSelection) { + IStructuredSelection ss = (IStructuredSelection) selection; + if (ss.size() == 1) { + Object object = ss.getFirstElement(); + if (object instanceof ICElement) { + return (ICElement) object; + } + } } return null; } - - protected IRepositionableMemoryRendering getMemoryRendering( IWorkbenchPart part, ISelection selection ) { - if (selection != null && selection instanceof IStructuredSelection && !selection.isEmpty()) { - Object obj = ((IStructuredSelection)selection).getFirstElement(); - if (obj != null) { - if (obj instanceof IAdaptable) { - return ((IAdaptable)obj).getAdapter(IRepositionableMemoryRendering.class); - } - } - } - return null; - } - - @SuppressWarnings("deprecation") - protected ICWatchpointTarget getWatchpointTarget( IWorkbenchPart part, ISelection selection ) { - if (selection != null && selection instanceof IStructuredSelection && !selection.isEmpty()) { - Object obj = ((IStructuredSelection)selection).getFirstElement(); - if (obj != null) { - if (obj instanceof IAdaptable) { - ICWatchpointTarget target = ((IAdaptable)obj).getAdapter(ICWatchpointTarget.class); - if (target == null) { - target = ((IAdaptable)obj).getAdapter( - org.eclipse.cdt.debug.internal.core.ICWatchpointTarget.class); - } - return target; - } - } - } - return null; - } - - + + /** + * Returns the variable object at the given selection. + * Returns the C model element at the given selection. + * @param part Workbench part where the selection is. + * @param selection Selection in part. + * @return C model variable, if found. + */ + protected IVariable getVariableFromSelection(IWorkbenchPart part, ISelection selection) { + ICElement element = getCElementFromSelection(part, selection); + if (element instanceof IVariable) { + return (IVariable) element; + } + return null; + } + + protected IRepositionableMemoryRendering getMemoryRendering(IWorkbenchPart part, ISelection selection) { + if (selection != null && selection instanceof IStructuredSelection && !selection.isEmpty()) { + Object obj = ((IStructuredSelection) selection).getFirstElement(); + if (obj != null) { + if (obj instanceof IAdaptable) { + return ((IAdaptable) obj).getAdapter(IRepositionableMemoryRendering.class); + } + } + } + return null; + } + + @SuppressWarnings("deprecation") + protected ICWatchpointTarget getWatchpointTarget(IWorkbenchPart part, ISelection selection) { + if (selection != null && selection instanceof IStructuredSelection && !selection.isEmpty()) { + Object obj = ((IStructuredSelection) selection).getFirstElement(); + if (obj != null) { + if (obj instanceof IAdaptable) { + ICWatchpointTarget target = ((IAdaptable) obj).getAdapter(ICWatchpointTarget.class); + if (target == null) { + target = ((IAdaptable) obj) + .getAdapter(org.eclipse.cdt.debug.internal.core.ICWatchpointTarget.class); + } + return target; + } + } + } + return null; + } + /** * Reports the given error message to the user. * @param message Message to report. * @param part Workbench part where action was invoked. */ - protected void report( String message, IWorkbenchPart part ) { - IEditorStatusLine statusLine = part.getAdapter( IEditorStatusLine.class ); - if ( statusLine != null ) { - if ( message != null ) { - statusLine.setMessage( true, message, null ); - } - else { - statusLine.setMessage( true, null, null ); + protected void report(String message, IWorkbenchPart part) { + IEditorStatusLine statusLine = part.getAdapter(IEditorStatusLine.class); + if (statusLine != null) { + if (message != null) { + statusLine.setMessage(true, message, null); + } else { + statusLine.setMessage(true, null, null); } } - if ( message != null && CDebugUIPlugin.getActiveWorkbenchShell() != null ) { + if (message != null && CDebugUIPlugin.getActiveWorkbenchShell() != null) { CDebugUIPlugin.getActiveWorkbenchShell().getDisplay().beep(); } } /** - * Returns the resource being edited in the given workbench part. + * Returns the resource being edited in the given workbench part. * @param part Workbench part to check. * @return Resource being edited. */ - protected static IResource getResource( IWorkbenchPart part ) { + protected static IResource getResource(IWorkbenchPart part) { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - if ( part instanceof IEditorPart ) { - IEditorInput editorInput = ((IEditorPart)part).getEditorInput(); + if (part instanceof IEditorPart) { + IEditorInput editorInput = ((IEditorPart) part).getEditorInput(); return getResource(editorInput); } return root; @@ -705,36 +694,35 @@ abstract public class AbstractToggleBreakpointAdapter private static IResource getResource(IEditorInput editorInput) { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IResource resource = null; - if ( editorInput instanceof IFileEditorInput ) { - resource = ((IFileEditorInput)editorInput).getFile(); - } - else if ( editorInput instanceof ExternalEditorInput ) { - resource = ((ExternalEditorInput)editorInput).getMarkerResource(); + if (editorInput instanceof IFileEditorInput) { + resource = ((IFileEditorInput) editorInput).getFile(); + } else if (editorInput instanceof ExternalEditorInput) { + resource = ((ExternalEditorInput) editorInput).getMarkerResource(); } - if ( resource != null ) + if (resource != null) return resource; /* This file is not in a project, let default case handle it */ - ILocationProvider provider = editorInput.getAdapter( ILocationProvider.class ); - if ( provider != null ) { - IPath location = provider.getPath( editorInput ); - if ( location != null ) { - IFile[] files = root.findFilesForLocationURI( URIUtil.toURI( location ) ); - if ( files.length > 0 && files[0].isAccessible()) + ILocationProvider provider = editorInput.getAdapter(ILocationProvider.class); + if (provider != null) { + IPath location = provider.getPath(editorInput); + if (location != null) { + IFile[] files = root.findFilesForLocationURI(URIUtil.toURI(location)); + if (files.length > 0 && files[0].isAccessible()) return files[0]; } } return root; } - private String getSourceHandle( IEditorInput input ) throws CoreException { - return CDebugUIUtils.getEditorFilePath( input ); + private String getSourceHandle(IEditorInput input) throws CoreException { + return CDebugUIUtils.getEditorFilePath(input); } - protected String getSourceHandle( IDeclaration declaration ) { + protected String getSourceHandle(IDeclaration declaration) { ITranslationUnit tu = declaration.getTranslationUnit(); - if ( tu != null ) { + if (tu != null) { IPath location = tu.getLocation(); - if ( location != null ) { + if (location != null) { return location.toOSString(); } } @@ -742,17 +730,17 @@ abstract public class AbstractToggleBreakpointAdapter } /** - * Returns the resource file containing the C model element. - * + * Returns the resource file containing the C model element. + * * @param declaration model element - * @return resource for c model element. Cannot be null, will return workspace root when no resource file can be found. + * @return resource for c model element. Cannot be null, will return workspace root when no resource file can be found. */ - - protected IResource getElementResource( IDeclaration declaration ) { + + protected IResource getElementResource(IDeclaration declaration) { IResource resource = declaration.getUnderlyingResource(); if (resource != null) return resource; - + try { IEditorInput editorInput = EditorUtility.getEditorInput(declaration); return getResource(editorInput); @@ -762,258 +750,259 @@ abstract public class AbstractToggleBreakpointAdapter return ResourcesPlugin.getWorkspace().getRoot(); } - private String getFunctionName( IFunction function ) { + private String getFunctionName(IFunction function) { String functionName = function.getElementName(); - StringBuilder name = new StringBuilder( functionName ); + StringBuilder name = new StringBuilder(functionName); ITranslationUnit tu = function.getTranslationUnit(); - if ( tu != null && tu.isCXXLanguage() ) { - appendParameters( name, function ); + if (tu != null && tu.isCXXLanguage()) { + appendParameters(name, function); } return name.toString(); } - private String getMethodName( IMethod method ) { + private String getMethodName(IMethod method) { StringBuilder name = new StringBuilder(); String methodName = method.getElementName(); ICElement parent = method.getParent(); - while( parent != null - && (parent.getElementType() == ICElement.C_NAMESPACE || parent.getElementType() == ICElement.C_CLASS - || parent.getElementType() == ICElement.C_STRUCT || parent.getElementType() == ICElement.C_UNION) ) { - name.append( parent.getElementName() ).append( "::" ); //$NON-NLS-1$ + while (parent != null && (parent.getElementType() == ICElement.C_NAMESPACE + || parent.getElementType() == ICElement.C_CLASS || parent.getElementType() == ICElement.C_STRUCT + || parent.getElementType() == ICElement.C_UNION)) { + name.append(parent.getElementName()).append("::"); //$NON-NLS-1$ parent = parent.getParent(); } - name.append( methodName ); - appendParameters( name, method ); + name.append(methodName); + appendParameters(name, method); return name.toString(); } - private void appendParameters( StringBuilder sb, IFunctionDeclaration fd ) { + private void appendParameters(StringBuilder sb, IFunctionDeclaration fd) { String[] params = fd.getParameterTypes(); - sb.append( '(' ); - for( int i = 0; i < params.length; ++i ) { - sb.append( params[i] ); - if ( i != params.length - 1 ) - sb.append( ',' ); + sb.append('('); + for (int i = 0; i < params.length; ++i) { + sb.append(params[i]); + if (i != params.length - 1) + sb.append(','); } - sb.append( ')' ); + sb.append(')'); } - private String getVariableName( IVariable variable ) { + private String getVariableName(IVariable variable) { return variable.getElementName(); } - private ITranslationUnit getTranslationUnit( IFile file ) { - Object element = CoreModel.getDefault().create( file ); - if ( element instanceof ITranslationUnit ) { - return (ITranslationUnit)element; + private ITranslationUnit getTranslationUnit(IFile file) { + Object element = CoreModel.getDefault().create(file); + if (element instanceof ITranslationUnit) { + return (ITranslationUnit) element; } return null; } private boolean toggleBreakpointEnable(IWorkbenchPart part) { - ITextEditor textEditor = getTextEditor(part); - if(textEditor != null) { - IVerticalRulerInfo info = textEditor.getAdapter(IVerticalRulerInfo.class); - if(info != null) { - EnableDisableBreakpointRulerAction enableAction = new EnableDisableBreakpointRulerAction(part, info); - enableAction.update(); - enableAction.run(); - } - } - return false; - } - - /** - * Returns the text editor associated with the given part or <code>null</code> - * if none. In case of a multi-page editor, this method should be used to retrieve - * the correct editor to perform the breakpoint operation on. - * - * @param part workbench part - * @return text editor part or <code>null</code> - */ - protected ITextEditor getTextEditor(IWorkbenchPart part) { - if (part instanceof ITextEditor) { - return (ITextEditor) part; - } - return part.getAdapter(ITextEditor.class); - } - - /** - * Resolves the {@link IBreakpoint} from the given editor and ruler information. Returns <code>null</code> - * if no breakpoint exists or the operation fails. - * - * @param editor the editor - * @param info the current ruler information - * @return the {@link IBreakpoint} from the current editor position or <code>null</code> - */ - protected IBreakpoint getBreakpointFromEditor(ITextEditor editor, IVerticalRulerInfo info) { - IAnnotationModel annotationModel = editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput()); - IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput()); - if (annotationModel != null) { - Iterator<Annotation> iterator = annotationModel.getAnnotationIterator(); - while (iterator.hasNext()) { - Object object = iterator.next(); - if (object instanceof SimpleMarkerAnnotation) { - SimpleMarkerAnnotation markerAnnotation = (SimpleMarkerAnnotation) object; - IMarker marker = markerAnnotation.getMarker(); - try { - if (marker.isSubtypeOf(IBreakpoint.BREAKPOINT_MARKER)) { - Position position = annotationModel.getPosition(markerAnnotation); - int line = document.getLineOfOffset(position.getOffset()); - if (line == info.getLineOfLastMouseButtonActivity()) { - IBreakpoint breakpoint = DebugPlugin.getDefault().getBreakpointManager().getBreakpoint(marker); - if (breakpoint != null) { - return breakpoint; - } - } - } - } catch (CoreException e) { - } catch (BadLocationException e) { - } - } - } - } - return null; - } - - /** - * Opens the properties dialog for the given breakpoint. This method can be - * used on an existing breakpoint or on a blank breakpoint which doesn't - * have an associated marker yet. - * - * @param bp - * The breakpoint to edit. This breakpoint may not have an - * associated marker yet. - * @param part - * Workbench part where the action was invoked. - * @param resource - * Workbench resource to create the breakpoint on. - * @param attributes - * Breakpoint attributes to show in properties dialog. If the - * breakpoint already exists, this attribute map can be used to - * override the attributes currently in the breakpoint. Can be - * <code>null</code>. - */ - protected void openBreakpointPropertiesDialog(ICBreakpoint bp, IWorkbenchPart part, IResource resource, - Map<String, Object> attributes) { - ISelection debugContext = DebugUITools.getDebugContextManager() - .getContextService(part.getSite().getWorkbenchWindow()).getActiveContext(part.getSite().getId()); - CBreakpointContext bpContext = new CBreakpointContext(bp, debugContext, resource, attributes); - - String initialPageId = null; - if (bp.getMarker() == null) { - // Bug 433308 - Always show Common page initially for new breakpoints - initialPageId = CBreakpointPropertyDialogAction.PAGE_ID_COMMON; - } - PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(part.getSite().getShell(), bpContext, initialPageId , - null, null); - if (dialog != null) { - dialog.open(); - } - } - - /** - * Finds the line breakpoint at the given location. - * - * @param sourceHandle - * Source handle for the line breakpoint. - * @param resource - * Resource of the line breakpoint. - * @param lineNumber - * Line number. - * @return Line breakpoint with given parameters, if found. - * @throws CoreException - * Exception thrown while reading breakpoints' properties. - */ - protected abstract ICLineBreakpoint findLineBreakpoint(String sourceHandle, IResource resource, int lineNumber) - throws CoreException; + ITextEditor textEditor = getTextEditor(part); + if (textEditor != null) { + IVerticalRulerInfo info = textEditor.getAdapter(IVerticalRulerInfo.class); + if (info != null) { + EnableDisableBreakpointRulerAction enableAction = new EnableDisableBreakpointRulerAction(part, info); + enableAction.update(); + enableAction.run(); + } + } + return false; + } + + /** + * Returns the text editor associated with the given part or <code>null</code> + * if none. In case of a multi-page editor, this method should be used to retrieve + * the correct editor to perform the breakpoint operation on. + * + * @param part workbench part + * @return text editor part or <code>null</code> + */ + protected ITextEditor getTextEditor(IWorkbenchPart part) { + if (part instanceof ITextEditor) { + return (ITextEditor) part; + } + return part.getAdapter(ITextEditor.class); + } + + /** + * Resolves the {@link IBreakpoint} from the given editor and ruler information. Returns <code>null</code> + * if no breakpoint exists or the operation fails. + * + * @param editor the editor + * @param info the current ruler information + * @return the {@link IBreakpoint} from the current editor position or <code>null</code> + */ + protected IBreakpoint getBreakpointFromEditor(ITextEditor editor, IVerticalRulerInfo info) { + IAnnotationModel annotationModel = editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput()); + IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput()); + if (annotationModel != null) { + Iterator<Annotation> iterator = annotationModel.getAnnotationIterator(); + while (iterator.hasNext()) { + Object object = iterator.next(); + if (object instanceof SimpleMarkerAnnotation) { + SimpleMarkerAnnotation markerAnnotation = (SimpleMarkerAnnotation) object; + IMarker marker = markerAnnotation.getMarker(); + try { + if (marker.isSubtypeOf(IBreakpoint.BREAKPOINT_MARKER)) { + Position position = annotationModel.getPosition(markerAnnotation); + int line = document.getLineOfOffset(position.getOffset()); + if (line == info.getLineOfLastMouseButtonActivity()) { + IBreakpoint breakpoint = DebugPlugin.getDefault().getBreakpointManager() + .getBreakpoint(marker); + if (breakpoint != null) { + return breakpoint; + } + } + } + } catch (CoreException e) { + } catch (BadLocationException e) { + } + } + } + } + return null; + } + + /** + * Opens the properties dialog for the given breakpoint. This method can be + * used on an existing breakpoint or on a blank breakpoint which doesn't + * have an associated marker yet. + * + * @param bp + * The breakpoint to edit. This breakpoint may not have an + * associated marker yet. + * @param part + * Workbench part where the action was invoked. + * @param resource + * Workbench resource to create the breakpoint on. + * @param attributes + * Breakpoint attributes to show in properties dialog. If the + * breakpoint already exists, this attribute map can be used to + * override the attributes currently in the breakpoint. Can be + * <code>null</code>. + */ + protected void openBreakpointPropertiesDialog(ICBreakpoint bp, IWorkbenchPart part, IResource resource, + Map<String, Object> attributes) { + ISelection debugContext = DebugUITools.getDebugContextManager() + .getContextService(part.getSite().getWorkbenchWindow()).getActiveContext(part.getSite().getId()); + CBreakpointContext bpContext = new CBreakpointContext(bp, debugContext, resource, attributes); + + String initialPageId = null; + if (bp.getMarker() == null) { + // Bug 433308 - Always show Common page initially for new breakpoints + initialPageId = CBreakpointPropertyDialogAction.PAGE_ID_COMMON; + } + PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(part.getSite().getShell(), bpContext, + initialPageId, null, null); + if (dialog != null) { + dialog.open(); + } + } + + /** + * Finds the line breakpoint at the given location. + * + * @param sourceHandle + * Source handle for the line breakpoint. + * @param resource + * Resource of the line breakpoint. + * @param lineNumber + * Line number. + * @return Line breakpoint with given parameters, if found. + * @throws CoreException + * Exception thrown while reading breakpoints' properties. + */ + protected abstract ICLineBreakpoint findLineBreakpoint(String sourceHandle, IResource resource, int lineNumber) + throws CoreException; /** * Creates a line breakpoint at the given location. * @param interactive true if action should open a dialog to let user edit - * breakpoint properties prior to creation. + * breakpoint properties prior to creation. * @param part Workbench part where action was invoked. * @param source Handle Source handle for the new breakpoint. * @param resource Resource to create breakpoint on. * @param lineNumber Line number for new breakpoint. * @throws CoreException Exception while creating breakpoint. */ - protected abstract void createLineBreakpoint(boolean interactive, IWorkbenchPart part, String sourceHandle, - IResource resource, int lineNumber) throws CoreException; - - /** - * Finds the function breakpoint at the given location. - * - * @param sourceHandle - * Source handle for the line breakpoint. - * @param resource - * Resource of the line breakpoint. - * @param functionName - * Function for the breakpoint. - * @return Function breakpoint with given parameters, if found. - * @throws CoreException - * Exception thrown while reading breakpoints' properties. - */ - protected abstract ICFunctionBreakpoint findFunctionBreakpoint(String sourceHandle, IResource resource, - String functionName) throws CoreException; - - /** - * Creates a function breakpoint at the given location. - * @param interactive true if action should open a dialog to let user edit - * breakpoint properties prior to creation. - * @param part Workbench part where action was invoked. - * @param source Handle Source handle for the new breakpoint. - * @param resource Resource to create breakpoint on. - * @param charStart Beginning of range where function is located. Can be - * -1 if not known. - * @param charStart End of range where function is located. Can be - * -1 if not known. - * @param lineNumber Line number where the function is located. - * @throws CoreException Exception while creating breakpoint. - */ - protected abstract void createFunctionBreakpoint(boolean interactive, IWorkbenchPart part, String sourceHandle, - IResource resource, String functionName, int charStart, int charEnd, int lineNumber) throws CoreException; + protected abstract void createLineBreakpoint(boolean interactive, IWorkbenchPart part, String sourceHandle, + IResource resource, int lineNumber) throws CoreException; + + /** + * Finds the function breakpoint at the given location. + * + * @param sourceHandle + * Source handle for the line breakpoint. + * @param resource + * Resource of the line breakpoint. + * @param functionName + * Function for the breakpoint. + * @return Function breakpoint with given parameters, if found. + * @throws CoreException + * Exception thrown while reading breakpoints' properties. + */ + protected abstract ICFunctionBreakpoint findFunctionBreakpoint(String sourceHandle, IResource resource, + String functionName) throws CoreException; + + /** + * Creates a function breakpoint at the given location. + * @param interactive true if action should open a dialog to let user edit + * breakpoint properties prior to creation. + * @param part Workbench part where action was invoked. + * @param source Handle Source handle for the new breakpoint. + * @param resource Resource to create breakpoint on. + * @param charStart Beginning of range where function is located. Can be + * -1 if not known. + * @param charStart End of range where function is located. Can be + * -1 if not known. + * @param lineNumber Line number where the function is located. + * @throws CoreException Exception while creating breakpoint. + */ + protected abstract void createFunctionBreakpoint(boolean interactive, IWorkbenchPart part, String sourceHandle, + IResource resource, String functionName, int charStart, int charEnd, int lineNumber) throws CoreException; /** * Finds the watchpoint with given expression. - * - * @param sourceHandle Source handle for the line breakpoint. - * @param resource Resource of the line breakpoint. - * @param expression Expression of the breakpoint. - * @return Watchpoing with given parameters, if found. - * @throws CoreException Exception thrown while reading breakpoints' + * + * @param sourceHandle Source handle for the line breakpoint. + * @param resource Resource of the line breakpoint. + * @param expression Expression of the breakpoint. + * @return Watchpoing with given parameters, if found. + * @throws CoreException Exception thrown while reading breakpoints' + */ + protected abstract ICWatchpoint findWatchpoint(String sourceHandle, IResource resource, String expression) + throws CoreException; + + /** + * Creates a watchpoint at the given location. + * @param interactive true if action should open a dialog to let user edit + * breakpoint properties prior to creation. + * @param part Workbench part where action was invoked. + * @param source Handle Source handle for the new breakpoint. + * @param resource Resource to create breakpoint on. + * @param charStart Beginning of range where variable is located. Can be + * -1 if not known. + * @param charStart End of range where variable is located. Can be + * -1 if not known. + * @param lineNumber Line number where the variable is located. + * @throws CoreException Exception while creating breakpoint. + */ + protected abstract void createWatchpoint(boolean interactive, IWorkbenchPart part, String sourceHandle, + IResource resource, int charStart, int charEnd, int lineNumber, String expression, String memorySpace, + String range) throws CoreException; + + /** + * Creates an event breakpoint of the given type. + * @param interactive true if action should open a dialog to let user edit + * breakpoint properties prior to creation. + * @param part Workbench part where action was invoked. + * @param resource Resource to create breakpoint on. + * @param type Type of event breakpoint. + * @param arg Arugment of event breakpoint. + * @throws CoreException Exception while creating breakpoint. */ - protected abstract ICWatchpoint findWatchpoint( String sourceHandle, IResource resource, String expression ) - throws CoreException; - - /** - * Creates a watchpoint at the given location. - * @param interactive true if action should open a dialog to let user edit - * breakpoint properties prior to creation. - * @param part Workbench part where action was invoked. - * @param source Handle Source handle for the new breakpoint. - * @param resource Resource to create breakpoint on. - * @param charStart Beginning of range where variable is located. Can be - * -1 if not known. - * @param charStart End of range where variable is located. Can be - * -1 if not known. - * @param lineNumber Line number where the variable is located. - * @throws CoreException Exception while creating breakpoint. - */ - protected abstract void createWatchpoint(boolean interactive, IWorkbenchPart part, String sourceHandle, - IResource resource, int charStart, int charEnd, int lineNumber, String expression, String memorySpace, - String range) throws CoreException; - - /** - * Creates an event breakpoint of the given type. - * @param interactive true if action should open a dialog to let user edit - * breakpoint properties prior to creation. - * @param part Workbench part where action was invoked. - * @param resource Resource to create breakpoint on. - * @param type Type of event breakpoint. - * @param arg Arugment of event breakpoint. - * @throws CoreException Exception while creating breakpoint. - */ - protected abstract void createEventBreakpoint(boolean interactive, IWorkbenchPart part, IResource resource, - String type, String arg) throws CoreException; + protected abstract void createEventBreakpoint(boolean interactive, IWorkbenchPart part, IResource resource, + String type, String arg) throws CoreException; } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AddWatchpointActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AddWatchpointActionDelegate.java index 955c5b89d95..dbd44b6097c 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AddWatchpointActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AddWatchpointActionDelegate.java @@ -12,7 +12,7 @@ * QNX Software Systems - Initial API and implementation * Freescale Semiconductor - Address watchpoints, https://bugs.eclipse.org/bugs/show_bug.cgi?id=118299 *******************************************************************************/ -package org.eclipse.cdt.debug.ui.breakpoints; +package org.eclipse.cdt.debug.ui.breakpoints; import org.eclipse.cdt.debug.internal.ui.actions.ActionMessages; import org.eclipse.cdt.debug.internal.ui.actions.breakpoints.ToggleBreakpointAdapter; @@ -27,11 +27,11 @@ import org.eclipse.ui.IViewActionDelegate; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.actions.ActionDelegate; - + /** * A delegate for the "Add Watchpoint" action. Clients can register this object on * a model-specific element which supports a toggle breakpoints target. - * + * * @noextend This class is not intended to be subclassed by clients. * @since 7.2 */ @@ -40,13 +40,13 @@ public class AddWatchpointActionDelegate extends ActionDelegate implements IView private IWorkbenchPart fPart; private ISelection fSelection; private ToggleBreakpointAdapter fDefaultToggleTarget = new ToggleBreakpointAdapter(); - + /* (non-Javadoc) * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart) */ @Override - public void init( IViewPart view ) { - setView( view ); + public void init(IViewPart view) { + setView(view); } private void setView(IViewPart view) { @@ -56,34 +56,35 @@ public class AddWatchpointActionDelegate extends ActionDelegate implements IView protected IWorkbenchPart getPart() { return fPart; } - + @Override public void selectionChanged(IAction action, ISelection selection) { - fSelection = selection; + fSelection = selection; } - + @Override public void setActivePart(IAction action, IWorkbenchPart targetPart) { - fPart = targetPart; + fPart = targetPart; } - + /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ @Override - public void run( IAction action ) { - IToggleBreakpointsTarget toggleTarget = DebugUITools.getToggleBreakpointsTargetManager().getToggleBreakpointsTarget(fPart, fSelection); - IToggleBreakpointsTargetCExtension cToggleTarget = null; - if (toggleTarget instanceof IToggleBreakpointsTargetCExtension) { - cToggleTarget = (IToggleBreakpointsTargetCExtension)toggleTarget; - } else { - cToggleTarget = fDefaultToggleTarget; - } - - try { - cToggleTarget.createWatchpointsInteractive(fPart, fSelection); - } catch (CoreException e) { - CDebugUIPlugin.errorDialog( ActionMessages.getString( "AddWatchpointActionDelegate.0" ), e ); //$NON-NLS-1$ - } + public void run(IAction action) { + IToggleBreakpointsTarget toggleTarget = DebugUITools.getToggleBreakpointsTargetManager() + .getToggleBreakpointsTarget(fPart, fSelection); + IToggleBreakpointsTargetCExtension cToggleTarget = null; + if (toggleTarget instanceof IToggleBreakpointsTargetCExtension) { + cToggleTarget = (IToggleBreakpointsTargetCExtension) toggleTarget; + } else { + cToggleTarget = fDefaultToggleTarget; + } + + try { + cToggleTarget.createWatchpointsInteractive(fPart, fSelection); + } catch (CoreException e) { + CDebugUIPlugin.errorDialog(ActionMessages.getString("AddWatchpointActionDelegate.0"), e); //$NON-NLS-1$ + } } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AddWatchpointOnVariableActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AddWatchpointOnVariableActionDelegate.java index e31278cef3d..5b7d404b778 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AddWatchpointOnVariableActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AddWatchpointOnVariableActionDelegate.java @@ -13,7 +13,6 @@ *******************************************************************************/ package org.eclipse.cdt.debug.ui.breakpoints; - import org.eclipse.cdt.debug.core.ICWatchpointTarget; import org.eclipse.cdt.debug.internal.core.CRequest; import org.eclipse.debug.core.DebugPlugin; @@ -24,10 +23,10 @@ import org.eclipse.jface.viewers.TreeSelection; /** * Invoked when user right clicks on an element in the Variables or Expressions - * view and selects 'Add Watchpoint (C/C++)' Clients can register this action for - * their specific element type which adapts to {@link ICWatchpointTarget}. - * - * + * view and selects 'Add Watchpoint (C/C++)' Clients can register this action for + * their specific element type which adapts to {@link ICWatchpointTarget}. + * + * * @noextend This class is not intended to be subclassed by clients. * @since 7.2 */ @@ -35,7 +34,7 @@ public class AddWatchpointOnVariableActionDelegate extends AddWatchpointActionDe /** The target variable/expression */ private ICWatchpointTarget fVar; - + /** * Constructor */ @@ -45,10 +44,12 @@ public class AddWatchpointOnVariableActionDelegate extends AddWatchpointActionDe private class CanCreateWatchpointRequest extends CRequest implements ICWatchpointTarget.CanCreateWatchpointRequest { boolean fCanCreate; + @Override public boolean getCanCreate() { return fCanCreate; } + @Override public void setCanCreate(boolean value) { fCanCreate = value; @@ -57,21 +58,21 @@ public class AddWatchpointOnVariableActionDelegate extends AddWatchpointActionDe /** * Record the target variable/expression - * + * * @see org.eclipse.ui.actions.ActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, * org.eclipse.jface.viewers.ISelection) */ @Override public void selectionChanged(final IAction action, ISelection selection) { - super.selectionChanged(action, selection); + super.selectionChanged(action, selection); fVar = null; if (selection == null || selection.isEmpty()) { action.setEnabled(false); return; } if (selection instanceof TreeSelection) { - Object obj = ((TreeSelection)selection).getFirstElement(); - fVar = (ICWatchpointTarget)DebugPlugin.getAdapter(obj, ICWatchpointTarget.class); + Object obj = ((TreeSelection) selection).getFirstElement(); + fVar = (ICWatchpointTarget) DebugPlugin.getAdapter(obj, ICWatchpointTarget.class); if (fVar != null) { final ICWatchpointTarget.CanCreateWatchpointRequest request = new CanCreateWatchpointRequest() { @Override @@ -83,12 +84,11 @@ public class AddWatchpointOnVariableActionDelegate extends AddWatchpointActionDe return; } assert false : "action should not have been available for object " + obj; //$NON-NLS-1$ - } - else if (selection instanceof StructuredSelection) { + } else if (selection instanceof StructuredSelection) { // Not sure why, but sometimes we get an extraneous empty StructuredSelection. Seems harmless enough - assert ((StructuredSelection)selection).getFirstElement() == null : "action installed in unexpected type of view/part"; //$NON-NLS-1$ - } - else { + assert ((StructuredSelection) selection) + .getFirstElement() == null : "action installed in unexpected type of view/part"; //$NON-NLS-1$ + } else { assert false : "action installed in unexpected type of view/part"; //$NON-NLS-1$ } action.setEnabled(false); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CBreakpointPropertyDialogAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CBreakpointPropertyDialogAction.java index c5df54dc4e5..3cc96e5d78b 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CBreakpointPropertyDialogAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CBreakpointPropertyDialogAction.java @@ -34,7 +34,7 @@ import org.eclipse.ui.internal.IWorkbenchHelpContextIds; import org.eclipse.ui.internal.WorkbenchMessages; /** - * Action for opening a Property Pages Dialog on the C breakpoint object + * Action for opening a Property Pages Dialog on the C breakpoint object * in the currently selected element. * <p> * Generally speaking, this action is useful in pop-up menus because it allows @@ -55,158 +55,159 @@ import org.eclipse.ui.internal.WorkbenchMessages; */ public class CBreakpointPropertyDialogAction extends SelectionProviderAction { - /** - * Provides the shell in which to open the property dialog. - */ - private IShellProvider fShellProvider; - - private IDebugContextProvider fDebugContextProvider; - - static final String PAGE_ID_COMMON = "org.eclipse.cdt.debug.ui.propertypages.breakpoint.common"; //$NON-NLS-1$ - - public CBreakpointPropertyDialogAction(IShellProvider shell, ISelectionProvider selectionProvider, IDebugContextProvider debugContextProvider) { - super(selectionProvider, WorkbenchMessages.PropertyDialog_text); - Assert.isNotNull(shell); - fDebugContextProvider = debugContextProvider; - fShellProvider = shell; - setToolTipText(WorkbenchMessages.PropertyDialog_toolTip); - PlatformUI.getWorkbench().getHelpSystem().setHelp(this, - IWorkbenchHelpContextIds.PROPERTY_DIALOG_ACTION); - } - - protected ISelection getDebugContext() { - return fDebugContextProvider.getActiveContext(); - } - - /** - * Returns whether this action is actually applicable to the current - * selection. If this action is disabled, it will return <code>false</code> - * without further calculation. If it is enabled, it will check with the - * workbench's property page manager to see if there are any property pages - * registered for the selected element's type. - * <p> - * This method is generally too expensive to use when updating the enabled - * state of the action on each selection change. - * </p> - * - * @return <code>true</code> if the selection is not empty and there are - * property pages for the selected element, and <code>false</code> - * otherwise - */ - public boolean isCBreakpointSelection() { - if (!isEnabled()) { - return false; - } - return isApplicableForSelection(getStructuredSelection(), getDebugContext()); - } - - /** - * Returns whether this action is applicable to the current selection. This - * checks that the selection is not empty, and checks with the workbench's - * property page manager to see if there are any property pages registered - * for the selected element's type. - * <p> - * This method is generally too expensive to use when updating the enabled - * state of the action on each selection change. - * </p> - * - * @param selection - * The selection to test - * @return <code>true</code> if the selection is of not empty and there are - * property pages for the selected element, and <code>false</code> - * otherwise - */ - public boolean isApplicableForSelection(IStructuredSelection selection, ISelection debugContext) { - return isCBreakpointSelection(selection); - } - - /** - * Returns whether the given selection contains only elements of type ICBreakpoint - * @param selection - * @return - */ - private boolean isCBreakpointSelection(IStructuredSelection selection) { - if (selection.isEmpty()) return false; - - for (Iterator<?> itr = selection.iterator(); itr.hasNext();) { - if ( !(itr.next() instanceof ICBreakpoint) ) { - return false; - } - } - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.action.IAction#run() - */ - public void run() { - CBreakpointContext bpContext = getCBreakpointContext(); - if (bpContext != null) { - PreferenceDialog dialog = createDialog(bpContext); - - if (dialog != null) { - TreeViewer viewer = dialog.getTreeViewer(); - if (viewer != null) { - viewer.setComparator(new ViewerComparator() { - @Override - public int category(Object element) { - if (element instanceof IPreferenceNode) { - IPreferenceNode node = (IPreferenceNode)element; - if ( PAGE_ID_COMMON.equals(node.getId()) ) { - return 0; - } else if (node.getSubNodes() == null || node.getSubNodes().length == 0) { - // Pages without children (not categories) - return super.category(element) + 1; - } - } - // Categories last. - return super.category(element) + 2; - } - }); - // Expand all categories - viewer.expandToLevel(TreeViewer.ALL_LEVELS); - } - - dialog.open(); - } - - } - } - - private CBreakpointContext getCBreakpointContext() { - IStructuredSelection ss = getStructuredSelection(); - if (ss.size() >= 1 && ss.getFirstElement() instanceof ICBreakpoint) { - return new CBreakpointContext((ICBreakpoint)ss.getFirstElement(), fDebugContextProvider.getActiveContext()); - } - return null; - } - - /** - * Create the dialog for the receiver. If no pages are found, an informative - * message dialog is presented instead. - * - * @return PreferenceDialog or <code>null</code> if no applicable pages - * are found. - */ - protected PreferenceDialog createDialog(CBreakpointContext bpContext) { - IStructuredSelection ss = getStructuredSelection(); - if (ss.isEmpty()) - return null; - - String initialPageId = null; - if (bpContext.getBreakpoint().getMarker() == null) { - // Bug 433308 - Always show Common page initially for new breakpoints - initialPageId = PAGE_ID_COMMON; - } - return PreferencesUtil.createPropertyDialogOn(fShellProvider.getShell(), bpContext, initialPageId, null, null); - } - - - /* (non-Javadoc) - * @see org.eclipse.ui.actions.SelectionProviderAction#selectionChanged(org.eclipse.jface.viewers.IStructuredSelection) - */ - public void selectionChanged(IStructuredSelection selection) { - setEnabled(!selection.isEmpty()); - } - + /** + * Provides the shell in which to open the property dialog. + */ + private IShellProvider fShellProvider; + + private IDebugContextProvider fDebugContextProvider; + + static final String PAGE_ID_COMMON = "org.eclipse.cdt.debug.ui.propertypages.breakpoint.common"; //$NON-NLS-1$ + + public CBreakpointPropertyDialogAction(IShellProvider shell, ISelectionProvider selectionProvider, + IDebugContextProvider debugContextProvider) { + super(selectionProvider, WorkbenchMessages.PropertyDialog_text); + Assert.isNotNull(shell); + fDebugContextProvider = debugContextProvider; + fShellProvider = shell; + setToolTipText(WorkbenchMessages.PropertyDialog_toolTip); + PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IWorkbenchHelpContextIds.PROPERTY_DIALOG_ACTION); + } + + protected ISelection getDebugContext() { + return fDebugContextProvider.getActiveContext(); + } + + /** + * Returns whether this action is actually applicable to the current + * selection. If this action is disabled, it will return <code>false</code> + * without further calculation. If it is enabled, it will check with the + * workbench's property page manager to see if there are any property pages + * registered for the selected element's type. + * <p> + * This method is generally too expensive to use when updating the enabled + * state of the action on each selection change. + * </p> + * + * @return <code>true</code> if the selection is not empty and there are + * property pages for the selected element, and <code>false</code> + * otherwise + */ + public boolean isCBreakpointSelection() { + if (!isEnabled()) { + return false; + } + return isApplicableForSelection(getStructuredSelection(), getDebugContext()); + } + + /** + * Returns whether this action is applicable to the current selection. This + * checks that the selection is not empty, and checks with the workbench's + * property page manager to see if there are any property pages registered + * for the selected element's type. + * <p> + * This method is generally too expensive to use when updating the enabled + * state of the action on each selection change. + * </p> + * + * @param selection + * The selection to test + * @return <code>true</code> if the selection is of not empty and there are + * property pages for the selected element, and <code>false</code> + * otherwise + */ + public boolean isApplicableForSelection(IStructuredSelection selection, ISelection debugContext) { + return isCBreakpointSelection(selection); + } + + /** + * Returns whether the given selection contains only elements of type ICBreakpoint + * @param selection + * @return + */ + private boolean isCBreakpointSelection(IStructuredSelection selection) { + if (selection.isEmpty()) + return false; + + for (Iterator<?> itr = selection.iterator(); itr.hasNext();) { + if (!(itr.next() instanceof ICBreakpoint)) { + return false; + } + } + return true; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.action.IAction#run() + */ + public void run() { + CBreakpointContext bpContext = getCBreakpointContext(); + if (bpContext != null) { + PreferenceDialog dialog = createDialog(bpContext); + + if (dialog != null) { + TreeViewer viewer = dialog.getTreeViewer(); + if (viewer != null) { + viewer.setComparator(new ViewerComparator() { + @Override + public int category(Object element) { + if (element instanceof IPreferenceNode) { + IPreferenceNode node = (IPreferenceNode) element; + if (PAGE_ID_COMMON.equals(node.getId())) { + return 0; + } else if (node.getSubNodes() == null || node.getSubNodes().length == 0) { + // Pages without children (not categories) + return super.category(element) + 1; + } + } + // Categories last. + return super.category(element) + 2; + } + }); + // Expand all categories + viewer.expandToLevel(TreeViewer.ALL_LEVELS); + } + + dialog.open(); + } + + } + } + + private CBreakpointContext getCBreakpointContext() { + IStructuredSelection ss = getStructuredSelection(); + if (ss.size() >= 1 && ss.getFirstElement() instanceof ICBreakpoint) { + return new CBreakpointContext((ICBreakpoint) ss.getFirstElement(), + fDebugContextProvider.getActiveContext()); + } + return null; + } + + /** + * Create the dialog for the receiver. If no pages are found, an informative + * message dialog is presented instead. + * + * @return PreferenceDialog or <code>null</code> if no applicable pages + * are found. + */ + protected PreferenceDialog createDialog(CBreakpointContext bpContext) { + IStructuredSelection ss = getStructuredSelection(); + if (ss.isEmpty()) + return null; + + String initialPageId = null; + if (bpContext.getBreakpoint().getMarker() == null) { + // Bug 433308 - Always show Common page initially for new breakpoints + initialPageId = PAGE_ID_COMMON; + } + return PreferencesUtil.createPropertyDialogOn(fShellProvider.getShell(), bpContext, initialPageId, null, null); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.actions.SelectionProviderAction#selectionChanged(org.eclipse.jface.viewers.IStructuredSelection) + */ + public void selectionChanged(IStructuredSelection selection) { + setEnabled(!selection.isEmpty()); + } + } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CBreakpointUIContributionFactory.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CBreakpointUIContributionFactory.java index 8408faf17ce..0f831d1be19 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CBreakpointUIContributionFactory.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CBreakpointUIContributionFactory.java @@ -1,6 +1,6 @@ /******************************************************************************* * Copyright (c) 2008, 2012 QNX Software Systems and others. - * + * * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -47,9 +47,9 @@ public class CBreakpointUIContributionFactory { /** * Calculates the breakpoint contributions for the given breakpoint. - * + * * @param breakpoint Breakpoint to find UI contributions for. - * @return non-null array of ICBreakpointsUIContribution + * @return non-null array of ICBreakpointsUIContribution * @throws CoreException if cannot get marker attributes from bearkpoint */ public ICBreakpointsUIContribution[] getBreakpointUIContributions(IBreakpoint breakpoint) throws CoreException { @@ -58,104 +58,97 @@ public class CBreakpointUIContributionFactory { Map<String, Object> attributes = Collections.emptyMap(); String markerType = CDIDebugModel.calculateMarkerType(breakpoint); if (bmarker != null) { - Map<String, Object> _attributes = bmarker.getAttributes(); - attributes = _attributes; - markerType = bmarker.getType(); + Map<String, Object> _attributes = bmarker.getAttributes(); + attributes = _attributes; + markerType = bmarker.getType(); } return getBreakpointUIContributions(debugModelId, markerType, attributes); } - /** - * Calculates the breakpoint contributions for the given breakpoint. - * - * @param breakpoint Breakpoint to find UI contributions for. - * @param attributes Attributes of the breakpoint - * @return non-null array of ICBreakpointsUIContribution - * @throws CoreException if cannot get marker attributes from bearkpoint - * @since 7.2 - */ - public ICBreakpointsUIContribution[] getBreakpointUIContributions(String[] debugModelIDs, IBreakpoint breakpoint, - Map<String, Object> attributes) throws CoreException - { - IMarker bmarker = breakpoint.getMarker(); - String markerType = CDIDebugModel.calculateMarkerType(breakpoint); - if (bmarker != null) { - markerType = bmarker.getType(); - } - return getBreakpointUIContributions(debugModelIDs, markerType, attributes); - } - + /** + * Calculates the breakpoint contributions for the given breakpoint. + * + * @param breakpoint Breakpoint to find UI contributions for. + * @param attributes Attributes of the breakpoint + * @return non-null array of ICBreakpointsUIContribution + * @throws CoreException if cannot get marker attributes from bearkpoint + * @since 7.2 + */ + public ICBreakpointsUIContribution[] getBreakpointUIContributions(String[] debugModelIDs, IBreakpoint breakpoint, + Map<String, Object> attributes) throws CoreException { + IMarker bmarker = breakpoint.getMarker(); + String markerType = CDIDebugModel.calculateMarkerType(breakpoint); + if (bmarker != null) { + markerType = bmarker.getType(); + } + return getBreakpointUIContributions(debugModelIDs, markerType, attributes); + } + /** * Default debug model ID list which will cause only the general UI contributions to be returned. * @since 7.2 */ public final static String[] DEBUG_MODEL_IDS_DEFAULT = new String[] {}; - - /** - * Calculates the breakpoint UI contributions for the given breakpoint. - * - * @param debugModelId The debug model ID of the active debug context for - * which to calculate contributions. - * @param breakpoint Breakpoint to find UI contributions for. - * @param markerType Marker type of the breakpoint. - * @param attributes Attributes of the breakpoint - * @return non-null array of ICBreakpointsUIContribution - * @throws CoreException - * @throws CoreException if cannot get marker attributes from berakpoint - */ + + /** + * Calculates the breakpoint UI contributions for the given breakpoint. + * + * @param debugModelId The debug model ID of the active debug context for + * which to calculate contributions. + * @param breakpoint Breakpoint to find UI contributions for. + * @param markerType Marker type of the breakpoint. + * @param attributes Attributes of the breakpoint + * @return non-null array of ICBreakpointsUIContribution + * @throws CoreException + * @throws CoreException if cannot get marker attributes from berakpoint + */ public ICBreakpointsUIContribution[] getBreakpointUIContributions(String debugModelId, String markerType, - Map<String, Object> attributes) - { - return getBreakpointUIContributions( - debugModelId != null ? new String[] { debugModelId } : null, - markerType, - attributes); - + Map<String, Object> attributes) { + return getBreakpointUIContributions(debugModelId != null ? new String[] { debugModelId } : null, markerType, + attributes); + } - /** - * Calculates the breakpoint UI contributions for the given breakpoint. - * - * @param debugModelId The debug model IDs of the active debug context for - * which to calculate contributions. - * @param breakpoint Breakpoint to find UI contributions for. - * @param markerType Marker type of the breakpoint. - * @param attributes Attributes of the breakpoint - * @return non-null array of ICBreakpointsUIContribution - * @throws CoreException - * @throws CoreException if cannot get marker attributes from berakpoint - * - * @since 7.2 - */ - public ICBreakpointsUIContribution[] getBreakpointUIContributions(String[] debugModelIds, String markerType, - Map<String, Object> attributes) - { - List<String> debugModelIdsList = null; - if (debugModelIds != null ) { - debugModelIdsList = Arrays.asList(debugModelIds); - } - ArrayList<ICBreakpointsUIContribution> list = new ArrayList<ICBreakpointsUIContribution>(); - for (ICBreakpointsUIContribution con : contributions) { - try { - if (con.getDebugModelId() == null || - ((debugModelIdsList == null || debugModelIdsList.contains(con.getDebugModelId())))) - { - String contributedMarkerType = con.getMarkerType(); - if (isMarkerSubtypeOf(markerType, contributedMarkerType)) { - if (attributes == null || con.isApplicable(attributes)) { - list.add(con); - } - } - } - } catch (Exception e) { - CDebugUIPlugin.log(e); - } + /** + * Calculates the breakpoint UI contributions for the given breakpoint. + * + * @param debugModelId The debug model IDs of the active debug context for + * which to calculate contributions. + * @param breakpoint Breakpoint to find UI contributions for. + * @param markerType Marker type of the breakpoint. + * @param attributes Attributes of the breakpoint + * @return non-null array of ICBreakpointsUIContribution + * @throws CoreException + * @throws CoreException if cannot get marker attributes from berakpoint + * + * @since 7.2 + */ + public ICBreakpointsUIContribution[] getBreakpointUIContributions(String[] debugModelIds, String markerType, + Map<String, Object> attributes) { + List<String> debugModelIdsList = null; + if (debugModelIds != null) { + debugModelIdsList = Arrays.asList(debugModelIds); + } + ArrayList<ICBreakpointsUIContribution> list = new ArrayList<ICBreakpointsUIContribution>(); + for (ICBreakpointsUIContribution con : contributions) { + try { + if (con.getDebugModelId() == null + || ((debugModelIdsList == null || debugModelIdsList.contains(con.getDebugModelId())))) { + String contributedMarkerType = con.getMarkerType(); + if (isMarkerSubtypeOf(markerType, contributedMarkerType)) { + if (attributes == null || con.isApplicable(attributes)) { + list.add(con); + } + } + } + } catch (Exception e) { + CDebugUIPlugin.log(e); + } - } - return list.toArray(new ICBreakpointsUIContribution[list.size()]); - } + } + return list.toArray(new ICBreakpointsUIContribution[list.size()]); + } - public boolean isMarkerSubtypeOf(String currentType, String type) throws CoreException { return getWorkspace().getMarkerManager().isSubtype(currentType, type); } @@ -173,17 +166,16 @@ public class CBreakpointUIContributionFactory { IConfigurationElement[] elements = ep.getConfigurationElements(); for (int i = 0; i < elements.length; i++) { IConfigurationElement configurationElement = elements[i]; - if (configurationElement.getName().equals(ICBreakpointsUIContribution.BREAKPOINT_LABELS) || - configurationElement.getName().equals(ICBreakpointsUIContribution.BREAKPOINT_EDITORS)) - { - String mainElement = configurationElement.getName(); + if (configurationElement.getName().equals(ICBreakpointsUIContribution.BREAKPOINT_LABELS) + || configurationElement.getName().equals(ICBreakpointsUIContribution.BREAKPOINT_EDITORS)) { + String mainElement = configurationElement.getName(); String modelId = configurationElement.getAttribute("debugModelId"); //$NON-NLS-1$ String markerType = getRequired(configurationElement, "markerType"); //$NON-NLS-1$ if (markerType == null) continue; IConfigurationElement[] children = configurationElement.getChildren("attribute"); //$NON-NLS-1$ for (IConfigurationElement att : children) { - + DefaultCBreakpointUIContribution adapter = new DefaultCBreakpointUIContribution(att); adapter.setMainElement(mainElement); adapter.setMarkerType(markerType); @@ -197,13 +189,11 @@ public class CBreakpointUIContributionFactory { } } - private boolean processAttribute(IConfigurationElement attrElement, - DefaultCBreakpointUIContribution adapter) - { + private boolean processAttribute(IConfigurationElement attrElement, DefaultCBreakpointUIContribution adapter) { String attrId = getRequired(attrElement, "name"); //$NON-NLS-1$ String attrLabel = getRequired(attrElement, "label"); //$NON-NLS-1$ String fieldEditorClass = attrElement.getAttribute("fieldEditor"); //$NON-NLS-1$ - String fieldEditorFactoryClass = attrElement.getAttribute("fieldEditorFactory"); //$NON-NLS-1$ + String fieldEditorFactoryClass = attrElement.getAttribute("fieldEditorFactory"); //$NON-NLS-1$ String type = attrElement.getAttribute("type"); //$NON-NLS-1$ String svisible = attrElement.getAttribute("visible"); //$NON-NLS-1$ @@ -223,7 +213,7 @@ public class CBreakpointUIContributionFactory { adapter.setId(attrId); adapter.setLabel(attrLabel); adapter.setControlClass(fieldEditorClass); - adapter.setFieldEditorFactory(fieldEditorFactoryClass); + adapter.setFieldEditorFactory(fieldEditorFactoryClass); adapter.setType(type); adapter.setVisible(visible); addContribution(adapter); @@ -276,7 +266,8 @@ public class CBreakpointUIContributionFactory { CDebugUIPlugin.log(new Status(IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, "Extension " //$NON-NLS-1$ + configurationElement.getDeclaringExtension().getUniqueIdentifier() - + " missing required attribute: " + name, null)); //$NON-NLS-1$ + + " missing required attribute: " + name, //$NON-NLS-1$ + null)); return elementValue; } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CEventBreakpointsLabelProviderFactory.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CEventBreakpointsLabelProviderFactory.java index d804261239e..857dd821cd7 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CEventBreakpointsLabelProviderFactory.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CEventBreakpointsLabelProviderFactory.java @@ -1,6 +1,6 @@ /******************************************************************************* * Copyright (c) 2008, 2016 QNX Software Systems and others. - * + * * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -52,7 +52,7 @@ public class CEventBreakpointsLabelProviderFactory implements IAdapterFactory { for (ICBreakpointsUIContribution con : bscs) { Object attValue = breakpoint.getMarker().getAttribute(con.getId()); - + if (con.getId().equals(ICEventBreakpoint.EVENT_TYPE_ID)) { if (!Arrays.asList(con.getPossibleValues()).contains(attValue)) continue; @@ -87,13 +87,13 @@ public class CEventBreakpointsLabelProviderFactory implements IAdapterFactory { * particularly the code that determines the proper overlays. This * adapter is actually only called from within CDebugModelPresentation * and we know it will do the right thing for an event breakpoint if we - * return null here. - * + * return null here. + * * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object) */ @Override public Image getImage(Object element) { - + return null; } }; @@ -102,8 +102,8 @@ public class CEventBreakpointsLabelProviderFactory implements IAdapterFactory { int ignoreCount = breakpoint.getIgnoreCount(); if (ignoreCount > 0) { label.append(' '); - label.append(MessageFormat.format( - DebugCoreMessages.getString("CDebugUtils.3"), new Object[] { Integer.toString(ignoreCount) })); //$NON-NLS-1$ + label.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.3"), //$NON-NLS-1$ + new Object[] { Integer.toString(ignoreCount) })); } return label; } @@ -112,13 +112,13 @@ public class CEventBreakpointsLabelProviderFactory implements IAdapterFactory { String condition = breakpoint.getCondition(); if (condition != null && condition.length() > 0) { buffer.append(' '); - buffer.append(MessageFormat - .format(DebugCoreMessages.getString("CDebugUtils.4"), new Object[] { condition })); //$NON-NLS-1$ + buffer.append( + MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.4"), new Object[] { condition })); //$NON-NLS-1$ } } private static IElementLabelProvider fElementLabelProvider = new BreakpointLabelProvider(); - + @SuppressWarnings("unchecked") @Override public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) { diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/DefaultCBreakpointUIContribution.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/DefaultCBreakpointUIContribution.java index d194e392109..e708998db19 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/DefaultCBreakpointUIContribution.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/DefaultCBreakpointUIContribution.java @@ -1,6 +1,6 @@ /******************************************************************************* * Copyright (c) 2008, 2012 QNX Software Systems and others. - * + * * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -29,9 +29,9 @@ import org.eclipse.jface.preference.FieldEditor; import org.eclipse.swt.widgets.Composite; class DefaultCBreakpointUIContribution implements ICBreakpointsUIContribution { - - private final IConfigurationElement fConfig; - private String mainElement; + + private final IConfigurationElement fConfig; + private String mainElement; private String attLabel; private String attId; private String fieldEditorClassName; @@ -44,10 +44,9 @@ class DefaultCBreakpointUIContribution implements ICBreakpointsUIContribution { private Map<String, String> conditions = new HashMap<String, String>(); DefaultCBreakpointUIContribution(IConfigurationElement config) { - fConfig = config; + fConfig = config; } - - + @Override public String getId() { return attId; @@ -65,41 +64,40 @@ class DefaultCBreakpointUIContribution implements ICBreakpointsUIContribution { @Override public String getMainElement() { - return mainElement; + return mainElement; } - - static private Class<?>[] fieldSignature = new Class[] { String.class, String.class, - Composite.class }; + + static private Class<?>[] fieldSignature = new Class[] { String.class, String.class, Composite.class }; @Override public FieldEditor getFieldEditor(String name, String labelText, Composite parent) { - if (fieldEditorFactory != null) { - return fieldEditorFactory.createFieldEditor(name, labelText, parent); - } else if (fieldEditorFactoryClass != null) { - try { - fieldEditorFactory = (IFieldEditorFactory) fConfig.createExecutableExtension("fieldEditorFactory"); //$NON-NLS-1$ - } catch (CoreException e) { - CDebugUIPlugin.log(e); - return null; - } - return fieldEditorFactory.createFieldEditor(name, labelText, parent); - } else if (fieldEditorClassName != null) { - try { - @SuppressWarnings("unchecked") - Class<FieldEditor> cclass = (Class<FieldEditor>)Class.forName(fieldEditorClassName); - Constructor<FieldEditor> constructor = cclass.getConstructor(fieldSignature); - FieldEditor editor = constructor.newInstance(name, labelText, parent); - if (editor instanceof ICBreakpointsUIContributionUser) { - ((ICBreakpointsUIContributionUser)editor).setContribution(this); - } - return editor; - } catch (Exception e) { - CDebugUIPlugin.log(e); - return null; - } - } else { - return new ReadOnlyFieldEditor(name, labelText, parent); - } + if (fieldEditorFactory != null) { + return fieldEditorFactory.createFieldEditor(name, labelText, parent); + } else if (fieldEditorFactoryClass != null) { + try { + fieldEditorFactory = (IFieldEditorFactory) fConfig.createExecutableExtension("fieldEditorFactory"); //$NON-NLS-1$ + } catch (CoreException e) { + CDebugUIPlugin.log(e); + return null; + } + return fieldEditorFactory.createFieldEditor(name, labelText, parent); + } else if (fieldEditorClassName != null) { + try { + @SuppressWarnings("unchecked") + Class<FieldEditor> cclass = (Class<FieldEditor>) Class.forName(fieldEditorClassName); + Constructor<FieldEditor> constructor = cclass.getConstructor(fieldSignature); + FieldEditor editor = constructor.newInstance(name, labelText, parent); + if (editor instanceof ICBreakpointsUIContributionUser) { + ((ICBreakpointsUIContributionUser) editor).setContribution(this); + } + return editor; + } catch (Exception e) { + CDebugUIPlugin.log(e); + return null; + } + } else { + return new ReadOnlyFieldEditor(name, labelText, parent); + } } @Override @@ -127,9 +125,9 @@ class DefaultCBreakpointUIContribution implements ICBreakpointsUIContribution { @Override public boolean isApplicable(Map<String, Object> properties) { - for (Object key : conditions.keySet()) { + for (Object key : conditions.keySet()) { Object bpValue = properties.get(key); - if ( bpValue == null || !bpValue.equals(conditions.get(key)) ) { + if (bpValue == null || !bpValue.equals(conditions.get(key))) { return false; } } @@ -137,9 +135,9 @@ class DefaultCBreakpointUIContribution implements ICBreakpointsUIContribution { } public void setMainElement(String mainElement) { - this.mainElement = mainElement; + this.mainElement = mainElement; } - + public void setLabel(String attLabel) { this.attLabel = attLabel; } @@ -151,9 +149,9 @@ class DefaultCBreakpointUIContribution implements ICBreakpointsUIContribution { public void setControlClass(String controlClass) { this.fieldEditorClassName = controlClass; } - + public void setFieldEditorFactory(String factoryClass) { - fieldEditorFactoryClass = factoryClass; + fieldEditorFactoryClass = factoryClass; } public void setMarkerType(String markerId) { diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/ICBreakpointContext.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/ICBreakpointContext.java index 67a353597f8..d73b85bf751 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/ICBreakpointContext.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/ICBreakpointContext.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation *******************************************************************************/ @@ -19,40 +19,40 @@ import org.eclipse.debug.ui.contexts.IDebugContextProvider; import org.eclipse.jface.preference.IPreferenceStore; /** - * Input for the breakpoint properties dialog. It captures both the + * Input for the breakpoint properties dialog. It captures both the * selected breakpoint object as well as the selected debug context. * This combined context can then be used by breakpoint property - * pages to access model and target specific breakpoint settings. - * + * pages to access model and target specific breakpoint settings. + * * @since 7.2 */ public interface ICBreakpointContext extends IDebugContextProvider { - /** - * Returns the breakpoint object that this context represents. - * <p> - * Note: The returned breakpoint may not yet have an associated marker. - * This is for the case where the property dialog is opened for a breakpoint - * that is yet to be created. - * - * @return Breakpoint object. - */ - public ICBreakpoint getBreakpoint(); - - /** - * Resource object that the breakpoint marker is on. In case where - * the breakpoint marker is not yet created, clients can access the intended - * breakpoint resource object through this method. - * - * @return The breakpoint's resource object. - */ - public IResource getResource(); - - /** - * Returns the preference store to be used by property pages. This - * preference overrides values in the breakpoint marker. - * @return Preference store for the property pages. - */ - public IPreferenceStore getPreferenceStore(); - + /** + * Returns the breakpoint object that this context represents. + * <p> + * Note: The returned breakpoint may not yet have an associated marker. + * This is for the case where the property dialog is opened for a breakpoint + * that is yet to be created. + * + * @return Breakpoint object. + */ + public ICBreakpoint getBreakpoint(); + + /** + * Resource object that the breakpoint marker is on. In case where + * the breakpoint marker is not yet created, clients can access the intended + * breakpoint resource object through this method. + * + * @return The breakpoint's resource object. + */ + public IResource getResource(); + + /** + * Returns the preference store to be used by property pages. This + * preference overrides values in the breakpoint marker. + * @return Preference store for the property pages. + */ + public IPreferenceStore getPreferenceStore(); + } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/ICBreakpointsUIContribution.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/ICBreakpointsUIContribution.java index b007171b0d5..724d4e23143 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/ICBreakpointsUIContribution.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/ICBreakpointsUIContribution.java @@ -1,6 +1,6 @@ /******************************************************************************* * Copyright (c) 2008, 2012 QNX Software Systems and others. - * + * * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -21,40 +21,39 @@ import java.util.Map; import org.eclipse.jface.preference.FieldEditor; import org.eclipse.swt.widgets.Composite; - /** - * Interface representing a contributed UI element for breakpoint properties + * Interface representing a contributed UI element for breakpoint properties * dialogs. - * + * * @noimplement This interface is not intended to be implemented by clients. * @noextend This interface is not intended to be extended by clients. */ public interface ICBreakpointsUIContribution { - /** - * Main element name of breakpoint labels extension element. - * @since 7.2 - */ - public static final String BREAKPOINT_LABELS = "breakpointLabels"; //$NON-NLS-1$ - - /** - * Main element name of breakpoint editors extension element. - * @since 7.2 - */ - public static final String BREAKPOINT_EDITORS = "breakpointEditors"; //$NON-NLS-1$ + /** + * Main element name of breakpoint labels extension element. + * @since 7.2 + */ + public static final String BREAKPOINT_LABELS = "breakpointLabels"; //$NON-NLS-1$ + + /** + * Main element name of breakpoint editors extension element. + * @since 7.2 + */ + public static final String BREAKPOINT_EDITORS = "breakpointEditors"; //$NON-NLS-1$ /** * Attribute id * @return */ public String getId(); - + /** * Extenralizable label for this attribute id * @return */ public String getLabel(); - + /** * Creates FieldEditor for given attribute or null if not needed * @param name - property name, must be the same as breakpoint attribute @@ -63,7 +62,7 @@ public interface ICBreakpointsUIContribution { * @return ready to use FieldEditor */ public FieldEditor getFieldEditor(String name, String labelText, Composite parent); - + /** * Returns the element name under which this attribute was added. The value should either be * "breakpointLabels" or "breakpointEditors". @@ -71,47 +70,48 @@ public interface ICBreakpointsUIContribution { * @since 7.2 */ public String getMainElement(); - + /** * Get raw field editor class name * @return class name */ public String getFieldEditorClassName(); + /** * Return list of possible values that attributes can take, of null of no restrictions * @return */ public String[] getPossibleValues(); - + /** * Get label for given attribute value, externalizable string * @param value * @return */ public String getLabelForValue(String value); - + /** * Get type of the attribute * @return */ public String getType(); - + /** * Get marker type for which this attribute is created * @return */ - public String getMarkerType(); - - /** - * Get debug model id - * @return - */ - public String getDebugModelId(); - - /** - * Return true if setting for an attribute applicable for setting of other attributes provided by the map - * @param map - contains pairs of attribute=value for other breakpoint attributes - * @return - */ - public boolean isApplicable(Map<String, Object> map); + public String getMarkerType(); + + /** + * Get debug model id + * @return + */ + public String getDebugModelId(); + + /** + * Return true if setting for an attribute applicable for setting of other attributes provided by the map + * @param map - contains pairs of attribute=value for other breakpoint attributes + * @return + */ + public boolean isApplicable(Map<String, Object> map); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/ICBreakpointsUIContributionUser.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/ICBreakpointsUIContributionUser.java index f19dedd47a4..c78510f96b8 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/ICBreakpointsUIContributionUser.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/ICBreakpointsUIContributionUser.java @@ -15,7 +15,7 @@ package org.eclipse.cdt.debug.ui.breakpoints; /** * This interface can be implemented by FieldEditors used in {@extensionPoint org.eclipse.cdt.debug.ui.breakpointContribution} extension. - * This allow to connect field back to parent that creates it {@link ICBreakpointsUIContribution} + * This allow to connect field back to parent that creates it {@link ICBreakpointsUIContribution} */ public interface ICBreakpointsUIContributionUser { /** diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/IFieldEditorFactory.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/IFieldEditorFactory.java index e9df6dbb151..8e13b98ab54 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/IFieldEditorFactory.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/IFieldEditorFactory.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation *******************************************************************************/ @@ -20,22 +20,22 @@ import org.eclipse.swt.widgets.Composite; * Factory for creating field editors contributed through the <code> * org.eclipse.cdt.debug.ui.breakpointContribution</code> extension point. * <p> - * Field editors do not have a non-arg constructor, therefore custom editors - * cannot be created directly by the extension point directly. This factory - * allows clients to instantiate a custom field editor which is not on the class + * Field editors do not have a non-arg constructor, therefore custom editors + * cannot be created directly by the extension point directly. This factory + * allows clients to instantiate a custom field editor which is not on the class * path of the CDT debug UI plugin. * </p> * @since 7.2 */ public interface IFieldEditorFactory { - - /** - * Creates a field editor with given parameters. - * - * @param name Field editor's property name. - * @param labelText Field editors label. - * @param parent Field editors parent control. - * @return Newly created field editor. - */ - public FieldEditor createFieldEditor(String name, String labelText, Composite parent); + + /** + * Creates a field editor with given parameters. + * + * @param name Field editor's property name. + * @param labelText Field editors label. + * @param parent Field editors parent control. + * @return Newly created field editor. + */ + public FieldEditor createFieldEditor(String name, String labelText, Composite parent); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/IToggleBreakpointsTargetCExtension.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/IToggleBreakpointsTargetCExtension.java index 9bb97b91a77..c420db8e250 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/IToggleBreakpointsTargetCExtension.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/IToggleBreakpointsTargetCExtension.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation *******************************************************************************/ @@ -20,8 +20,8 @@ import org.eclipse.ui.IWorkbenchPart; /** * Second extension interface for {@link org.eclipse.debug.ui.actions.IToggleBreakpointsTarget}. - * This interface provides the ability open edit a breakpoint's properties and - * to create a breakpoint in the given context with additional user input + * This interface provides the ability open edit a breakpoint's properties and + * to create a breakpoint in the given context with additional user input * (such as using a dialog or a wizard). * <p> * Clients implementing <code>IToggleBreakpointsTarget</code> may optionally @@ -32,140 +32,140 @@ import org.eclipse.ui.IWorkbenchPart; */ public interface IToggleBreakpointsTargetCExtension extends IToggleBreakpointsTargetExtension { - /** - * Returns whether the toggle target can create a line breakpoint at the - * given location. If the implementation does not support creating the - * breakpoint interactively then it should return <code>false</code>. - * <p> - * The selection varies depending on the given part. For example, - * a text selection is provided for text editors, and a structured - * selection is provided for tree views, and may be a multi-selection. - * </p> - * @param part the part on which the action has been invoked - * @param selection selection on which line breakpoints should be toggled - * @return Returns <code>true</code> if toggle target is able interactively - * create a breakpoint(s) at the given location. - */ - public boolean canCreateLineBreakpointsInteractive(IWorkbenchPart part, ISelection selection); + /** + * Returns whether the toggle target can create a line breakpoint at the + * given location. If the implementation does not support creating the + * breakpoint interactively then it should return <code>false</code>. + * <p> + * The selection varies depending on the given part. For example, + * a text selection is provided for text editors, and a structured + * selection is provided for tree views, and may be a multi-selection. + * </p> + * @param part the part on which the action has been invoked + * @param selection selection on which line breakpoints should be toggled + * @return Returns <code>true</code> if toggle target is able interactively + * create a breakpoint(s) at the given location. + */ + public boolean canCreateLineBreakpointsInteractive(IWorkbenchPart part, ISelection selection); + + /** + * Creates new line breakpoints interactively. The implementation should + * allows the user to edit all of the breakpoint's settings prior to + * creating the breakpoint. Unlike the + * {@link #toggleLineBreakpoints(IWorkbenchPart, ISelection)} + * method, this method does not remove the existing breakpoint at given + * location. It always creates a new breakpoint + * <p> + * The selection varies depending on the given part. For example, + * a text selection is provided for text editors, and a structured + * selection is provided for tree views, and may be a multi-selection. + * </p> + * @param part the part on which the action has been invoked + * @param selection selection on which line breakpoints should be toggled + * @throws CoreException if unable to perform the action + */ + public void createLineBreakpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException; /** - * Creates new line breakpoints interactively. The implementation should - * allows the user to edit all of the breakpoint's settings prior to - * creating the breakpoint. Unlike the - * {@link #toggleLineBreakpoints(IWorkbenchPart, ISelection)} - * method, this method does not remove the existing breakpoint at given - * location. It always creates a new breakpoint - * <p> - * The selection varies depending on the given part. For example, - * a text selection is provided for text editors, and a structured - * selection is provided for tree views, and may be a multi-selection. - * </p> - * @param part the part on which the action has been invoked - * @param selection selection on which line breakpoints should be toggled - * @throws CoreException if unable to perform the action - */ - public void createLineBreakpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException; - - /** - * Returns whether the toggle target can create a watchpoint at the - * given location. If the implementation does not support creating the - * breakpoint interactively then it should return <code>false</code>. - * <p> - * The selection varies depending on the given part. For example, - * a text selection is provided for text editors, and a structured - * selection is provided for tree views, and may be a multi-selection. - * </p> - * @param part the part on which the action has been invoked - * @param selection selection on which line breakpoints should be toggled - * @return Returns <code>true</code> if toggle target is able interactively - * create a breakpoint(s) at the given location. - */ - public boolean canCreateWatchpointsInteractive(IWorkbenchPart part, ISelection selection); + * Returns whether the toggle target can create a watchpoint at the + * given location. If the implementation does not support creating the + * breakpoint interactively then it should return <code>false</code>. + * <p> + * The selection varies depending on the given part. For example, + * a text selection is provided for text editors, and a structured + * selection is provided for tree views, and may be a multi-selection. + * </p> + * @param part the part on which the action has been invoked + * @param selection selection on which line breakpoints should be toggled + * @return Returns <code>true</code> if toggle target is able interactively + * create a breakpoint(s) at the given location. + */ + public boolean canCreateWatchpointsInteractive(IWorkbenchPart part, ISelection selection); - /** - * Creates new watchpoint interactively. The implementation should - * allows the user to edit all of the breakpoint's settings prior to - * creating the breakpoint. Unlike the - * {@link #toggleLineBreakpoints(IWorkbenchPart, ISelection)} - * method, this method does not remove the existing breakpoint at given - * location. It always creates a new breakpoint - * <p> - * The selection varies depending on the given part. For example, - * a text selection is provided for text editors, and a structured - * selection is provided for tree views, and may be a multi-selection. - * </p> - * @param part the part on which the action has been invoked - * @param selection selection on which line breakpoints should be toggled - * @throws CoreException if unable to perform the action - */ - public void createWatchpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException; - - /** - * Returns whether the toggle target can create a function breakpoint at the - * given location. If the implementation does not support creating the - * breakpoint interactively then it should return <code>false</code>. - * <p> - * The selection varies depending on the given part. For example, - * a text selection is provided for text editors, and a structured - * selection is provided for tree views, and may be a multi-selection. - * </p> - * @param part the part on which the action has been invoked - * @param selection selection on which line breakpoints should be toggled - * @return Returns <code>true</code> if toggle target is able interactively - * create a breakpoint(s) at the given location. - */ - public boolean canCreateFunctionBreakpointInteractive(IWorkbenchPart part, ISelection selection); - - /** - * Creates new function breakpoint interactively. The implementation should - * allows the user to edit all of the breakpoint's settings prior to - * creating the breakpoint. Unlike the - * {@link #toggleLineBreakpoints(IWorkbenchPart, ISelection)} - * method, this method does not remove the existing breakpoint at given - * location. It always creates a new breakpoint - * <p> - * The selection varies depending on the given part. For example, - * a text selection is provided for text editors, and a structured - * selection is provided for tree views, and may be a multi-selection. - * </p> - * @param part the part on which the action has been invoked - * @param selection selection on which line breakpoints should be toggled - * @throws CoreException if unable to perform the action - */ - public void createFunctionBreakpointInteractive(IWorkbenchPart part, ISelection selection) throws CoreException; - - /** - * Returns whether the toggle target can create an event breakpoint at the - * given location. If the implementation does not support creating the - * breakpoint interactively then it should return <code>false</code>. - * <p> - * The selection varies depending on the given part. For example, - * a text selection is provided for text editors, and a structured - * selection is provided for tree views, and may be a multi-selection. - * </p> - * @param part the part on which the action has been invoked - * @param selection selection on which line breakpoints should be toggled - * @return Returns <code>true</code> if toggle target is able interactively - * create a breakpoint(s) at the given location. - */ - public boolean canCreateEventBreakpointsInteractive(IWorkbenchPart part, ISelection selection); + /** + * Creates new watchpoint interactively. The implementation should + * allows the user to edit all of the breakpoint's settings prior to + * creating the breakpoint. Unlike the + * {@link #toggleLineBreakpoints(IWorkbenchPart, ISelection)} + * method, this method does not remove the existing breakpoint at given + * location. It always creates a new breakpoint + * <p> + * The selection varies depending on the given part. For example, + * a text selection is provided for text editors, and a structured + * selection is provided for tree views, and may be a multi-selection. + * </p> + * @param part the part on which the action has been invoked + * @param selection selection on which line breakpoints should be toggled + * @throws CoreException if unable to perform the action + */ + public void createWatchpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException; + + /** + * Returns whether the toggle target can create a function breakpoint at the + * given location. If the implementation does not support creating the + * breakpoint interactively then it should return <code>false</code>. + * <p> + * The selection varies depending on the given part. For example, + * a text selection is provided for text editors, and a structured + * selection is provided for tree views, and may be a multi-selection. + * </p> + * @param part the part on which the action has been invoked + * @param selection selection on which line breakpoints should be toggled + * @return Returns <code>true</code> if toggle target is able interactively + * create a breakpoint(s) at the given location. + */ + public boolean canCreateFunctionBreakpointInteractive(IWorkbenchPart part, ISelection selection); + + /** + * Creates new function breakpoint interactively. The implementation should + * allows the user to edit all of the breakpoint's settings prior to + * creating the breakpoint. Unlike the + * {@link #toggleLineBreakpoints(IWorkbenchPart, ISelection)} + * method, this method does not remove the existing breakpoint at given + * location. It always creates a new breakpoint + * <p> + * The selection varies depending on the given part. For example, + * a text selection is provided for text editors, and a structured + * selection is provided for tree views, and may be a multi-selection. + * </p> + * @param part the part on which the action has been invoked + * @param selection selection on which line breakpoints should be toggled + * @throws CoreException if unable to perform the action + */ + public void createFunctionBreakpointInteractive(IWorkbenchPart part, ISelection selection) throws CoreException; + + /** + * Returns whether the toggle target can create an event breakpoint at the + * given location. If the implementation does not support creating the + * breakpoint interactively then it should return <code>false</code>. + * <p> + * The selection varies depending on the given part. For example, + * a text selection is provided for text editors, and a structured + * selection is provided for tree views, and may be a multi-selection. + * </p> + * @param part the part on which the action has been invoked + * @param selection selection on which line breakpoints should be toggled + * @return Returns <code>true</code> if toggle target is able interactively + * create a breakpoint(s) at the given location. + */ + public boolean canCreateEventBreakpointsInteractive(IWorkbenchPart part, ISelection selection); + + /** + * Creates a new event breakpoint interactively. The implementation should + * allows the user to edit all of the breakpoint's settings prior to + * creating the breakpoint. Unlike the + * {@link #toggleLineBreakpoints(IWorkbenchPart, ISelection)} + * method, this method does not remove the existing breakpoint at given + * location. It always creates a new breakpoint + * <p> + * The selection varies depending on the given part. For example, + * a text selection is provided for text editors, and a structured + * selection is provided for tree views, and may be a multi-selection. + * </p> + * @param part the part on which the action has been invoked + * @param selection selection on which line breakpoints should be toggled + * @throws CoreException if unable to perform the action + */ + public void createEventBreakpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException; - /** - * Creates a new event breakpoint interactively. The implementation should - * allows the user to edit all of the breakpoint's settings prior to - * creating the breakpoint. Unlike the - * {@link #toggleLineBreakpoints(IWorkbenchPart, ISelection)} - * method, this method does not remove the existing breakpoint at given - * location. It always creates a new breakpoint - * <p> - * The selection varies depending on the given part. For example, - * a text selection is provided for text editors, and a structured - * selection is provided for tree views, and may be a multi-selection. - * </p> - * @param part the part on which the action has been invoked - * @param selection selection on which line breakpoints should be toggled - * @throws CoreException if unable to perform the action - */ - public void createEventBreakpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException; - } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/debuggerconsole/IDebuggerConsole.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/debuggerconsole/IDebuggerConsole.java index 50c0c8140ad..5b88f6c2498 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/debuggerconsole/IDebuggerConsole.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/debuggerconsole/IDebuggerConsole.java @@ -20,33 +20,33 @@ import org.eclipse.ui.part.IPageBookViewPage; public interface IDebuggerConsole extends IConsole { /** * Returns the launch associated with this console. - * + * * @return the launch associated with this console. */ ILaunch getLaunch(); - + /** * Creates and returns a new page for this console. The page is displayed * for this console in the console given view. - * + * * @param view the view in which the page is to be created * @return a page book view page representation of this console */ IPageBookViewPage createDebuggerPage(IDebuggerConsoleView view); - + /** * Request a re-computation of the name of the console. */ void resetName(); - + /** - * This console has become selected, the implementation shall use this + * This console has become selected, the implementation shall use this * notification to e.g. keep other views in sync with the context of the console */ void consoleSelected(); /** - * Stop processing but don't dispose this console yet, + * Stop processing but don't dispose this console yet, * i.e. It's desirable to keep the last I/O information available to the user * @since 8.2 */ diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/debuggerconsole/IDebuggerConsoleManager.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/debuggerconsole/IDebuggerConsoleManager.java index bf39cd1bf3e..33880e3947c 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/debuggerconsole/IDebuggerConsoleManager.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/debuggerconsole/IDebuggerConsoleManager.java @@ -19,15 +19,15 @@ public interface IDebuggerConsoleManager { /** * Registers the given listener for console notifications. Has * no effect if an identical listener is already registered. - * + * * @param listener listener to register */ public void addConsoleListener(IConsoleListener listener); - + /** * Unregisters the given listener for console notifications. Has * no effect if listener is not already registered. - * + * * @param listener listener to unregister */ public void removeConsoleListener(IConsoleListener listener); @@ -35,25 +35,25 @@ public interface IDebuggerConsoleManager { /** * Adds the given console to the console manager. Has no effect for * equivalent consoles already registered. - * + * * @param console console to add */ public void addConsole(IDebuggerConsole console); - + /** * Removes the given console from the console manager. - * + * * @param console console to remove */ public void removeConsole(IDebuggerConsole console); - + /** * Returns a array of consoles registered with the console manager. - * + * * @return an array of consoles registered with the console manager */ public IDebuggerConsole[] getConsoles(); - + /** * Shows the console view, by opening it if necessary. * Once open, or if the view was already open, it is brought to the front. diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentBaseChangeUpdate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentBaseChangeUpdate.java index c8526b56304..ae322d59349 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentBaseChangeUpdate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentBaseChangeUpdate.java @@ -19,29 +19,29 @@ package org.eclipse.cdt.debug.ui.disassembly; * <p> * Clients are not intended to implement this interface. * </p> - * + * * This interface is experimental */ public interface IDocumentBaseChangeUpdate extends IDocumentUpdate { - /** - * Returns the offset of the old base element. - * - * @return the offset of the old base element - */ - public int getOriginalOffset(); + /** + * Returns the offset of the old base element. + * + * @return the offset of the old base element + */ + public int getOriginalOffset(); - /** - * Sets the base element to use with the given presentation context. - * - * @param base the base element to use with the given presentation context - */ - public void setBaseElement( Object base ); + /** + * Sets the base element to use with the given presentation context. + * + * @param base the base element to use with the given presentation context + */ + public void setBaseElement(Object base); - /** - * Sets the offset of the new base element. - * - * @param offset the offset of the new base element - */ - public void setOffset( int offset ); + /** + * Sets the offset of the new base element. + * + * @param offset the offset of the new base element + */ + public void setOffset(int offset); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementAnnotationProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementAnnotationProvider.java index 1145106ee1a..4384b83e9fd 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementAnnotationProvider.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementAnnotationProvider.java @@ -16,16 +16,16 @@ package org.eclipse.cdt.debug.ui.disassembly; /** * Provides context sensitive annotations for source elements. - * + * * This interface is experimental. */ public interface IDocumentElementAnnotationProvider { - /** - * Updates the annotations of the specified source elements. - * - * @param updates each update specifies the element and context - * for which annotations are requested and stores the results - */ - public void update( IDocumentElementAnnotationUpdate[] updates ); + /** + * Updates the annotations of the specified source elements. + * + * @param updates each update specifies the element and context + * for which annotations are requested and stores the results + */ + public void update(IDocumentElementAnnotationUpdate[] updates); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementAnnotationUpdate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementAnnotationUpdate.java index 385416a9706..330dca8719c 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementAnnotationUpdate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementAnnotationUpdate.java @@ -21,15 +21,15 @@ import org.eclipse.jface.text.source.Annotation; * <p> * Clients are not intended to implement this interface. * </p> - * + * * This interface is experimental */ public interface IDocumentElementAnnotationUpdate extends IDocumentUpdate { - - /** - * Adds an annotation to this request. - * - * @param annotation the annotation to add - */ - public void addAnnotation( Annotation annotation ); + + /** + * Adds an annotation to this request. + * + * @param annotation the annotation to add + */ + public void addAnnotation(Annotation annotation); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementContentProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementContentProvider.java index 59bc92c7632..c9aaf19ef4a 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementContentProvider.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementContentProvider.java @@ -16,24 +16,24 @@ package org.eclipse.cdt.debug.ui.disassembly; /** * Provides a content for a virtual source viewer. - * + * * This interface is experimental. */ public interface IDocumentElementContentProvider { - /** - * Updates the base element of the source viewer. - * This method is called when the viewer's input is changed. - * - * @param update the new input. - */ - public void updateInput( IDocumentBaseChangeUpdate update ); + /** + * Updates the base element of the source viewer. + * This method is called when the viewer's input is changed. + * + * @param update the new input. + */ + public void updateInput(IDocumentBaseChangeUpdate update); - /** - * Updates the source content as requested by the given update. - * This method is called when the viewer requires to update it's content. - * - * @param update specifies the lines to update and stores result - */ - public void updateContent( IDocumentElementContentUpdate update ); + /** + * Updates the source content as requested by the given update. + * This method is called when the viewer requires to update it's content. + * + * @param update specifies the lines to update and stores result + */ + public void updateContent(IDocumentElementContentUpdate update); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementContentUpdate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementContentUpdate.java index 92387657e59..7b21f1edbd5 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementContentUpdate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementContentUpdate.java @@ -15,56 +15,56 @@ package org.eclipse.cdt.debug.ui.disassembly; /** - * A content update request for a source viewer. + * A content update request for a source viewer. * <p> * Clients are not intended to implement this interface. * </p> - * + * * This interface is experimental. */ public interface IDocumentElementContentUpdate extends IDocumentUpdate { - /** - * Returns the line number associated with the base element. - * Can be outside of the requested line interval. - * - * @return line number associated with the element - */ - public int getOriginalOffset(); + /** + * Returns the line number associated with the base element. + * Can be outside of the requested line interval. + * + * @return line number associated with the element + */ + public int getOriginalOffset(); - /** - * Returns the number of lines requested. - * - * @return number of lines requested - */ - public int getRequestedLineCount(); + /** + * Returns the number of lines requested. + * + * @return number of lines requested + */ + public int getRequestedLineCount(); - /** - * Sets the offset of the base element - * - * @param offset offset of the base element - */ - public void setOffset( int offset ); + /** + * Sets the offset of the base element + * + * @param offset offset of the base element + */ + public void setOffset(int offset); - /** - * Sets the number of lines in this update request - * - * @param lineCount number of lines - */ - public void setLineCount( int lineCount ); + /** + * Sets the number of lines in this update request + * + * @param lineCount number of lines + */ + public void setLineCount(int lineCount); - /** - * Adds a source element for the given line number - * - * @param line line number - * @param element element to add - */ - public void addElement( int line, Object element ) throws IndexOutOfBoundsException; + /** + * Adds a source element for the given line number + * + * @param line line number + * @param element element to add + */ + public void addElement(int line, Object element) throws IndexOutOfBoundsException; - /** - * Indicates whether or not the element should be revealed - * - * @return whether or not the element should be revealed - */ - public boolean reveal(); + /** + * Indicates whether or not the element should be revealed + * + * @return whether or not the element should be revealed + */ + public boolean reveal(); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementLabelProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementLabelProvider.java index f8ae4b7904a..5c2065ee72d 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementLabelProvider.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementLabelProvider.java @@ -16,16 +16,16 @@ package org.eclipse.cdt.debug.ui.disassembly; /** * Provides context sensitive labels for source elements. - * + * * This interface is experimental. */ public interface IDocumentElementLabelProvider { - /** - * Updates the specified labels. - * - * @param updates each update specifies the element and context - * for which a label is requested and stores the label attributes - */ - public void update( IDocumentElementLabelUpdate[] updates ); + /** + * Updates the specified labels. + * + * @param updates each update specifies the element and context + * for which a label is requested and stores the label attributes + */ + public void update(IDocumentElementLabelUpdate[] updates); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementLabelUpdate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementLabelUpdate.java index 09823b54caa..e6d7c58247f 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementLabelUpdate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementLabelUpdate.java @@ -19,16 +19,16 @@ package org.eclipse.cdt.debug.ui.disassembly; * <p> * Clients are not intended to implement this interface. * </p> - * + * * This interface is experimental. */ public interface IDocumentElementLabelUpdate extends IDocumentUpdate { - /** - * Sets the text of the label of the specified attribute. - * - * @param attribute the attribute name - * @param text the label text to set - */ - public void setLabel( String attribute, String text ); + /** + * Sets the text of the label of the specified attribute. + * + * @param attribute the attribute name + * @param text the label text to set + */ + public void setLabel(String attribute, String text); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentPresentation.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentPresentation.java index 3962390c31d..2aa9c91ac5f 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentPresentation.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentPresentation.java @@ -23,14 +23,14 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationConte * Clients may implement and extend this interface to provide * special contexts. Implementations must subclass {@link PresentationContext}. * </p> - * + * * This interface is experimental. */ public interface IDocumentPresentation extends IPresentationContext { - /** - * Temporary attribute for testing. - */ - public static final String ATTR_LINE_LABEL = "lineLabel"; //$NON-NLS-1$ + /** + * Temporary attribute for testing. + */ + public static final String ATTR_LINE_LABEL = "lineLabel"; //$NON-NLS-1$ } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentUpdate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentUpdate.java index 6b99b78e108..b967105f2a2 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentUpdate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentUpdate.java @@ -21,24 +21,24 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate; * <p> * Clients are not intended to implement this interface. * </p> - * + * * Use the element path instead of this interface? - * + * * This interface is experimental */ public interface IDocumentUpdate extends IViewerUpdate { - /** - * Returns the root element associated with this request. - * - * @return the root element - */ - public Object getRootElement(); - - /** - * Returns the base element associated with this request. - * - * @return the base element - */ - public Object getBaseElement(); + /** + * Returns the root element associated with this request. + * + * @return the root element + */ + public Object getRootElement(); + + /** + * Returns the base element associated with this request. + * + * @return the base element + */ + public Object getBaseElement(); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IElementToggleBreakpointAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IElementToggleBreakpointAdapter.java index 4b58d58d861..aa9afd4422e 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IElementToggleBreakpointAdapter.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IElementToggleBreakpointAdapter.java @@ -19,18 +19,18 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationCont /** * An adapter to support breakpoint creation/deletion for the disassembly editor. - * + * * This interface is experimental. */ public interface IElementToggleBreakpointAdapter { - /** - * Creates new line breakpoints or removes existing breakpoints for the given element. - */ - public void toggleLineBreakpoints( IPresentationContext presentationContext, Object element ) throws CoreException; + /** + * Creates new line breakpoints or removes existing breakpoints for the given element. + */ + public void toggleLineBreakpoints(IPresentationContext presentationContext, Object element) throws CoreException; - /** - * Returns whether line breakpoints can be toggled on the given element. - */ - public boolean canToggleLineBreakpoints( IPresentationContext presentationContext, Object element ); + /** + * Returns whether line breakpoints can be toggled on the given element. + */ + public boolean canToggleLineBreakpoints(IPresentationContext presentationContext, Object element); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/AbstractContributedRulerColumn.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/AbstractContributedRulerColumn.java index 58e33dcd16a..626fd52106b 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/AbstractContributedRulerColumn.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/AbstractContributedRulerColumn.java @@ -19,7 +19,6 @@ import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.ui.IWorkbenchPart; - /** * Helper class for contributions to the * <code>org.eclipse.cdt.debug.ui.disassemblyRulerColumns</code> extension point. @@ -44,14 +43,14 @@ public abstract class AbstractContributedRulerColumn implements IContributedRule public final void setDescriptor(RulerColumnDescriptor descriptor) { Assert.isLegal(descriptor != null); Assert.isTrue(fDescriptor == null); - fDescriptor= descriptor; + fDescriptor = descriptor; } @Override public final void setDisassemblyPart(IWorkbenchPart disassembly) { Assert.isLegal(disassembly != null); Assert.isTrue(fDisassembly == null); - fDisassembly= disassembly; + fDisassembly = disassembly; } @Override diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IColumnSupport.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IColumnSupport.java index e9c07dea3b7..3e7cd3bee7a 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IColumnSupport.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IColumnSupport.java @@ -14,7 +14,6 @@ *******************************************************************************/ package org.eclipse.cdt.debug.ui.disassembly.rulers; - /** * Provides support to modify and query the visibility of * ruler columns and test whether a ruler column is supported. diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IContributedRulerColumn.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IContributedRulerColumn.java index 489d306a89d..6bf267a55d1 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IContributedRulerColumn.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IContributedRulerColumn.java @@ -14,12 +14,10 @@ *******************************************************************************/ package org.eclipse.cdt.debug.ui.disassembly.rulers; - import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.jface.text.source.IVerticalRulerColumn; import org.eclipse.ui.IWorkbenchPart; - /** * Interface that has to be implemented by contributions to the * <code>org.eclipse.cdt.debug.ui.disassembly.rulerColumns</code> extension point. diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnDescriptor.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnDescriptor.java index 6f1272cd336..dcb302a64f5 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnDescriptor.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnDescriptor.java @@ -29,7 +29,6 @@ import org.eclipse.ui.internal.texteditor.rulers.RulerColumnMessages; import org.eclipse.ui.internal.texteditor.rulers.RulerColumnPlacement; import org.eclipse.ui.internal.texteditor.rulers.RulerColumnTarget; - /** * The description of an extension to the * <code>org.eclipse.ui.workbench.texteditor.rulerColumns</code> extension point. Instances are @@ -40,25 +39,25 @@ import org.eclipse.ui.internal.texteditor.rulers.RulerColumnTarget; */ public final class RulerColumnDescriptor { /** The extension schema name of the class attribute. */ - private static final String CLASS= "class"; //$NON-NLS-1$ + private static final String CLASS = "class"; //$NON-NLS-1$ /** The extension schema name of the id attribute. */ - private static final String ID= "id"; //$NON-NLS-1$ + private static final String ID = "id"; //$NON-NLS-1$ /** The extension schema name of the optional name attribute. */ - private static final String NAME= "name"; //$NON-NLS-1$ + private static final String NAME = "name"; //$NON-NLS-1$ /** The extension schema name of the optional enabled attribute. */ - private static final String ENABLED= "enabled"; //$NON-NLS-1$ + private static final String ENABLED = "enabled"; //$NON-NLS-1$ /** The extension schema name of the optional icon attribute. */ - private static final String ICON= "icon"; //$NON-NLS-1$ + private static final String ICON = "icon"; //$NON-NLS-1$ /** The extension schema name of the optional global attribute. */ - private static final String GLOBAL= "global"; //$NON-NLS-1$ + private static final String GLOBAL = "global"; //$NON-NLS-1$ /** The extension schema name of the optional menu inclusion attribute. */ - private static final String INCLUDE_IN_MENU= "includeInMenu"; //$NON-NLS-1$ + private static final String INCLUDE_IN_MENU = "includeInMenu"; //$NON-NLS-1$ /** The extension schema name of the targetEditor element. */ - private static final String TARGET_ID= "targetId"; //$NON-NLS-1$ + private static final String TARGET_ID = "targetId"; //$NON-NLS-1$ /** The extension schema name of the targetClass element. */ - private static final String TARGET_CLASS= "targetClass"; //$NON-NLS-1$ + private static final String TARGET_CLASS = "targetClass"; //$NON-NLS-1$ /** The extension schema name of the placement element. */ - private static final String PLACEMENT= "placement"; //$NON-NLS-1$ + private static final String PLACEMENT = "placement"; //$NON-NLS-1$ /** The identifier of the extension. */ private final String fId; @@ -87,50 +86,53 @@ public final class RulerColumnDescriptor { * @throws InvalidRegistryObjectException if the configuration element is no longer valid * @throws CoreException if the configuration element does not conform to the extension point spec */ - RulerColumnDescriptor(IConfigurationElement element, RulerColumnRegistry registry) throws InvalidRegistryObjectException, CoreException { + RulerColumnDescriptor(IConfigurationElement element, RulerColumnRegistry registry) + throws InvalidRegistryObjectException, CoreException { Assert.isLegal(registry != null); Assert.isLegal(element != null); - fElement= element; + fElement = element; - ExtensionPointHelper helper= new ExtensionPointHelper(element); + ExtensionPointHelper helper = new ExtensionPointHelper(element); - fId= helper.getNonNullAttribute(ID); - fName= helper.getDefaultAttribute(NAME, fId); + fId = helper.getNonNullAttribute(ID); + fName = helper.getDefaultAttribute(NAME, fId); helper.getNonNullAttribute(CLASS); // just check validity - URL iconURL= helper.getDefaultResourceURL(ICON, null); - fIcon= iconURL == null ? null : ImageDescriptor.createFromURL(iconURL); - fDefaultEnablement= helper.getDefaultAttribute(ENABLED, true); - fIsGlobal= helper.getDefaultAttribute(GLOBAL, true); - fIncludeInMenu= helper.getDefaultAttribute(INCLUDE_IN_MENU, true); - - IConfigurationElement[] targetEditors= element.getChildren(TARGET_ID); - IConfigurationElement[] targetClasses= element.getChildren(TARGET_CLASS); - - RulerColumnTarget combined= null; - for (int i= 0; i < targetEditors.length; i++) { - IConfigurationElement targetEditor= targetEditors[i]; - RulerColumnTarget target= RulerColumnTarget.createEditorIdTarget(new ExtensionPointHelper(targetEditor).getNonNullAttribute(ID)); - combined= RulerColumnTarget.createOrTarget(combined, target); + URL iconURL = helper.getDefaultResourceURL(ICON, null); + fIcon = iconURL == null ? null : ImageDescriptor.createFromURL(iconURL); + fDefaultEnablement = helper.getDefaultAttribute(ENABLED, true); + fIsGlobal = helper.getDefaultAttribute(GLOBAL, true); + fIncludeInMenu = helper.getDefaultAttribute(INCLUDE_IN_MENU, true); + + IConfigurationElement[] targetEditors = element.getChildren(TARGET_ID); + IConfigurationElement[] targetClasses = element.getChildren(TARGET_CLASS); + + RulerColumnTarget combined = null; + for (int i = 0; i < targetEditors.length; i++) { + IConfigurationElement targetEditor = targetEditors[i]; + RulerColumnTarget target = RulerColumnTarget + .createEditorIdTarget(new ExtensionPointHelper(targetEditor).getNonNullAttribute(ID)); + combined = RulerColumnTarget.createOrTarget(combined, target); } - for (int i= 0; i < targetClasses.length; i++) { - IConfigurationElement targetClass= targetClasses[i]; - RulerColumnTarget target= RulerColumnTarget.createClassTarget(new ExtensionPointHelper(targetClass).getNonNullAttribute(CLASS)); - combined= RulerColumnTarget.createOrTarget(combined, target); + for (int i = 0; i < targetClasses.length; i++) { + IConfigurationElement targetClass = targetClasses[i]; + RulerColumnTarget target = RulerColumnTarget + .createClassTarget(new ExtensionPointHelper(targetClass).getNonNullAttribute(CLASS)); + combined = RulerColumnTarget.createOrTarget(combined, target); } - fTarget= combined; + fTarget = combined; - IConfigurationElement[] placements= element.getChildren(PLACEMENT); + IConfigurationElement[] placements = element.getChildren(PLACEMENT); switch (placements.length) { - case 0: - fRulerColumnPlacement= new RulerColumnPlacement(); - break; - case 1: - fRulerColumnPlacement= new RulerColumnPlacement(placements[0]); - break; - default: - helper.fail(RulerColumnMessages.RulerColumnDescriptor_invalid_placement_msg); - fRulerColumnPlacement= null; // dummy - break; + case 0: + fRulerColumnPlacement = new RulerColumnPlacement(); + break; + case 1: + fRulerColumnPlacement = new RulerColumnPlacement(placements[0]); + break; + default: + helper.fail(RulerColumnMessages.RulerColumnDescriptor_invalid_placement_msg); + fRulerColumnPlacement = null; // dummy + break; } Assert.isTrue(fTarget != null); @@ -209,20 +211,20 @@ public final class RulerColumnDescriptor { * Returns <code>true</code> if this contribution matches the passed disassembly part , <code>false</code> if not. * * @param disassembly the disassembly part to check - * @return <code>true</code> if this contribution targets the passed disassembly part + * @return <code>true</code> if this contribution targets the passed disassembly part */ public boolean matchesPart(IWorkbenchPart disassembly) { Assert.isLegal(disassembly != null); - RulerColumnTarget target= getTarget(); + RulerColumnTarget target = getTarget(); - IWorkbenchPartSite site= disassembly.getSite(); + IWorkbenchPartSite site = disassembly.getSite(); if (site != null && target.matchesEditorId(site.getId())) return true; if (target.matchesClass(disassembly.getClass())) return true; - IContentType contentType= getContentType(disassembly); + IContentType contentType = getContentType(disassembly); return contentType != null && target.matchesContentType(contentType); } @@ -235,9 +237,10 @@ public final class RulerColumnDescriptor { * @throws CoreException as thrown by {@link IConfigurationElement#createExecutableExtension(String)} * @throws InvalidRegistryObjectException as thrown by {@link IConfigurationElement#createExecutableExtension(String)} */ - public IContributedRulerColumn createColumn(IWorkbenchPart disassembly) throws CoreException, InvalidRegistryObjectException { + public IContributedRulerColumn createColumn(IWorkbenchPart disassembly) + throws CoreException, InvalidRegistryObjectException { Assert.isLegal(disassembly != null); - IContributedRulerColumn column= (IContributedRulerColumn)fElement.createExecutableExtension(CLASS); + IContributedRulerColumn column = (IContributedRulerColumn) fElement.createExecutableExtension(CLASS); column.setDescriptor(this); column.setDisassemblyPart(disassembly); column.columnCreated(); @@ -262,9 +265,9 @@ public final class RulerColumnDescriptor { */ @Override public int hashCode() { - final int prime= 31; - int result= 1; - result= prime * result + ((fId == null) ? 0 : fId.hashCode()); + final int prime = 31; + int result = 1; + result = prime * result + ((fId == null) ? 0 : fId.hashCode()); return result; } @@ -279,7 +282,7 @@ public final class RulerColumnDescriptor { return false; if (getClass() != obj.getClass()) return false; - final RulerColumnDescriptor other= (RulerColumnDescriptor) obj; + final RulerColumnDescriptor other = (RulerColumnDescriptor) obj; if (fId == null) { if (other.fId != null) return false; diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnPreferenceAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnPreferenceAdapter.java index 37dfc52979e..42d51d7b0f9 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnPreferenceAdapter.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnPreferenceAdapter.java @@ -36,11 +36,11 @@ public final class RulerColumnPreferenceAdapter { * @param store the preference store * @param key the key */ - public RulerColumnPreferenceAdapter(IPreferenceStore store, String key) { + public RulerColumnPreferenceAdapter(IPreferenceStore store, String key) { Assert.isLegal(store != null); Assert.isLegal(key != null); - fStore= store; - fKey= key; + fStore = store; + fKey = key; } /** @@ -51,8 +51,9 @@ public final class RulerColumnPreferenceAdapter { */ public boolean isEnabled(RulerColumnDescriptor descriptor) { Assert.isLegal(descriptor != null); - String preference= fStore.getString(fKey); - return StringSetSerializer.deserialize(preference).contains(descriptor.getId()) ^ descriptor.getDefaultEnablement(); + String preference = fStore.getString(fKey); + return StringSetSerializer.deserialize(preference).contains(descriptor.getId()) + ^ descriptor.getDefaultEnablement(); } /** @@ -64,11 +65,11 @@ public final class RulerColumnPreferenceAdapter { */ public void setEnabled(RulerColumnDescriptor descriptor, boolean enabled) { Assert.isLegal(descriptor != null); - String id= descriptor.getId(); - String preference= fStore.getString(fKey); - Set<String> marked= StringSetSerializer.deserialize(preference); - boolean shouldMark= enabled ^ descriptor.getDefaultEnablement(); - boolean isMarked= marked.contains(id); + String id = descriptor.getId(); + String preference = fStore.getString(fKey); + Set<String> marked = StringSetSerializer.deserialize(preference); + boolean shouldMark = enabled ^ descriptor.getDefaultEnablement(); + boolean isMarked = marked.contains(id); if (isMarked != shouldMark) { if (shouldMark) marked.add(id); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnRegistry.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnRegistry.java index 89dcbf90b54..d4410636ba5 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnRegistry.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnRegistry.java @@ -43,7 +43,6 @@ import org.eclipse.ui.texteditor.ConfigurationElementSorter; import com.ibm.icu.text.MessageFormat; - /** * A registry for all extensions to the * <code>rulerColumns</code> extension point. @@ -53,11 +52,11 @@ import com.ibm.icu.text.MessageFormat; */ public final class RulerColumnRegistry { - private static final String EXTENSION_POINT= "disassemblyRulerColumns"; //$NON-NLS-1$ - private static final String QUALIFIED_EXTENSION_POINT= CDebugUIPlugin.PLUGIN_ID + '.' + EXTENSION_POINT; + private static final String EXTENSION_POINT = "disassemblyRulerColumns"; //$NON-NLS-1$ + private static final String QUALIFIED_EXTENSION_POINT = CDebugUIPlugin.PLUGIN_ID + '.' + EXTENSION_POINT; /** The singleton instance. */ - private static RulerColumnRegistry fgSingleton= null; + private static RulerColumnRegistry fgSingleton = null; /** * Returns the default computer registry. @@ -66,7 +65,7 @@ public final class RulerColumnRegistry { */ public static synchronized RulerColumnRegistry getDefault() { if (fgSingleton == null) { - fgSingleton= new RulerColumnRegistry(); + fgSingleton = new RulerColumnRegistry(); } return fgSingleton; @@ -76,16 +75,16 @@ public final class RulerColumnRegistry { * All descriptors (element type: * {@link RulerColumnDescriptor}). */ - private List<RulerColumnDescriptor> fDescriptors= null; + private List<RulerColumnDescriptor> fDescriptors = null; /** * All descriptors by id (element type: {@link RulerColumnDescriptor}). */ - private Map<String, RulerColumnDescriptor> fDescriptorMap= null; + private Map<String, RulerColumnDescriptor> fDescriptorMap = null; /** * <code>true</code> if this registry has been loaded. */ - private boolean fLoaded= false; + private boolean fLoaded = false; /** * Creates a new instance. @@ -131,8 +130,8 @@ public final class RulerColumnRegistry { private void ensureExtensionPointRead() { boolean reload; synchronized (this) { - reload= !fLoaded; - fLoaded= true; + reload = !fLoaded; + fLoaded = true; } if (reload) reload(); @@ -146,17 +145,18 @@ public final class RulerColumnRegistry { * </p> */ public void reload() { - IExtensionRegistry registry= Platform.getExtensionRegistry(); - List<IConfigurationElement> elements= new ArrayList<IConfigurationElement>(Arrays.asList(registry.getConfigurationElementsFor(CDebugUIPlugin.PLUGIN_ID, EXTENSION_POINT))); + IExtensionRegistry registry = Platform.getExtensionRegistry(); + List<IConfigurationElement> elements = new ArrayList<IConfigurationElement>( + Arrays.asList(registry.getConfigurationElementsFor(CDebugUIPlugin.PLUGIN_ID, EXTENSION_POINT))); - List<RulerColumnDescriptor> descriptors= new ArrayList<RulerColumnDescriptor>(); - Map<String, RulerColumnDescriptor> descriptorMap= new HashMap<String, RulerColumnDescriptor>(); + List<RulerColumnDescriptor> descriptors = new ArrayList<RulerColumnDescriptor>(); + Map<String, RulerColumnDescriptor> descriptorMap = new HashMap<String, RulerColumnDescriptor>(); - for (Iterator<IConfigurationElement> iter= elements.iterator(); iter.hasNext();) { - IConfigurationElement element= iter.next(); + for (Iterator<IConfigurationElement> iter = elements.iterator(); iter.hasNext();) { + IConfigurationElement element = iter.next(); try { - RulerColumnDescriptor desc= new RulerColumnDescriptor(element, this); - String id= desc.getId(); + RulerColumnDescriptor desc = new RulerColumnDescriptor(element, this); + String id = desc.getId(); if (descriptorMap.containsKey(id)) { noteDuplicateId(desc); continue; @@ -179,8 +179,8 @@ public final class RulerColumnRegistry { sort(descriptors); synchronized (this) { - fDescriptors= Collections.unmodifiableList(descriptors); - fDescriptorMap= Collections.unmodifiableMap(descriptorMap); + fDescriptors = Collections.unmodifiableList(descriptors); + fDescriptorMap = Collections.unmodifiableMap(descriptorMap); } } @@ -197,48 +197,48 @@ public final class RulerColumnRegistry { * 2. Insert into Directed Acyclic Graph * 3. TopoSort DAG: pick the source with the lowest gravity and remove from DAG */ - ConfigurationElementSorter sorter= new ConfigurationElementSorter() { + ConfigurationElementSorter sorter = new ConfigurationElementSorter() { @Override public IConfigurationElement getConfigurationElement(Object object) { return ((RulerColumnDescriptor) object).getConfigurationElement(); } }; - RulerColumnDescriptor[] array= new RulerColumnDescriptor[descriptors.size()]; + RulerColumnDescriptor[] array = new RulerColumnDescriptor[descriptors.size()]; descriptors.toArray(array); sorter.sort(array); - Map<String, RulerColumnDescriptor> descriptorsById= new HashMap<String, RulerColumnDescriptor>(); + Map<String, RulerColumnDescriptor> descriptorsById = new HashMap<String, RulerColumnDescriptor>(); for (RulerColumnDescriptor desc : array) { descriptorsById.put(desc.getId(), desc); } - DAG dag= new DAG(); + DAG dag = new DAG(); for (RulerColumnDescriptor desc : array) { dag.addVertex(desc); - Set<?> before= desc.getPlacement().getConstraints(); - for (Iterator<?> it= before.iterator(); it.hasNext();) { - RulerColumnPlacementConstraint constraint= (RulerColumnPlacementConstraint) it.next(); - String id= constraint.getId(); - RulerColumnDescriptor target= descriptorsById.get(id); + Set<?> before = desc.getPlacement().getConstraints(); + for (Iterator<?> it = before.iterator(); it.hasNext();) { + RulerColumnPlacementConstraint constraint = (RulerColumnPlacementConstraint) it.next(); + String id = constraint.getId(); + RulerColumnDescriptor target = descriptorsById.get(id); if (target == null) { noteUnknownTarget(desc, id); } else { boolean success; if (constraint.isBefore()) - success= dag.addEdge(desc, target); + success = dag.addEdge(desc, target); else - success= dag.addEdge(target, desc); + success = dag.addEdge(target, desc); if (!success) noteCycle(desc, target); } } } - Comparator<RulerColumnDescriptor> gravityComp= new Comparator<RulerColumnDescriptor>() { + Comparator<RulerColumnDescriptor> gravityComp = new Comparator<RulerColumnDescriptor>() { @Override public int compare(RulerColumnDescriptor o1, RulerColumnDescriptor o2) { - float diff= o1.getPlacement().getGravity() - o2.getPlacement().getGravity(); + float diff = o1.getPlacement().getGravity() - o2.getPlacement().getGravity(); if (diff == 0) return 0; if (diff < 0) @@ -248,46 +248,50 @@ public final class RulerColumnRegistry { }; /* Topological sort - always select the source with the least gravity */ - Set<RulerColumnDescriptor> toProcess= dag.getSources(); - int index= 0; + Set<RulerColumnDescriptor> toProcess = dag.getSources(); + int index = 0; while (!toProcess.isEmpty()) { - RulerColumnDescriptor next= Collections.min(toProcess, gravityComp); - array[index]= next; + RulerColumnDescriptor next = Collections.min(toProcess, gravityComp); + array[index] = next; index++; dag.removeVertex(next); - toProcess= dag.getSources(); + toProcess = dag.getSources(); } Assert.isTrue(index == array.length); - ListIterator<RulerColumnDescriptor> it= descriptors.listIterator(); - for (int i= 0; i < index; i++) { + ListIterator<RulerColumnDescriptor> it = descriptors.listIterator(); + for (int i = 0; i < index; i++) { it.next(); it.set(array[i]); } } private void noteInvalidExtension(IConfigurationElement element, InvalidRegistryObjectException x) { - String message= MessageFormat.format(RulerColumnMessages.RulerColumnRegistry_invalid_msg, new Object[] {ExtensionPointHelper.findId(element)}); + String message = MessageFormat.format(RulerColumnMessages.RulerColumnRegistry_invalid_msg, + new Object[] { ExtensionPointHelper.findId(element) }); warnUser(message, x); } private void noteUnknownTarget(RulerColumnDescriptor desc, String referencedId) { - String message= MessageFormat.format(RulerColumnMessages.RulerColumnRegistry_unresolved_placement_msg, new Object[] {QUALIFIED_EXTENSION_POINT, referencedId, desc.getName(), desc.getContributor()}); + String message = MessageFormat.format(RulerColumnMessages.RulerColumnRegistry_unresolved_placement_msg, + new Object[] { QUALIFIED_EXTENSION_POINT, referencedId, desc.getName(), desc.getContributor() }); warnUser(message, null); } private void noteCycle(RulerColumnDescriptor desc, RulerColumnDescriptor target) { - String message= MessageFormat.format(RulerColumnMessages.RulerColumnRegistry_cyclic_placement_msg, new Object[] {QUALIFIED_EXTENSION_POINT, target.getName(), desc.getName(), desc.getContributor()}); + String message = MessageFormat.format(RulerColumnMessages.RulerColumnRegistry_cyclic_placement_msg, + new Object[] { QUALIFIED_EXTENSION_POINT, target.getName(), desc.getName(), desc.getContributor() }); warnUser(message, null); } private void noteDuplicateId(RulerColumnDescriptor desc) { - String message= MessageFormat.format(RulerColumnMessages.RulerColumnRegistry_duplicate_id_msg, new Object[] {QUALIFIED_EXTENSION_POINT, desc.getId(), desc.getContributor()}); + String message = MessageFormat.format(RulerColumnMessages.RulerColumnRegistry_duplicate_id_msg, + new Object[] { QUALIFIED_EXTENSION_POINT, desc.getId(), desc.getContributor() }); warnUser(message, null); } private void warnUser(String message, Exception exception) { - IStatus status= new Status(IStatus.WARNING, TextEditorPlugin.PLUGIN_ID, IStatus.OK, message, exception); + IStatus status = new Status(IStatus.WARNING, TextEditorPlugin.PLUGIN_ID, IStatus.OK, message, exception); warnUser(status); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/editors/AbstractDebugTextHover.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/editors/AbstractDebugTextHover.java index 408d3c9a4ec..ac56028de79 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/editors/AbstractDebugTextHover.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/editors/AbstractDebugTextHover.java @@ -76,24 +76,27 @@ import org.eclipse.ui.IEditorPart; /** * The text hovering support for C/C++ debugger. - * + * * @since 7.0 */ public abstract class AbstractDebugTextHover implements ICEditorTextHover, ITextHoverExtension { - /** + /** * ASTVisitor checking for side-effect expressions. */ private static class ExpressionChecker extends ASTVisitor { private boolean fValid; + private ExpressionChecker() { shouldVisitExpressions = true; } + private boolean check(IASTNode node) { fValid = true; node.accept(this); return fValid; } + @Override public int visit(IASTExpression expression) { if (expression instanceof IASTFunctionCallExpression) { @@ -146,15 +149,15 @@ public abstract class AbstractDebugTextHover implements ICEditorTextHover, IText * @return <code>true</code> if this hover can evaluate an expression */ protected abstract boolean canEvaluate(); - + /** * Compute a value for given expression. - * + * * @param expression * @return a result string or <code>null</code> if the expression could not be evaluated */ protected abstract String evaluateExpression(String expression); - + @Override public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { if (canEvaluate()) { @@ -176,7 +179,7 @@ public abstract class AbstractDebugTextHover implements ICEditorTextHover, IText } return null; } - + @Override public IRegion getHoverRegion(ITextViewer viewer, int offset) { if (viewer != null) @@ -202,7 +205,7 @@ public abstract class AbstractDebugTextHover implements ICEditorTextHover, IText * The default implementation uses an AST to compute a valid, side-effect free * expression. * </p> - * + * * @param textViewer the underlying text viewer * @param hoverRegion the hover region as returned by {@link #getHoverRegion(ITextViewer, int)} * @return an expression string or <code>null</code> if no valid expression could be computed @@ -228,7 +231,7 @@ public abstract class AbstractDebugTextHover implements ICEditorTextHover, IText /** * Compute a valid expression from AST if available. - * + * * @param document * @param hoverRegion * @return a valid expression string, an empty string to indicate an invalid @@ -241,7 +244,8 @@ public abstract class AbstractDebugTextHover implements ICEditorTextHover, IText return null; } final Position expressionPosition = new Position(0); - SharedASTJob job = new SharedASTJob(CDebugUIMessages.getString("AbstractDebugTextHover.jobName"), (ITranslationUnit) cElement) { //$NON-NLS-1$ + SharedASTJob job = new SharedASTJob(CDebugUIMessages.getString("AbstractDebugTextHover.jobName"), //$NON-NLS-1$ + (ITranslationUnit) cElement) { @Override public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException { if (ast == null) { @@ -249,31 +253,32 @@ public abstract class AbstractDebugTextHover implements ICEditorTextHover, IText } int offset = hoverRegion.getOffset(); int length = hoverRegion.getLength(); - IASTName name= ast.getNodeSelector(null).findEnclosingName(offset, length); + IASTName name = ast.getNodeSelector(null).findEnclosingName(offset, length); if (name != null) { - IASTImageLocation imageLoc = name.getImageLocation(); - if (imageLoc == null) { - return Status.CANCEL_STATUS; - } - int kind = imageLoc.getLocationKind(); - switch (kind) { - case IASTImageLocation.ARGUMENT_TO_MACRO_EXPANSION: - computeMacroArgumentExtent(name, expressionPosition); - break; - default: - if (name.getParent() instanceof IASTPreprocessorMacroExpansion) { - // special case: macro expansion as expression - IASTNode node = ast.getNodeSelector(null).findEnclosingNodeInExpansion(imageLoc.getNodeOffset(), imageLoc.getNodeLength()); - if (node instanceof IASTExpression) { - IASTFileLocation exprLoc = node.getFileLocation(); - if (exprLoc.getNodeOffset() == imageLoc.getNodeOffset()) { - computeExpressionExtent(node, expressionPosition); - } - } - } else { - computeExpressionExtent(name, expressionPosition); - } - } + IASTImageLocation imageLoc = name.getImageLocation(); + if (imageLoc == null) { + return Status.CANCEL_STATUS; + } + int kind = imageLoc.getLocationKind(); + switch (kind) { + case IASTImageLocation.ARGUMENT_TO_MACRO_EXPANSION: + computeMacroArgumentExtent(name, expressionPosition); + break; + default: + if (name.getParent() instanceof IASTPreprocessorMacroExpansion) { + // special case: macro expansion as expression + IASTNode node = ast.getNodeSelector(null) + .findEnclosingNodeInExpansion(imageLoc.getNodeOffset(), imageLoc.getNodeLength()); + if (node instanceof IASTExpression) { + IASTFileLocation exprLoc = node.getFileLocation(); + if (exprLoc.getNodeOffset() == imageLoc.getNodeOffset()) { + computeExpressionExtent(node, expressionPosition); + } + } + } else { + computeExpressionExtent(name, expressionPosition); + } + } } else { // not a name, but might still be an expression (e.g. this or a selected expression) IASTNode node = ast.getNodeSelector(null).findEnclosingNode(offset, length); @@ -288,45 +293,47 @@ public abstract class AbstractDebugTextHover implements ICEditorTextHover, IText } return Status.OK_STATUS; } - - private void computeMacroArgumentExtent(IASTName name, Position pos) { - IASTImageLocation imageLoc = name.getImageLocation(); - int startOffset = imageLoc.getNodeOffset(); - int endOffset = startOffset + imageLoc.getNodeLength(); - // do some black magic to consider field reference expressions - IASTNode expr = name.getParent(); - int macroOffset = name.getFileLocation().getNodeOffset(); - if (expr instanceof IASTFieldReference) { - IASTExpression ownerExpr= ((IASTFieldReference) expr).getFieldOwner(); - while (ownerExpr instanceof IASTFieldReference || ownerExpr instanceof IASTArraySubscriptExpression) { - if (ownerExpr instanceof IASTArraySubscriptExpression) { - ownerExpr = ((IASTArraySubscriptExpression) ownerExpr).getArrayExpression(); - } else { - ownerExpr= ((IASTFieldReference) ownerExpr).getFieldOwner(); - } - } - if (ownerExpr instanceof IASTIdExpression) { - IASTName ownerName = ((IASTIdExpression) ownerExpr).getName(); - IASTImageLocation ownerImageLoc = ownerName.getImageLocation(); - final int nameOffset= ownerImageLoc.getNodeOffset(); - // offset should be inside macro expansion - if (nameOffset < startOffset && nameOffset > macroOffset) { - startOffset = nameOffset; - } - } - } - ExpressionChecker checker = new ExpressionChecker(); - if (checker.check(expr)) { - pos.offset = startOffset; - pos.length = endOffset - startOffset; - } - } + + private void computeMacroArgumentExtent(IASTName name, Position pos) { + IASTImageLocation imageLoc = name.getImageLocation(); + int startOffset = imageLoc.getNodeOffset(); + int endOffset = startOffset + imageLoc.getNodeLength(); + // do some black magic to consider field reference expressions + IASTNode expr = name.getParent(); + int macroOffset = name.getFileLocation().getNodeOffset(); + if (expr instanceof IASTFieldReference) { + IASTExpression ownerExpr = ((IASTFieldReference) expr).getFieldOwner(); + while (ownerExpr instanceof IASTFieldReference + || ownerExpr instanceof IASTArraySubscriptExpression) { + if (ownerExpr instanceof IASTArraySubscriptExpression) { + ownerExpr = ((IASTArraySubscriptExpression) ownerExpr).getArrayExpression(); + } else { + ownerExpr = ((IASTFieldReference) ownerExpr).getFieldOwner(); + } + } + if (ownerExpr instanceof IASTIdExpression) { + IASTName ownerName = ((IASTIdExpression) ownerExpr).getName(); + IASTImageLocation ownerImageLoc = ownerName.getImageLocation(); + final int nameOffset = ownerImageLoc.getNodeOffset(); + // offset should be inside macro expansion + if (nameOffset < startOffset && nameOffset > macroOffset) { + startOffset = nameOffset; + } + } + } + ExpressionChecker checker = new ExpressionChecker(); + if (checker.check(expr)) { + pos.offset = startOffset; + pos.length = endOffset - startOffset; + } + } + private void computeExpressionExtent(IASTNode node0, Position pos) { IASTNode node = node0; while (node != null && !(node instanceof IASTExpression) && !(node instanceof IASTDeclaration)) { node = node.getParent(); } - IASTNodeLocation loc = null; + IASTNodeLocation loc = null; if (node instanceof IASTExpression && !(node instanceof IASTIdExpression)) { ExpressionChecker checker = new ExpressionChecker(); if (checker.check(node)) { @@ -336,17 +343,17 @@ public abstract class AbstractDebugTextHover implements ICEditorTextHover, IText // fallback: use simple name loc = ((IASTName) node0).getImageLocation(); if (loc == null) { - IASTNodeLocation[] locations = node0.getNodeLocations(); - // avoid macro expansions - if (locations.length == 1 && !(locations[0] instanceof IASTMacroExpansionLocation)) { - loc = locations[0]; - } + IASTNodeLocation[] locations = node0.getNodeLocations(); + // avoid macro expansions + if (locations.length == 1 && !(locations[0] instanceof IASTMacroExpansionLocation)) { + loc = locations[0]; + } } } - if (loc != null) { - pos.offset = loc.getNodeOffset(); - pos.length = loc.getNodeLength(); - } + if (loc != null) { + pos.offset = loc.getNodeOffset(); + pos.length = loc.getNodeLength(); + } } private boolean insideInactiveCode(IASTTranslationUnit ast, int offset) { @@ -372,7 +379,7 @@ public abstract class AbstractDebugTextHover implements ICEditorTextHover, IText return false; } if (statement instanceof IASTPreprocessorIfStatement) { - IASTPreprocessorIfStatement ifStmt = (IASTPreprocessorIfStatement)statement; + IASTPreprocessorIfStatement ifStmt = (IASTPreprocessorIfStatement) statement; inactiveCodeStack.push(Boolean.valueOf(inInactiveCode)); if (!ifStmt.taken()) { if (!inInactiveCode) { @@ -381,7 +388,7 @@ public abstract class AbstractDebugTextHover implements ICEditorTextHover, IText } } } else if (statement instanceof IASTPreprocessorIfdefStatement) { - IASTPreprocessorIfdefStatement ifdefStmt = (IASTPreprocessorIfdefStatement)statement; + IASTPreprocessorIfdefStatement ifdefStmt = (IASTPreprocessorIfdefStatement) statement; inactiveCodeStack.push(Boolean.valueOf(inInactiveCode)); if (!ifdefStmt.taken()) { if (!inInactiveCode) { @@ -390,7 +397,7 @@ public abstract class AbstractDebugTextHover implements ICEditorTextHover, IText } } } else if (statement instanceof IASTPreprocessorIfndefStatement) { - IASTPreprocessorIfndefStatement ifndefStmt = (IASTPreprocessorIfndefStatement)statement; + IASTPreprocessorIfndefStatement ifndefStmt = (IASTPreprocessorIfndefStatement) statement; inactiveCodeStack.push(Boolean.valueOf(inInactiveCode)); if (!ifndefStmt.taken()) { if (!inInactiveCode) { @@ -399,7 +406,7 @@ public abstract class AbstractDebugTextHover implements ICEditorTextHover, IText } } } else if (statement instanceof IASTPreprocessorElseStatement) { - IASTPreprocessorElseStatement elseStmt = (IASTPreprocessorElseStatement)statement; + IASTPreprocessorElseStatement elseStmt = (IASTPreprocessorElseStatement) statement; if (!elseStmt.taken() && !inInactiveCode) { inactiveCodeStart = nodeEnd; inInactiveCode = true; @@ -411,7 +418,7 @@ public abstract class AbstractDebugTextHover implements ICEditorTextHover, IText inInactiveCode = false; } } else if (statement instanceof IASTPreprocessorElifStatement) { - IASTPreprocessorElifStatement elifStmt = (IASTPreprocessorElifStatement)statement; + IASTPreprocessorElifStatement elifStmt = (IASTPreprocessorElifStatement) statement; if (!elifStmt.taken() && !inInactiveCode) { inactiveCodeStart = nodeEnd; inInactiveCode = true; @@ -432,12 +439,13 @@ public abstract class AbstractDebugTextHover implements ICEditorTextHover, IText } } inInactiveCode = wasInInactiveCode; + } catch (EmptyStackException e) { } - catch (EmptyStackException e) {} } } return false; } + private boolean insideComment(IASTTranslationUnit ast, int offset) { IASTComment[] comments = ast.getComments(); for (IASTComment comment : comments) { @@ -446,7 +454,8 @@ public abstract class AbstractDebugTextHover implements ICEditorTextHover, IText } IASTNodeLocation location = comment.getFileLocation(); if (location != null) { - if (location.getNodeOffset() <= offset && offset < location.getNodeOffset() + location.getNodeLength()) { + if (location.getNodeOffset() <= offset + && offset < location.getNodeOffset() + location.getNodeLength()) { return true; } } @@ -471,10 +480,10 @@ public abstract class AbstractDebugTextHover implements ICEditorTextHover, IText try { // Get expression text removing comments, obsolete whitespace, etc. StringBuilder result = new StringBuilder(); - ITypedRegion[] partitions = TextUtilities.computePartitioning(document, ICPartitions.C_PARTITIONING, + ITypedRegion[] partitions = TextUtilities.computePartitioning(document, ICPartitions.C_PARTITIONING, expressionPosition.offset, expressionPosition.length, false); for (ITypedRegion partition : partitions) { - if (IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType()) + if (IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType()) || ICPartitions.C_CHARACTER.equals(partition.getType()) || ICPartitions.C_STRING.equals(partition.getType())) { result.append(document.get(partition.getOffset(), partition.getLength())); @@ -490,7 +499,7 @@ public abstract class AbstractDebugTextHover implements ICEditorTextHover, IText // return empty string to indicate invalid expression return ""; //$NON-NLS-1$ } - + /** * Returns the debug context the expression should be evaluated against. * The default implementation returns {@link DebugUITools#getDebugContext()}. @@ -505,7 +514,7 @@ public abstract class AbstractDebugTextHover implements ICEditorTextHover, IText protected final IEditorPart getEditor() { return fEditor; } - + /** * Append HTML for the given variable to the given buffer */ diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/importexecutable/AbstractImportExecutableWizard.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/importexecutable/AbstractImportExecutableWizard.java index 5ab1423ba1e..7aa49bf3cb9 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/importexecutable/AbstractImportExecutableWizard.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/importexecutable/AbstractImportExecutableWizard.java @@ -69,13 +69,13 @@ public abstract class AbstractImportExecutableWizard extends Wizard implements I } CCorePlugin.getDefault().setProjectDescription(newProject, pd, true, new NullProgressMonitor()); } - + /** * Adds the executables to a new or existing project. The executables are * added as external links. * If an executable of the same name already exists then the existing linked * resource's location is replaced by the local location's value. - * + * * @param project - * project receiving the executables * @throws CoreException @@ -120,7 +120,7 @@ public abstract class AbstractImportExecutableWizard extends Wizard implements I } public void createLaunchConfiguration(ICProject targetProject) throws CoreException { - + ILaunchConfigurationWorkingCopy wc = this.getSelectedLaunchConfigurationType().newInstance(null, this.getImportExecutablePage2().getNewConfigurationName()); @@ -133,9 +133,11 @@ public abstract class AbstractImportExecutableWizard extends Wizard implements I @Override public IStatus runInUIThread(IProgressMonitor monitor) { - DebugUITools.openLaunchConfigurationDialogOnGroup(CUIPlugin.getActiveWorkbenchShell(), selection, identifier); + DebugUITools.openLaunchConfigurationDialogOnGroup(CUIPlugin.getActiveWorkbenchShell(), selection, + identifier); return Status.OK_STATUS; - }}; + } + }; openLaunchConfigJob.schedule(); } @@ -175,18 +177,16 @@ public abstract class AbstractImportExecutableWizard extends Wizard implements I setWindowTitle(getDefaultWindowTitle()); setNeedsProgressMonitor(true); } - + @Override public boolean performFinish() { ICProject targetProject = null; try { if (pageTwo.isCreateNewProjectSelected()) { - IProject newProject = createCProjectForExecutable(pageTwo - .getNewProjectName()); + IProject newProject = createCProjectForExecutable(pageTwo.getNewProjectName()); setupProject(newProject); - targetProject = CCorePlugin.getDefault().getCoreModel().create( - newProject); + targetProject = CCorePlugin.getDefault().getCoreModel().create(newProject); } else { targetProject = pageTwo.getExistingCProject(); } @@ -200,20 +200,20 @@ public abstract class AbstractImportExecutableWizard extends Wizard implements I } return true; } - + /** * Subclasses should override this method to modify the launch configuration * created by the wizard. The default implementation sets up the project * and program names. * @param config the launch configuration created by the wizard - * @param targetProject + * @param targetProject */ public void setConfigurationDefaults(ILaunchConfigurationWorkingCopy config, ICProject project) { - config.setMappedResources(new IResource[] {project.getProject()}); + config.setMappedResources(new IResource[] { project.getProject() }); config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, project.getProject().getName()); - config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, new File(getImportExecutablePage() - .getSelectedExecutables()[0]).getName()); + config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, + new File(getImportExecutablePage().getSelectedExecutables()[0]).getName()); } @@ -225,18 +225,17 @@ public abstract class AbstractImportExecutableWizard extends Wizard implements I /** * The wizard will only display launch configuration types that you support. * This method will be called for each available type. - * + * * @param type - * the type of launch configuration * @return - if the wizard supports this launch configuration type */ - public abstract boolean supportsConfigurationType( - ILaunchConfigurationType type); + public abstract boolean supportsConfigurationType(ILaunchConfigurationType type); /** * Return true if you want the wizard to ask the user to select * the binary parser. Otherwise it will only use the default one. - * A subclass can specify the default parser by overriding + * A subclass can specify the default parser by overriding * getDefaultBinaryParserID. * @return - If the binary parser selection combo should be displayed. */ @@ -250,7 +249,8 @@ public abstract class AbstractImportExecutableWizard extends Wizard implements I * @return */ public String[] getDefaultBinaryParserIDs() { - String defaultBinaryParserId = CCorePlugin.getDefault().getPluginPreferences().getDefaultString(CCorePlugin.PREF_BINARY_PARSER); + String defaultBinaryParserId = CCorePlugin.getDefault().getPluginPreferences() + .getDefaultString(CCorePlugin.PREF_BINARY_PARSER); if (defaultBinaryParserId == null || defaultBinaryParserId.length() == 0) { defaultBinaryParserId = CCorePlugin.DEFAULT_BINARY_PARSER_UNIQ_ID; } @@ -259,8 +259,7 @@ public abstract class AbstractImportExecutableWizard extends Wizard implements I public String getDefaultProjectName() { String defaultName = ""; //$NON-NLS-1$ - String[] executables = getImportExecutablePage() - .getSelectedExecutables(); + String[] executables = getImportExecutablePage().getSelectedExecutables(); if (executables.length > 0) { String fileName = new File(executables[0]).getName(); defaultName = Messages.ImportExecutablePageTwo_DefaultProjectPrefix + fileName; diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/importexecutable/ImportExecutablePageOne.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/importexecutable/ImportExecutablePageOne.java index 19f6907bf6e..5090574e160 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/importexecutable/ImportExecutablePageOne.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/importexecutable/ImportExecutablePageOne.java @@ -101,19 +101,19 @@ public class ImportExecutablePageOne extends WizardPage { private IExtension[] binaryParserExtensions; private Combo binaryParserCombo; - + public ImportExecutablePageOne(AbstractImportExecutableWizard wizard) { super("ImportApplicationPageOne"); //$NON-NLS-1$ this.wizard = wizard; setPageComplete(false); setTitle(wizard.getPageOneTitle()); setDescription(wizard.getPageOneDescription()); - + supportedBinaryParserIds = wizard.getDefaultBinaryParserIDs(); - - IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, CCorePlugin.BINARY_PARSER_SIMPLE_ID); - if (point != null) - { + + IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, + CCorePlugin.BINARY_PARSER_SIMPLE_ID); + if (point != null) { IExtension[] exts = point.getExtensions(); ArrayList<IExtension> extensionsInUse = new ArrayList<>(); for (int i = 0; i < exts.length; i++) { @@ -123,12 +123,12 @@ public class ImportExecutablePageOne extends WizardPage { } binaryParserExtensions = extensionsInUse.toArray(new IExtension[extensionsInUse.size()]); } - + supportedBinaryParsers = new IBinaryParser[supportedBinaryParserIds.length]; for (int i = 0; i < supportedBinaryParserIds.length; i++) { for (int j = 0; j < binaryParserExtensions.length; j++) { if (binaryParserExtensions[j].getUniqueIdentifier().equals(supportedBinaryParserIds[i])) - supportedBinaryParsers[i] = instantiateBinaryParser(binaryParserExtensions[j]); + supportedBinaryParsers[i] = instantiateBinaryParser(binaryParserExtensions[j]); } } @@ -137,7 +137,7 @@ public class ImportExecutablePageOne extends WizardPage { public String[] getSupportedBinaryParserIds() { return supportedBinaryParserIds; } - + private void checkControlState() { selectSingleFile = selectSingleButton.getSelection(); singleExecutablePathField.setEnabled(selectSingleFile); @@ -150,8 +150,7 @@ public class ImportExecutablePageOne extends WizardPage { selectMultipleTitle.setEnabled(!selectSingleFile); } - private boolean collectExecutableFiles(Collection<File> files, File directory, - IProgressMonitor monitor) { + private boolean collectExecutableFiles(Collection<File> files, File directory, IProgressMonitor monitor) { if (monitor.isCanceled()) return false; @@ -176,16 +175,15 @@ public class ImportExecutablePageOne extends WizardPage { @Override public void createControl(Composite parent) { - + initializeDialogUnits(parent); Composite workArea = new Composite(parent, SWT.NONE); setControl(workArea); workArea.setLayout(new GridLayout()); - workArea.setLayoutData(new GridData(GridData.FILL_BOTH - | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL)); - + workArea.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL)); + //bug 189003: to fix the tab order on the page if (wizard.userSelectsBinaryParser()) { Composite binaryParserGroup = new Composite(workArea, SWT.NONE); @@ -196,15 +194,14 @@ public class ImportExecutablePageOne extends WizardPage { binaryParserGroup.setLayout(layout); createSelectBinaryParser(binaryParserGroup); } - + Composite selectExecutableGroup = new Composite(workArea, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 3; layout.makeColumnsEqualWidth = false; layout.marginWidth = 0; selectExecutableGroup.setLayout(layout); - selectExecutableGroup.setLayoutData(new GridData( - GridData.FILL_HORIZONTAL)); + selectExecutableGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); createSelectExecutable(selectExecutableGroup); createExecutablesRoot(selectExecutableGroup); @@ -212,7 +209,8 @@ public class ImportExecutablePageOne extends WizardPage { Dialog.applyDialogFont(workArea); selectSingleButton.setSelection(true); checkControlState(); - CDebugUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp( getControl(), ICDebugHelpContextIds.IMPORT_EXECUTABLE_PAGE_ONE ); + CDebugUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(getControl(), + ICDebugHelpContextIds.IMPORT_EXECUTABLE_PAGE_ONE); } private void createExecutablesList(Composite workArea) { @@ -227,12 +225,11 @@ public class ImportExecutablePageOne extends WizardPage { layout.makeColumnsEqualWidth = false; listComposite.setLayout(layout); - listComposite.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL - | GridData.GRAB_VERTICAL | GridData.FILL_BOTH)); + listComposite + .setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH)); executablesViewer = new CheckboxTreeViewer(listComposite, SWT.BORDER); - GridData listData = new GridData(GridData.GRAB_HORIZONTAL - | GridData.GRAB_VERTICAL | GridData.FILL_BOTH); + GridData listData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH); executablesViewer.getControl().setLayoutData(listData); executablesViewer.setContentProvider(new ITreeContentProvider() { @@ -263,8 +260,7 @@ public class ImportExecutablePageOne extends WizardPage { } @Override - public void inputChanged(Viewer viewer, Object oldInput, - Object newInput) { + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } }); @@ -285,14 +281,12 @@ public class ImportExecutablePageOne extends WizardPage { }); executablesViewer.setInput(this); - executablesViewer.getTree().getAccessible().addAccessibleListener( - new AccessibleAdapter() { - @Override - public void getName(AccessibleEvent e) { - e.result = wizard.getExecutableListLabel(); - } - } - ); + executablesViewer.getTree().getAccessible().addAccessibleListener(new AccessibleAdapter() { + @Override + public void getName(AccessibleEvent e) { + e.result = wizard.getExecutableListLabel(); + } + }); createSelectionButtons(listComposite); } @@ -306,8 +300,7 @@ public class ImportExecutablePageOne extends WizardPage { @Override public void widgetSelected(SelectionEvent e) { checkControlState(); - String selectedDirectory = multipleExecutablePathField - .getText().trim(); + String selectedDirectory = multipleExecutablePathField.getText().trim(); setErrorMessage(null); if (selectedDirectory.length() == 0) { @@ -320,16 +313,14 @@ public class ImportExecutablePageOne extends WizardPage { // project location entry field this.multipleExecutablePathField = new Text(workArea, SWT.BORDER); - multipleExecutablePathField.getAccessible().addAccessibleListener( - new AccessibleAdapter() { - @Override - public void getName(AccessibleEvent e) { - e.result = Messages.ImportExecutablePageOne_SearchDirectory; - } - } - ); - this.multipleExecutablePathField.setLayoutData(new GridData( - GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); + multipleExecutablePathField.getAccessible().addAccessibleListener(new AccessibleAdapter() { + @Override + public void getName(AccessibleEvent e) { + e.result = Messages.ImportExecutablePageOne_SearchDirectory; + } + }); + this.multipleExecutablePathField + .setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); selectMultipleBrowseButton = new Button(workArea, SWT.PUSH); selectMultipleBrowseButton.setText(Messages.ImportExecutablePageOne_Browse); setButtonLayoutData(selectMultipleBrowseButton); @@ -345,8 +336,7 @@ public class ImportExecutablePageOne extends WizardPage { multipleExecutablePathField.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { - updateExecutablesList(multipleExecutablePathField.getText() - .trim()); + updateExecutablesList(multipleExecutablePathField.getText().trim()); } }); @@ -356,23 +346,23 @@ public class ImportExecutablePageOne extends WizardPage { if (binaryParserExtensions.length == 0) return; - + Label label = new Label(workArea, SWT.NONE); label.setText(Messages.ImportExecutablePageOne_SelectBinaryParser); - + binaryParserCombo = new Combo(workArea, SWT.READ_ONLY); final IExtension[] exts = binaryParserExtensions; for (int i = 0; i < exts.length; i++) { - binaryParserCombo.add(exts[i].getLabel()); - if (supportedBinaryParserIds[0].equals(exts[i].getUniqueIdentifier())) - binaryParserCombo.select(i); - } - - + binaryParserCombo.add(exts[i].getLabel()); + if (supportedBinaryParserIds[0].equals(exts[i].getUniqueIdentifier())) + binaryParserCombo.select(i); + } + binaryParserCombo.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { } + @Override public void widgetSelected(SelectionEvent e) { supportedBinaryParsers[0] = instantiateBinaryParser(exts[binaryParserCombo.getSelectionIndex()]); @@ -387,13 +377,13 @@ public class ImportExecutablePageOne extends WizardPage { } } }); - + // Dummy to fill out the third column new Label(workArea, SWT.NONE); } - + private static boolean isExtensionVisible(IExtension ext) { - IConfigurationElement[] elements = ext.getConfigurationElements(); + IConfigurationElement[] elements = ext.getConfigurationElements(); for (int i = 0; i < elements.length; i++) { IConfigurationElement[] children = elements[i].getChildren("filter"); //$NON-NLS-1$ for (int j = 0; j < children.length; j++) { @@ -412,12 +402,12 @@ public class ImportExecutablePageOne extends WizardPage { private IBinaryParser instantiateBinaryParser(IExtension ext) { IBinaryParser parser = null; - IConfigurationElement[] elements = ext.getConfigurationElements(); + IConfigurationElement[] elements = ext.getConfigurationElements(); for (int i = 0; i < elements.length; i++) { IConfigurationElement[] children = elements[i].getChildren("run"); //$NON-NLS-1$ for (int j = 0; j < children.length; j++) { try { - parser = (IBinaryParser)children[j].createExecutableExtension("class"); //$NON-NLS-1$ + parser = (IBinaryParser) children[j].createExecutableExtension("class"); //$NON-NLS-1$ } catch (CoreException e) { CDebugUIPlugin.log(e); } @@ -425,7 +415,7 @@ public class ImportExecutablePageOne extends WizardPage { } return parser; } - + private void createSelectExecutable(Composite workArea) { // project specification group @@ -446,14 +436,12 @@ public class ImportExecutablePageOne extends WizardPage { // project location entry field this.singleExecutablePathField = new Text(workArea, SWT.BORDER); - singleExecutablePathField.getAccessible().addAccessibleListener( - new AccessibleAdapter() { - @Override - public void getName(AccessibleEvent e) { - e.result = Messages.ImportExecutablePageOne_SelectExecutable; - } - } - ); + singleExecutablePathField.getAccessible().addAccessibleListener(new AccessibleAdapter() { + @Override + public void getName(AccessibleEvent e) { + e.result = Messages.ImportExecutablePageOne_SelectExecutable; + } + }); // Set the data name field so Abbot based tests can find it. singleExecutablePathField.setData("name", "singleExecutablePathField"); //$NON-NLS-1$ //$NON-NLS-2$ singleExecutablePathField.addModifyListener(new ModifyListener() { @@ -465,8 +453,7 @@ public class ImportExecutablePageOne extends WizardPage { }); - this.singleExecutablePathField.setLayoutData(new GridData( - GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); + this.singleExecutablePathField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); selectSingleBrowseButton = new Button(workArea, SWT.PUSH); selectSingleBrowseButton.setText(Messages.ImportExecutablePageOne_Browse); setButtonLayoutData(selectSingleBrowseButton); @@ -480,7 +467,7 @@ public class ImportExecutablePageOne extends WizardPage { if (res != null) { if (Platform.getOS().equals(Platform.OS_MACOSX) && res.endsWith(".app")) //$NON-NLS-1$ { - // On Mac OS X the file dialog will let you select the + // On Mac OS X the file dialog will let you select the // package but not the executable inside. Path macPath = new Path(res); res = res + "/Contents/MacOS/" + macPath.lastSegment(); //$NON-NLS-1$ @@ -500,8 +487,7 @@ public class ImportExecutablePageOne extends WizardPage { layout.marginHeight = 0; buttonsComposite.setLayout(layout); - buttonsComposite.setLayoutData(new GridData( - GridData.VERTICAL_ALIGN_BEGINNING)); + buttonsComposite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); selectAll = new Button(buttonsComposite, SWT.PUSH); selectAll.setText(Messages.ImportExecutablePageOne_SelectAll); @@ -542,8 +528,7 @@ public class ImportExecutablePageOne extends WizardPage { Object[] checkedFiles = executablesViewer.getCheckedElements(); selectedExecutablePaths = new String[checkedFiles.length]; for (int i = 0; i < checkedFiles.length; i++) { - selectedExecutablePaths[i] = ((File) checkedFiles[i]) - .getAbsolutePath(); + selectedExecutablePaths[i] = ((File) checkedFiles[i]).getAbsolutePath(); } } return selectedExecutablePaths; @@ -551,10 +536,8 @@ public class ImportExecutablePageOne extends WizardPage { protected void handleLocationBrowseButtonPressed() { - DirectoryDialog dialog = new DirectoryDialog( - multipleExecutablePathField.getShell()); - dialog - .setMessage(Messages.ImportExecutablePageOne_SelectADirectory); + DirectoryDialog dialog = new DirectoryDialog(multipleExecutablePathField.getShell()); + dialog.setMessage(Messages.ImportExecutablePageOne_SelectADirectory); String dirName = multipleExecutablePathField.getText().trim(); if (dirName.length() == 0) @@ -589,8 +572,7 @@ public class ImportExecutablePageOne extends WizardPage { return; // don't repeat the same search - the user might just be tabbing to // traverse - if (previouslySearchedDirectory != null - && previouslySearchedDirectory.equals(path)) + if (previouslySearchedDirectory != null && previouslySearchedDirectory.equals(path)) return; previouslySearchedDirectory = path; try { @@ -625,11 +607,9 @@ public class ImportExecutablePageOne extends WizardPage { private boolean isBinary(File file, IBinaryParser parser) { if (parser != null) { try { - IBinaryParser.IBinaryFile bin = parser.getBinary(new Path(file - .getAbsolutePath())); - return bin != null - && (bin.getType() == IBinaryParser.IBinaryFile.EXECUTABLE || bin - .getType() == IBinaryParser.IBinaryFile.SHARED); + IBinaryParser.IBinaryFile bin = parser.getBinary(new Path(file.getAbsolutePath())); + return bin != null && (bin.getType() == IBinaryParser.IBinaryFile.EXECUTABLE + || bin.getType() == IBinaryParser.IBinaryFile.SHARED); } catch (IOException e) { return false; } @@ -649,44 +629,40 @@ public class ImportExecutablePageOne extends WizardPage { * @return - is it recognized by any of the binary parsers? */ private boolean isBinary(File file, boolean checkOthers) { - + for (int i = 0; i < supportedBinaryParsers.length; i++) { if (isBinary(file, supportedBinaryParsers[i])) - return true; + return true; } // See if any of the other parsers will work with this file. // If so, pick the first one that will. Only do this if the user // is picking the binary parser. - if (checkOthers && binaryParserCombo != null) - { + if (checkOthers && binaryParserCombo != null) { for (int i = 0; i < binaryParserExtensions.length; i++) { IBinaryParser parser = instantiateBinaryParser(binaryParserExtensions[i]); - if (isBinary(file, parser)) - { + if (isBinary(file, parser)) { supportedBinaryParserIds[0] = binaryParserExtensions[i].getUniqueIdentifier(); supportedBinaryParsers[0] = parser; binaryParserCombo.select(i); return true; } - } + } } return false; } - + private void validateExe(String path) { setErrorMessage(null); setPageComplete(false); if (path.length() > 0) { File testFile = new File(path); if (testFile.exists()) { - if (isBinary(testFile, true)) - { + if (isBinary(testFile, true)) { executables = new File[1]; executables[0] = testFile; setPageComplete(true); - } - else + } else setErrorMessage(Messages.ImportExecutablePageOne_NoteAnEXE); } else { setErrorMessage(Messages.ImportExecutablePageOne_NoSuchFile); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/importexecutable/ImportExecutablePageTwo.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/importexecutable/ImportExecutablePageTwo.java index f9877e38dce..a1d6ad5b514 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/importexecutable/ImportExecutablePageTwo.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/importexecutable/ImportExecutablePageTwo.java @@ -94,17 +94,16 @@ public class ImportExecutablePageTwo extends WizardPage { } private void addLaunchConfigTypes() { - ILaunchConfigurationType[] configTypeList = DebugPlugin.getDefault() - .getLaunchManager().getLaunchConfigurationTypes(); + ILaunchConfigurationType[] configTypeList = DebugPlugin.getDefault().getLaunchManager() + .getLaunchConfigurationTypes(); int j = 0, capp = 0; for (int i = 0; i < configTypeList.length; i++) { ILaunchConfigurationType type = configTypeList[i]; String configTypeName = type.getName(); - if (type.isPublic() - && type.supportsMode(ILaunchManager.DEBUG_MODE)) { + if (type.isPublic() && type.supportsMode(ILaunchManager.DEBUG_MODE)) { if (wizard.supportsConfigurationType(type)) { configTypes.add(configTypeName); - + if (type.getIdentifier().equals(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_APP)) { capp = j; } @@ -120,8 +119,7 @@ public class ImportExecutablePageTwo extends WizardPage { if (isCreateNewProjectSelected) { String defaultName = wizard.getDefaultProjectName(); if (defaultName.length() > 0) { - ICProject cProject = CoreModel.getDefault().getCModel() - .getCProject(defaultName); + ICProject cProject = CoreModel.getDefault().getCModel().getCProject(defaultName); if (cProject.exists()) { isCreateNewProjectSelected = false; existingProjectName.setText(defaultName); @@ -142,8 +140,7 @@ public class ImportExecutablePageTwo extends WizardPage { ICProject[] projects = getCProjects(); ILabelProvider labelProvider = new CElementLabelProvider(); - ElementListSelectionDialog dialog = new ElementListSelectionDialog( - getShell(), labelProvider); + ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider); dialog.setTitle("Select a Project"); //$NON-NLS-1$ dialog.setMessage("Choose a project for the executable."); //$NON-NLS-1$ dialog.setElements(projects); @@ -162,7 +159,7 @@ public class ImportExecutablePageTwo extends WizardPage { @Override public void createControl(Composite parent) { - + Composite container = new Composite(parent, SWT.NULL); container.setLayout(new GridLayout()); // @@ -203,8 +200,7 @@ public class ImportExecutablePageTwo extends WizardPage { final GridData gridData_1 = new GridData(); gridData_1.horizontalSpan = 3; newProjectLabel.setLayoutData(gridData_1); - newProjectLabel - .setText(Messages.ImportExecutablePageTwo_ProjectLabel); + newProjectLabel.setText(Messages.ImportExecutablePageTwo_ProjectLabel); final Label dummy2 = new Label(composite, SWT.NONE); final GridData gridData_2 = new GridData(); @@ -271,8 +267,7 @@ public class ImportExecutablePageTwo extends WizardPage { createLaunch.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - isCreateLaunchConfigurationSelected = createLaunch - .getSelection(); + isCreateLaunchConfigurationSelected = createLaunch.getSelection(); setLaunchConfigurationName(configurationName.getText().trim()); updateControls(); } @@ -292,8 +287,7 @@ public class ImportExecutablePageTwo extends WizardPage { }); configurationNameLabel = new Label(composite, SWT.NONE); - configurationNameLabel.setLayoutData(new GridData( - GridData.HORIZONTAL_ALIGN_END)); + configurationNameLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); configurationNameLabel.setText(Messages.ImportExecutablePageTwo_Name); configurationName = new Text(composite, SWT.BORDER); @@ -310,20 +304,20 @@ public class ImportExecutablePageTwo extends WizardPage { }); addLaunchConfigTypes(); updateControls(); - CDebugUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp( getControl(), ICDebugHelpContextIds.IMPORT_EXECUTABLE_PAGE_TWO ); + CDebugUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(getControl(), + ICDebugHelpContextIds.IMPORT_EXECUTABLE_PAGE_TWO); } private ICProject[] getCProjects() throws CModelException { - ICProject cproject[] = CoreModel.getDefault().getCModel() - .getCProjects(); + ICProject cproject[] = CoreModel.getDefault().getCModel().getCProjects(); ArrayList<ICProject> list = new ArrayList<>(cproject.length); for (int i = 0; i < cproject.length; i++) { ICDescriptor cdesciptor = null; try { - cdesciptor = CCorePlugin.getDefault().getCProjectDescription( - (IProject) cproject[i].getResource(), false); + cdesciptor = CCorePlugin.getDefault().getCProjectDescription((IProject) cproject[i].getResource(), + false); if (cdesciptor != null) { String projectPlatform = cdesciptor.getPlatform(); if (filterPlatform.equals("*") //$NON-NLS-1$ @@ -346,8 +340,7 @@ public class ImportExecutablePageTwo extends WizardPage { if (projectName.length() < 1) { return null; } - ICProject cProject = CoreModel.getDefault().getCModel().getCProject( - projectName); + ICProject cProject = CoreModel.getDefault().getCModel().getCProject(projectName); if (!cProject.exists()) return null; return cProject; @@ -368,8 +361,8 @@ public class ImportExecutablePageTwo extends WizardPage { protected ILaunchConfigurationType getSelectedLaunchConfigurationType() { ILaunchConfigurationType result = null; String selectedTypeName = configTypes.getText(); - ILaunchConfigurationType[] configTypeList = DebugPlugin.getDefault() - .getLaunchManager().getLaunchConfigurationTypes(); + ILaunchConfigurationType[] configTypeList = DebugPlugin.getDefault().getLaunchManager() + .getLaunchConfigurationTypes(); for (int i = 0; i < configTypeList.length; i++) { if (selectedTypeName.equals(configTypeList[i].getName())) { result = configTypeList[i]; @@ -388,8 +381,8 @@ public class ImportExecutablePageTwo extends WizardPage { } private void setLaunchConfigurationName(String defaultName) { - configurationName.setText(DebugPlugin.getDefault().getLaunchManager() - .generateUniqueLaunchConfigurationNameFrom(defaultName)); + configurationName.setText( + DebugPlugin.getDefault().getLaunchManager().generateUniqueLaunchConfigurationNameFrom(defaultName)); updateControls(); } @@ -406,11 +399,11 @@ public class ImportExecutablePageTwo extends WizardPage { if (shouldUpdateButtons && getContainer().getCurrentPage() != null) getContainer().updateButtons(); } - - @Override + + @Override public boolean isPageComplete() { - setErrorMessage(null); - setWarningMessage(null); + setErrorMessage(null); + setWarningMessage(null); if (isCreateNewProjectSelected()) { if (getNewProjectName().length() == 0) { @@ -432,7 +425,7 @@ public class ImportExecutablePageTwo extends WizardPage { setErrorMessage(Messages.ImportExecutablePageTwo_BadProjectName); return false; } - + // check if executables with same names already exist in the existing project String[] executables = wizard.getImportExecutablePage().getSelectedExecutables(); List<String> existingNames = new ArrayList<String>(); @@ -443,7 +436,7 @@ public class ImportExecutablePageTwo extends WizardPage { } } if (!existingNames.isEmpty()) { - setWarningMessage(NLS.bind(Messages.ImportExecutablePageTwo_ExecutableAlreadyExists, + setWarningMessage(NLS.bind(Messages.ImportExecutablePageTwo_ExecutableAlreadyExists, StringUtil.join(existingNames, ", "))); //$NON-NLS-1$ } @@ -455,26 +448,25 @@ public class ImportExecutablePageTwo extends WizardPage { } return super.isPageComplete(); } - - /** - * Returns the executable resource having the specified path within the project. - * @param project - the project of the executable file - * @param executable - the string path of the executable - * @return the executable file - */ - private IFile getExecutableFile(IProject project, String executable) { + + /** + * Returns the executable resource having the specified path within the project. + * @param project - the project of the executable file + * @param executable - the string path of the executable + * @return the executable file + */ + private IFile getExecutableFile(IProject project, String executable) { IPath location = Path.fromOSString(executable); String name = location.toFile().getName(); return project.getFile(name); - } - - /** - * Sets or clears the warning message for this page. - * @param message - the message, or <code>null</code> to clear the message - */ - private void setWarningMessage(String message) { - setMessage(message, IMessageProvider.WARNING); - } + } + /** + * Sets or clears the warning message for this page. + * @param message - the message, or <code>null</code> to clear the message + */ + private void setWarningMessage(String message) { + setMessage(message, IMessageProvider.WARNING); + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/importexecutable/ImportExecutableWizard.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/importexecutable/ImportExecutableWizard.java index f351563fa18..09e7d6300d4 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/importexecutable/ImportExecutableWizard.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/importexecutable/ImportExecutableWizard.java @@ -20,11 +20,11 @@ import org.eclipse.swt.widgets.FileDialog; * Reference implementation of a wizard that imports executables. * Create your own version to import specific kinds of executables * with product specific messages and launch configuration types. - * + * * */ public class ImportExecutableWizard extends AbstractImportExecutableWizard { - + @Override public String getPageOneTitle() { return Messages.ImportExecutableWizard_pageOneTitle; diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/preferences/ReadOnlyFieldEditor.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/preferences/ReadOnlyFieldEditor.java index a969bbd07df..cbc1f84f204 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/preferences/ReadOnlyFieldEditor.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/preferences/ReadOnlyFieldEditor.java @@ -77,22 +77,22 @@ public class ReadOnlyFieldEditor extends FieldEditor implements ICBreakpointsUIC protected void doLoad() { if (textField != null) { String value = getPreferenceStore().getString(getPreferenceName()); - if (contribution!=null) { - if ("integer".equals (contribution.getType())) { //$NON-NLS-1$ - value = Integer.toString( getPreferenceStore().getInt(getPreferenceName()) ); - } else if ("boolean".equals (contribution.getType()) ) {//$NON-NLS-1$ - value = Boolean.toString( getPreferenceStore().getBoolean(getPreferenceName()) ); - } else if ("float".equals (contribution.getType()) ) {//$NON-NLS-1$ - value = Float.toString( getPreferenceStore().getFloat(getPreferenceName()) ); - } else if ("double".equals (contribution.getType()) ) {//$NON-NLS-1$ - value = Double.toString( getPreferenceStore().getDouble(getPreferenceName()) ); - } + if (contribution != null) { + if ("integer".equals(contribution.getType())) { //$NON-NLS-1$ + value = Integer.toString(getPreferenceStore().getInt(getPreferenceName())); + } else if ("boolean".equals(contribution.getType())) {//$NON-NLS-1$ + value = Boolean.toString(getPreferenceStore().getBoolean(getPreferenceName())); + } else if ("float".equals(contribution.getType())) {//$NON-NLS-1$ + value = Float.toString(getPreferenceStore().getFloat(getPreferenceName())); + } else if ("double".equals(contribution.getType())) {//$NON-NLS-1$ + value = Double.toString(getPreferenceStore().getDouble(getPreferenceName())); + } String tryValue = contribution.getLabelForValue(value); - if (tryValue!=null) + if (tryValue != null) value = tryValue; } if (value != null) { - textField.setText(value); + textField.setText(value); } } } @@ -191,7 +191,6 @@ public class ReadOnlyFieldEditor extends FieldEditor implements ICBreakpointsUIC getTextControl(parent).setEnabled(enabled); } - @Override protected void doStore() { // nothing diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/provisional/IRepositionableMemoryRendering2.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/provisional/IRepositionableMemoryRendering2.java index 72d70c07b82..3df06a83f34 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/provisional/IRepositionableMemoryRendering2.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/provisional/IRepositionableMemoryRendering2.java @@ -25,7 +25,7 @@ public interface IRepositionableMemoryRendering2 extends IRepositionableMemoryRe /** * Position the rendering to the given address. - * + * * @param address * the address to go to * @param expression diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/DefaultSourceLocator.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/DefaultSourceLocator.java index 55521680478..c4aeee5b380 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/DefaultSourceLocator.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/DefaultSourceLocator.java @@ -11,7 +11,7 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.ui.sourcelookup; +package org.eclipse.cdt.debug.ui.sourcelookup; import java.util.ArrayList; import java.util.Arrays; @@ -30,7 +30,7 @@ import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.sourcelookup.ISourceContainer; import org.eclipse.debug.core.sourcelookup.containers.DefaultSourceContainer; import org.w3c.dom.Element; - + /** * The replacement of the old default source locator. Used only for migration purposes. */ @@ -57,7 +57,7 @@ public class DefaultSourceLocator extends CSourceLookupDirector { ICSourceLocator csl = old.getAdapter(ICSourceLocator.class); setFindDuplicates(csl.searchForDuplicateFiles()); ICSourceLocation[] locations = csl.getSourceLocations(); - + // Check if the old source locator includes all referenced projects. // If so, DefaultSpourceContainer should be used. IProject project = csl.getProject(); @@ -69,24 +69,25 @@ public class DefaultSourceLocator extends CSourceLookupDirector { } boolean includesDefault = true; for (int i = 0; i < locations.length; ++i) { - if (locations[i] instanceof IProjectSourceLocation && ((IProjectSourceLocation)locations[i]).isGeneric()) { - if (!names.contains(((IProjectSourceLocation)locations[i]).getProject().getName())) { + if (locations[i] instanceof IProjectSourceLocation && ((IProjectSourceLocation) locations[i]).isGeneric()) { + if (!names.contains(((IProjectSourceLocation) locations[i]).getProject().getName())) { includesDefault = false; break; } } } - + // Generate an array of new source containers including DefaultSourceContainer ArrayList<ICSourceLocation> locs = new ArrayList<ICSourceLocation>(locations.length); for (int i = 0; i < locations.length; ++i) { - if (!includesDefault || !(locations[i] instanceof IProjectSourceLocation && - names.contains(((IProjectSourceLocation)locations[i]).getProject().getName()))) { + if (!includesDefault || !(locations[i] instanceof IProjectSourceLocation + && names.contains(((IProjectSourceLocation) locations[i]).getProject().getName()))) { locs.add(locations[i]); } } - - ISourceContainer[] containers = SourceUtils.convertSourceLocations(locs.toArray(new ICSourceLocation[locs.size()])); + + ISourceContainer[] containers = SourceUtils + .convertSourceLocations(locs.toArray(new ICSourceLocation[locs.size()])); ArrayList<ISourceContainer> cons = new ArrayList<ISourceContainer>(Arrays.asList(containers)); if (includesDefault) { DefaultSourceContainer defaultContainer = new DefaultSourceContainer(); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/OldDefaultSourceLocator.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/OldDefaultSourceLocator.java index 02854a8561a..29775459fdd 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/OldDefaultSourceLocator.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/OldDefaultSourceLocator.java @@ -51,7 +51,8 @@ public class OldDefaultSourceLocator implements IPersistableSourceLocator, IAdap /** * Identifier for the 'Default C/C++ Source Locator' extension (value <code>"org.eclipse.cdt.debug.ui.DefaultSourceLocator"</code>). */ - public static final String ID_DEFAULT_SOURCE_LOCATOR = CDebugUIPlugin.getUniqueIdentifier() + ".DefaultSourceLocator"; //$NON-NLS-1$ + public static final String ID_DEFAULT_SOURCE_LOCATOR = CDebugUIPlugin.getUniqueIdentifier() + + ".DefaultSourceLocator"; //$NON-NLS-1$ // to support old configurations public static final String ID_OLD_DEFAULT_SOURCE_LOCATOR = "org.eclipse.cdt.launch" + ".DefaultSourceLocator"; //$NON-NLS-1$ //$NON-NLS-2$ @@ -76,30 +77,27 @@ public class OldDefaultSourceLocator implements IPersistableSourceLocator, IAdap */ @Override public String getMemento() throws CoreException { - if ( getCSourceLocator() != null ) { + if (getCSourceLocator() != null) { Document document = null; Throwable ex = null; try { document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); - Element element = document.createElement( ELEMENT_NAME ); - document.appendChild( element ); - element.setAttribute( ATTR_PROJECT, getCSourceLocator().getProject().getName() ); + Element element = document.createElement(ELEMENT_NAME); + document.appendChild(element); + element.setAttribute(ATTR_PROJECT, getCSourceLocator().getProject().getName()); IPersistableSourceLocator psl = getPersistableSourceLocator(); - if ( psl != null ) { - element.setAttribute( ATTR_MEMENTO, psl.getMemento() ); + if (psl != null) { + element.setAttribute(ATTR_MEMENTO, psl.getMemento()); } - return CDebugUtils.serializeDocument( document ); - } - catch( ParserConfigurationException e ) { + return CDebugUtils.serializeDocument(document); + } catch (ParserConfigurationException e) { ex = e; - } - catch( IOException e ) { + } catch (IOException e) { ex = e; - } - catch( TransformerException e ) { + } catch (TransformerException e) { ex = e; } - abort( SourceLookupMessages.getString( "OldDefaultSourceLocator.1" ), ex ); //$NON-NLS-1$ + abort(SourceLookupMessages.getString("OldDefaultSourceLocator.1"), ex); //$NON-NLS-1$ } return null; } @@ -108,67 +106,65 @@ public class OldDefaultSourceLocator implements IPersistableSourceLocator, IAdap * @see org.eclipse.debug.core.model.IPersistableSourceLocator#initializeFromMemento(java.lang.String) */ @Override - public void initializeFromMemento( String memento ) throws CoreException { + public void initializeFromMemento(String memento) throws CoreException { Exception ex = null; try { Element root = null; DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - StringReader reader = new StringReader( memento ); - InputSource source = new InputSource( reader ); - root = parser.parse( source ).getDocumentElement(); - if ( !root.getNodeName().equalsIgnoreCase( ELEMENT_NAME ) ) { - abort( SourceLookupMessages.getString( "OldDefaultSourceLocator.2" ), null ); //$NON-NLS-1$ + StringReader reader = new StringReader(memento); + InputSource source = new InputSource(reader); + root = parser.parse(source).getDocumentElement(); + if (!root.getNodeName().equalsIgnoreCase(ELEMENT_NAME)) { + abort(SourceLookupMessages.getString("OldDefaultSourceLocator.2"), null); //$NON-NLS-1$ } - String projectName = root.getAttribute( ATTR_PROJECT ); - String data = root.getAttribute( ATTR_MEMENTO ); - if ( isEmpty( projectName ) ) { - abort( SourceLookupMessages.getString( "OldDefaultSourceLocator.3" ), null ); //$NON-NLS-1$ + String projectName = root.getAttribute(ATTR_PROJECT); + String data = root.getAttribute(ATTR_MEMENTO); + if (isEmpty(projectName)) { + abort(SourceLookupMessages.getString("OldDefaultSourceLocator.3"), null); //$NON-NLS-1$ } - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( projectName ); - if ( getCSourceLocator() == null ) - setCSourceLocator( SourceLookupFactory.createSourceLocator( project ) ); - if ( getCSourceLocator().getProject() != null && !getCSourceLocator().getProject().equals( project ) ) + IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); + if (getCSourceLocator() == null) + setCSourceLocator(SourceLookupFactory.createSourceLocator(project)); + if (getCSourceLocator().getProject() != null && !getCSourceLocator().getProject().equals(project)) return; - if ( project == null || !project.exists() || !project.isOpen() ) - abort( MessageFormat.format( SourceLookupMessages.getString( "OldDefaultSourceLocator.4" ), new Object[]{ projectName } ), null ); //$NON-NLS-1$ + if (project == null || !project.exists() || !project.isOpen()) + abort(MessageFormat.format(SourceLookupMessages.getString("OldDefaultSourceLocator.4"), //$NON-NLS-1$ + new Object[] { projectName }), null); IPersistableSourceLocator psl = getPersistableSourceLocator(); - if ( psl != null ) - psl.initializeFromMemento( data ); + if (psl != null) + psl.initializeFromMemento(data); else - abort( SourceLookupMessages.getString( "OldDefaultSourceLocator.5" ), null ); //$NON-NLS-1$ + abort(SourceLookupMessages.getString("OldDefaultSourceLocator.5"), null); //$NON-NLS-1$ return; - } - catch( ParserConfigurationException e ) { + } catch (ParserConfigurationException e) { ex = e; - } - catch( SAXException e ) { + } catch (SAXException e) { ex = e; - } - catch( IOException e ) { + } catch (IOException e) { ex = e; } - abort( SourceLookupMessages.getString( "OldDefaultSourceLocator.6" ), ex ); //$NON-NLS-1$ + abort(SourceLookupMessages.getString("OldDefaultSourceLocator.6"), ex); //$NON-NLS-1$ } /* (non-Javadoc) * @see org.eclipse.debug.core.model.IPersistableSourceLocator#initializeDefaults(org.eclipse.debug.core.ILaunchConfiguration) */ @Override - public void initializeDefaults( ILaunchConfiguration configuration ) throws CoreException { - setCSourceLocator( SourceLookupFactory.createSourceLocator( getProject( configuration ) ) ); - String memento = configuration.getAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, "" ); //$NON-NLS-1$ - if ( !isEmpty( memento ) ) - initializeFromMemento( memento ); + public void initializeDefaults(ILaunchConfiguration configuration) throws CoreException { + setCSourceLocator(SourceLookupFactory.createSourceLocator(getProject(configuration))); + String memento = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, ""); //$NON-NLS-1$ + if (!isEmpty(memento)) + initializeFromMemento(memento); } @Override - public <T> T getAdapter( Class<T> adapter ) { - if ( getCSourceLocator() instanceof IAdaptable ) { - if ( adapter.equals( ICSourceLocator.class ) ) { - return ((IAdaptable)getCSourceLocator()).getAdapter( adapter ); + public <T> T getAdapter(Class<T> adapter) { + if (getCSourceLocator() instanceof IAdaptable) { + if (adapter.equals(ICSourceLocator.class)) { + return ((IAdaptable) getCSourceLocator()).getAdapter(adapter); } - if ( adapter.equals( IResourceChangeListener.class ) ) { - return ((IAdaptable)getCSourceLocator()).getAdapter( adapter ); + if (adapter.equals(IResourceChangeListener.class)) { + return ((IAdaptable) getCSourceLocator()).getAdapter(adapter); } } return null; @@ -178,7 +174,7 @@ public class OldDefaultSourceLocator implements IPersistableSourceLocator, IAdap * @see org.eclipse.debug.core.model.ISourceLocator#getSourceElement(org.eclipse.debug.core.model.IStackFrame) */ @Override - public Object getSourceElement( IStackFrame stackFrame ) { + public Object getSourceElement(IStackFrame stackFrame) { return null; } @@ -186,36 +182,38 @@ public class OldDefaultSourceLocator implements IPersistableSourceLocator, IAdap return fSourceLocator; } - private void setCSourceLocator( ICSourceLocator locator ) { + private void setCSourceLocator(ICSourceLocator locator) { fSourceLocator = locator; } private IPersistableSourceLocator getPersistableSourceLocator() { ICSourceLocator sl = getCSourceLocator(); - return (sl instanceof IPersistableSourceLocator) ? (IPersistableSourceLocator)sl : null; + return (sl instanceof IPersistableSourceLocator) ? (IPersistableSourceLocator) sl : null; } /** * Throws an internal error exception */ - private void abort( String message, Throwable e ) throws CoreException { - IStatus s = new Status( IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), 0, message, e ); - throw new CoreException( s ); + private void abort(String message, Throwable e) throws CoreException { + IStatus s = new Status(IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), 0, message, e); + throw new CoreException(s); } - private boolean isEmpty( String string ) { + private boolean isEmpty(String string) { return string == null || string.trim().length() == 0; } - private IProject getProject( ILaunchConfiguration configuration ) throws CoreException { - String projectName = configuration.getAttribute( ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null ); - if ( !isEmpty( projectName ) ) { - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( projectName ); - if ( project.exists() ) { + private IProject getProject(ILaunchConfiguration configuration) throws CoreException { + String projectName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, + (String) null); + if (!isEmpty(projectName)) { + IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); + if (project.exists()) { return project; } } - abort( MessageFormat.format( SourceLookupMessages.getString( "OldDefaultSourceLocator.9" ), new Object[]{ projectName } ), null ); //$NON-NLS-1$ + abort(MessageFormat.format(SourceLookupMessages.getString("OldDefaultSourceLocator.9"), //$NON-NLS-1$ + new Object[] { projectName }), null); return null; } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourceLookupMessages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourceLookupMessages.java index ab85df94d1b..aa1531dc944 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourceLookupMessages.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourceLookupMessages.java @@ -20,16 +20,15 @@ public class SourceLookupMessages { private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.ui.sourcelookup.SourceLookupMessages";//$NON-NLS-1$ - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); private SourceLookupMessages() { } - public static String getString( String key ) { + public static String getString(String key) { try { - return RESOURCE_BUNDLE.getString( key ); - } - catch( MissingResourceException e ) { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { return '!' + key + '!'; } } |