diff options
author | Jonah Graham | 2018-11-20 16:20:42 +0000 |
---|---|---|
committer | Jonah Graham | 2018-11-22 21:47:02 +0000 |
commit | 170e654b4796bad1453ae85a427b97317d67a69a (patch) | |
tree | 6ca9b8a8fedd5fd25f97eb79c408312e256ff981 /debug | |
parent | 35996a5c5ca5c254959ba48241eaada6dbf8628d (diff) | |
download | org.eclipse.cdt-170e654b4796bad1453ae85a427b97317d67a69a.tar.gz org.eclipse.cdt-170e654b4796bad1453ae85a427b97317d67a69a.tar.xz org.eclipse.cdt-170e654b4796bad1453ae85a427b97317d67a69a.zip |
Bug 540373: Cleanup: Format & Remove trailing whitespace
This was done by selecting all projects in Eclipse then
Source -> Clean Up... -> choosing:
- Format source code
- Remove trailing white spaces on all lines
and completing the wizard
Change-Id: I63685372c6bcc67719bcf145123bcb72e5b00394
Diffstat (limited to 'debug')
507 files changed, 17987 insertions, 17867 deletions
diff --git a/debug/org.eclipse.cdt.debug.application.tests/src/org/eclipse/cdt/debug/application/tests/AllTests.java b/debug/org.eclipse.cdt.debug.application.tests/src/org/eclipse/cdt/debug/application/tests/AllTests.java index 60f40a5ad58..eac8f1e1208 100644 --- a/debug/org.eclipse.cdt.debug.application.tests/src/org/eclipse/cdt/debug/application/tests/AllTests.java +++ b/debug/org.eclipse.cdt.debug.application.tests/src/org/eclipse/cdt/debug/application/tests/AllTests.java @@ -17,9 +17,7 @@ import org.junit.runner.RunWith; import org.junit.runners.Suite; @RunWith(Suite.class) -@Suite.SuiteClasses({ - StandaloneTest1.class, -}) +@Suite.SuiteClasses({ StandaloneTest1.class, }) public class AllTests { diff --git a/debug/org.eclipse.cdt.debug.application.tests/src/org/eclipse/cdt/debug/application/tests/StandaloneTest1.java b/debug/org.eclipse.cdt.debug.application.tests/src/org/eclipse/cdt/debug/application/tests/StandaloneTest1.java index 1987fb33d9c..0f243b1ebd1 100644 --- a/debug/org.eclipse.cdt.debug.application.tests/src/org/eclipse/cdt/debug/application/tests/StandaloneTest1.java +++ b/debug/org.eclipse.cdt.debug.application.tests/src/org/eclipse/cdt/debug/application/tests/StandaloneTest1.java @@ -117,7 +117,8 @@ public class StandaloneTest1 extends StandaloneTest { boolean found = false; try { final Matcher<MenuItem> matcher = withMnemonic(menuText); - WaitForObjectCondition<MenuItem> waitForMenuItem = Conditions.waitForMenuItem(shell.menu(), matcher, false, 0); + WaitForObjectCondition<MenuItem> waitForMenuItem = Conditions.waitForMenuItem(shell.menu(), matcher, false, + 0); bot.waitUntil(waitForMenuItem, 50); found = true; } catch (TimeoutException e) { diff --git a/debug/org.eclipse.cdt.debug.application.tests/src/org/eclipse/cdt/debug/application/tests/Utilities.java b/debug/org.eclipse.cdt.debug.application.tests/src/org/eclipse/cdt/debug/application/tests/Utilities.java index 428067ef510..17f3ead4d69 100644 --- a/debug/org.eclipse.cdt.debug.application.tests/src/org/eclipse/cdt/debug/application/tests/Utilities.java +++ b/debug/org.eclipse.cdt.debug.application.tests/src/org/eclipse/cdt/debug/application/tests/Utilities.java @@ -43,7 +43,7 @@ public class Utilities { return instance; } - public IPath getProjectPath (String name) { + public IPath getProjectPath(String name) { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IPath rootLocation = root.getLocation(); @@ -52,18 +52,17 @@ public class Utilities { return destProjectDirPath; } - public boolean buildProject (String name) { + public boolean buildProject(String name) { File destProjectDir = getProjectPath(name).toFile(); String resourceDirPath = "/projects/" + name; //$NON-NLS-1$ try { - String path = FileLocator.toFileURL( - this.getClass().getResource(resourceDirPath)).getPath(); + String path = FileLocator.toFileURL(this.getClass().getResource(resourceDirPath)).getPath(); File projectDir = new Path(path).toFile(); copy(projectDir, destProjectDir); - Process process = execute(new String[]{"make","all","2>&1"}, null, destProjectDir, false); + Process process = execute(new String[] { "make", "all", "2>&1" }, null, destProjectDir, false); boolean done = false; while (!done) { @@ -86,7 +85,7 @@ public class Utilities { } } process.destroy(); - process = execute(new String[]{"ls","-l"}, null, destProjectDir, false); + process = execute(new String[] { "ls", "-l" }, null, destProjectDir, false); done = false; while (!done) { @@ -116,13 +115,13 @@ public class Utilities { return true; } - public boolean cleanProject (String name) { + public boolean cleanProject(String name) { IPath destProjectDirPath = getProjectPath(name); File destProjectDir = destProjectDirPath.toFile(); - + try { - Process process = execute(new String[]{"make","clean"}, null, destProjectDir, false); + Process process = execute(new String[] { "make", "clean" }, null, destProjectDir, false); boolean done = false; while (!done) { @@ -166,7 +165,8 @@ public class Utilities { } } - private static Process startProcess(String[] commandArray, String[] envp, File workDir, boolean usePty) throws IOException { + private static Process startProcess(String[] commandArray, String[] envp, File workDir, boolean usePty) + throws IOException { if (workDir == null) { return ProcessFactory.getFactory().exec(commandArray, envp); } @@ -177,13 +177,12 @@ public class Utilities { } } - public static void copy (File src, File dest) - throws IOException { + public static void copy(File src, File dest) throws IOException { if (src.isDirectory()) { // ensure destination directory exists - if (!dest.exists()){ + if (!dest.exists()) { dest.mkdir(); } diff --git a/debug/org.eclipse.cdt.debug.application/src-config-generator/org/eclipse/cdt/debug/application/ConfigGenerator.java b/debug/org.eclipse.cdt.debug.application/src-config-generator/org/eclipse/cdt/debug/application/ConfigGenerator.java index 82d74479ed9..b0d04b60c04 100644 --- a/debug/org.eclipse.cdt.debug.application/src-config-generator/org/eclipse/cdt/debug/application/ConfigGenerator.java +++ b/debug/org.eclipse.cdt.debug.application/src-config-generator/org/eclipse/cdt/debug/application/ConfigGenerator.java @@ -73,7 +73,7 @@ public class ConfigGenerator { r.write("osgi.bundles="); //$NON-NLS-1$ // Write all plug-in names - for (int i =0; i < pluginList.size(); i++) { + for (int i = 0; i < pluginList.size(); i++) { String pluginName = pluginList.get(i); if (PLUGINS_NOT_IN_SCRIPT_VERSION.contains(pluginName)) { continue; diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/Activator.java b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/Activator.java index c31a0183561..4c3c205f90e 100644 --- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/Activator.java +++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/Activator.java @@ -27,7 +27,7 @@ public class Activator extends AbstractUIPlugin { // The shared instance private static Activator plugin; - + /** * The constructor */ diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/Application.java b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/Application.java index f99e0795a78..76e2d1a924c 100644 --- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/Application.java +++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/Application.java @@ -32,7 +32,7 @@ import org.eclipse.ui.PlatformUI; * This class controls all aspects of the application's execution */ public class Application implements IApplication { - + public static final String WORKSPACE_NAME = "workspace-cdtdebug"; //$NON-NLS-1$ private Location fInstanceLoc = null; @@ -47,7 +47,7 @@ public class Application implements IApplication { if (!setupWorkspaceLocation(display)) { return IApplication.EXIT_OK; } - + int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor()); if (returnCode == PlatformUI.RETURN_RESTART) return IApplication.EXIT_RESTART; @@ -56,47 +56,47 @@ public class Application implements IApplication { } finally { display.dispose(); } - + } - + private boolean setupWorkspaceLocation(Display display) throws IOException { - // fetch the Location that we will be modifying - fInstanceLoc = Platform.getInstanceLocation(); - - // -data @noDefault in <applName>.ini allows us to set the workspace here. - // If the user wants to change the location then he has to change - // @noDefault to a specific location or remove -data @noDefault for - // default location - if (!fInstanceLoc.allowsDefault() && !fInstanceLoc.isSet()) { - File workspaceRoot = new Path(System.getProperty("user.home")).toFile(); //$NON-NLS-1$ - - if (!workspaceRoot.exists()) { - MessageDialog.openError(display.getActiveShell(), - Messages.Application_WorkspaceCreationError, - MessageFormat.format(Messages.Application_WorkspaceRootNotExistError, new Object[] { workspaceRoot })); - return false; - } - - if (!workspaceRoot.canWrite()) { - MessageDialog.openError(display.getActiveShell(), - Messages.Application_WorkspaceCreationError, - MessageFormat.format(Messages.Application_WorkspaceRootPermissionError, new Object[] { workspaceRoot })); - return false; - } - - String workspace = workspaceRoot.getAbsolutePath() + File.separator + WORKSPACE_NAME; - // set location to workspace - fInstanceLoc.set(new URL("file", null, workspace), false); //$NON-NLS-1$ - } - - if (!fInstanceLoc.lock()) { - MessageDialog.openError(display.getActiveShell(), - Messages.Application_WorkspaceCreationError, - MessageFormat.format(Messages.Application_WorkspaceInUseError, new Object[] { fInstanceLoc.getURL().getPath() })); - return false; - } - - return true; + // fetch the Location that we will be modifying + fInstanceLoc = Platform.getInstanceLocation(); + + // -data @noDefault in <applName>.ini allows us to set the workspace here. + // If the user wants to change the location then he has to change + // @noDefault to a specific location or remove -data @noDefault for + // default location + if (!fInstanceLoc.allowsDefault() && !fInstanceLoc.isSet()) { + File workspaceRoot = new Path(System.getProperty("user.home")).toFile(); //$NON-NLS-1$ + + if (!workspaceRoot.exists()) { + MessageDialog.openError(display.getActiveShell(), Messages.Application_WorkspaceCreationError, + MessageFormat.format(Messages.Application_WorkspaceRootNotExistError, + new Object[] { workspaceRoot })); + return false; + } + + if (!workspaceRoot.canWrite()) { + MessageDialog.openError(display.getActiveShell(), Messages.Application_WorkspaceCreationError, + MessageFormat.format(Messages.Application_WorkspaceRootPermissionError, + new Object[] { workspaceRoot })); + return false; + } + + String workspace = workspaceRoot.getAbsolutePath() + File.separator + WORKSPACE_NAME; + // set location to workspace + fInstanceLoc.set(new URL("file", null, workspace), false); //$NON-NLS-1$ + } + + if (!fInstanceLoc.lock()) { + MessageDialog.openError(display.getActiveShell(), Messages.Application_WorkspaceCreationError, + MessageFormat.format(Messages.Application_WorkspaceInUseError, + new Object[] { fInstanceLoc.getURL().getPath() })); + return false; + } + + return true; } /* (non-Javadoc) diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationActionBarAdvisor.java b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationActionBarAdvisor.java index 26cc2e3070c..287daefa584 100644 --- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationActionBarAdvisor.java +++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationActionBarAdvisor.java @@ -59,11 +59,11 @@ public class ApplicationActionBarAdvisor extends ActionBarAdvisor { private IWorkbenchAction helpContentsAction; private IWorkbenchAction helpSearchAction; private IWorkbenchAction dynamicHelpAction; - private IWorkbenchAction aboutAction; + private IWorkbenchAction aboutAction; - private IWorkbenchAction undoAction; - private IWorkbenchAction redoAction; - private IWorkbenchAction refreshAction; + private IWorkbenchAction undoAction; + private IWorkbenchAction redoAction; + private IWorkbenchAction refreshAction; public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) { super(configurer); @@ -94,40 +94,38 @@ public class ApplicationActionBarAdvisor extends ActionBarAdvisor { corefileAction = COREFILE.create(window); register(corefileAction); - editActionSetAction = ActionFactory.EDIT_ACTION_SETS - .create(window); + editActionSetAction = ActionFactory.EDIT_ACTION_SETS.create(window); register(editActionSetAction); - - helpContentsAction = ActionFactory.HELP_CONTENTS.create(window); - register(helpContentsAction); - - helpSearchAction = ActionFactory.HELP_SEARCH.create(window); - register(helpSearchAction); - - dynamicHelpAction = ActionFactory.DYNAMIC_HELP.create(window); - register(dynamicHelpAction); - - undoAction = ActionFactory.UNDO.create(window); - register(undoAction); - - redoAction = ActionFactory.REDO.create(window); - register(redoAction); - - refreshAction = ActionFactory.REFRESH.create(window); - register(refreshAction); - - aboutAction = ActionFactory.ABOUT.create(window); - aboutAction - .setImageDescriptor(IDEInternalWorkbenchImages - .getImageDescriptor(IDEInternalWorkbenchImages.IMG_OBJS_DEFAULT_PROD)); - register(aboutAction); - - openPreferencesAction = ActionFactory.PREFERENCES.create(window); - register(openPreferencesAction); + + helpContentsAction = ActionFactory.HELP_CONTENTS.create(window); + register(helpContentsAction); + + helpSearchAction = ActionFactory.HELP_SEARCH.create(window); + register(helpSearchAction); + + dynamicHelpAction = ActionFactory.DYNAMIC_HELP.create(window); + register(dynamicHelpAction); + + undoAction = ActionFactory.UNDO.create(window); + register(undoAction); + + redoAction = ActionFactory.REDO.create(window); + register(redoAction); + + refreshAction = ActionFactory.REFRESH.create(window); + register(refreshAction); + + aboutAction = ActionFactory.ABOUT.create(window); + aboutAction.setImageDescriptor( + IDEInternalWorkbenchImages.getImageDescriptor(IDEInternalWorkbenchImages.IMG_OBJS_DEFAULT_PROD)); + register(aboutAction); + + openPreferencesAction = ActionFactory.PREFERENCES.create(window); + register(openPreferencesAction); } @Override - protected void fillMenuBar(IMenuManager menuBar) { + protected void fillMenuBar(IMenuManager menuBar) { menuBar.add(createFileMenu()); menuBar.add(createEditMenu()); menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); @@ -138,7 +136,7 @@ public class ApplicationActionBarAdvisor extends ActionBarAdvisor { /** * Creates and returns the File menu. */ - private MenuManager createFileMenu() { + private MenuManager createFileMenu() { MenuManager menu = new MenuManager(Messages.FileMenuName, IWorkbenchActionConstants.M_FILE); menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_START)); @@ -176,317 +174,268 @@ public class ApplicationActionBarAdvisor extends ActionBarAdvisor { menu.add(quitItem); menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_END)); return menu; - } - - /** - * Creates and returns the Edit menu. - */ - private MenuManager createEditMenu() { - MenuManager menu = new MenuManager(Messages.EditMenuName, IWorkbenchActionConstants.M_EDIT); - menu.add(new GroupMarker(IWorkbenchActionConstants.EDIT_START)); - - menu.add(undoAction); - menu.add(redoAction); - menu.add(new GroupMarker(IWorkbenchActionConstants.UNDO_EXT)); - menu.add(new Separator()); - - menu.add(getCutItem()); - menu.add(getCopyItem()); - menu.add(getPasteItem()); - menu.add(new GroupMarker(IWorkbenchActionConstants.CUT_EXT)); - menu.add(new Separator()); - - menu.add(getDeleteItem()); - menu.add(getSelectAllItem()); - menu.add(new Separator()); - - menu.add(getFindItem()); - menu.add(new GroupMarker(IWorkbenchActionConstants.FIND_EXT)); - menu.add(new Separator()); - - menu.add(getBookmarkItem()); - menu.add(getTaskItem()); - menu.add(new GroupMarker(IWorkbenchActionConstants.ADD_EXT)); - - menu.add(new GroupMarker(IWorkbenchActionConstants.EDIT_END)); - menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); - return menu; - } - - /** - * Creates and returns the Window menu. - */ - private MenuManager createWindowMenu() { - MenuManager menu = new MenuManager( - Messages.WindowMenuName, IWorkbenchActionConstants.M_WINDOW); - - - addPerspectiveActions(menu); - Separator sep = new Separator(IWorkbenchActionConstants.MB_ADDITIONS); - sep.setVisible(!Util.isMac()); - menu.add(sep); - - // See the comment for quit in createFileMenu - ActionContributionItem openPreferencesItem = new ActionContributionItem(openPreferencesAction); - openPreferencesItem.setVisible(!Util.isMac()); - menu.add(openPreferencesItem); - - menu.add(ContributionItemFactory.OPEN_WINDOWS.create(getWindow())); - return menu; - } - - /** - * Creates and returns the Help menu. - */ - private MenuManager createHelpMenu() { - MenuManager menu = new MenuManager(Messages.HelpMenuName, IWorkbenchActionConstants.M_HELP); - menu.add(new GroupMarker("group.intro.ext")); //$NON-NLS-1$ - menu.add(new GroupMarker("group.main")); //$NON-NLS-1$ - menu.add(helpContentsAction); - menu.add(helpSearchAction); - menu.add(dynamicHelpAction); - menu.add(new GroupMarker("group.assist")); //$NON-NLS-1$ - // HELP_START should really be the first item, but it was after - // quickStartAction and tipsAndTricksAction in 2.1. - menu.add(new GroupMarker(IWorkbenchActionConstants.HELP_START)); - menu.add(new GroupMarker("group.main.ext")); //$NON-NLS-1$ - menu.add(new GroupMarker("group.tutorials")); //$NON-NLS-1$ - menu.add(new GroupMarker("group.tools")); //$NON-NLS-1$ - menu.add(new GroupMarker("group.updates")); //$NON-NLS-1$ - menu.add(new GroupMarker(IWorkbenchActionConstants.HELP_END)); - menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); - // about should always be at the bottom - menu.add(new Separator("group.about")); //$NON-NLS-1$ - - ActionContributionItem aboutItem = new ActionContributionItem(aboutAction); - aboutItem.setVisible(!Util.isMac()); - menu.add(aboutItem); - menu.add(new GroupMarker("group.about.ext")); //$NON-NLS-1$ - return menu; - } - /** - * Adds the perspective actions to the specified menu. - */ - private void addPerspectiveActions(MenuManager menu) { - { - MenuManager showViewMenuMgr = new MenuManager(Messages.ShowViewMenuName, "showView"); //$NON-NLS-1$ - IContributionItem showViewMenu = ContributionItemFactory.VIEWS_SHORTLIST - .create(getWindow()); - showViewMenuMgr.add(showViewMenu); - menu.add(showViewMenuMgr); - } - menu.add(new Separator()); - menu.add(editActionSetAction); - menu.add(getResetPerspectiveItem()); - } - - private IContributionItem getItem(String actionId, String commandId, - String image, String disabledImage, String label, String tooltip, String helpContextId) { - ISharedImages sharedImages = getWindow().getWorkbench() - .getSharedImages(); - - IActionCommandMappingService acms = getWindow() - .getService(IActionCommandMappingService.class); - acms.map(actionId, commandId); - - CommandContributionItemParameter commandParm = new CommandContributionItemParameter( - getWindow(), actionId, commandId, null, sharedImages - .getImageDescriptor(image), sharedImages - .getImageDescriptor(disabledImage), null, label, null, - tooltip, CommandContributionItem.STYLE_PUSH, null, false); - return new CommandContributionItem(commandParm); - } - - private IContributionItem getResetPerspectiveItem() { - return getItem( - ActionFactory.RESET_PERSPECTIVE.getId(), - ActionFactory.RESET_PERSPECTIVE.getCommandId(), - null, - null, - Messages.ResetPerspective_text, - Messages.ResetPerspective_toolTip, - IWorkbenchHelpContextIds.RESET_PERSPECTIVE_ACTION); - } - - private IContributionItem getCutItem() { - return getItem( - ActionFactory.CUT.getId(), - ActionFactory.CUT.getCommandId(), - ISharedImages.IMG_TOOL_CUT, - ISharedImages.IMG_TOOL_CUT_DISABLED, - Messages.Workbench_cut, - Messages.Workbench_cutToolTip, null); - } - - private IContributionItem getCopyItem() { - return getItem( - ActionFactory.COPY.getId(), - ActionFactory.COPY.getCommandId(), - ISharedImages.IMG_TOOL_COPY, - ISharedImages.IMG_TOOL_COPY_DISABLED, - Messages.Workbench_copy, - Messages.Workbench_copyToolTip, null); - } - - private IContributionItem getPasteItem() { - return getItem( - ActionFactory.PASTE.getId(), - ActionFactory.PASTE.getCommandId(), - ISharedImages.IMG_TOOL_PASTE, - ISharedImages.IMG_TOOL_PASTE_DISABLED, - Messages.Workbench_paste, - Messages.Workbench_pasteToolTip, null); - } - - - private IContributionItem getSelectAllItem() { - return getItem( - ActionFactory.SELECT_ALL.getId(), - ActionFactory.SELECT_ALL.getCommandId(), - null, null, Messages.Workbench_selectAll, - Messages.Workbench_selectAllToolTip, null); - } - - private IContributionItem getFindItem() { - return getItem( - ActionFactory.FIND.getId(), - ActionFactory.FIND.getCommandId(), - null, null, Messages.Workbench_findReplace, - Messages.Workbench_findReplaceToolTip, null); - } - - private IContributionItem getBookmarkItem() { - return getItem( - IDEActionFactory.BOOKMARK.getId(), - IDEActionFactory.BOOKMARK.getCommandId(), - null, null, Messages.Workbench_addBookmark, - Messages.Workbench_addBookmarkToolTip, null); - } - - private IContributionItem getTaskItem() { - return getItem( - IDEActionFactory.ADD_TASK.getId(), - IDEActionFactory.ADD_TASK.getCommandId(), - null, null, Messages.Workbench_addTask, - Messages.Workbench_addTaskToolTip, null); - } - - private IContributionItem getDeleteItem() { - return getItem(ActionFactory.DELETE.getId(), - ActionFactory.DELETE.getCommandId(), - ISharedImages.IMG_TOOL_DELETE, - ISharedImages.IMG_TOOL_DELETE_DISABLED, - Messages.Workbench_delete, - Messages.Workbench_deleteToolTip, - IWorkbenchHelpContextIds.DELETE_RETARGET_ACTION); - } - - private static class WorkbenchCommandAction extends CommandAction implements - IWorkbenchAction { - /** - * @param commandIdIn - * @param window - */ - public WorkbenchCommandAction(String commandIdIn, - IWorkbenchWindow window) { - super(window, commandIdIn); - } - } - - /** - * Workbench action (id: "corefile", commandId: "org.eclipse.cdt.debug.application.command.debugCore"): - * Debug an executable with a core file. This action maintains its enablement state. - */ - private static final ActionFactory COREFILE = new ActionFactory("corefile", //$NON-NLS-1$ - COREFILE_COMMAND_ID) { - - /* (non-Javadoc) - * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow) - */ - @Override - public IWorkbenchAction create(IWorkbenchWindow window) { - if (window == null) { - throw new IllegalArgumentException(); - } - WorkbenchCommandAction action = new WorkbenchCommandAction( - getCommandId(), window); - action.setId(getId()); - action.setText(Messages.CoreFileMenuName); - action.setToolTipText(Messages.CoreFile_toolTip); - return action; - } - }; - - /** - * Workbench action (id: "newexecutable", commandId: "org.eclipse.cdt.debug.application.command.debugNewExecutable"): - * Debug an executable. This action maintains its enablement state. - */ - private static final ActionFactory NEW_EXECUTABLE = new ActionFactory("newexecutable", //$NON-NLS-1$ - NEW_EXECUTABLE_COMMAND_ID) { - - /* (non-Javadoc) - * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow) - */ - @Override - public IWorkbenchAction create(IWorkbenchWindow window) { - if (window == null) { - throw new IllegalArgumentException(); - } - WorkbenchCommandAction action = new WorkbenchCommandAction( - getCommandId(), window); - action.setId(getId()); - action.setText(Messages.NewExecutableMenuName); - action.setToolTipText(Messages.NewExecutable_toolTip); - return action; - } - }; - - /** - * Workbench action (id: "remoteexecutable", commandId: "org.eclipse.cdt.debug.application.command.debugRemoteExecutable"): - * Debug a remote executable. This action maintains its enablement state. - */ - private static final ActionFactory REMOTE_EXECUTABLE = new ActionFactory("remoteexecutable", //$NON-NLS-1$ - REMOTE_EXECUTABLE_COMMAND_ID) { - - /* (non-Javadoc) - * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow) - */ - @Override - public IWorkbenchAction create(IWorkbenchWindow window) { - if (window == null) { - throw new IllegalArgumentException(); - } - WorkbenchCommandAction action = new WorkbenchCommandAction( - getCommandId(), window); - action.setId(getId()); - action.setText(Messages.RemoteExecutableMenuName); - action.setToolTipText(Messages.RemoteExecutable_toolTip); - return action; - } - }; - - /** - * Workbench action (id: "attachexecutable", commandId: "org.eclipse.cdt.debug.application.command.debugAttachedExecutable"): - * Attach and debug an existing executable. This action maintains its enablement state. - */ - private static final ActionFactory ATTACH_EXECUTABLE = new ActionFactory("attachexecutable", //$NON-NLS-1$ - ATTACH_EXECUTABLE_COMMAND_ID) { - - /* (non-Javadoc) - * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow) - */ - @Override - public IWorkbenchAction create(IWorkbenchWindow window) { - if (window == null) { - throw new IllegalArgumentException(); - } - WorkbenchCommandAction action = new WorkbenchCommandAction( - getCommandId(), window); - action.setId(getId()); - action.setText(Messages.AttachedExecutableMenuName); - action.setToolTipText(Messages.AttachedExecutable_toolTip); - return action; - } - }; + } + + /** + * Creates and returns the Edit menu. + */ + private MenuManager createEditMenu() { + MenuManager menu = new MenuManager(Messages.EditMenuName, IWorkbenchActionConstants.M_EDIT); + menu.add(new GroupMarker(IWorkbenchActionConstants.EDIT_START)); + + menu.add(undoAction); + menu.add(redoAction); + menu.add(new GroupMarker(IWorkbenchActionConstants.UNDO_EXT)); + menu.add(new Separator()); + + menu.add(getCutItem()); + menu.add(getCopyItem()); + menu.add(getPasteItem()); + menu.add(new GroupMarker(IWorkbenchActionConstants.CUT_EXT)); + menu.add(new Separator()); + + menu.add(getDeleteItem()); + menu.add(getSelectAllItem()); + menu.add(new Separator()); + + menu.add(getFindItem()); + menu.add(new GroupMarker(IWorkbenchActionConstants.FIND_EXT)); + menu.add(new Separator()); + + menu.add(getBookmarkItem()); + menu.add(getTaskItem()); + menu.add(new GroupMarker(IWorkbenchActionConstants.ADD_EXT)); + + menu.add(new GroupMarker(IWorkbenchActionConstants.EDIT_END)); + menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); + return menu; + } + + /** + * Creates and returns the Window menu. + */ + private MenuManager createWindowMenu() { + MenuManager menu = new MenuManager(Messages.WindowMenuName, IWorkbenchActionConstants.M_WINDOW); + + addPerspectiveActions(menu); + Separator sep = new Separator(IWorkbenchActionConstants.MB_ADDITIONS); + sep.setVisible(!Util.isMac()); + menu.add(sep); + + // See the comment for quit in createFileMenu + ActionContributionItem openPreferencesItem = new ActionContributionItem(openPreferencesAction); + openPreferencesItem.setVisible(!Util.isMac()); + menu.add(openPreferencesItem); + + menu.add(ContributionItemFactory.OPEN_WINDOWS.create(getWindow())); + return menu; + } + + /** + * Creates and returns the Help menu. + */ + private MenuManager createHelpMenu() { + MenuManager menu = new MenuManager(Messages.HelpMenuName, IWorkbenchActionConstants.M_HELP); + menu.add(new GroupMarker("group.intro.ext")); //$NON-NLS-1$ + menu.add(new GroupMarker("group.main")); //$NON-NLS-1$ + menu.add(helpContentsAction); + menu.add(helpSearchAction); + menu.add(dynamicHelpAction); + menu.add(new GroupMarker("group.assist")); //$NON-NLS-1$ + // HELP_START should really be the first item, but it was after + // quickStartAction and tipsAndTricksAction in 2.1. + menu.add(new GroupMarker(IWorkbenchActionConstants.HELP_START)); + menu.add(new GroupMarker("group.main.ext")); //$NON-NLS-1$ + menu.add(new GroupMarker("group.tutorials")); //$NON-NLS-1$ + menu.add(new GroupMarker("group.tools")); //$NON-NLS-1$ + menu.add(new GroupMarker("group.updates")); //$NON-NLS-1$ + menu.add(new GroupMarker(IWorkbenchActionConstants.HELP_END)); + menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); + // about should always be at the bottom + menu.add(new Separator("group.about")); //$NON-NLS-1$ + + ActionContributionItem aboutItem = new ActionContributionItem(aboutAction); + aboutItem.setVisible(!Util.isMac()); + menu.add(aboutItem); + menu.add(new GroupMarker("group.about.ext")); //$NON-NLS-1$ + return menu; + } + + /** + * Adds the perspective actions to the specified menu. + */ + private void addPerspectiveActions(MenuManager menu) { + { + MenuManager showViewMenuMgr = new MenuManager(Messages.ShowViewMenuName, "showView"); //$NON-NLS-1$ + IContributionItem showViewMenu = ContributionItemFactory.VIEWS_SHORTLIST.create(getWindow()); + showViewMenuMgr.add(showViewMenu); + menu.add(showViewMenuMgr); + } + menu.add(new Separator()); + menu.add(editActionSetAction); + menu.add(getResetPerspectiveItem()); + } + + private IContributionItem getItem(String actionId, String commandId, String image, String disabledImage, + String label, String tooltip, String helpContextId) { + ISharedImages sharedImages = getWindow().getWorkbench().getSharedImages(); + + IActionCommandMappingService acms = getWindow().getService(IActionCommandMappingService.class); + acms.map(actionId, commandId); + + CommandContributionItemParameter commandParm = new CommandContributionItemParameter(getWindow(), actionId, + commandId, null, sharedImages.getImageDescriptor(image), sharedImages.getImageDescriptor(disabledImage), + null, label, null, tooltip, CommandContributionItem.STYLE_PUSH, null, false); + return new CommandContributionItem(commandParm); + } + + private IContributionItem getResetPerspectiveItem() { + return getItem(ActionFactory.RESET_PERSPECTIVE.getId(), ActionFactory.RESET_PERSPECTIVE.getCommandId(), null, + null, Messages.ResetPerspective_text, Messages.ResetPerspective_toolTip, + IWorkbenchHelpContextIds.RESET_PERSPECTIVE_ACTION); + } + + private IContributionItem getCutItem() { + return getItem(ActionFactory.CUT.getId(), ActionFactory.CUT.getCommandId(), ISharedImages.IMG_TOOL_CUT, + ISharedImages.IMG_TOOL_CUT_DISABLED, Messages.Workbench_cut, Messages.Workbench_cutToolTip, null); + } + + private IContributionItem getCopyItem() { + return getItem(ActionFactory.COPY.getId(), ActionFactory.COPY.getCommandId(), ISharedImages.IMG_TOOL_COPY, + ISharedImages.IMG_TOOL_COPY_DISABLED, Messages.Workbench_copy, Messages.Workbench_copyToolTip, null); + } + + private IContributionItem getPasteItem() { + return getItem(ActionFactory.PASTE.getId(), ActionFactory.PASTE.getCommandId(), ISharedImages.IMG_TOOL_PASTE, + ISharedImages.IMG_TOOL_PASTE_DISABLED, Messages.Workbench_paste, Messages.Workbench_pasteToolTip, null); + } + + private IContributionItem getSelectAllItem() { + return getItem(ActionFactory.SELECT_ALL.getId(), ActionFactory.SELECT_ALL.getCommandId(), null, null, + Messages.Workbench_selectAll, Messages.Workbench_selectAllToolTip, null); + } + + private IContributionItem getFindItem() { + return getItem(ActionFactory.FIND.getId(), ActionFactory.FIND.getCommandId(), null, null, + Messages.Workbench_findReplace, Messages.Workbench_findReplaceToolTip, null); + } + + private IContributionItem getBookmarkItem() { + return getItem(IDEActionFactory.BOOKMARK.getId(), IDEActionFactory.BOOKMARK.getCommandId(), null, null, + Messages.Workbench_addBookmark, Messages.Workbench_addBookmarkToolTip, null); + } + + private IContributionItem getTaskItem() { + return getItem(IDEActionFactory.ADD_TASK.getId(), IDEActionFactory.ADD_TASK.getCommandId(), null, null, + Messages.Workbench_addTask, Messages.Workbench_addTaskToolTip, null); + } + + private IContributionItem getDeleteItem() { + return getItem(ActionFactory.DELETE.getId(), ActionFactory.DELETE.getCommandId(), ISharedImages.IMG_TOOL_DELETE, + ISharedImages.IMG_TOOL_DELETE_DISABLED, Messages.Workbench_delete, Messages.Workbench_deleteToolTip, + IWorkbenchHelpContextIds.DELETE_RETARGET_ACTION); + } + + private static class WorkbenchCommandAction extends CommandAction implements IWorkbenchAction { + /** + * @param commandIdIn + * @param window + */ + public WorkbenchCommandAction(String commandIdIn, IWorkbenchWindow window) { + super(window, commandIdIn); + } + } + + /** + * Workbench action (id: "corefile", commandId: "org.eclipse.cdt.debug.application.command.debugCore"): + * Debug an executable with a core file. This action maintains its enablement state. + */ + private static final ActionFactory COREFILE = new ActionFactory("corefile", //$NON-NLS-1$ + COREFILE_COMMAND_ID) { + + /* (non-Javadoc) + * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow) + */ + @Override + public IWorkbenchAction create(IWorkbenchWindow window) { + if (window == null) { + throw new IllegalArgumentException(); + } + WorkbenchCommandAction action = new WorkbenchCommandAction(getCommandId(), window); + action.setId(getId()); + action.setText(Messages.CoreFileMenuName); + action.setToolTipText(Messages.CoreFile_toolTip); + return action; + } + }; + + /** + * Workbench action (id: "newexecutable", commandId: "org.eclipse.cdt.debug.application.command.debugNewExecutable"): + * Debug an executable. This action maintains its enablement state. + */ + private static final ActionFactory NEW_EXECUTABLE = new ActionFactory("newexecutable", //$NON-NLS-1$ + NEW_EXECUTABLE_COMMAND_ID) { + + /* (non-Javadoc) + * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow) + */ + @Override + public IWorkbenchAction create(IWorkbenchWindow window) { + if (window == null) { + throw new IllegalArgumentException(); + } + WorkbenchCommandAction action = new WorkbenchCommandAction(getCommandId(), window); + action.setId(getId()); + action.setText(Messages.NewExecutableMenuName); + action.setToolTipText(Messages.NewExecutable_toolTip); + return action; + } + }; + + /** + * Workbench action (id: "remoteexecutable", commandId: "org.eclipse.cdt.debug.application.command.debugRemoteExecutable"): + * Debug a remote executable. This action maintains its enablement state. + */ + private static final ActionFactory REMOTE_EXECUTABLE = new ActionFactory("remoteexecutable", //$NON-NLS-1$ + REMOTE_EXECUTABLE_COMMAND_ID) { + + /* (non-Javadoc) + * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow) + */ + @Override + public IWorkbenchAction create(IWorkbenchWindow window) { + if (window == null) { + throw new IllegalArgumentException(); + } + WorkbenchCommandAction action = new WorkbenchCommandAction(getCommandId(), window); + action.setId(getId()); + action.setText(Messages.RemoteExecutableMenuName); + action.setToolTipText(Messages.RemoteExecutable_toolTip); + return action; + } + }; + + /** + * Workbench action (id: "attachexecutable", commandId: "org.eclipse.cdt.debug.application.command.debugAttachedExecutable"): + * Attach and debug an existing executable. This action maintains its enablement state. + */ + private static final ActionFactory ATTACH_EXECUTABLE = new ActionFactory("attachexecutable", //$NON-NLS-1$ + ATTACH_EXECUTABLE_COMMAND_ID) { + + /* (non-Javadoc) + * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow) + */ + @Override + public IWorkbenchAction create(IWorkbenchWindow window) { + if (window == null) { + throw new IllegalArgumentException(); + } + WorkbenchCommandAction action = new WorkbenchCommandAction(getCommandId(), window); + action.setId(getId()); + action.setText(Messages.AttachedExecutableMenuName); + action.setToolTipText(Messages.AttachedExecutable_toolTip); + return action; + } + }; } diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationWorkbenchAdvisor.java b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationWorkbenchAdvisor.java index 5bddf2c6ad3..e98171a2811 100644 --- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationWorkbenchAdvisor.java +++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationWorkbenchAdvisor.java @@ -27,11 +27,11 @@ public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor { super.initialize(configurer); configurer.setSaveAndRestore(false); } - - @Override + + @Override public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { - return new ApplicationWorkbenchWindowAdvisor(configurer); - } + return new ApplicationWorkbenchWindowAdvisor(configurer); + } @Override public String getInitialWindowPerspectiveId() { diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationWorkbenchWindowAdvisor.java b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationWorkbenchWindowAdvisor.java index 56d07a0c04b..21a5cead23e 100644 --- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationWorkbenchWindowAdvisor.java +++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationWorkbenchWindowAdvisor.java @@ -68,20 +68,20 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { super(); } } - - public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { - super(configurer); - } - @Override + public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { + super(configurer); + } + + @Override public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) { - return new ApplicationActionBarAdvisor(configurer); - } - - @Override + return new ApplicationActionBarAdvisor(configurer); + } + + @Override public void preWindowOpen() { - IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); -// configurer.setInitialSize(new Point(400, 300)); + IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); + // configurer.setInitialSize(new Point(400, 300)); configurer.setShowCoolBar(true); configurer.setShowStatusLine(true); configurer.setShowMenuBar(true); @@ -105,7 +105,7 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { // Private method to search for executable names on PATH private String findExecutable(String input) { String result = input; - + Path x = new Path(input); try { if (!x.isAbsolute() && x.segmentCount() == 1) { @@ -132,13 +132,13 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { } return result; } - + private void appendChar(StringBuilder builder, int repeat, char c) { for (int i = 0; i < repeat; i++) { builder.append(c); } } - + private boolean needsEscaping(String input) { for (int i = 0; i < input.length(); i++) { char c = input.charAt(i); @@ -148,7 +148,7 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { } return false; } - + private String escapeArg(String arg) { if (!arg.isEmpty() && !needsEscaping(arg)) { return arg; @@ -161,7 +161,7 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { i++; numberOfBackslashes++; } - + if (i == arg.length()) { appendChar(buffer, numberOfBackslashes * 2, '\\'); break; @@ -176,12 +176,11 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { buffer.append('"'); return buffer.toString(); } - + public class PostWindowCreateRunnable implements IRunnableWithProgress { @Override - public void run(IProgressMonitor monitor) - throws InvocationTargetException, InterruptedException { + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask(Messages.InitializingDebugger, 10); boolean attachExecutable = false; String executable = null; @@ -203,32 +202,30 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { ++i; if (i < args.length) buildLog = args[i]; - } - else if ("-a".equals(args[i])) { //$NON-NLS-1$ + } else if ("-a".equals(args[i])) { //$NON-NLS-1$ attachExecutable = true; // Make sure 'executable' is still null in case we are dealing with a remote // session that is also an attach, as the -r flag could have been set first executable = null; - + // Check for optional pid if (i + 1 < args.length) { - if (!args[i+1].startsWith("-")) { //$NON-NLS-1$ + if (!args[i + 1].startsWith("-")) { //$NON-NLS-1$ ++i; pid = args[i]; } } - } - else if ("-c".equals(args[i])) { //$NON-NLS-1$ + } else if ("-c".equals(args[i])) { //$NON-NLS-1$ ++i; corefile = ""; //$NON-NLS-1$ executable = ""; //$NON-NLS-1$ if (i < args.length) corefile = args[i]; - } - else if ("-r".equals(args[i])) { //$NON-NLS-1$ + } else if ("-r".equals(args[i])) { //$NON-NLS-1$ ++i; remoteAddress = ""; //$NON-NLS-1$ - if (!attachExecutable) executable = ""; //$NON-NLS-1$ + if (!attachExecutable) + executable = ""; //$NON-NLS-1$ if (i < args.length) { String[] params = args[i].split(":"); //$NON-NLS-1$ if (params.length == 2) { @@ -236,8 +233,7 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { remotePort = params[1]; } } - } - else if ("-e".equals(args[i])) { //$NON-NLS-1$ + } else if ("-e".equals(args[i])) { //$NON-NLS-1$ ++i; if (i < args.length) executable = findExecutable(args[i]); @@ -264,7 +260,7 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { corefile = coreFile.getCanonicalPath(); if (executableFile == null || !executableFile.exists() || !coreFile.exists()) { final CoreFileInfo info = new CoreFileInfo("", "", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ $NON-NLS-2$ $NON-NLS-3$ - final IStatus errorStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, + final IStatus errorStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, Messages.GdbDebugNewExecutableCommand_Binary_file_does_not_exist, null); final String executablePath = executable; final String coreFilePath = corefile; @@ -282,8 +278,7 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { info.setHostPath(info2.getHostPath()); info.setCoreFilePath(info2.getCoreFilePath()); } else { - ErrorDialog.openError(null, - Messages.DebuggerInitializingProblem, null, errorStatus, + ErrorDialog.openError(null, Messages.DebuggerInitializingProblem, null, errorStatus, IStatus.ERROR | IStatus.WARNING); } } @@ -304,39 +299,39 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { executableFile = new File(executable); executable = executableFile.getCanonicalPath(); } - + Integer port = null; try { port = Integer.parseInt(remotePort); } catch (NumberFormatException e) { port = null; } - - if ((!attachExecutable && (executableFile == null || !executableFile.exists())) || - remoteAddress.length() == 0 || port == null) { + + if ((!attachExecutable && (executableFile == null || !executableFile.exists())) + || remoteAddress.length() == 0 || port == null) { final RemoteExecutableInfo[] info = new RemoteExecutableInfo[1]; - final IStatus errorStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, + final IStatus errorStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, Messages.GdbDebugNewExecutableCommand_Binary_file_does_not_exist, null); final String executablePath = executable; final String addressStr = remoteAddress; final String portStr = remotePort; final String buildLogPath = buildLog; final boolean attach = attachExecutable; - + Display.getDefault().syncExec(new Runnable() { @Override public void run() { - RemoteExecutableDialog dialog = new RemoteExecutableDialog(getWindowConfigurer().getWindow().getShell(), - executablePath, buildLogPath, addressStr, portStr, attach); + RemoteExecutableDialog dialog = new RemoteExecutableDialog( + getWindowConfigurer().getWindow().getShell(), executablePath, buildLogPath, + addressStr, portStr, attach); dialog.setBlockOnOpen(true); if (dialog.open() == IDialogConstants.OK_ID) { info[0] = dialog.getExecutableInfo(); } else { info[0] = null; - ErrorDialog.openError(null, - Messages.DebuggerInitializingProblem, null, errorStatus, + ErrorDialog.openError(null, Messages.DebuggerInitializingProblem, null, errorStatus, IStatus.ERROR | IStatus.WARNING); } } @@ -363,7 +358,7 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { } if (!executableFile.exists() || (buildLogFile != null && !buildLogFile.exists())) { final NewExecutableInfo info = new NewExecutableInfo("", "", "", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ $NON-NLS-2$ $NON-NLS-3$ - final IStatus errorStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, + final IStatus errorStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, Messages.GdbDebugNewExecutableCommand_Binary_file_does_not_exist, null); final String executablePath = executable; final String executableArgs = arguments; @@ -374,16 +369,16 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { @Override public void run() { - NewExecutableDialog dialog = new NewExecutableDialog(getWindowConfigurer().getWindow().getShell(), - 0, executablePath, buildLogPath, executableArgs); + NewExecutableDialog dialog = new NewExecutableDialog( + getWindowConfigurer().getWindow().getShell(), 0, executablePath, buildLogPath, + executableArgs); dialog.setBlockOnOpen(true); if (dialog.open() == IDialogConstants.OK_ID) { NewExecutableInfo info2 = dialog.getExecutableInfo(); info.setHostPath(info2.getHostPath()); info.setArguments(info2.getArguments()); } else { - ErrorDialog.openError(null, - Messages.DebuggerInitializingProblem, null, errorStatus, + ErrorDialog.openError(null, Messages.DebuggerInitializingProblem, null, errorStatus, IStatus.ERROR | IStatus.WARNING); } } @@ -399,20 +394,23 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { } } monitor.worked(1); - if (remoteAddress != null && remoteAddress.length() > 0 && - remotePort != null && remotePort.length() > 0) { - config = DebugRemoteExecutable.createLaunchConfig(monitor, buildLog, executable, remoteAddress, remotePort, attachExecutable); + if (remoteAddress != null && remoteAddress.length() > 0 && remotePort != null + && remotePort.length() > 0) { + config = DebugRemoteExecutable.createLaunchConfig(monitor, buildLog, executable, remoteAddress, + remotePort, attachExecutable); } else if (attachExecutable) { config = DebugAttachedExecutable.createLaunchConfig(monitor, buildLog, pid); } else if (corefile != null && corefile.length() > 0) { config = DebugCoreFile.createLaunchConfig(monitor, buildLog, executable, corefile); } else if (executable != null && executable.length() > 0) { - config = DebugExecutable.importAndCreateLaunchConfig(monitor, executable, buildLog, arguments, true); + config = DebugExecutable.importAndCreateLaunchConfig(monitor, executable, buildLog, arguments, + true); } else { // No executable specified, look for last launch // and offer that to the end-user. monitor.subTask(Messages.RestorePreviousLaunch); - String memento = ResourcesPlugin.getWorkspace().getRoot().getPersistentProperty(new QualifiedName(STANDALONE_QUALIFIER, LAST_LAUNCH)); + String memento = ResourcesPlugin.getWorkspace().getRoot() + .getPersistentProperty(new QualifiedName(STANDALONE_QUALIFIER, LAST_LAUNCH)); if (memento != null) config = DebugExecutable.getLaunchManager().getLaunchConfiguration(memento); String oldExecutable = ""; //$NON-NLS-1$ @@ -424,7 +422,7 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { oldBuildLog = config.getAttribute(ICDTStandaloneDebugLaunchConstants.BUILD_LOG_LOCATION, ""); //$NON-NLS-1$ } final NewExecutableInfo info = new NewExecutableInfo("", "", "", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ $NON-NLS-2$ $NON-NLS-3$ - final IStatus errorStatus = new Status(IStatus.WARNING, Activator.PLUGIN_ID, 0, + final IStatus errorStatus = new Status(IStatus.WARNING, Activator.PLUGIN_ID, 0, Messages.GdbDebugNewExecutableCommand_Binary_file_does_not_exist, null); final String executablePath = oldExecutable; final String executableArgs = oldArguments; @@ -436,8 +434,9 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { @Override public void run() { - NewExecutableDialog dialog = new NewExecutableDialog(getWindowConfigurer().getWindow().getShell(), - 0, executablePath, buildLogPath, executableArgs); + NewExecutableDialog dialog = new NewExecutableDialog( + getWindowConfigurer().getWindow().getShell(), 0, executablePath, buildLogPath, + executableArgs); dialog.setBlockOnOpen(true); if (dialog.open() == IDialogConstants.OK_ID) { NewExecutableInfo info2 = dialog.getExecutableInfo(); @@ -445,8 +444,7 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { info.setArguments(info2.getArguments()); info.setBuildLog(info2.getBuildLog()); } else { - ErrorDialog.openError(null, - Messages.DebuggerInitializingProblem, null, errorStatus, + ErrorDialog.openError(null, Messages.DebuggerInitializingProblem, null, errorStatus, IStatus.ERROR | IStatus.WARNING); } } @@ -464,14 +462,12 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { // the executable, we need to create a new configuration // and remove artifacts from the old one. if (config == null || !executable.equals(oldExecutable)) - config = DebugExecutable.importAndCreateLaunchConfig(monitor, executable, buildLog, arguments, true); + config = DebugExecutable.importAndCreateLaunchConfig(monitor, executable, buildLog, arguments, + true); ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy(); - wc.setAttribute(ICDTStandaloneDebugLaunchConstants.BUILD_LOG_LOCATION, - buildLog); + wc.setAttribute(ICDTStandaloneDebugLaunchConstants.BUILD_LOG_LOCATION, buildLog); if (arguments != null) - wc.setAttribute( - ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, - arguments); + wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, arguments); config = wc.doSave(); monitor.worked(7); @@ -503,7 +499,7 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { try { LaunchJobs.getLaunchJob().join(); } catch (InterruptedException e) { - IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, + IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, Messages.LaunchInterruptedError, e); ResourcesPlugin.getPlugin().getLog().log(status); } @@ -521,7 +517,7 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { monitor.done(); } } - + } @Override @@ -534,18 +530,14 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { private void disconnectFromWorkspace() { // save the workspace - final MultiStatus status = new MultiStatus( - Activator.PLUGIN_ID, 1, - Messages.ProblemSavingWorkbench, null); + final MultiStatus status = new MultiStatus(Activator.PLUGIN_ID, 1, Messages.ProblemSavingWorkbench, null); try { - final ProgressMonitorDialog p = new ProgressMonitorDialog( - null); + final ProgressMonitorDialog p = new ProgressMonitorDialog(null); IRunnableWithProgress runnable = new IRunnableWithProgress() { @Override - public void run(IProgressMonitor monitor) { + public void run(IProgressMonitor monitor) { try { - status.merge(ResourcesPlugin - .getWorkspace().save(true, monitor)); + status.merge(ResourcesPlugin.getWorkspace().save(true, monitor)); } catch (CoreException e) { status.merge(e.getStatus()); } @@ -553,24 +545,18 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { }; p.run(true, false, runnable); } catch (InvocationTargetException e) { - status.merge(new Status(IStatus.ERROR, - Activator.PLUGIN_ID, 1, - Messages.InternalError, - e.getTargetException())); + status.merge( + new Status(IStatus.ERROR, Activator.PLUGIN_ID, 1, Messages.InternalError, e.getTargetException())); } catch (InterruptedException e) { - status.merge(new Status(IStatus.ERROR, - Activator.PLUGIN_ID, 1, - Messages.InternalError, e)); + status.merge(new Status(IStatus.ERROR, Activator.PLUGIN_ID, 1, Messages.InternalError, e)); } - ErrorDialog.openError(null, - Messages.ProblemsSavingWorkspace, null, status, - IStatus.ERROR | IStatus.WARNING); + ErrorDialog.openError(null, Messages.ProblemsSavingWorkspace, null, status, IStatus.ERROR | IStatus.WARNING); if (!status.isOK()) { ResourcesPlugin.getPlugin().getLog().log(status); } - } + } } diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/CoreFileDialog.java b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/CoreFileDialog.java index 43bb8e8cc9c..86880ea74d3 100644 --- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/CoreFileDialog.java +++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/CoreFileDialog.java @@ -41,136 +41,135 @@ public class CoreFileDialog extends TitleAreaDialog { private int fFlags = 0; private CoreFileInfo fInfo = null; - + private Text fHostBinaryText; private Text fTargetBinaryText; private Text fCoreFileText; - + private final String fHostBinary; private final String fCoreFile; - - public CoreFileDialog (Shell parentShell) { + + public CoreFileDialog(Shell parentShell) { this(parentShell, 0); } - - public CoreFileDialog( Shell parentShell, int flags ) { + + public CoreFileDialog(Shell parentShell, int flags) { this(parentShell, flags, null, null); } - public CoreFileDialog( Shell parentShell, int flags, String hostBinary, String coreFile) { - super( parentShell ); - setShellStyle( getShellStyle() | SWT.RESIZE ); + public CoreFileDialog(Shell parentShell, int flags, String hostBinary, String coreFile) { + super(parentShell); + setShellStyle(getShellStyle() | SWT.RESIZE); fFlags = flags; fHostBinary = hostBinary; fCoreFile = coreFile; } @Override - protected Control createContents( Composite parent ) { - Control control = super.createContents( parent ); + protected Control createContents(Composite parent) { + Control control = super.createContents(parent); validate(); return control; } @Override - protected Control createDialogArea( Composite parent ) { + protected Control createDialogArea(Composite parent) { boolean remote = (fFlags & REMOTE) > 0; - getShell().setText( Messages.GdbDebugCoreFileCommand_Debug_Core_File ); - setTitle( Messages.GdbDebugNewExecutableCommand_Select_Binary ); - String message = ( remote ) ? - Messages.GdbDebugNewExecutableCommand_Select_binaries_on_host_and_target : - Messages.GdbDebugCoreFileCommand_Select_binary_and_specify_corefile; - setMessage( message ); - - Composite control = (Composite)super.createDialogArea( parent ); - Composite comp = new Composite( control, SWT.NONE ); - GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true ); - GridLayout layout = new GridLayout( 3, false ); - comp.setLayout( layout ); - comp.setLayoutData( gd ); - - new Label( comp, SWT.None ).setText( remote ? Messages.GdbDebugNewExecutableCommand_Binary_on_host : Messages.GdbDebugExecutableCommand_Binary ); - fHostBinaryText = new Text( comp, SWT.BORDER ); + getShell().setText(Messages.GdbDebugCoreFileCommand_Debug_Core_File); + setTitle(Messages.GdbDebugNewExecutableCommand_Select_Binary); + String message = (remote) ? Messages.GdbDebugNewExecutableCommand_Select_binaries_on_host_and_target + : Messages.GdbDebugCoreFileCommand_Select_binary_and_specify_corefile; + setMessage(message); + + Composite control = (Composite) super.createDialogArea(parent); + Composite comp = new Composite(control, SWT.NONE); + GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); + GridLayout layout = new GridLayout(3, false); + comp.setLayout(layout); + comp.setLayoutData(gd); + + new Label(comp, SWT.None).setText(remote ? Messages.GdbDebugNewExecutableCommand_Binary_on_host + : Messages.GdbDebugExecutableCommand_Binary); + fHostBinaryText = new Text(comp, SWT.BORDER); if (fHostBinary != null) fHostBinaryText.setText(fHostBinary); - fHostBinaryText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) ); - fHostBinaryText.addModifyListener( new ModifyListener() { - + fHostBinaryText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + fHostBinaryText.addModifyListener(new ModifyListener() { + @Override - public void modifyText( ModifyEvent e ) { + public void modifyText(ModifyEvent e) { validate(); } - } ); - Button browseButton = new Button( comp, SWT.PUSH ); - browseButton.setText( Messages.GdbDebugExecutableCommand_Browse ); - browseButton.setFont( JFaceResources.getDialogFont() ); - setButtonLayoutData( browseButton ); - browseButton.addSelectionListener( new SelectionAdapter() { + }); + Button browseButton = new Button(comp, SWT.PUSH); + browseButton.setText(Messages.GdbDebugExecutableCommand_Browse); + browseButton.setFont(JFaceResources.getDialogFont()); + setButtonLayoutData(browseButton); + browseButton.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected( SelectionEvent e ) { - FileDialog dialog = new FileDialog( getShell() ); - dialog.setFileName( fHostBinaryText.getText() ); + public void widgetSelected(SelectionEvent e) { + FileDialog dialog = new FileDialog(getShell()); + dialog.setFileName(fHostBinaryText.getText()); String result = dialog.open(); - if ( result != null ) { - fHostBinaryText.setText( result ); + if (result != null) { + fHostBinaryText.setText(result); } } - } ); - - if ( remote ) { - new Label( comp, SWT.None ).setText( Messages.GdbDebugNewExecutableCommand_Binary_on_target ); - fTargetBinaryText = new Text( comp, SWT.BORDER ); - fTargetBinaryText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false, 2, 1 ) ); - fTargetBinaryText.addModifyListener( new ModifyListener() { - + }); + + if (remote) { + new Label(comp, SWT.None).setText(Messages.GdbDebugNewExecutableCommand_Binary_on_target); + fTargetBinaryText = new Text(comp, SWT.BORDER); + fTargetBinaryText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); + fTargetBinaryText.addModifyListener(new ModifyListener() { + @Override - public void modifyText( ModifyEvent e ) { + public void modifyText(ModifyEvent e) { validate(); } - } ); + }); } - - new Label( comp, SWT.None ).setText( Messages.GdbDebugCoreFileCommand_CoreFile ); - fCoreFileText = new Text( comp, SWT.BORDER ); + new Label(comp, SWT.None).setText(Messages.GdbDebugCoreFileCommand_CoreFile); + fCoreFileText = new Text(comp, SWT.BORDER); if (fCoreFile != null) fCoreFileText.setText(fCoreFile); - fCoreFileText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) ); - fCoreFileText.addModifyListener( new ModifyListener() { - + fCoreFileText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + fCoreFileText.addModifyListener(new ModifyListener() { + @Override - public void modifyText( ModifyEvent e ) { + public void modifyText(ModifyEvent e) { validate(); } - } ); - - Button browseButton2 = new Button( comp, SWT.PUSH ); - browseButton2.setText( Messages.GdbDebugExecutableCommand_Browse ); - browseButton2.setFont( JFaceResources.getDialogFont() ); - setButtonLayoutData( browseButton2 ); - browseButton2.addSelectionListener( new SelectionAdapter() { + }); + + Button browseButton2 = new Button(comp, SWT.PUSH); + browseButton2.setText(Messages.GdbDebugExecutableCommand_Browse); + browseButton2.setFont(JFaceResources.getDialogFont()); + setButtonLayoutData(browseButton2); + browseButton2.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected( SelectionEvent e ) { - FileDialog dialog = new FileDialog( getShell() ); - dialog.setFileName( fCoreFileText.getText() ); + public void widgetSelected(SelectionEvent e) { + FileDialog dialog = new FileDialog(getShell()); + dialog.setFileName(fCoreFileText.getText()); String result = dialog.open(); - if ( result != null ) { - fCoreFileText.setText( result ); + if (result != null) { + fCoreFileText.setText(result); } } - } ); - + }); + return control; } @Override protected void okPressed() { - String targetPath = ( fTargetBinaryText != null ) ? fTargetBinaryText.getText().trim() : null; + String targetPath = (fTargetBinaryText != null) ? fTargetBinaryText.getText().trim() : null; String coreFile = fCoreFileText.getText().trim(); - fInfo = new CoreFileInfo( fHostBinaryText.getText().trim(), targetPath, coreFile ); + fInfo = new CoreFileInfo(fHostBinaryText.getText().trim(), targetPath, coreFile); super.okPressed(); } @@ -183,47 +182,39 @@ public class CoreFileDialog extends TitleAreaDialog { StringBuilder sb = new StringBuilder(); String hostBinary = fHostBinaryText.getText().trim(); String corefile = fCoreFileText.getText(); - if ( hostBinary.isEmpty() ) { - sb.append( ( remote ) ? - Messages.GdbDebugNewExecutableCommand_Host_binary_must_be_specified : - Messages.GdbDebugNewExecutableCommand_Binary_must_be_specified ); - } - else { - File file = new File( hostBinary ); - if ( !file.exists() ) { - sb.append( ( remote ) ? - Messages.GdbDebugNewExecutableCommand_Host_binary_file_does_not_exist : - Messages.GdbDebugNewExecutableCommand_Binary_file_does_not_exist ); + if (hostBinary.isEmpty()) { + sb.append((remote) ? Messages.GdbDebugNewExecutableCommand_Host_binary_must_be_specified + : Messages.GdbDebugNewExecutableCommand_Binary_must_be_specified); + } else { + File file = new File(hostBinary); + if (!file.exists()) { + sb.append((remote) ? Messages.GdbDebugNewExecutableCommand_Host_binary_file_does_not_exist + : Messages.GdbDebugNewExecutableCommand_Binary_file_does_not_exist); + } else if (file.isDirectory()) { + sb.append((remote) ? Messages.GdbDebugNewExecutableCommand_Invalid_host_binary + : Messages.GdbDebugNewExecutableCommand_Invalid_binary); } - else if ( file.isDirectory() ) { - sb.append( ( remote ) ? - Messages.GdbDebugNewExecutableCommand_Invalid_host_binary : - Messages.GdbDebugNewExecutableCommand_Invalid_binary ); - } - } - if ( sb.length() == 0 && corefile.isEmpty() ) { - sb.append( ( remote ) ? - Messages.GdbDebugCoreFileCommand_Core_file_must_be_specified : - Messages.GdbDebugCoreFileCommand_Core_file_must_be_specified ); } - else if (sb.length() == 0 && !corefile.isEmpty()) { - File file = new File( corefile ); - if ( !file.exists() ) { - sb.append( Messages.GdbDebugCoreFileCommand_Core_file_does_not_exist ); - } - else if ( file.isDirectory() ) { - sb.append( Messages.GdbDebugCoreFileCommand_Invalid_core_file ); + if (sb.length() == 0 && corefile.isEmpty()) { + sb.append((remote) ? Messages.GdbDebugCoreFileCommand_Core_file_must_be_specified + : Messages.GdbDebugCoreFileCommand_Core_file_must_be_specified); + } else if (sb.length() == 0 && !corefile.isEmpty()) { + File file = new File(corefile); + if (!file.exists()) { + sb.append(Messages.GdbDebugCoreFileCommand_Core_file_does_not_exist); + } else if (file.isDirectory()) { + sb.append(Messages.GdbDebugCoreFileCommand_Invalid_core_file); } } if (sb.length() == 0 && fTargetBinaryText != null) { - if ( fTargetBinaryText.getText().trim().length() == 0 ) { - if ( sb.length() != 0 ) { - sb.append( "\n " ); //$NON-NLS-1$ + if (fTargetBinaryText.getText().trim().length() == 0) { + if (sb.length() != 0) { + sb.append("\n "); //$NON-NLS-1$ } - sb.append( Messages.GdbDebugNewExecutableCommand_Binary_on_target_must_be_specified ); + sb.append(Messages.GdbDebugNewExecutableCommand_Binary_on_target_must_be_specified); } } - setErrorMessage( ( sb.length() != 0 ) ? sb.toString() : null ); - getButton( IDialogConstants.OK_ID ).setEnabled( getErrorMessage() == null ); + setErrorMessage((sb.length() != 0) ? sb.toString() : null); + getButton(IDialogConstants.OK_ID).setEnabled(getErrorMessage() == null); } }
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/CoreFileInfo.java b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/CoreFileInfo.java index af03bc8ae9a..3ed46519d70 100644 --- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/CoreFileInfo.java +++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/CoreFileInfo.java @@ -16,8 +16,8 @@ package org.eclipse.cdt.debug.application; /** - * This class provides information required to start - * debugging an executable. + * This class provides information required to start + * debugging an executable. */ public class CoreFileInfo { private String fHostPath; @@ -30,23 +30,23 @@ public class CoreFileInfo { fTargetPath = targetPath; fCoreFilePath = coreFilePath; } - + /** * Returns the path of the executable on the host */ public String getHostPath() { return fHostPath; } - + /** * Sets the path of the executable on the host */ public void setHostPath(String path) { fHostPath = path; } - + /** - * For remote sessions returns the path of the executable + * For remote sessions returns the path of the executable * on the target. Otherwise returns null. */ public String getTargetPath() { @@ -59,23 +59,23 @@ public class CoreFileInfo { public void setTargetPath(String path) { fTargetPath = path; } - + /** * Get the build log path. - * + * * @return the build log path or null */ public String getCoreFilePath() { return fCoreFilePath; } - + /** * Sets the build log path. - * + * * @param path */ public void setCoreFilePath(String path) { fCoreFilePath = path; } - + }
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/GCCCompileOptionsParser.java b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/GCCCompileOptionsParser.java index 697336d601b..673efa45286 100644 --- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/GCCCompileOptionsParser.java +++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/GCCCompileOptionsParser.java @@ -18,7 +18,7 @@ import org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildComman public class GCCCompileOptionsParser extends GCCBuildCommandParser { private String currentResourceName; - + public GCCCompileOptionsParser() { super(); } @@ -35,7 +35,7 @@ public class GCCCompileOptionsParser extends GCCBuildCommandParser { protected String parseResourceName(String line) { return getCurrentResourceName(); } - + @Override public GCCCompileOptionsParser cloneShallow() throws CloneNotSupportedException { return (GCCCompileOptionsParser) super.cloneShallow(); diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/Messages.java b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/Messages.java index ae68e183f0c..77be7c7cdf2 100644 --- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/Messages.java +++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/Messages.java @@ -37,7 +37,7 @@ public class Messages extends NLS { public static String LaunchInterruptedError; public static String LaunchMissingError; public static String DebuggerInitializingProblem; - + public static String GdbDebugNewExecutableCommand_Arguments; public static String GdbDebugExecutableCommand_Binary; public static String GdbDebugExecutableCommand_Binary_Optional; @@ -108,13 +108,11 @@ public class Messages extends NLS { public static String AttachedExecutable_toolTip; public static String AttachedExecutableMenuName; public static String Application_WorkspaceRootNotExistError; - public static String Application_WorkspaceCreationError ; + public static String Application_WorkspaceCreationError; public static String Application_WorkspaceRootPermissionError; public static String Application_WorkspaceInUseError; - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle - .getBundle(BUNDLE_NAME); - + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); private Messages() { } diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/NewExecutableDialog.java b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/NewExecutableDialog.java index 07c41661f28..74718023852 100644 --- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/NewExecutableDialog.java +++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/NewExecutableDialog.java @@ -41,27 +41,27 @@ public class NewExecutableDialog extends TitleAreaDialog { private int fFlags = 0; private NewExecutableInfo fInfo = null; - + private Text fHostBinaryText; private Text fTargetBinaryText; private Text fBuildLogText; private Text fArgumentsText; - + private final String fHostBinary; private final String fBuildLog; private final String fArgs; - public NewExecutableDialog (Shell parentShell) { + public NewExecutableDialog(Shell parentShell) { this(parentShell, 0); } - - public NewExecutableDialog( Shell parentShell, int flags ) { + + public NewExecutableDialog(Shell parentShell, int flags) { this(parentShell, flags, null, null, null); } - public NewExecutableDialog( Shell parentShell, int flags, String hostBinary, String buildLog, String args) { - super( parentShell ); - setShellStyle( getShellStyle() | SWT.RESIZE ); + public NewExecutableDialog(Shell parentShell, int flags, String hostBinary, String buildLog, String args) { + super(parentShell); + setShellStyle(getShellStyle() | SWT.RESIZE); fFlags = flags; fHostBinary = hostBinary; fBuildLog = buildLog; @@ -69,101 +69,99 @@ public class NewExecutableDialog extends TitleAreaDialog { } @Override - protected Control createContents( Composite parent ) { - Control control = super.createContents( parent ); + protected Control createContents(Composite parent) { + Control control = super.createContents(parent); validate(); return control; } @Override - protected Control createDialogArea( Composite parent ) { + protected Control createDialogArea(Composite parent) { boolean remote = (fFlags & REMOTE) > 0; - getShell().setText( Messages.GdbDebugNewExecutableCommand_Debug_New_Executable ); - setTitle( Messages.GdbDebugNewExecutableCommand_Select_Binary ); - String message = ( remote ) ? - Messages.GdbDebugNewExecutableCommand_Select_binaries_on_host_and_target : - Messages.GdbDebugNewExecutableCommand_Select_binary_and_specify_arguments; - setMessage( message ); - - Composite control = (Composite)super.createDialogArea( parent ); - Composite comp = new Composite( control, SWT.NONE ); - GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true ); - GridLayout layout = new GridLayout( 3, false ); - comp.setLayout( layout ); - comp.setLayoutData( gd ); - - new Label( comp, SWT.None ).setText( remote ? Messages.GdbDebugNewExecutableCommand_Binary_on_host : Messages.GdbDebugExecutableCommand_Binary ); - fHostBinaryText = new Text( comp, SWT.BORDER ); + getShell().setText(Messages.GdbDebugNewExecutableCommand_Debug_New_Executable); + setTitle(Messages.GdbDebugNewExecutableCommand_Select_Binary); + String message = (remote) ? Messages.GdbDebugNewExecutableCommand_Select_binaries_on_host_and_target + : Messages.GdbDebugNewExecutableCommand_Select_binary_and_specify_arguments; + setMessage(message); + + Composite control = (Composite) super.createDialogArea(parent); + Composite comp = new Composite(control, SWT.NONE); + GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); + GridLayout layout = new GridLayout(3, false); + comp.setLayout(layout); + comp.setLayoutData(gd); + + new Label(comp, SWT.None).setText(remote ? Messages.GdbDebugNewExecutableCommand_Binary_on_host + : Messages.GdbDebugExecutableCommand_Binary); + fHostBinaryText = new Text(comp, SWT.BORDER); if (fHostBinary != null) fHostBinaryText.setText(fHostBinary); - fHostBinaryText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) ); - fHostBinaryText.addModifyListener( new ModifyListener() { - + fHostBinaryText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + fHostBinaryText.addModifyListener(new ModifyListener() { + @Override - public void modifyText( ModifyEvent e ) { + public void modifyText(ModifyEvent e) { validate(); } - } ); - Button browseButton = new Button( comp, SWT.PUSH ); - browseButton.setText( Messages.GdbDebugExecutableCommand_Browse ); - browseButton.setFont( JFaceResources.getDialogFont() ); - setButtonLayoutData( browseButton ); - browseButton.addSelectionListener( new SelectionAdapter() { + }); + Button browseButton = new Button(comp, SWT.PUSH); + browseButton.setText(Messages.GdbDebugExecutableCommand_Browse); + browseButton.setFont(JFaceResources.getDialogFont()); + setButtonLayoutData(browseButton); + browseButton.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected( SelectionEvent e ) { - FileDialog dialog = new FileDialog( getShell() ); - dialog.setFileName( fHostBinaryText.getText() ); + public void widgetSelected(SelectionEvent e) { + FileDialog dialog = new FileDialog(getShell()); + dialog.setFileName(fHostBinaryText.getText()); String result = dialog.open(); - if ( result != null ) { - fHostBinaryText.setText( result ); + if (result != null) { + fHostBinaryText.setText(result); } } - } ); - - if ( remote ) { - new Label( comp, SWT.None ).setText( Messages.GdbDebugNewExecutableCommand_Binary_on_target ); - fTargetBinaryText = new Text( comp, SWT.BORDER ); - fTargetBinaryText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false, 2, 1 ) ); - fTargetBinaryText.addModifyListener( new ModifyListener() { - + }); + + if (remote) { + new Label(comp, SWT.None).setText(Messages.GdbDebugNewExecutableCommand_Binary_on_target); + fTargetBinaryText = new Text(comp, SWT.BORDER); + fTargetBinaryText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); + fTargetBinaryText.addModifyListener(new ModifyListener() { + @Override - public void modifyText( ModifyEvent e ) { + public void modifyText(ModifyEvent e) { validate(); } - } ); + }); } - - new Label( comp, SWT.None ).setText( Messages.GdbDebugNewExecutableCommand_Arguments ); - fArgumentsText = new Text( comp, SWT.BORDER ); - fArgumentsText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false, 2, 1 ) ); + new Label(comp, SWT.None).setText(Messages.GdbDebugNewExecutableCommand_Arguments); + fArgumentsText = new Text(comp, SWT.BORDER); + fArgumentsText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); if (fArgs != null) fArgumentsText.setText(fArgs); - - new Label( comp, SWT.None ).setText( Messages.GdbDebugExecutableCommand_BuildLog ); - fBuildLogText = new Text( comp, SWT.BORDER ); + new Label(comp, SWT.None).setText(Messages.GdbDebugExecutableCommand_BuildLog); + fBuildLogText = new Text(comp, SWT.BORDER); if (fBuildLog != null) fBuildLogText.setText(fBuildLog); - fBuildLogText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false, 2, 1 ) ); - fBuildLogText.addModifyListener( new ModifyListener() { - + fBuildLogText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); + fBuildLogText.addModifyListener(new ModifyListener() { + @Override - public void modifyText( ModifyEvent e ) { + public void modifyText(ModifyEvent e) { validate(); } - } ); + }); return control; } @Override protected void okPressed() { - String targetPath = ( fTargetBinaryText != null ) ? fTargetBinaryText.getText().trim() : null; + String targetPath = (fTargetBinaryText != null) ? fTargetBinaryText.getText().trim() : null; String args = fArgumentsText.getText().trim(); String buildLog = fBuildLogText.getText().trim(); - fInfo = new NewExecutableInfo( fHostBinaryText.getText().trim(), targetPath, buildLog, args ); + fInfo = new NewExecutableInfo(fHostBinaryText.getText().trim(), targetPath, buildLog, args); super.okPressed(); } @@ -175,43 +173,37 @@ public class NewExecutableDialog extends TitleAreaDialog { boolean remote = (fFlags & REMOTE) > 0; StringBuilder sb = new StringBuilder(); String hostBinary = fHostBinaryText.getText().trim(); - if ( hostBinary.isEmpty() ) { - sb.append( ( remote ) ? - Messages.GdbDebugNewExecutableCommand_Host_binary_must_be_specified : - Messages.GdbDebugNewExecutableCommand_Binary_must_be_specified ); - } - else { - File file = new File( hostBinary ); - if ( !file.exists() ) { - sb.append( ( remote ) ? - Messages.GdbDebugNewExecutableCommand_Host_binary_file_does_not_exist : - Messages.GdbDebugNewExecutableCommand_Binary_file_does_not_exist ); - } - else if ( file.isDirectory() ) { - sb.append( ( remote ) ? - Messages.GdbDebugNewExecutableCommand_Invalid_host_binary : - Messages.GdbDebugNewExecutableCommand_Invalid_binary ); + if (hostBinary.isEmpty()) { + sb.append((remote) ? Messages.GdbDebugNewExecutableCommand_Host_binary_must_be_specified + : Messages.GdbDebugNewExecutableCommand_Binary_must_be_specified); + } else { + File file = new File(hostBinary); + if (!file.exists()) { + sb.append((remote) ? Messages.GdbDebugNewExecutableCommand_Host_binary_file_does_not_exist + : Messages.GdbDebugNewExecutableCommand_Binary_file_does_not_exist); + } else if (file.isDirectory()) { + sb.append((remote) ? Messages.GdbDebugNewExecutableCommand_Invalid_host_binary + : Messages.GdbDebugNewExecutableCommand_Invalid_binary); } } String buildLog = fBuildLogText.getText(); if (sb.length() == 0 && !buildLog.isEmpty()) { - File file = new File( buildLog ); - if ( !file.exists() ) { - sb.append( Messages.GdbDebugNewExecutableCommand_BuildLog_file_does_not_exist ); - } - else if ( file.isDirectory() ) { - sb.append( Messages.GdbDebugNewExecutableCommand_Invalid_buildLog ); + File file = new File(buildLog); + if (!file.exists()) { + sb.append(Messages.GdbDebugNewExecutableCommand_BuildLog_file_does_not_exist); + } else if (file.isDirectory()) { + sb.append(Messages.GdbDebugNewExecutableCommand_Invalid_buildLog); } } if (sb.length() == 0 && fTargetBinaryText != null) { - if ( fTargetBinaryText.getText().trim().length() == 0 ) { - if ( sb.length() != 0 ) { - sb.append( "\n " ); //$NON-NLS-1$ + if (fTargetBinaryText.getText().trim().length() == 0) { + if (sb.length() != 0) { + sb.append("\n "); //$NON-NLS-1$ } - sb.append( Messages.GdbDebugNewExecutableCommand_Binary_on_target_must_be_specified ); + sb.append(Messages.GdbDebugNewExecutableCommand_Binary_on_target_must_be_specified); } } - setErrorMessage( ( sb.length() != 0 ) ? sb.toString() : null ); - getButton( IDialogConstants.OK_ID ).setEnabled( getErrorMessage() == null ); + setErrorMessage((sb.length() != 0) ? sb.toString() : null); + getButton(IDialogConstants.OK_ID).setEnabled(getErrorMessage() == null); } }
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/NewExecutableInfo.java b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/NewExecutableInfo.java index 0663339f141..a1ab2225878 100644 --- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/NewExecutableInfo.java +++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/NewExecutableInfo.java @@ -16,8 +16,8 @@ package org.eclipse.cdt.debug.application; /** - * This class provides information required to start - * debugging an executable. + * This class provides information required to start + * debugging an executable. */ public class NewExecutableInfo { private String fHostPath; @@ -32,23 +32,23 @@ public class NewExecutableInfo { fBuildLog = buildLog; fArguments = args; } - + /** * Returns the path of the executable on the host */ public String getHostPath() { return fHostPath; } - + /** * Sets the path of the executable on the host */ public void setHostPath(String path) { fHostPath = path; } - + /** - * For remote sessions returns the path of the executable + * For remote sessions returns the path of the executable * on the target. Otherwise returns null. */ public String getTargetPath() { @@ -61,32 +61,32 @@ public class NewExecutableInfo { public void setTargetPath(String path) { fTargetPath = path; } - + /** * Get the build log path. - * + * * @return the build log path or null */ public String getBuildLog() { return fBuildLog; } - + /** * Sets the build log path. - * + * * @param path */ public void setBuildLog(String path) { fBuildLog = path; } - + /** * Returns the arguments to pass to the executable, or null */ public String getArguments() { return fArguments; - } - + } + /** * Sets the arguments to pass to the executable */ diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/RemoteExecutableDialog.java b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/RemoteExecutableDialog.java index 2633dd2905b..77a35ee4e80 100644 --- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/RemoteExecutableDialog.java +++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/RemoteExecutableDialog.java @@ -40,27 +40,28 @@ import org.eclipse.swt.widgets.Text; public class RemoteExecutableDialog extends TitleAreaDialog { private RemoteExecutableInfo fInfo = null; - + private Text fHostBinaryText; private Label fBinaryLabel; private Text fBuildLogText; private Text fAddressText; private Text fPortText; private Button fAttachButton; - + private final String fHostBinary; private final String fBuildLog; private final String fAddress; private final String fPort; private final boolean fAttach; - public RemoteExecutableDialog (Shell parentShell) { + public RemoteExecutableDialog(Shell parentShell) { this(parentShell, null, null, null, null, false); } - public RemoteExecutableDialog( Shell parentShell, String hostBinary, String buildLog, String address, String port, boolean attach) { - super( parentShell ); - setShellStyle( getShellStyle() | SWT.RESIZE ); + public RemoteExecutableDialog(Shell parentShell, String hostBinary, String buildLog, String address, String port, + boolean attach) { + super(parentShell); + setShellStyle(getShellStyle() | SWT.RESIZE); fHostBinary = hostBinary; fBuildLog = buildLog; fAddress = address; @@ -69,116 +70,114 @@ public class RemoteExecutableDialog extends TitleAreaDialog { } @Override - protected Control createContents( Composite parent ) { - Control control = super.createContents( parent ); + protected Control createContents(Composite parent) { + Control control = super.createContents(parent); validate(); return control; } @Override - protected Control createDialogArea( Composite parent ) { + protected Control createDialogArea(Composite parent) { - getShell().setText( Messages.GdbDebugRemoteExecutableCommand_Debug_Remote_Executable ); - setTitle( Messages.GdbDebugRemoteExecutableCommand_Select_Remote_Options ); + getShell().setText(Messages.GdbDebugRemoteExecutableCommand_Debug_Remote_Executable); + setTitle(Messages.GdbDebugRemoteExecutableCommand_Select_Remote_Options); String message = Messages.GdbDebugRemoteExecutableCommand_Select_Remote_Options; - setMessage( message ); - - Composite control = (Composite)super.createDialogArea( parent ); - Composite comp = new Composite( control, SWT.NONE ); - GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true ); - GridLayout layout = new GridLayout( 3, false ); - comp.setLayout( layout ); - comp.setLayoutData( gd ); - - fBinaryLabel = new Label( comp, SWT.None ); - fBinaryLabel.setText(fAttach ? Messages.GdbDebugExecutableCommand_Binary_Optional : - Messages.GdbDebugExecutableCommand_Binary ); - fHostBinaryText = new Text( comp, SWT.BORDER ); + setMessage(message); + + Composite control = (Composite) super.createDialogArea(parent); + Composite comp = new Composite(control, SWT.NONE); + GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); + GridLayout layout = new GridLayout(3, false); + comp.setLayout(layout); + comp.setLayoutData(gd); + + fBinaryLabel = new Label(comp, SWT.None); + fBinaryLabel.setText(fAttach ? Messages.GdbDebugExecutableCommand_Binary_Optional + : Messages.GdbDebugExecutableCommand_Binary); + fHostBinaryText = new Text(comp, SWT.BORDER); if (fHostBinary != null) fHostBinaryText.setText(fHostBinary); - fHostBinaryText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) ); - fHostBinaryText.addModifyListener( new ModifyListener() { - + fHostBinaryText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + fHostBinaryText.addModifyListener(new ModifyListener() { + @Override - public void modifyText( ModifyEvent e ) { + public void modifyText(ModifyEvent e) { validate(); } - } ); - Button browseButton = new Button( comp, SWT.PUSH ); - browseButton.setText( Messages.GdbDebugExecutableCommand_Browse ); - browseButton.setFont( JFaceResources.getDialogFont() ); - setButtonLayoutData( browseButton ); - browseButton.addSelectionListener( new SelectionAdapter() { + }); + Button browseButton = new Button(comp, SWT.PUSH); + browseButton.setText(Messages.GdbDebugExecutableCommand_Browse); + browseButton.setFont(JFaceResources.getDialogFont()); + setButtonLayoutData(browseButton); + browseButton.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected( SelectionEvent e ) { - FileDialog dialog = new FileDialog( getShell() ); - dialog.setFileName( fHostBinaryText.getText() ); + public void widgetSelected(SelectionEvent e) { + FileDialog dialog = new FileDialog(getShell()); + dialog.setFileName(fHostBinaryText.getText()); String result = dialog.open(); - if ( result != null ) { - fHostBinaryText.setText( result ); + if (result != null) { + fHostBinaryText.setText(result); } } - } ); - - new Label( comp, SWT.None ).setText( Messages.GdbDebugExecutableCommand_BuildLog ); - fBuildLogText = new Text( comp, SWT.BORDER ); + }); + + new Label(comp, SWT.None).setText(Messages.GdbDebugExecutableCommand_BuildLog); + fBuildLogText = new Text(comp, SWT.BORDER); if (fBuildLog != null) fBuildLogText.setText(fBuildLog); - fBuildLogText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false, 2, 1 ) ); - fBuildLogText.addModifyListener( new ModifyListener() { - + fBuildLogText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); + fBuildLogText.addModifyListener(new ModifyListener() { + @Override - public void modifyText( ModifyEvent e ) { + public void modifyText(ModifyEvent e) { validate(); } - } ); + }); - new Label( comp, SWT.None ).setText( Messages.GdbDebugRemoteExecutableCommand_Host_name_or_ip_address ); - fAddressText = new Text( comp, SWT.BORDER ); + new Label(comp, SWT.None).setText(Messages.GdbDebugRemoteExecutableCommand_Host_name_or_ip_address); + fAddressText = new Text(comp, SWT.BORDER); if (fAddress != null) fAddressText.setText(fAddress); - fAddressText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false, 2, 1 ) ); - fAddressText.addModifyListener( new ModifyListener() { - + fAddressText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); + fAddressText.addModifyListener(new ModifyListener() { + @Override - public void modifyText( ModifyEvent e ) { + public void modifyText(ModifyEvent e) { validate(); } - } ); + }); - new Label( comp, SWT.None ).setText( Messages.GdbDebugRemoteExecutableCommand_Port_number ); - fPortText = new Text( comp, SWT.BORDER ); + new Label(comp, SWT.None).setText(Messages.GdbDebugRemoteExecutableCommand_Port_number); + fPortText = new Text(comp, SWT.BORDER); if (fPort != null) fPortText.setText(fPort); - fPortText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false, 2, 1 ) ); - fPortText.addModifyListener( new ModifyListener() { - + fPortText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); + fPortText.addModifyListener(new ModifyListener() { + @Override - public void modifyText( ModifyEvent e ) { + public void modifyText(ModifyEvent e) { validate(); } - } ); + }); - fAttachButton = new Button( comp, SWT.CHECK); - fAttachButton.setText( Messages.GdbDebugRemoteExecutableCommand_Attach); + fAttachButton = new Button(comp, SWT.CHECK); + fAttachButton.setText(Messages.GdbDebugRemoteExecutableCommand_Attach); fAttachButton.setSelection(fAttach); fAttachButton.addSelectionListener(new SelectionListener() { - + @Override public void widgetSelected(SelectionEvent e) { - fBinaryLabel.setText(fAttachButton.getSelection() ? - Messages.GdbDebugExecutableCommand_Binary_Optional : - Messages.GdbDebugExecutableCommand_Binary ); + fBinaryLabel.setText(fAttachButton.getSelection() ? Messages.GdbDebugExecutableCommand_Binary_Optional + : Messages.GdbDebugExecutableCommand_Binary); validate(); } - + @Override public void widgetDefaultSelected(SelectionEvent e) { - fBinaryLabel.setText(fAttachButton.getSelection() ? - Messages.GdbDebugExecutableCommand_Binary_Optional : - Messages.GdbDebugExecutableCommand_Binary ); + fBinaryLabel.setText(fAttachButton.getSelection() ? Messages.GdbDebugExecutableCommand_Binary_Optional + : Messages.GdbDebugExecutableCommand_Binary); validate(); } @@ -189,11 +188,8 @@ public class RemoteExecutableDialog extends TitleAreaDialog { @Override protected void okPressed() { - fInfo = new RemoteExecutableInfo( fHostBinaryText.getText().trim(), - fBuildLogText.getText().trim(), - fAddressText.getText().trim(), - fPortText.getText().trim(), - fAttachButton.getSelection() ); + fInfo = new RemoteExecutableInfo(fHostBinaryText.getText().trim(), fBuildLogText.getText().trim(), + fAddressText.getText().trim(), fPortText.getText().trim(), fAttachButton.getSelection()); super.okPressed(); } @@ -203,29 +199,27 @@ public class RemoteExecutableDialog extends TitleAreaDialog { private void validate() { String error = null; - + String hostBinary = fHostBinaryText.getText().trim(); if (hostBinary.isEmpty()) { boolean attach = fAttachButton.getSelection(); - if (!attach) error = Messages.GdbDebugNewExecutableCommand_Binary_must_be_specified; - } - else { + if (!attach) + error = Messages.GdbDebugNewExecutableCommand_Binary_must_be_specified; + } else { File file = new File(hostBinary); - if (!file.exists() ) { + if (!file.exists()) { error = Messages.GdbDebugNewExecutableCommand_Binary_file_does_not_exist; - } - else if (file.isDirectory()) { + } else if (file.isDirectory()) { error = Messages.GdbDebugNewExecutableCommand_Invalid_binary; } } - + String buildLog = fBuildLogText.getText(); if (error == null && !buildLog.isEmpty()) { File file = new File(buildLog); if (!file.exists()) { error = Messages.GdbDebugNewExecutableCommand_BuildLog_file_does_not_exist; - } - else if (file.isDirectory()) { + } else if (file.isDirectory()) { error = Messages.GdbDebugNewExecutableCommand_Invalid_buildLog; } } @@ -248,7 +242,7 @@ public class RemoteExecutableDialog extends TitleAreaDialog { } } - setErrorMessage((error != null ) ? error : null); + setErrorMessage((error != null) ? error : null); getButton(IDialogConstants.OK_ID).setEnabled(getErrorMessage() == null); } }
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/RemoteExecutableInfo.java b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/RemoteExecutableInfo.java index 13a6fb5f368..a0aca88a0a7 100644 --- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/RemoteExecutableInfo.java +++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/RemoteExecutableInfo.java @@ -17,7 +17,7 @@ package org.eclipse.cdt.debug.application; /** - * This class provides information required to start debugging a remote executable. + * This class provides information required to start debugging a remote executable. */ public class RemoteExecutableInfo { private final String fHostPath; @@ -34,7 +34,7 @@ public class RemoteExecutableInfo { fPort = port; fAttach = attach; } - + public RemoteExecutableInfo(RemoteExecutableInfo info) { fHostPath = info.getHostPath(); fBuildLog = info.getBuildLog(); @@ -42,29 +42,29 @@ public class RemoteExecutableInfo { fPort = info.getPort(); fAttach = info.isAttach(); } - + /** * Returns the path of the executable on the host */ public String getHostPath() { return fHostPath; } - + public String getAddress() { return fAddress; } - + public String getPort() { return fPort; } - + public boolean isAttach() { return fAttach; } /** * Get the build log path. - * + * * @return the build log path or null */ public String getBuildLog() { diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/BuildOptionsParser.java b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/BuildOptionsParser.java index 9e7e3f48ba9..8ef46b6939f 100644 --- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/BuildOptionsParser.java +++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/BuildOptionsParser.java @@ -38,12 +38,12 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; public class BuildOptionsParser implements IWorkspaceRunnable, IMarkerGenerator { - + private final IProject project; private final File buildLog; - private static final String GCC_BUILD_OPTIONS_PROVIDER_ID = "org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"; //$NON-NLS-1$ - - public BuildOptionsParser (IProject project, File buildLog) { + private static final String GCC_BUILD_OPTIONS_PROVIDER_ID = "org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"; //$NON-NLS-1$ + + public BuildOptionsParser(IProject project, File buildLog) { this.project = project; this.buildLog = buildLog; } @@ -56,27 +56,24 @@ public class BuildOptionsParser implements IWorkspaceRunnable, IMarkerGenerator br = new BufferedReader(new FileReader(buildLog)); // Calculate how many source files we have to process and use that as a basis monitor.beginTask(Messages.GetBuildOptions, 10); - + // Find the GCCBuildCommandParser for the configuration. - ICProjectDescriptionManager projDescManager = CCorePlugin - .getDefault().getProjectDescriptionManager(); - ICProjectDescription projDesc = projDescManager - .getProjectDescription(project, - false); - ICConfigurationDescription ccdesc = projDesc - .getActiveConfiguration(); + ICProjectDescriptionManager projDescManager = CCorePlugin.getDefault().getProjectDescriptionManager(); + ICProjectDescription projDesc = projDescManager.getProjectDescription(project, false); + ICConfigurationDescription ccdesc = projDesc.getActiveConfiguration(); GCCBuildCommandParser parser = null; if (ccdesc instanceof ILanguageSettingsProvidersKeeper) { - ILanguageSettingsProvidersKeeper keeper = (ILanguageSettingsProvidersKeeper)ccdesc; + ILanguageSettingsProvidersKeeper keeper = (ILanguageSettingsProvidersKeeper) ccdesc; List<ILanguageSettingsProvider> list = keeper.getLanguageSettingProviders(); for (ILanguageSettingsProvider p : list) { // System.out.println("language settings provider " + p.getId()); if (p.getId().equals(GCC_BUILD_OPTIONS_PROVIDER_ID)) { - parser = (GCCBuildCommandParser)p; + parser = (GCCBuildCommandParser) p; } } } - ErrorParserManager epm = new ErrorParserManager(project, this, new String[]{"org.eclipse.cdt.core.CWDLocator"}); //$NON-NLS-1$ + ErrorParserManager epm = new ErrorParserManager(project, this, + new String[] { "org.eclipse.cdt.core.CWDLocator" }); //$NON-NLS-1$ // Start up the parser and process lines generated from the .debug_macro section. parser.startup(ccdesc, epm); monitor.beginTask(Messages.GetBuildOptions, 10); @@ -88,20 +85,19 @@ public class BuildOptionsParser implements IWorkspaceRunnable, IMarkerGenerator parser.shutdown(); if (br != null) br.close(); - + } catch (CoreException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); - } + } monitor.done(); } @Override - public void addMarker(IResource file, int lineNumber, String errorDesc, - int severity, String errorVar) { + public void addMarker(IResource file, int lineNumber, String errorDesc, int severity, String errorVar) { // do nothing } diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/CompilerOptionParser.java b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/CompilerOptionParser.java index 1544197de70..ed6c206c50a 100644 --- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/CompilerOptionParser.java +++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/CompilerOptionParser.java @@ -45,12 +45,12 @@ import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; public class CompilerOptionParser implements IWorkspaceRunnable { - - private static final String GCC_COMPILE_OPTIONS_PROVIDER_ID = "org.eclipse.cdt.debug.application.DwarfLanguageSettingsProvider"; //$NON-NLS-1$ + + private static final String GCC_COMPILE_OPTIONS_PROVIDER_ID = "org.eclipse.cdt.debug.application.DwarfLanguageSettingsProvider"; //$NON-NLS-1$ private final IProject project; private final String executable; - - public CompilerOptionParser (IProject project, String executable) { + + public CompilerOptionParser(IProject project, String executable) { this.project = project; this.executable = executable; } @@ -63,7 +63,7 @@ public class CompilerOptionParser implements IWorkspaceRunnable { } } - + @Override public void run(IProgressMonitor monitor) { try { @@ -103,25 +103,18 @@ public class CompilerOptionParser implements IWorkspaceRunnable { } ISymbolReader reader = bf.getAdapter(ISymbolReader.class); - String[] sourceFiles = reader - .getSourceFiles(); + String[] sourceFiles = reader.getSourceFiles(); monitor.beginTask(Messages.GetCompilerOptions, sourceFiles.length * 2 + 1); - + for (String sourceFile : sourceFiles) { - IPath sourceFilePath = new Path( - sourceFile); - String sourceName = sourceFilePath - .lastSegment(); - IContainer c = createFromRoot(project, - new Path(sourceFile)); - Path sourceNamePath = new Path( - sourceName); - IFile source = c - .getFile(sourceNamePath); + IPath sourceFilePath = new Path(sourceFile); + String sourceName = sourceFilePath.lastSegment(); + IContainer c = createFromRoot(project, new Path(sourceFile)); + Path sourceNamePath = new Path(sourceName); + IFile source = c.getFile(sourceNamePath); if (!source.isLinked()) { try { - source.createLink(sourceFilePath, 0, - null); + source.createLink(sourceFilePath, 0, null); } catch (Exception e) { // ignore file not found errors since certain headers might not be found // or are a different version from that used to compile the source (e.g. std headers) @@ -129,24 +122,20 @@ public class CompilerOptionParser implements IWorkspaceRunnable { } monitor.worked(1); } - + // Find the GCCCompileOptions LanguageSettingsProvider for the configuration. IWorkingDirectoryTracker cwdTracker = new CWDTracker(); - ICProjectDescriptionManager projDescManager = CCorePlugin - .getDefault().getProjectDescriptionManager(); - ICProjectDescription projDesc = projDescManager - .getProjectDescription(project, - false); - ICConfigurationDescription ccdesc = projDesc - .getActiveConfiguration(); + ICProjectDescriptionManager projDescManager = CCorePlugin.getDefault().getProjectDescriptionManager(); + ICProjectDescription projDesc = projDescManager.getProjectDescription(project, false); + ICConfigurationDescription ccdesc = projDesc.getActiveConfiguration(); GCCCompileOptionsParser parser = null; if (ccdesc instanceof ILanguageSettingsProvidersKeeper) { - ILanguageSettingsProvidersKeeper keeper = (ILanguageSettingsProvidersKeeper)ccdesc; + ILanguageSettingsProvidersKeeper keeper = (ILanguageSettingsProvidersKeeper) ccdesc; List<ILanguageSettingsProvider> list = keeper.getLanguageSettingProviders(); for (ILanguageSettingsProvider p : list) { // System.out.println("language settings provider " + p.getId()); if (p.getId().equals(GCC_COMPILE_OPTIONS_PROVIDER_ID)) { - parser = (GCCCompileOptionsParser)p; + parser = (GCCCompileOptionsParser) p; } } } @@ -154,14 +143,11 @@ public class CompilerOptionParser implements IWorkspaceRunnable { parser.startup(ccdesc, cwdTracker); // Get compile options for each source file and process via the parser // to generate LanguageSettingsEntries. - if (reader instanceof - ICompileOptionsFinder) { - ICompileOptionsFinder f = - (ICompileOptionsFinder) reader; + if (reader instanceof ICompileOptionsFinder) { + ICompileOptionsFinder f = (ICompileOptionsFinder) reader; for (String fileName : sourceFiles) { parser.setCurrentResourceName(fileName); - parser.processLine(f - .getCompileOptions(fileName)); + parser.processLine(f.getCompileOptions(fileName)); monitor.worked(1); } parser.shutdown(); // this will serialize the data to an xml file and create an event. @@ -174,17 +160,16 @@ public class CompilerOptionParser implements IWorkspaceRunnable { } monitor.done(); } - - private IContainer createFromRoot(IProject exeProject, IPath path) - throws CoreException { + + private IContainer createFromRoot(IProject exeProject, IPath path) throws CoreException { int segmentCount = path.segmentCount() - 1; IContainer currentFolder = exeProject; for (int i = 0; i < segmentCount; i++) { currentFolder = currentFolder.getFolder(new Path(path.segment(i))); if (!currentFolder.exists()) { - ((IFolder) currentFolder).create(IResource.VIRTUAL - | IResource.DERIVED, true, new NullProgressMonitor()); + ((IFolder) currentFolder).create(IResource.VIRTUAL | IResource.DERIVED, true, + new NullProgressMonitor()); } } diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugAttachedExecutable.java b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugAttachedExecutable.java index 41a35f6b61f..4592e8edd7b 100644 --- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugAttachedExecutable.java +++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugAttachedExecutable.java @@ -48,10 +48,9 @@ public class DebugAttachedExecutable { private static final String GCC_BUILTIN_PROVIDER_ID = "org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector"; //$NON-NLS-1$ private static final String GCC_COMPILE_OPTIONS_PROVIDER_ID = "org.eclipse.cdt.debug.application.DwarfLanguageSettingsProvider"; //$NON-NLS-1$ - private static final String GCC_BUILD_OPTIONS_PROVIDER_ID = "org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"; //$NON-NLS-1$ + private static final String GCC_BUILD_OPTIONS_PROVIDER_ID = "org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"; //$NON-NLS-1$ private static final String DEBUG_PROJECT_ID = "org.eclipse.cdt.debug"; //$NON-NLS-1$ - public DebugAttachedExecutable() { } @@ -61,13 +60,14 @@ public class DebugAttachedExecutable { // Create a new project that doesn't already exist. Use the base project name and add // a numerical suffix as needed. - private static IProject createCProjectForExecutable(String projectName) throws OperationCanceledException, CoreException { + private static IProject createCProjectForExecutable(String projectName) + throws OperationCanceledException, CoreException { IWorkspace workspace = ResourcesPlugin.getWorkspace(); IProject newProjectHandle = workspace.getRoot().getProject(projectName); int projectSuffix = 2; - while (newProjectHandle.exists()){ + while (newProjectHandle.exists()) { newProjectHandle = workspace.getRoot().getProject(projectName + projectSuffix); projectSuffix++; } @@ -83,30 +83,28 @@ public class DebugAttachedExecutable { /** * Import given executable into the Executables project then create a launch configuration. - * + * * @param monitor * @param buildLog * @throws CoreException * @throws InterruptedException */ - public static ILaunchConfiguration createLaunchConfig(IProgressMonitor monitor, - String buildLog) - throws CoreException, InterruptedException { + public static ILaunchConfiguration createLaunchConfig(IProgressMonitor monitor, String buildLog) + throws CoreException, InterruptedException { return createLaunchConfig(monitor, buildLog, null); } /** * Import given executable into the Executables project then create a launch configuration. - * + * * @param monitor * @param buildLog * @param pid * @throws CoreException * @throws InterruptedException */ - public static ILaunchConfiguration createLaunchConfig(IProgressMonitor monitor, - String buildLog, String pid) - throws CoreException, InterruptedException { + public static ILaunchConfiguration createLaunchConfig(IProgressMonitor monitor, String buildLog, String pid) + throws CoreException, InterruptedException { ILaunchConfiguration config = null; String defaultProjectName = "Executables"; //$NON-NLS-1$ @@ -116,18 +114,14 @@ public class DebugAttachedExecutable { monitor.worked(3); File buildLogFile = null; - final ICProjectDescriptionManager projDescManager = CCorePlugin - .getDefault().getProjectDescriptionManager(); + final ICProjectDescriptionManager projDescManager = CCorePlugin.getDefault().getProjectDescriptionManager(); - ICProjectDescription projectDescription = projDescManager - .getProjectDescription(project, - ICProjectDescriptionManager.GET_WRITABLE); + ICProjectDescription projectDescription = projDescManager.getProjectDescription(project, + ICProjectDescriptionManager.GET_WRITABLE); monitor.subTask(Messages.SetLanguageProviders); - final ICConfigurationDescription ccd = projectDescription - .getActiveConfiguration(); - String[] langProviderIds = ((ILanguageSettingsProvidersKeeper) ccd) - .getDefaultLanguageSettingsProvidersIds(); + final ICConfigurationDescription ccd = projectDescription.getActiveConfiguration(); + String[] langProviderIds = ((ILanguageSettingsProvidersKeeper) ccd).getDefaultLanguageSettingsProvidersIds(); boolean found = false; for (int i = 0; i < langProviderIds.length; ++i) { if (langProviderIds[i].equals(GCC_BUILTIN_PROVIDER_ID)) { @@ -138,8 +132,7 @@ public class DebugAttachedExecutable { // Look for the GCC builtin LanguageSettingsProvider id. If it isn't already // there, add it. if (!found) { - langProviderIds = Arrays.copyOf(langProviderIds, - langProviderIds.length + 1); + langProviderIds = Arrays.copyOf(langProviderIds, langProviderIds.length + 1); langProviderIds[langProviderIds.length - 1] = GCC_BUILTIN_PROVIDER_ID; } found = false; @@ -151,8 +144,7 @@ public class DebugAttachedExecutable { } // Look for our macro parser provider id. If it isn't added already, do so now. if (!found) { - langProviderIds = Arrays.copyOf(langProviderIds, - langProviderIds.length + 1); + langProviderIds = Arrays.copyOf(langProviderIds, langProviderIds.length + 1); langProviderIds[langProviderIds.length - 1] = GCC_COMPILE_OPTIONS_PROVIDER_ID; } @@ -169,8 +161,7 @@ public class DebugAttachedExecutable { } // Look for our macro parser provider id. If it isn't added already, do so now. if (!found) { - langProviderIds = Arrays.copyOf(langProviderIds, - langProviderIds.length + 1); + langProviderIds = Arrays.copyOf(langProviderIds, langProviderIds.length + 1); langProviderIds[langProviderIds.length - 1] = GCC_BUILD_OPTIONS_PROVIDER_ID; } } @@ -181,30 +172,25 @@ public class DebugAttachedExecutable { .createLanguageSettingsProviders(langProviderIds); // Update the providers for the configuration. - ((ILanguageSettingsProvidersKeeper) ccd) - .setLanguageSettingProviders(providers); + ((ILanguageSettingsProvidersKeeper) ccd).setLanguageSettingProviders(providers); monitor.worked(1); // Update the project description. - projDescManager.setProjectDescription(project, - projectDescription); - + projDescManager.setProjectDescription(project, projectDescription); // Serialize the language settings for the project now in case we don't run a // language settings provider which will do this in shutdown. - ICProjectDescription projDescReadOnly = projDescManager - .getProjectDescription(project, - false); + ICProjectDescription projDescReadOnly = projDescManager.getProjectDescription(project, false); LanguageSettingsManager.serializeLanguageSettings(projDescReadOnly); monitor.worked(1); - if (buildLogFile != null) + if (buildLogFile != null) // We need to parse the build log to get compile options. We need to lock the // workspace when we do this so we don't have multiple copies of GCCBuildOptionsParser // LanguageSettingsProvider and we end up filling in the wrong one. - project.getWorkspace().run(new BuildOptionsParser(project, buildLogFile), + project.getWorkspace().run(new BuildOptionsParser(project, buildLogFile), ResourcesPlugin.getWorkspace().getRoot(), IWorkspace.AVOID_UPDATE, new NullProgressMonitor()); // System.out.println("about to close all editors"); @@ -235,23 +221,18 @@ public class DebugAttachedExecutable { ILaunchConfiguration config = null; try { ILaunchConfigurationType configType = getLaunchConfigType(); - ILaunchConfigurationWorkingCopy wc = configType.newInstance( - null, + ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, getLaunchManager().generateLaunchConfigurationName("CDT_DBG_ATTACH")); //$NON-NLS-1$ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH); - wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, - "Executables"); //$NON-NLS-1$ - wc.setAttribute( - ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, - (String) null); + wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, "Executables"); //$NON-NLS-1$ + wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null); if (pid != null) { - wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_ATTACH_PROCESS_ID, - Integer.valueOf(pid)); + wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_ATTACH_PROCESS_ID, Integer.valueOf(pid)); } - + if (save) { config = wc.doSave(); } else { diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugAttachedExecutableHandler.java b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugAttachedExecutableHandler.java index c129f4a7489..9bc9d5eafa0 100644 --- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugAttachedExecutableHandler.java +++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugAttachedExecutableHandler.java @@ -29,9 +29,10 @@ public class DebugAttachedExecutableHandler extends AbstractHandler { @Override public Object execute(ExecutionEvent event) throws ExecutionException { - + try { - final ILaunchConfiguration config = DebugAttachedExecutable.createLaunchConfig(new NullProgressMonitor(), null); + final ILaunchConfiguration config = DebugAttachedExecutable.createLaunchConfig(new NullProgressMonitor(), + null); if (config != null) { Display.getDefault().syncExec(new Runnable() { diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugCoreFile.java b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugCoreFile.java index 49a729507c5..c1e21bd933c 100644 --- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugCoreFile.java +++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugCoreFile.java @@ -23,17 +23,17 @@ import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchManager; public class DebugCoreFile { - + public DebugCoreFile() { } - + public static ILaunchManager getLaunchManager() { return DebugPlugin.getDefault().getLaunchManager(); } - + /** * Import given executable into the Executables project then create a launch configuration. - * + * * @param monitor * @param executable * @param buildLog @@ -41,9 +41,8 @@ public class DebugCoreFile { * @throws CoreException * @throws InterruptedException */ - public static ILaunchConfiguration createLaunchConfig(IProgressMonitor monitor, - String buildLog, String executable, String coreFile) - throws CoreException, InterruptedException { + public static ILaunchConfiguration createLaunchConfig(IProgressMonitor monitor, String buildLog, String executable, + String coreFile) throws CoreException, InterruptedException { ILaunchConfiguration config = null; config = createConfiguration(coreFile, executable, true); @@ -52,26 +51,22 @@ public class DebugCoreFile { } protected static ILaunchConfigurationType getLaunchConfigType() { - return getLaunchManager().getLaunchConfigurationType(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_POST_MORTEM); + return getLaunchManager().getLaunchConfigurationType(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_POST_MORTEM); } - + protected static ILaunchConfiguration createConfiguration(String corePath, String exePath, boolean save) { ILaunchConfiguration config = null; try { ILaunchConfigurationType configType = getLaunchConfigType(); - ILaunchConfigurationWorkingCopy wc = configType.newInstance( - null, + ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, getLaunchManager().generateLaunchConfigurationName("CDT_DBG_CORE")); //$NON-NLS-1$ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE); wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, corePath); wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, exePath); - wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, - "Executables"); //$NON-NLS-1$ - wc.setAttribute( - ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, - (String) null); + wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, "Executables"); //$NON-NLS-1$ + wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null); if (save) { config = wc.doSave(); } else { diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugCoreFileHandler.java b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugCoreFileHandler.java index 9b3836c55e4..b383d0e8596 100644 --- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugCoreFileHandler.java +++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugCoreFileHandler.java @@ -33,13 +33,14 @@ public class DebugCoreFileHandler extends AbstractHandler { @Override public Object execute(ExecutionEvent event) throws ExecutionException { - + CoreFileDialog dialog = new CoreFileDialog(new Shell()); - + if (dialog.open() == IDialogConstants.OK_ID) { CoreFileInfo info = dialog.getCoreFileInfo(); try { - final ILaunchConfiguration config = DebugCoreFile.createLaunchConfig(new NullProgressMonitor(), null, info.getHostPath(), info.getCoreFilePath()); + final ILaunchConfiguration config = DebugCoreFile.createLaunchConfig(new NullProgressMonitor(), null, + info.getHostPath(), info.getCoreFilePath()); if (config != null) { Display.getDefault().syncExec(new Runnable() { diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugExecutable.java b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugExecutable.java index b53793774be..c8dbc209e2a 100644 --- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugExecutable.java +++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugExecutable.java @@ -54,23 +54,23 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; public class DebugExecutable { - + private static final String GCC_BUILTIN_PROVIDER_ID = "org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector"; //$NON-NLS-1$ private static final String GCC_COMPILE_OPTIONS_PROVIDER_ID = "org.eclipse.cdt.debug.application.DwarfLanguageSettingsProvider"; //$NON-NLS-1$ - private static final String GCC_BUILD_OPTIONS_PROVIDER_ID = "org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"; //$NON-NLS-1$ + private static final String GCC_BUILD_OPTIONS_PROVIDER_ID = "org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"; //$NON-NLS-1$ private static final String STANDALONE_QUALIFIER = "org.eclipse.cdt.debug.application"; //$NON-NLS-1$ private static final String LAST_LAUNCH = "lastLaunch"; //$NON-NLS-1$ + public DebugExecutable() { } - + public static ILaunchManager getLaunchManager() { return DebugPlugin.getDefault().getLaunchManager(); } - - + /** * Import given executable into the Executables project then create a launch configuration. - * + * * @param monitor * @param executable * @param buildLog @@ -78,14 +78,12 @@ public class DebugExecutable { * @throws CoreException * @throws InterruptedException */ - public static ILaunchConfiguration importAndCreateLaunchConfig(IProgressMonitor monitor, - String executable, String buildLog, String arguments, boolean startup) - throws CoreException, InterruptedException { + public static ILaunchConfiguration importAndCreateLaunchConfig(IProgressMonitor monitor, String executable, + String buildLog, String arguments, boolean startup) throws CoreException, InterruptedException { ILaunchConfiguration config = null; File executableFile = new File(executable); String defaultProjectName = "Executables"; //$NON-NLS-1$ - ICProject cProject = CoreModel.getDefault().getCModel() - .getCProject(defaultProjectName); + ICProject cProject = CoreModel.getDefault().getCModel().getCProject(defaultProjectName); // if a valid executable is specified, remove any executables already loaded in workspace if (startup && cProject.exists() && executableFile.exists()) { monitor.subTask(Messages.RemoveOldExecutable); @@ -94,16 +92,18 @@ public class DebugExecutable { Executable[] executables = new Executable[elist.size()]; elist.toArray(executables); @SuppressWarnings("unused") - IStatus rc = ExecutablesManager.getExecutablesManager().removeExecutables(executables, new NullProgressMonitor()); + IStatus rc = ExecutablesManager.getExecutablesManager().removeExecutables(executables, + new NullProgressMonitor()); // Remove all old members of the Executables project from the last run IResource[] resources = proj.members(); for (IResource resource : resources) { - resource.delete(IResource.ALWAYS_DELETE_PROJECT_CONTENT|IResource.FORCE, new NullProgressMonitor()); + resource.delete(IResource.ALWAYS_DELETE_PROJECT_CONTENT | IResource.FORCE, new NullProgressMonitor()); } monitor.worked(1); // Find last launch if one exists - String memento = ResourcesPlugin.getWorkspace().getRoot().getPersistentProperty(new QualifiedName(STANDALONE_QUALIFIER, LAST_LAUNCH)); + String memento = ResourcesPlugin.getWorkspace().getRoot() + .getPersistentProperty(new QualifiedName(STANDALONE_QUALIFIER, LAST_LAUNCH)); if (memento != null) { ILaunchConfiguration lastConfiguration = getLaunchManager().getLaunchConfiguration(memento); try { @@ -114,14 +114,14 @@ public class DebugExecutable { // do nothing } } - + // Delete all launch configurations that specify the project we are about to delete ILaunchConfiguration lconfigs[] = getLaunchManager().getLaunchConfigurations(); for (ILaunchConfiguration lconfig : lconfigs) { if (lconfig.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, "").equals(proj.getName())) //$NON-NLS-1$ lconfig.delete(); } - + // Delete project because we have deleted .cproject and settings files // by this point so just create a new Executables C project to use for // importing the new executable. @@ -133,8 +133,7 @@ public class DebugExecutable { @Override public IStatus run(IProgressMonitor monitor) { - ExecutablesManager.getExecutablesManager().importExecutables( - fileNames, monitor); + ExecutablesManager.getExecutablesManager().importExecutables(fileNames, monitor); return Status.OK_STATUS; } }; @@ -149,21 +148,19 @@ public class DebugExecutable { if (exec.getName().contains(executableFile.getName())) cProject = CoreModel.getDefault().getCModel().getCProject(exec.getProject().getName()); } - + if (cProject.exists()) { File buildLogFile = null; final IProject project = cProject.getProject(); - final ICProjectDescriptionManager projDescManager = CCorePlugin - .getDefault().getProjectDescriptionManager(); + final ICProjectDescriptionManager projDescManager = CCorePlugin.getDefault() + .getProjectDescriptionManager(); - ICProjectDescription projectDescription = projDescManager - .getProjectDescription(project, - ICProjectDescriptionManager.GET_WRITABLE); + ICProjectDescription projectDescription = projDescManager.getProjectDescription(project, + ICProjectDescriptionManager.GET_WRITABLE); monitor.subTask(Messages.SetLanguageProviders); - final ICConfigurationDescription ccd = projectDescription - .getActiveConfiguration(); + final ICConfigurationDescription ccd = projectDescription.getActiveConfiguration(); String[] langProviderIds = ((ILanguageSettingsProvidersKeeper) ccd) .getDefaultLanguageSettingsProvidersIds(); boolean found = false; @@ -176,8 +173,7 @@ public class DebugExecutable { // Look for the GCC builtin LanguageSettingsProvider id. If it isn't already // there, add it. if (!found) { - langProviderIds = Arrays.copyOf(langProviderIds, - langProviderIds.length + 1); + langProviderIds = Arrays.copyOf(langProviderIds, langProviderIds.length + 1); langProviderIds[langProviderIds.length - 1] = GCC_BUILTIN_PROVIDER_ID; } found = false; @@ -189,8 +185,7 @@ public class DebugExecutable { } // Look for our macro parser provider id. If it isn't added already, do so now. if (!found) { - langProviderIds = Arrays.copyOf(langProviderIds, - langProviderIds.length + 1); + langProviderIds = Arrays.copyOf(langProviderIds, langProviderIds.length + 1); langProviderIds[langProviderIds.length - 1] = GCC_COMPILE_OPTIONS_PROVIDER_ID; } @@ -207,8 +202,7 @@ public class DebugExecutable { } // Look for our macro parser provider id. If it isn't added already, do so now. if (!found) { - langProviderIds = Arrays.copyOf(langProviderIds, - langProviderIds.length + 1); + langProviderIds = Arrays.copyOf(langProviderIds, langProviderIds.length + 1); langProviderIds[langProviderIds.length - 1] = GCC_BUILD_OPTIONS_PROVIDER_ID; } } @@ -219,39 +213,37 @@ public class DebugExecutable { .createLanguageSettingsProviders(langProviderIds); // Update the providers for the configuration. - ((ILanguageSettingsProvidersKeeper) ccd) - .setLanguageSettingProviders(providers); - + ((ILanguageSettingsProvidersKeeper) ccd).setLanguageSettingProviders(providers); + monitor.worked(1); - + // Update the project description. - projDescManager.setProjectDescription(project, - projectDescription); - + projDescManager.setProjectDescription(project, projectDescription); + // Serialize the language settings for the project now in case we don't run a // language settings provider which will do this in shutdown. - ICProjectDescription projDescReadOnly = projDescManager - .getProjectDescription(project, - false); + ICProjectDescription projDescReadOnly = projDescManager.getProjectDescription(project, false); LanguageSettingsManager.serializeLanguageSettings(projDescReadOnly); - + monitor.worked(1); - + if (!("".equals(executable))) //$NON-NLS-1$ // We need to parse the macro compile options if they exist. We need to lock the // workspace when we do this so we don't have multiple copies of our GCCCompilerOptionsParser // LanguageSettingsProvider and we end up filling in the wrong one. - project.getWorkspace().run(new CompilerOptionParser(project, executable), - ResourcesPlugin.getWorkspace().getRoot(), IWorkspace.AVOID_UPDATE, new NullProgressMonitor()); + project.getWorkspace().run(new CompilerOptionParser(project, executable), + ResourcesPlugin.getWorkspace().getRoot(), IWorkspace.AVOID_UPDATE, + new NullProgressMonitor()); - if (buildLogFile != null) + if (buildLogFile != null) // We need to parse the build log to get compile options. We need to lock the // workspace when we do this so we don't have multiple copies of GCCBuildOptionsParser // LanguageSettingsProvider and we end up filling in the wrong one. - project.getWorkspace().run(new BuildOptionsParser(project, buildLogFile), - ResourcesPlugin.getWorkspace().getRoot(), IWorkspace.AVOID_UPDATE, new NullProgressMonitor()); + project.getWorkspace().run(new BuildOptionsParser(project, buildLogFile), + ResourcesPlugin.getWorkspace().getRoot(), IWorkspace.AVOID_UPDATE, + new NullProgressMonitor()); } - + IWorkbench workbench = PlatformUI.getWorkbench(); if (workbench != null) { final IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); @@ -266,7 +258,8 @@ public class DebugExecutable { // If we are starting up the debugger, save the executable as the default executable to use if (startup) { String memento = config.getMemento(); - ResourcesPlugin.getWorkspace().getRoot().setPersistentProperty(new QualifiedName(STANDALONE_QUALIFIER, LAST_LAUNCH), memento); + ResourcesPlugin.getWorkspace().getRoot() + .setPersistentProperty(new QualifiedName(STANDALONE_QUALIFIER, LAST_LAUNCH), memento); } monitor.worked(1); } else { @@ -279,34 +272,27 @@ public class DebugExecutable { protected static ILaunchConfigurationType getLaunchConfigType() { return getLaunchManager().getLaunchConfigurationType(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_APP); } - - protected static ILaunchConfiguration createConfiguration(String bin, - String arguments, String buildLog, boolean save) { + + protected static ILaunchConfiguration createConfiguration(String bin, String arguments, String buildLog, + boolean save) { ILaunchConfiguration config = null; try { String progName = bin; ILaunchConfigurationType configType = getLaunchConfigType(); - ILaunchConfigurationWorkingCopy wc = configType.newInstance( - null, + ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, getLaunchManager().generateLaunchConfigurationName(bin)); - wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, - progName); - wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, - "Executables"); //$NON-NLS-1$ - wc.setAttribute(ICDTStandaloneDebugLaunchConstants.BUILD_LOG_LOCATION, - buildLog); - wc.setAttribute( - ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, - (String) null); + wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, progName); + wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, "Executables"); //$NON-NLS-1$ + wc.setAttribute(ICDTStandaloneDebugLaunchConstants.BUILD_LOG_LOCATION, buildLog); + wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null); if (arguments != null) { wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, arguments); } // Use the PWD as the working directory for the application being launched - wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, - System.getProperty("user.dir")); //$NON-NLS-1$ + wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, System.getProperty("user.dir")); //$NON-NLS-1$ if (save) { config = wc.doSave(); diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugNewExecutableHandler.java b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugNewExecutableHandler.java index 32e684d7692..919989364bc 100644 --- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugNewExecutableHandler.java +++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugNewExecutableHandler.java @@ -41,17 +41,18 @@ public class DebugNewExecutableHandler extends AbstractHandler { @Override public Object execute(ExecutionEvent event) throws ExecutionException { - + NewExecutableDialog dialog = new NewExecutableDialog(new Shell()); - + if (dialog.open() == IDialogConstants.OK_ID) { NewExecutableInfo info = dialog.getExecutableInfo(); String executable = info.getHostPath(); String arguments = info.getArguments(); String buildLog = info.getBuildLog(); - + try { - final ILaunchConfiguration config = DebugExecutable.importAndCreateLaunchConfig(new NullProgressMonitor(), executable, buildLog, arguments, false); + final ILaunchConfiguration config = DebugExecutable + .importAndCreateLaunchConfig(new NullProgressMonitor(), executable, buildLog, arguments, false); if (config != null) { final JobContainer LaunchJobs = new JobContainer(); Job.getJobManager().addJobChangeListener(new JobChangeAdapter() { @@ -78,7 +79,7 @@ public class DebugNewExecutableHandler extends AbstractHandler { try { LaunchJobs.getLaunchJob().join(); } catch (InterruptedException e) { - IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, + IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, Messages.LaunchInterruptedError, e); ResourcesPlugin.getPlugin().getLog().log(status); } diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugRemoteExecutable.java b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugRemoteExecutable.java index 81fdb3f9831..9d1fd8b6209 100644 --- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugRemoteExecutable.java +++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugRemoteExecutable.java @@ -24,17 +24,16 @@ import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchManager; public class DebugRemoteExecutable { - + public DebugRemoteExecutable() { } - + public static ILaunchManager getLaunchManager() { return DebugPlugin.getDefault().getLaunchManager(); } - - public static ILaunchConfiguration createLaunchConfig(IProgressMonitor monitor, - String buildLog, String executable, String address, String port, boolean attach) - throws CoreException, InterruptedException { + + public static ILaunchConfiguration createLaunchConfig(IProgressMonitor monitor, String buildLog, String executable, + String address, String port, boolean attach) throws CoreException, InterruptedException { ILaunchConfiguration config = null; config = createConfiguration(executable, address, port, attach, true); @@ -43,39 +42,35 @@ public class DebugRemoteExecutable { } protected static ILaunchConfigurationType getLaunchConfigType(boolean attach) { - return getLaunchManager().getLaunchConfigurationType( - attach ? ICDTLaunchConfigurationConstants.ID_LAUNCH_C_ATTACH : - ICDTLaunchConfigurationConstants.ID_LAUNCH_C_REMOTE_APP); + return getLaunchManager() + .getLaunchConfigurationType(attach ? ICDTLaunchConfigurationConstants.ID_LAUNCH_C_ATTACH + : ICDTLaunchConfigurationConstants.ID_LAUNCH_C_REMOTE_APP); } - - protected static ILaunchConfiguration createConfiguration(String exePath, String address, String port, boolean attach, boolean save) { + + protected static ILaunchConfiguration createConfiguration(String exePath, String address, String port, + boolean attach, boolean save) { ILaunchConfiguration config = null; try { ILaunchConfigurationType configType = getLaunchConfigType(attach); - ILaunchConfigurationWorkingCopy wc = configType.newInstance( - null, - getLaunchManager().generateLaunchConfigurationName( - attach ? "CDT_REMOTE_ATTACH" : "CDT_REMOTE")); //$NON-NLS-1$ //$NON-NLS-2$ + ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, + getLaunchManager().generateLaunchConfigurationName(attach ? "CDT_REMOTE_ATTACH" : "CDT_REMOTE")); //$NON-NLS-1$ //$NON-NLS-2$ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, - attach ? IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE_ATTACH : - IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE); + attach ? IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE_ATTACH + : IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE); if (exePath != null && exePath.length() > 0) { wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, exePath); } else { assert attach; } - wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, - "Executables"); //$NON-NLS-1$ - wc.setAttribute( - ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, - (String) null); - + wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, "Executables"); //$NON-NLS-1$ + wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null); + wc.setAttribute(IGDBLaunchConfigurationConstants.ATTR_REMOTE_TCP, true); wc.setAttribute(IGDBLaunchConfigurationConstants.ATTR_HOST, address); wc.setAttribute(IGDBLaunchConfigurationConstants.ATTR_PORT, port); - + if (save) { config = wc.doSave(); } else { diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugRemoteExecutableHandler.java b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugRemoteExecutableHandler.java index e5575963dcb..3b403fc4c42 100644 --- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugRemoteExecutableHandler.java +++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugRemoteExecutableHandler.java @@ -44,7 +44,8 @@ public class DebugRemoteExecutableHandler extends AbstractHandler { boolean attach = info.isAttach(); try { - final ILaunchConfiguration config = DebugRemoteExecutable.createLaunchConfig(new NullProgressMonitor(), buildLog, executable, address, port, attach); + final ILaunchConfiguration config = DebugRemoteExecutable.createLaunchConfig(new NullProgressMonitor(), + buildLog, executable, address, port, attach); if (config != null) { Display.getDefault().syncExec(new Runnable() { diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/JobContainer.java b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/JobContainer.java index 9f604257abb..cfea0da36d7 100644 --- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/JobContainer.java +++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/JobContainer.java @@ -17,6 +17,7 @@ import org.eclipse.core.runtime.jobs.Job; public class JobContainer { private Job launchJob; + public Job getLaunchJob() { return launchJob; } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDIDebugModel.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDIDebugModel.java index fa41955c31e..ea9e5f3ba87 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDIDebugModel.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDIDebugModel.java @@ -66,1315 +66,1319 @@ import org.eclipse.debug.core.model.ILineBreakpoint; */ public class CDIDebugModel { - /** - * Returns the identifier for the CDI debug model plug-in - * - * @return plugin identifier - */ - public static String getPluginIdentifier() { - return CDebugCorePlugin.getUniqueIdentifier(); - } + /** + * Returns the identifier for the CDI debug model plug-in + * + * @return plugin identifier + */ + public static String getPluginIdentifier() { + return CDebugCorePlugin.getUniqueIdentifier(); + } - /** - * Calculates breakpoint marker ID based on the breakpoint object type. - * - * @since 7.2 - */ - public static String calculateMarkerType(IBreakpoint bp) { - if (bp instanceof ICBreakpoint2) { - return ((ICBreakpoint2) bp).getMarkerType(); - } - if (bp instanceof ICDynamicPrintf) { - if (bp instanceof ICFunctionBreakpoint) { - return ICDynamicPrintf.C_FUNCTION_DYNAMICPRINTF_MARKER; - } else if (bp instanceof ICAddressBreakpoint) { - return ICDynamicPrintf.C_ADDRESS_DYNAMICPRINTF_MARKER; - } else if (bp instanceof ICLineBreakpoint) { - return ICDynamicPrintf.C_LINE_DYNAMICPRINTF_MARKER; - } else { - return ICDynamicPrintf.C_DYNAMICPRINTF_MARKER; - } - } else if (bp instanceof ICTracepoint) { - if (bp instanceof ICFunctionBreakpoint) { - return ICTracepoint.C_FUNCTION_TRACEPOINT_MARKER; - } else if (bp instanceof ICAddressBreakpoint) { - return ICTracepoint.C_ADDRESS_TRACEPOINT_MARKER; - } else if (bp instanceof ICLineBreakpoint) { - return ICTracepoint.C_LINE_TRACEPOINT_MARKER; - } else { - return ICTracepoint.C_TRACEPOINT_MARKER; - } - } else if (bp instanceof ICFunctionBreakpoint) { - return ICFunctionBreakpoint.C_FUNCTION_BREAKPOINT_MARKER; - } else if (bp instanceof ICAddressBreakpoint) { - return ICAddressBreakpoint.C_ADDRESS_BREAKPOINT_MARKER; - } else if (bp instanceof ICLineBreakpoint) { - return ICLineBreakpoint.C_LINE_BREAKPOINT_MARKER; - } else if (bp instanceof ICEventBreakpoint) { - return ICEventBreakpoint.C_EVENT_BREAKPOINT_MARKER; - } else if (bp instanceof ICBreakpoint) { - return ICBreakpoint.C_BREAKPOINT_MARKER; - } else if (bp instanceof ILineBreakpoint) { - return IBreakpoint.LINE_BREAKPOINT_MARKER; - } - return IBreakpoint.BREAKPOINT_MARKER; - } + /** + * Calculates breakpoint marker ID based on the breakpoint object type. + * + * @since 7.2 + */ + public static String calculateMarkerType(IBreakpoint bp) { + if (bp instanceof ICBreakpoint2) { + return ((ICBreakpoint2) bp).getMarkerType(); + } + if (bp instanceof ICDynamicPrintf) { + if (bp instanceof ICFunctionBreakpoint) { + return ICDynamicPrintf.C_FUNCTION_DYNAMICPRINTF_MARKER; + } else if (bp instanceof ICAddressBreakpoint) { + return ICDynamicPrintf.C_ADDRESS_DYNAMICPRINTF_MARKER; + } else if (bp instanceof ICLineBreakpoint) { + return ICDynamicPrintf.C_LINE_DYNAMICPRINTF_MARKER; + } else { + return ICDynamicPrintf.C_DYNAMICPRINTF_MARKER; + } + } else if (bp instanceof ICTracepoint) { + if (bp instanceof ICFunctionBreakpoint) { + return ICTracepoint.C_FUNCTION_TRACEPOINT_MARKER; + } else if (bp instanceof ICAddressBreakpoint) { + return ICTracepoint.C_ADDRESS_TRACEPOINT_MARKER; + } else if (bp instanceof ICLineBreakpoint) { + return ICTracepoint.C_LINE_TRACEPOINT_MARKER; + } else { + return ICTracepoint.C_TRACEPOINT_MARKER; + } + } else if (bp instanceof ICFunctionBreakpoint) { + return ICFunctionBreakpoint.C_FUNCTION_BREAKPOINT_MARKER; + } else if (bp instanceof ICAddressBreakpoint) { + return ICAddressBreakpoint.C_ADDRESS_BREAKPOINT_MARKER; + } else if (bp instanceof ICLineBreakpoint) { + return ICLineBreakpoint.C_LINE_BREAKPOINT_MARKER; + } else if (bp instanceof ICEventBreakpoint) { + return ICEventBreakpoint.C_EVENT_BREAKPOINT_MARKER; + } else if (bp instanceof ICBreakpoint) { + return ICBreakpoint.C_BREAKPOINT_MARKER; + } else if (bp instanceof ILineBreakpoint) { + return IBreakpoint.LINE_BREAKPOINT_MARKER; + } + return IBreakpoint.BREAKPOINT_MARKER; + } - /** - * Creates and returns a line breakpoint for the source defined by the given - * source handle, at the given line number. The marker associated with the - * breakpoint will be created on the specified resource. - * - * @param sourceHandle - * the handle to the breakpoint source - * @param resource - * the resource on which to create the associated breakpoint - * marker - * @param lineNumber - * the line number on which the breakpoint is set - line numbers - * are 1 based, associated with the source file in which the - * breakpoint is set - * @param enabled - * whether to enable or disable this breakpoint - * @param ignoreCount - * the number of times this breakpoint will be ignored - * @param condition - * the breakpoint condition - * @param register - * whether to add this breakpoint to the breakpoint manager - * @return a line breakpoint - * @throws CoreException - * if this method fails. Reasons include: - * <ul> - * <li>Failure creating underlying marker. The exception's - * status contains the underlying exception responsible for the - * failure.</li> - * </ul> - * @deprecated as of CDT 5.0 use - * {@link #createLineBreakpoint(String, IResource, int, int, boolean, int, String, boolean)} - */ - @Deprecated - public static ICLineBreakpoint createLineBreakpoint(String sourceHandle, IResource resource, int lineNumber, - boolean enabled, int ignoreCount, String condition, boolean register) throws CoreException { - return createLineBreakpoint(sourceHandle, resource, ICBreakpointType.REGULAR, lineNumber, enabled, ignoreCount, - condition, register); - } + /** + * Creates and returns a line breakpoint for the source defined by the given + * source handle, at the given line number. The marker associated with the + * breakpoint will be created on the specified resource. + * + * @param sourceHandle + * the handle to the breakpoint source + * @param resource + * the resource on which to create the associated breakpoint + * marker + * @param lineNumber + * the line number on which the breakpoint is set - line numbers + * are 1 based, associated with the source file in which the + * breakpoint is set + * @param enabled + * whether to enable or disable this breakpoint + * @param ignoreCount + * the number of times this breakpoint will be ignored + * @param condition + * the breakpoint condition + * @param register + * whether to add this breakpoint to the breakpoint manager + * @return a line breakpoint + * @throws CoreException + * if this method fails. Reasons include: + * <ul> + * <li>Failure creating underlying marker. The exception's + * status contains the underlying exception responsible for the + * failure.</li> + * </ul> + * @deprecated as of CDT 5.0 use + * {@link #createLineBreakpoint(String, IResource, int, int, boolean, int, String, boolean)} + */ + @Deprecated + public static ICLineBreakpoint createLineBreakpoint(String sourceHandle, IResource resource, int lineNumber, + boolean enabled, int ignoreCount, String condition, boolean register) throws CoreException { + return createLineBreakpoint(sourceHandle, resource, ICBreakpointType.REGULAR, lineNumber, enabled, ignoreCount, + condition, register); + } - /** - * Creates and returns a line breakpoint for the source defined by the given - * source handle, at the given line number. The marker associated with the - * breakpoint will be created on the specified resource. - * - * @param sourceHandle - * the handle to the breakpoint source - * @param resource - * the resource on which to create the associated breakpoint - * marker - * @param type - * a type constant from ICBreakpointType - * @param lineNumber - * the line number on which the breakpoint is set - line numbers - * are 1 based, associated with the source file in which the - * breakpoint is set - * @param enabled - * whether to enable or disable this breakpoint - * @param ignoreCount - * the number of times this breakpoint will be ignored - * @param condition - * the breakpoint condition - * @param register - * whether to add this breakpoint to the breakpoint manager - * @return a line breakpoint - * @throws CoreException - * if this method fails. Reasons include: - * <ul> - * <li>Failure creating underlying marker. The exception's - * status contains the underlying exception responsible for the - * failure.</li> - * </ul> - */ - public static ICLineBreakpoint createLineBreakpoint(String sourceHandle, IResource resource, int type, - int lineNumber, boolean enabled, int ignoreCount, String condition, boolean register) throws CoreException { - HashMap<String, Object> attributes = new HashMap<String, Object>(10); - setLineBreakpointAttributes(attributes, sourceHandle, type, lineNumber, enabled, ignoreCount, condition); - return new CLineBreakpoint(resource, attributes, register); - } + /** + * Creates and returns a line breakpoint for the source defined by the given + * source handle, at the given line number. The marker associated with the + * breakpoint will be created on the specified resource. + * + * @param sourceHandle + * the handle to the breakpoint source + * @param resource + * the resource on which to create the associated breakpoint + * marker + * @param type + * a type constant from ICBreakpointType + * @param lineNumber + * the line number on which the breakpoint is set - line numbers + * are 1 based, associated with the source file in which the + * breakpoint is set + * @param enabled + * whether to enable or disable this breakpoint + * @param ignoreCount + * the number of times this breakpoint will be ignored + * @param condition + * the breakpoint condition + * @param register + * whether to add this breakpoint to the breakpoint manager + * @return a line breakpoint + * @throws CoreException + * if this method fails. Reasons include: + * <ul> + * <li>Failure creating underlying marker. The exception's + * status contains the underlying exception responsible for the + * failure.</li> + * </ul> + */ + public static ICLineBreakpoint createLineBreakpoint(String sourceHandle, IResource resource, int type, + int lineNumber, boolean enabled, int ignoreCount, String condition, boolean register) throws CoreException { + HashMap<String, Object> attributes = new HashMap<String, Object>(10); + setLineBreakpointAttributes(attributes, sourceHandle, type, lineNumber, enabled, ignoreCount, condition); + return new CLineBreakpoint(resource, attributes, register); + } - /** - * Creates a line breakpoint without associated marker. - * <p> - * Note: Before a breakpoint created using this method can be used, the - * client must first create a marker and register the breakpoint. The former - * is accomplished using {@link IBreakpoint#setMarker(IMarker)}, the latter - * using {@link IBreakpointManager#addBreakpoint(IBreakpoint)}. - * - * @since 7.2 - */ - public static ICLineBreakpoint createBlankLineBreakpoint() { - return new CLineBreakpoint(); - } + /** + * Creates a line breakpoint without associated marker. + * <p> + * Note: Before a breakpoint created using this method can be used, the + * client must first create a marker and register the breakpoint. The former + * is accomplished using {@link IBreakpoint#setMarker(IMarker)}, the latter + * using {@link IBreakpointManager#addBreakpoint(IBreakpoint)}. + * + * @since 7.2 + */ + public static ICLineBreakpoint createBlankLineBreakpoint() { + return new CLineBreakpoint(); + } - /** - * @since 7.0 - */ - public static ICLineBreakpoint createLineTracepoint(String sourceHandle, IResource resource, int type, - int lineNumber, boolean enabled, int ignoreCount, String condition, boolean register) throws CoreException { - HashMap<String, Object> attributes = new HashMap<String, Object>(10); - setLineBreakpointAttributes(attributes, sourceHandle, type, lineNumber, enabled, ignoreCount, condition); - return new CLineTracepoint(resource, attributes, register); - } + /** + * @since 7.0 + */ + public static ICLineBreakpoint createLineTracepoint(String sourceHandle, IResource resource, int type, + int lineNumber, boolean enabled, int ignoreCount, String condition, boolean register) throws CoreException { + HashMap<String, Object> attributes = new HashMap<String, Object>(10); + setLineBreakpointAttributes(attributes, sourceHandle, type, lineNumber, enabled, ignoreCount, condition); + return new CLineTracepoint(resource, attributes, register); + } - /** - * Creates a line tracepoint without associated marker. - * <p> - * Note: Before a tracepoint created using this method can be used, the - * client must first create a marker and register the breakpoint. The former - * is accomplished using {@link IBreakpoint#setMarker(IMarker)}, the latter - * using {@link IBreakpointManager#addBreakpoint(IBreakpoint)}. - * - * @since 7.2 - */ - public static ICLineBreakpoint createBlankLineTracepoint() { - return new CLineTracepoint(); - } + /** + * Creates a line tracepoint without associated marker. + * <p> + * Note: Before a tracepoint created using this method can be used, the + * client must first create a marker and register the breakpoint. The former + * is accomplished using {@link IBreakpoint#setMarker(IMarker)}, the latter + * using {@link IBreakpointManager#addBreakpoint(IBreakpoint)}. + * + * @since 7.2 + */ + public static ICLineBreakpoint createBlankLineTracepoint() { + return new CLineTracepoint(); + } - /** - * @since 7.5 - */ - public static ICLineBreakpoint createLineDynamicPrintf(String sourceHandle, IResource resource, int type, - int lineNumber, boolean enabled, int ignoreCount, String condition, String printfStr, boolean register) throws CoreException { - HashMap<String, Object> attributes = new HashMap<String, Object>(10); - setLineBreakpointAttributes(attributes, sourceHandle, type, lineNumber, enabled, ignoreCount, condition); - attributes.put(ICDynamicPrintf.PRINTF_STRING, printfStr); - return new CLineDynamicPrintf(resource, attributes, register); - } + /** + * @since 7.5 + */ + public static ICLineBreakpoint createLineDynamicPrintf(String sourceHandle, IResource resource, int type, + int lineNumber, boolean enabled, int ignoreCount, String condition, String printfStr, boolean register) + throws CoreException { + HashMap<String, Object> attributes = new HashMap<String, Object>(10); + setLineBreakpointAttributes(attributes, sourceHandle, type, lineNumber, enabled, ignoreCount, condition); + attributes.put(ICDynamicPrintf.PRINTF_STRING, printfStr); + return new CLineDynamicPrintf(resource, attributes, register); + } - /** - * Creates a line dynamic printf without associated marker. - * <p> - * Note: Before a dynamic printf created using this method can be used, the - * client must first create a marker and register the breakpoint. The former - * is accomplished using {@link IBreakpoint#setMarker(IMarker)}, the latter - * using {@link IBreakpointManager#addBreakpoint(IBreakpoint)}. - * - * @since 7.5 - */ - public static ICLineBreakpoint createBlankLineDynamicPrintf() { - return new CLineDynamicPrintf(); - } - - /** - * Helper function for setting common line breakpoint attributes. - * - * @param attributes - * Map to write the attributes into. - * @param sourceHandle - * The handle to the breakpoint source. - * @param resource - * The resource on which to create the associated breakpoint - * marker. - * @param type - * A type constant from ICBreakpointType. - * @param lineNumber - * The line number on which the breakpoint is set - line numbers - * are 1 based, associated with the source file in which the - * breakpoint is set. - * @param enabled - * Whether to enable or disable this breakpoint. - * @param ignoreCount - * The number of times this breakpoint will be ignored. - * @param condition - * The breakpoint condition. - * @param register - * Whether to add this breakpoint to the breakpoint manager. - * - * @since 7.2 - */ - public static void setLineBreakpointAttributes(Map<String, Object> attributes, String sourceHandle, Integer type, - int lineNumber, boolean enabled, int ignoreCount, String condition) { - attributes.put(IBreakpoint.ID, getPluginIdentifier()); - attributes.put(IMarker.LINE_NUMBER, Integer.valueOf(lineNumber)); - attributes.put(IBreakpoint.ENABLED, Boolean.valueOf(enabled)); - attributes.put(ICBreakpoint.IGNORE_COUNT, Integer.valueOf(ignoreCount)); - attributes.put(ICBreakpoint.CONDITION, condition); - attributes.put(ICBreakpoint.SOURCE_HANDLE, sourceHandle); - attributes.put(ICBreakpointType.TYPE, type); + /** + * Creates a line dynamic printf without associated marker. + * <p> + * Note: Before a dynamic printf created using this method can be used, the + * client must first create a marker and register the breakpoint. The former + * is accomplished using {@link IBreakpoint#setMarker(IMarker)}, the latter + * using {@link IBreakpointManager#addBreakpoint(IBreakpoint)}. + * + * @since 7.5 + */ + public static ICLineBreakpoint createBlankLineDynamicPrintf() { + return new CLineDynamicPrintf(); + } - // Added for source relocated breakpoints. - if (!attributes.containsKey(ICLineBreakpoint2.REQUESTED_SOURCE_HANDLE)) { - attributes.put(ICLineBreakpoint2.REQUESTED_SOURCE_HANDLE, sourceHandle); - } - if (!attributes.containsKey(ICLineBreakpoint2.REQUESTED_LINE)) { - attributes.put(ICLineBreakpoint2.REQUESTED_LINE, Integer.valueOf(lineNumber)); - } - if (attributes.containsKey(IMarker.CHAR_START) - && !attributes.containsKey(ICLineBreakpoint2.REQUESTED_CHAR_START)) { - attributes.put(ICLineBreakpoint2.REQUESTED_CHAR_START, attributes.get(IMarker.CHAR_START)); - } - if (attributes.containsKey(IMarker.CHAR_END) && !attributes.containsKey(ICLineBreakpoint2.REQUESTED_CHAR_END)) { - attributes.put(ICLineBreakpoint2.REQUESTED_CHAR_END, attributes.get(IMarker.CHAR_END)); - } - } + /** + * Helper function for setting common line breakpoint attributes. + * + * @param attributes + * Map to write the attributes into. + * @param sourceHandle + * The handle to the breakpoint source. + * @param resource + * The resource on which to create the associated breakpoint + * marker. + * @param type + * A type constant from ICBreakpointType. + * @param lineNumber + * The line number on which the breakpoint is set - line numbers + * are 1 based, associated with the source file in which the + * breakpoint is set. + * @param enabled + * Whether to enable or disable this breakpoint. + * @param ignoreCount + * The number of times this breakpoint will be ignored. + * @param condition + * The breakpoint condition. + * @param register + * Whether to add this breakpoint to the breakpoint manager. + * + * @since 7.2 + */ + public static void setLineBreakpointAttributes(Map<String, Object> attributes, String sourceHandle, Integer type, + int lineNumber, boolean enabled, int ignoreCount, String condition) { + attributes.put(IBreakpoint.ID, getPluginIdentifier()); + attributes.put(IMarker.LINE_NUMBER, Integer.valueOf(lineNumber)); + attributes.put(IBreakpoint.ENABLED, Boolean.valueOf(enabled)); + attributes.put(ICBreakpoint.IGNORE_COUNT, Integer.valueOf(ignoreCount)); + attributes.put(ICBreakpoint.CONDITION, condition); + attributes.put(ICBreakpoint.SOURCE_HANDLE, sourceHandle); + attributes.put(ICBreakpointType.TYPE, type); - /** - * Creates and returns an address breakpoint for the source defined by the - * given source handle, at the given address. The marker associated with the - * breakpoint will be created on the specified resource. - * - * @param module - * the module name the breakpoint is set in - * @param sourceHandle - * the handle to the breakpoint source - * @param resource - * the resource on which to create the associated breakpoint - * marker - * @param address - * the address on which the breakpoint is set - * @param enabled - * whether to enable or disable this breakpoint - * @param ignoreCount - * the number of times this breakpoint will be ignored - * @param condition - * the breakpoint condition - * @param register - * whether to add this breakpoint to the breakpoint manager - * @return an address breakpoint - * @throws CoreException - * if this method fails. Reasons include: - * <ul> - * <li>Failure creating underlying marker. The exception's - * status contains the underlying exception responsible for the - * failure.</li> - * </ul> - * @deprecated as of CDT 5.0 use - * {@link #createAddressBreakpoint(String, String, IResource, int, int, IAddress, boolean, int, String, boolean)} - */ - @Deprecated - public static ICAddressBreakpoint createAddressBreakpoint(String module, String sourceHandle, IResource resource, - IAddress address, boolean enabled, int ignoreCount, String condition, boolean register) throws CoreException { - return createAddressBreakpoint(module, sourceHandle, resource, ICBreakpointType.REGULAR, -1, address, enabled, - ignoreCount, condition, register); - } + // Added for source relocated breakpoints. + if (!attributes.containsKey(ICLineBreakpoint2.REQUESTED_SOURCE_HANDLE)) { + attributes.put(ICLineBreakpoint2.REQUESTED_SOURCE_HANDLE, sourceHandle); + } + if (!attributes.containsKey(ICLineBreakpoint2.REQUESTED_LINE)) { + attributes.put(ICLineBreakpoint2.REQUESTED_LINE, Integer.valueOf(lineNumber)); + } + if (attributes.containsKey(IMarker.CHAR_START) + && !attributes.containsKey(ICLineBreakpoint2.REQUESTED_CHAR_START)) { + attributes.put(ICLineBreakpoint2.REQUESTED_CHAR_START, attributes.get(IMarker.CHAR_START)); + } + if (attributes.containsKey(IMarker.CHAR_END) && !attributes.containsKey(ICLineBreakpoint2.REQUESTED_CHAR_END)) { + attributes.put(ICLineBreakpoint2.REQUESTED_CHAR_END, attributes.get(IMarker.CHAR_END)); + } + } - /** - * Creates and returns an address breakpoint for the source defined by the - * given source handle, at the given address. The marker associated with the - * breakpoint will be created on the specified resource. - * - * @param module - * the module name the breakpoint is set in - * @param sourceHandle - * the handle to the breakpoint source - * @param resource - * the resource on which to create the associated breakpoint - * marker - * @param type - * a type constant from ICBreakpointType - * @param address - * the address on which the breakpoint is set - * @param enabled - * whether to enable or disable this breakpoint - * @param ignoreCount - * the number of times this breakpoint will be ignored - * @param condition - * the breakpoint condition - * @param register - * whether to add this breakpoint to the breakpoint manager - * @return an address breakpoint - * @throws CoreException - * if this method fails. Reasons include: - * <ul> - * <li>Failure creating underlying marker. The exception's - * status contains the underlying exception responsible for the - * failure.</li> - * </ul> - */ - public static ICAddressBreakpoint createAddressBreakpoint(String module, String sourceHandle, IResource resource, - int type, IAddress address, boolean enabled, int ignoreCount, String condition, boolean register) - throws CoreException { - return createAddressBreakpoint(module, sourceHandle, resource, type, -1, address, enabled, ignoreCount, - condition, register); - } + /** + * Creates and returns an address breakpoint for the source defined by the + * given source handle, at the given address. The marker associated with the + * breakpoint will be created on the specified resource. + * + * @param module + * the module name the breakpoint is set in + * @param sourceHandle + * the handle to the breakpoint source + * @param resource + * the resource on which to create the associated breakpoint + * marker + * @param address + * the address on which the breakpoint is set + * @param enabled + * whether to enable or disable this breakpoint + * @param ignoreCount + * the number of times this breakpoint will be ignored + * @param condition + * the breakpoint condition + * @param register + * whether to add this breakpoint to the breakpoint manager + * @return an address breakpoint + * @throws CoreException + * if this method fails. Reasons include: + * <ul> + * <li>Failure creating underlying marker. The exception's + * status contains the underlying exception responsible for the + * failure.</li> + * </ul> + * @deprecated as of CDT 5.0 use + * {@link #createAddressBreakpoint(String, String, IResource, int, int, IAddress, boolean, int, String, boolean)} + */ + @Deprecated + public static ICAddressBreakpoint createAddressBreakpoint(String module, String sourceHandle, IResource resource, + IAddress address, boolean enabled, int ignoreCount, String condition, boolean register) + throws CoreException { + return createAddressBreakpoint(module, sourceHandle, resource, ICBreakpointType.REGULAR, -1, address, enabled, + ignoreCount, condition, register); + } - /** - * Creates and returns an address breakpoint for the source defined by the - * given source handle, at the given address. The marker associated with the - * breakpoint will be created on the specified resource. - * - * @param module - * the module name the breakpoint is set in - * @param sourceHandle - * the handle to the breakpoint source - * @param resource - * the resource on which to create the associated breakpoint - * marker - * @param type - * a type constant from ICBreakpointType - * @param lineNumber - * the line number in the source file - * @param address - * the address on which the breakpoint is set - * @param enabled - * whether to enable or disable this breakpoint - * @param ignoreCount - * the number of times this breakpoint will be ignored - * @param condition - * the breakpoint condition - * @param register - * whether to add this breakpoint to the breakpoint manager - * @return an address breakpoint - * @throws CoreException - * if this method fails. Reasons include: - * <ul> - * <li>Failure creating underlying marker. The exception's - * status contains the underlying exception responsible for the - * failure.</li> - * </ul> - */ - public static ICAddressBreakpoint createAddressBreakpoint(String module, String sourceHandle, IResource resource, - int type, int lineNumber, IAddress address, boolean enabled, int ignoreCount, String condition, boolean register) - throws CoreException { - HashMap<String, Object> attributes = new HashMap<String, Object>(10); - setAddressBreakpointAttributes(attributes, module, sourceHandle, type, lineNumber, address, enabled, - ignoreCount, condition); - return new CAddressBreakpoint(resource, attributes, register); - } + /** + * Creates and returns an address breakpoint for the source defined by the + * given source handle, at the given address. The marker associated with the + * breakpoint will be created on the specified resource. + * + * @param module + * the module name the breakpoint is set in + * @param sourceHandle + * the handle to the breakpoint source + * @param resource + * the resource on which to create the associated breakpoint + * marker + * @param type + * a type constant from ICBreakpointType + * @param address + * the address on which the breakpoint is set + * @param enabled + * whether to enable or disable this breakpoint + * @param ignoreCount + * the number of times this breakpoint will be ignored + * @param condition + * the breakpoint condition + * @param register + * whether to add this breakpoint to the breakpoint manager + * @return an address breakpoint + * @throws CoreException + * if this method fails. Reasons include: + * <ul> + * <li>Failure creating underlying marker. The exception's + * status contains the underlying exception responsible for the + * failure.</li> + * </ul> + */ + public static ICAddressBreakpoint createAddressBreakpoint(String module, String sourceHandle, IResource resource, + int type, IAddress address, boolean enabled, int ignoreCount, String condition, boolean register) + throws CoreException { + return createAddressBreakpoint(module, sourceHandle, resource, type, -1, address, enabled, ignoreCount, + condition, register); + } + + /** + * Creates and returns an address breakpoint for the source defined by the + * given source handle, at the given address. The marker associated with the + * breakpoint will be created on the specified resource. + * + * @param module + * the module name the breakpoint is set in + * @param sourceHandle + * the handle to the breakpoint source + * @param resource + * the resource on which to create the associated breakpoint + * marker + * @param type + * a type constant from ICBreakpointType + * @param lineNumber + * the line number in the source file + * @param address + * the address on which the breakpoint is set + * @param enabled + * whether to enable or disable this breakpoint + * @param ignoreCount + * the number of times this breakpoint will be ignored + * @param condition + * the breakpoint condition + * @param register + * whether to add this breakpoint to the breakpoint manager + * @return an address breakpoint + * @throws CoreException + * if this method fails. Reasons include: + * <ul> + * <li>Failure creating underlying marker. The exception's + * status contains the underlying exception responsible for the + * failure.</li> + * </ul> + */ + public static ICAddressBreakpoint createAddressBreakpoint(String module, String sourceHandle, IResource resource, + int type, int lineNumber, IAddress address, boolean enabled, int ignoreCount, String condition, + boolean register) throws CoreException { + HashMap<String, Object> attributes = new HashMap<String, Object>(10); + setAddressBreakpointAttributes(attributes, module, sourceHandle, type, lineNumber, address, enabled, + ignoreCount, condition); + return new CAddressBreakpoint(resource, attributes, register); + } + + /** + * Creates an address breakpoint without associated marker. + * <p> + * Note: Before a breakpoint created using this method can be used, the + * client must first create a marker and register the breakpoint. The former + * is accomplished using {@link IBreakpoint#setMarker(IMarker)}, the latter + * using {@link IBreakpointManager#addBreakpoint(IBreakpoint)}. + * + * @since 7.2 + */ + public static ICAddressBreakpoint createBlankAddressBreakpoint() { + return new CAddressBreakpoint(); + } - /** - * Creates an address breakpoint without associated marker. - * <p> - * Note: Before a breakpoint created using this method can be used, the - * client must first create a marker and register the breakpoint. The former - * is accomplished using {@link IBreakpoint#setMarker(IMarker)}, the latter - * using {@link IBreakpointManager#addBreakpoint(IBreakpoint)}. - * - * @since 7.2 - */ - public static ICAddressBreakpoint createBlankAddressBreakpoint() { - return new CAddressBreakpoint(); - } + /** + * @since 7.0 + */ + public static ICAddressBreakpoint createAddressTracepoint(String module, String sourceHandle, IResource resource, + int type, int lineNumber, IAddress address, boolean enabled, int ignoreCount, String condition, + boolean register) throws CoreException { + HashMap<String, Object> attributes = new HashMap<String, Object>(10); + setAddressBreakpointAttributes(attributes, module, sourceHandle, type, lineNumber, address, enabled, + ignoreCount, condition); + return new CAddressTracepoint(resource, attributes, register); + } - /** - * @since 7.0 - */ - public static ICAddressBreakpoint createAddressTracepoint(String module, String sourceHandle, IResource resource, - int type, int lineNumber, IAddress address, boolean enabled, int ignoreCount, String condition, boolean register) - throws CoreException { - HashMap<String, Object> attributes = new HashMap<String, Object>(10); - setAddressBreakpointAttributes(attributes, module, sourceHandle, type, lineNumber, address, enabled, - ignoreCount, condition); - return new CAddressTracepoint(resource, attributes, register); - } + /** + * Creates an address tracepoint without associated marker. + * <p> + * Note: Before a tracepoint created using this method can be used, the + * client must first create a marker and register the breakpoint. The former + * is accomplished using {@link IBreakpoint#setMarker(IMarker)}, the latter + * using {@link IBreakpointManager#addBreakpoint(IBreakpoint)}. + * + * @since 7.2 + */ + public static ICAddressBreakpoint createBlankAddressTracepoint() { + return new CAddressTracepoint(); + } - /** - * Creates an address tracepoint without associated marker. - * <p> - * Note: Before a tracepoint created using this method can be used, the - * client must first create a marker and register the breakpoint. The former - * is accomplished using {@link IBreakpoint#setMarker(IMarker)}, the latter - * using {@link IBreakpointManager#addBreakpoint(IBreakpoint)}. - * - * @since 7.2 - */ - public static ICAddressBreakpoint createBlankAddressTracepoint() { - return new CAddressTracepoint(); - } + /** + * @since 7.5 + */ + public static ICAddressBreakpoint createAddressDynamicPrintf(String module, String sourceHandle, IResource resource, + int type, int lineNumber, IAddress address, boolean enabled, int ignoreCount, String condition, + String printfStr, boolean register) throws CoreException { + HashMap<String, Object> attributes = new HashMap<String, Object>(10); + setAddressBreakpointAttributes(attributes, module, sourceHandle, type, lineNumber, address, enabled, + ignoreCount, condition); + attributes.put(ICDynamicPrintf.PRINTF_STRING, printfStr); + return new CAddressDynamicPrintf(resource, attributes, register); + } - /** - * @since 7.5 - */ - public static ICAddressBreakpoint createAddressDynamicPrintf(String module, String sourceHandle, IResource resource, - int type, int lineNumber, IAddress address, boolean enabled, int ignoreCount, String condition, String printfStr, boolean register) - throws CoreException { - HashMap<String, Object> attributes = new HashMap<String, Object>(10); - setAddressBreakpointAttributes(attributes, module, sourceHandle, type, lineNumber, address, enabled, - ignoreCount, condition); - attributes.put(ICDynamicPrintf.PRINTF_STRING, printfStr); - return new CAddressDynamicPrintf(resource, attributes, register); - } + /** + * Creates an address dynamic printf without associated marker. + * <p> + * Note: Before a dynamic printf created using this method can be used, the + * client must first create a marker and register the breakpoint. The former + * is accomplished using {@link IBreakpoint#setMarker(IMarker)}, the latter + * using {@link IBreakpointManager#addBreakpoint(IBreakpoint)}. + * + * @since 7.5 + */ + public static ICAddressBreakpoint createBlankAddressDynamicPrintf() { + return new CAddressDynamicPrintf(); + } - /** - * Creates an address dynamic printf without associated marker. - * <p> - * Note: Before a dynamic printf created using this method can be used, the - * client must first create a marker and register the breakpoint. The former - * is accomplished using {@link IBreakpoint#setMarker(IMarker)}, the latter - * using {@link IBreakpointManager#addBreakpoint(IBreakpoint)}. - * - * @since 7.5 - */ - public static ICAddressBreakpoint createBlankAddressDynamicPrintf() { - return new CAddressDynamicPrintf(); - } - - /** - * Helper function for setting common address breakpoint attributes. - * - * @param attributes - * Map to write the attributes into. - * @param module - * the module name the breakpoint is set in - * @param sourceHandle - * the handle to the breakpoint source - * @param resource - * the resource on which to create the associated breakpoint - * marker - * @param type - * a type constant from ICBreakpointType - * @param lineNumber - * the line number in the source file - * @param address - * the address on which the breakpoint is set - * @param enabled - * whether to enable or disable this breakpoint - * @param ignoreCount - * the number of times this breakpoint will be ignored - * @param condition - * the breakpoint condition - * @param register - * whether to add this breakpoint to the breakpoint manager - * - * @since 7.2 - */ - public static void setAddressBreakpointAttributes(Map<String, Object> attributes, String module, - String sourceHandle, int type, int lineNumber, IAddress address, boolean enabled, int ignoreCount, - String condition) { - setLineBreakpointAttributes(attributes, sourceHandle, type, lineNumber, enabled, ignoreCount, condition); - attributes.put(IMarker.CHAR_START, Integer.valueOf(-1)); - attributes.put(IMarker.CHAR_END, Integer.valueOf(-1)); - attributes.put(ICLineBreakpoint.ADDRESS, address.toHexAddressString()); - attributes.put(ICBreakpoint.MODULE, module); - } + /** + * Helper function for setting common address breakpoint attributes. + * + * @param attributes + * Map to write the attributes into. + * @param module + * the module name the breakpoint is set in + * @param sourceHandle + * the handle to the breakpoint source + * @param resource + * the resource on which to create the associated breakpoint + * marker + * @param type + * a type constant from ICBreakpointType + * @param lineNumber + * the line number in the source file + * @param address + * the address on which the breakpoint is set + * @param enabled + * whether to enable or disable this breakpoint + * @param ignoreCount + * the number of times this breakpoint will be ignored + * @param condition + * the breakpoint condition + * @param register + * whether to add this breakpoint to the breakpoint manager + * + * @since 7.2 + */ + public static void setAddressBreakpointAttributes(Map<String, Object> attributes, String module, + String sourceHandle, int type, int lineNumber, IAddress address, boolean enabled, int ignoreCount, + String condition) { + setLineBreakpointAttributes(attributes, sourceHandle, type, lineNumber, enabled, ignoreCount, condition); + attributes.put(IMarker.CHAR_START, Integer.valueOf(-1)); + attributes.put(IMarker.CHAR_END, Integer.valueOf(-1)); + attributes.put(ICLineBreakpoint.ADDRESS, address.toHexAddressString()); + attributes.put(ICBreakpoint.MODULE, module); + } - /** - * Creates a watchpoint without associated marker. - * <p> - * Note: Before a watchpoint created using this method can be used, the - * client must first create a marker and register the breakpoint. The former - * is accomplished using {@link IBreakpoint#setMarker(IMarker)}, the latter - * using {@link IBreakpointManager#addBreakpoint(IBreakpoint)}. - * - * @since 7.2 - */ - public static ICWatchpoint createBlankWatchpoint() { - return new CWatchpoint(); - } + /** + * Creates a watchpoint without associated marker. + * <p> + * Note: Before a watchpoint created using this method can be used, the + * client must first create a marker and register the breakpoint. The former + * is accomplished using {@link IBreakpoint#setMarker(IMarker)}, the latter + * using {@link IBreakpointManager#addBreakpoint(IBreakpoint)}. + * + * @since 7.2 + */ + public static ICWatchpoint createBlankWatchpoint() { + return new CWatchpoint(); + } - /** - * Creates and returns a watchpoint for the source defined by the given - * source handle, at the given expression. The marker associated with the - * watchpoint will be created on the specified resource. - * - * @param sourceHandle - * the handle to the watchpoint source - * @param resource - * the resource on which to create the associated watchpoint - * marker - * @param writeAccess - * whether this is write watchpoint - * @param readAccess - * whether this is read watchpoint - * @param expression - * the expression on which the watchpoint is set - * @param enabled - * whether to enable or disable this breakpoint - * @param ignoreCount - * the number of times this breakpoint will be ignored - * @param condition - * the breakpoint condition - * @param register - * whether to add this breakpoint to the breakpoint manager - * @return a watchpoint - * @throws CoreException - * if this method fails. Reasons include: - * <ul> - * <li>Failure creating underlying marker. The exception's - * status contains the underlying exception responsible for the - * failure.</li> - * </ul> - */ - public static ICWatchpoint createWatchpoint(String sourceHandle, IResource resource, boolean writeAccess, - boolean readAccess, String expression, boolean enabled, int ignoreCount, String condition, boolean register) - throws CoreException { - HashMap<String, Object> attributes = new HashMap<String, Object>(10); - setWatchPointAttributes(attributes, sourceHandle, resource, writeAccess, readAccess, expression, "", //$NON-NLS-1$ - BigInteger.ZERO, enabled, ignoreCount, condition); - return new CWatchpoint(resource, attributes, register); - } + /** + * Creates and returns a watchpoint for the source defined by the given + * source handle, at the given expression. The marker associated with the + * watchpoint will be created on the specified resource. + * + * @param sourceHandle + * the handle to the watchpoint source + * @param resource + * the resource on which to create the associated watchpoint + * marker + * @param writeAccess + * whether this is write watchpoint + * @param readAccess + * whether this is read watchpoint + * @param expression + * the expression on which the watchpoint is set + * @param enabled + * whether to enable or disable this breakpoint + * @param ignoreCount + * the number of times this breakpoint will be ignored + * @param condition + * the breakpoint condition + * @param register + * whether to add this breakpoint to the breakpoint manager + * @return a watchpoint + * @throws CoreException + * if this method fails. Reasons include: + * <ul> + * <li>Failure creating underlying marker. The exception's + * status contains the underlying exception responsible for the + * failure.</li> + * </ul> + */ + public static ICWatchpoint createWatchpoint(String sourceHandle, IResource resource, boolean writeAccess, + boolean readAccess, String expression, boolean enabled, int ignoreCount, String condition, boolean register) + throws CoreException { + HashMap<String, Object> attributes = new HashMap<String, Object>(10); + setWatchPointAttributes(attributes, sourceHandle, resource, writeAccess, readAccess, expression, "", //$NON-NLS-1$ + BigInteger.ZERO, enabled, ignoreCount, condition); + return new CWatchpoint(resource, attributes, register); + } - /** - * Creates and returns a watchpoint for the source defined by the given - * source handle, at the given expression. The marker associated with the - * watchpoint will be created on the specified resource. - * - * @param sourceHandle - * the handle to the watchpoint source - * @param resource - * the resource on which to create the associated watchpoint - * marker - * @param type - * a type constant from ICBreakpointType - * @param writeAccess - * whether this is write watchpoint - * @param readAccess - * whether this is read watchpoint - * @param expression - * the expression on which the watchpoint is set - * @param enabled - * whether to enable or disable this breakpoint - * @param ignoreCount - * the number of times this breakpoint will be ignored - * @param condition - * the breakpoint condition - * @param register - * whether to add this breakpoint to the breakpoint manager - * @return a watchpoint - * @throws CoreException - * if this method fails. Reasons include: - * <ul> - * <li>Failure creating underlying marker. The exception's - * status contains the underlying exception responsible for the - * failure.</li> - * </ul> - * + /** + * Creates and returns a watchpoint for the source defined by the given + * source handle, at the given expression. The marker associated with the + * watchpoint will be created on the specified resource. + * + * @param sourceHandle + * the handle to the watchpoint source + * @param resource + * the resource on which to create the associated watchpoint + * marker + * @param type + * a type constant from ICBreakpointType + * @param writeAccess + * whether this is write watchpoint + * @param readAccess + * whether this is read watchpoint + * @param expression + * the expression on which the watchpoint is set + * @param enabled + * whether to enable or disable this breakpoint + * @param ignoreCount + * the number of times this breakpoint will be ignored + * @param condition + * the breakpoint condition + * @param register + * whether to add this breakpoint to the breakpoint manager + * @return a watchpoint + * @throws CoreException + * if this method fails. Reasons include: + * <ul> + * <li>Failure creating underlying marker. The exception's + * status contains the underlying exception responsible for the + * failure.</li> + * </ul> + * * @since 7.3 */ - public static ICWatchpoint createWatchpoint(String sourceHandle, IResource resource, int type, boolean writeAccess, - boolean readAccess, String expression, boolean enabled, int ignoreCount, String condition, boolean register) - throws CoreException { - HashMap<String, Object> attributes = new HashMap<String, Object>(10); - setWatchPointAttributes(attributes, sourceHandle, resource, type, writeAccess, readAccess, expression, "", //$NON-NLS-1$ - BigInteger.ZERO, enabled, ignoreCount, condition); - return new CWatchpoint(resource, attributes, register); - } + public static ICWatchpoint createWatchpoint(String sourceHandle, IResource resource, int type, boolean writeAccess, + boolean readAccess, String expression, boolean enabled, int ignoreCount, String condition, boolean register) + throws CoreException { + HashMap<String, Object> attributes = new HashMap<String, Object>(10); + setWatchPointAttributes(attributes, sourceHandle, resource, type, writeAccess, readAccess, expression, "", //$NON-NLS-1$ + BigInteger.ZERO, enabled, ignoreCount, condition); + return new CWatchpoint(resource, attributes, register); + } - /** - * Creates and returns a watchpoint for the source defined by the given - * source handle, at the given expression. The marker associated with the - * watchpoint will be created on the specified resource. - * - * @param sourceHandle - * the handle to the watchpoint source - * @param resource - * the resource on which to create the associated watchpoint - * marker - * @param charStart - * the first character index associated with the watchpoint, or - * -1 if unspecified, in the source file in which the watchpoint - * is set - * @param charEnd - * the last character index associated with the watchpoint, or -1 - * if unspecified, in the source file in which the watchpoint is - * set - * @param lineNumber - * the lineNumber on which the watchpoint is set, or -1 if - * unspecified - line numbers are 1 based, associated with the - * source file in which the watchpoint is set - * @param writeAccess - * whether this is write watchpoint - * @param readAccess - * whether this is read watchpoint - * @param expression - * the expression on which the watchpoint is set - * @param memorySpace - * the memory space in which the watchpoint is set - * @param range - * the range of the watchpoint in addressable units - * @param enabled - * whether to enable or disable this breakpoint - * @param ignoreCount - * the number of times this breakpoint will be ignored - * @param condition - * the breakpoint condition - * @param register - * whether to add this breakpoint to the breakpoint manager - * @return a watchpoint - * @throws CoreException - * if this method fails. Reasons include: - * <ul> - * <li>Failure creating underlying marker. The exception's - * status contains the underlying exception responsible for the - * failure.</li> - * </ul> - */ - public static ICWatchpoint createWatchpoint(String sourceHandle, IResource resource, int charStart, int charEnd, - int lineNumber, boolean writeAccess, boolean readAccess, String expression, String memorySpace, - BigInteger range, boolean enabled, int ignoreCount, String condition, boolean register) throws CoreException { - HashMap<String, Object> attributes = new HashMap<String, Object>(10); - setWatchPointAttributes(attributes, sourceHandle, resource, writeAccess, readAccess, expression, memorySpace, - range, enabled, ignoreCount, condition); - attributes.put(IMarker.CHAR_START, Integer.valueOf(charStart)); - attributes.put(IMarker.CHAR_END, Integer.valueOf(charEnd)); - attributes.put(IMarker.LINE_NUMBER, Integer.valueOf(lineNumber)); - return new CWatchpoint(resource, attributes, register); - } + /** + * Creates and returns a watchpoint for the source defined by the given + * source handle, at the given expression. The marker associated with the + * watchpoint will be created on the specified resource. + * + * @param sourceHandle + * the handle to the watchpoint source + * @param resource + * the resource on which to create the associated watchpoint + * marker + * @param charStart + * the first character index associated with the watchpoint, or + * -1 if unspecified, in the source file in which the watchpoint + * is set + * @param charEnd + * the last character index associated with the watchpoint, or -1 + * if unspecified, in the source file in which the watchpoint is + * set + * @param lineNumber + * the lineNumber on which the watchpoint is set, or -1 if + * unspecified - line numbers are 1 based, associated with the + * source file in which the watchpoint is set + * @param writeAccess + * whether this is write watchpoint + * @param readAccess + * whether this is read watchpoint + * @param expression + * the expression on which the watchpoint is set + * @param memorySpace + * the memory space in which the watchpoint is set + * @param range + * the range of the watchpoint in addressable units + * @param enabled + * whether to enable or disable this breakpoint + * @param ignoreCount + * the number of times this breakpoint will be ignored + * @param condition + * the breakpoint condition + * @param register + * whether to add this breakpoint to the breakpoint manager + * @return a watchpoint + * @throws CoreException + * if this method fails. Reasons include: + * <ul> + * <li>Failure creating underlying marker. The exception's + * status contains the underlying exception responsible for the + * failure.</li> + * </ul> + */ + public static ICWatchpoint createWatchpoint(String sourceHandle, IResource resource, int charStart, int charEnd, + int lineNumber, boolean writeAccess, boolean readAccess, String expression, String memorySpace, + BigInteger range, boolean enabled, int ignoreCount, String condition, boolean register) + throws CoreException { + HashMap<String, Object> attributes = new HashMap<String, Object>(10); + setWatchPointAttributes(attributes, sourceHandle, resource, writeAccess, readAccess, expression, memorySpace, + range, enabled, ignoreCount, condition); + attributes.put(IMarker.CHAR_START, Integer.valueOf(charStart)); + attributes.put(IMarker.CHAR_END, Integer.valueOf(charEnd)); + attributes.put(IMarker.LINE_NUMBER, Integer.valueOf(lineNumber)); + return new CWatchpoint(resource, attributes, register); + } - /** - * Creates and returns a watchpoint for the source defined by the given - * source handle, at the given expression and over the given range. The - * marker associated with the watchpoint will be created on the specified - * resource. - * - * @param sourceHandle - * the handle to the watchpoint source - * @param resource - * the resource on which to create the associated watchpoint - * marker - * @param writeAccess - * whether this is write watchpoint - * @param readAccess - * whether this is read watchpoint - * @param expression - * the expression on which the watchpoint is set - * @param memorySpace - * the memory space in which the watchpoint is set - * @param range - * the range of the watchpoint in addressable units - * @param enabled - * whether to enable or disable this breakpoint - * @param ignoreCount - * the number of times this breakpoint will be ignored - * @param condition - * the breakpoint condition - * @param register - * whether to add this breakpoint to the breakpoint manager - * @return the watchpoint that was created - * @throws CoreException - * if this method fails. Reasons include: - * <ul> - * <li>Failure creating underlying marker. The exception's - * status contains the underlying exception responsible for the - * failure.</li> - * </ul> - */ - public static ICWatchpoint createWatchpoint(String sourceHandle, IResource resource, boolean writeAccess, - boolean readAccess, String expression, String memorySpace, BigInteger range, boolean enabled, int ignoreCount, - String condition, boolean register) throws CoreException { - HashMap<String, Object> attributes = new HashMap<String, Object>(10); - setWatchPointAttributes(attributes, sourceHandle, resource, writeAccess, readAccess, expression, memorySpace, - range, enabled, ignoreCount, condition); - return new CWatchpoint(resource, attributes, register); - } + /** + * Creates and returns a watchpoint for the source defined by the given + * source handle, at the given expression and over the given range. The + * marker associated with the watchpoint will be created on the specified + * resource. + * + * @param sourceHandle + * the handle to the watchpoint source + * @param resource + * the resource on which to create the associated watchpoint + * marker + * @param writeAccess + * whether this is write watchpoint + * @param readAccess + * whether this is read watchpoint + * @param expression + * the expression on which the watchpoint is set + * @param memorySpace + * the memory space in which the watchpoint is set + * @param range + * the range of the watchpoint in addressable units + * @param enabled + * whether to enable or disable this breakpoint + * @param ignoreCount + * the number of times this breakpoint will be ignored + * @param condition + * the breakpoint condition + * @param register + * whether to add this breakpoint to the breakpoint manager + * @return the watchpoint that was created + * @throws CoreException + * if this method fails. Reasons include: + * <ul> + * <li>Failure creating underlying marker. The exception's + * status contains the underlying exception responsible for the + * failure.</li> + * </ul> + */ + public static ICWatchpoint createWatchpoint(String sourceHandle, IResource resource, boolean writeAccess, + boolean readAccess, String expression, String memorySpace, BigInteger range, boolean enabled, + int ignoreCount, String condition, boolean register) throws CoreException { + HashMap<String, Object> attributes = new HashMap<String, Object>(10); + setWatchPointAttributes(attributes, sourceHandle, resource, writeAccess, readAccess, expression, memorySpace, + range, enabled, ignoreCount, condition); + return new CWatchpoint(resource, attributes, register); + } - /** - * Helper function for setting common watchpoint attributes. - * - * @param attributes - * Map to write the attributes into. - * @param sourceHandle - * the handle to the watchpoint source - * @param resource - * the resource on which to create the associated watchpoint - * marker - * @param writeAccess - * whether this is write watchpoint - * @param readAccess - * whether this is read watchpoint - * @param expression - * the expression on which the watchpoint is set - * @param memorySpace - * the memory space in which the watchpoint is set - * @param range - * the range of the watchpoint in addressable units - * @param enabled - * whether to enable or disable this breakpoint - * @param ignoreCount - * the number of times this breakpoint will be ignored - * @param condition - * the breakpoint condition - * @param register - * whether to add this breakpoint to the breakpoint manager - * - * @since 7.2 - */ - public static void setWatchPointAttributes(Map<String, Object> attributes, String sourceHandle, IResource resource, - boolean writeAccess, boolean readAccess, String expression, String memorySpace, BigInteger range, - boolean enabled, int ignoreCount, String condition) { - attributes.put(IBreakpoint.ID, getPluginIdentifier()); - attributes.put(IBreakpoint.ENABLED, Boolean.valueOf(enabled)); - attributes.put(ICBreakpoint.IGNORE_COUNT, Integer.valueOf(ignoreCount)); - attributes.put(ICBreakpoint.CONDITION, condition); - attributes.put(ICBreakpoint.SOURCE_HANDLE, sourceHandle); - attributes.put(ICWatchpoint.EXPRESSION, expression); - attributes.put(ICWatchpoint2.MEMORYSPACE, memorySpace); - attributes.put(ICWatchpoint2.RANGE, range.toString()); - attributes.put(ICWatchpoint.READ, Boolean.valueOf(readAccess)); - attributes.put(ICWatchpoint.WRITE, Boolean.valueOf(writeAccess)); - } + /** + * Helper function for setting common watchpoint attributes. + * + * @param attributes + * Map to write the attributes into. + * @param sourceHandle + * the handle to the watchpoint source + * @param resource + * the resource on which to create the associated watchpoint + * marker + * @param writeAccess + * whether this is write watchpoint + * @param readAccess + * whether this is read watchpoint + * @param expression + * the expression on which the watchpoint is set + * @param memorySpace + * the memory space in which the watchpoint is set + * @param range + * the range of the watchpoint in addressable units + * @param enabled + * whether to enable or disable this breakpoint + * @param ignoreCount + * the number of times this breakpoint will be ignored + * @param condition + * the breakpoint condition + * @param register + * whether to add this breakpoint to the breakpoint manager + * + * @since 7.2 + */ + public static void setWatchPointAttributes(Map<String, Object> attributes, String sourceHandle, IResource resource, + boolean writeAccess, boolean readAccess, String expression, String memorySpace, BigInteger range, + boolean enabled, int ignoreCount, String condition) { + attributes.put(IBreakpoint.ID, getPluginIdentifier()); + attributes.put(IBreakpoint.ENABLED, Boolean.valueOf(enabled)); + attributes.put(ICBreakpoint.IGNORE_COUNT, Integer.valueOf(ignoreCount)); + attributes.put(ICBreakpoint.CONDITION, condition); + attributes.put(ICBreakpoint.SOURCE_HANDLE, sourceHandle); + attributes.put(ICWatchpoint.EXPRESSION, expression); + attributes.put(ICWatchpoint2.MEMORYSPACE, memorySpace); + attributes.put(ICWatchpoint2.RANGE, range.toString()); + attributes.put(ICWatchpoint.READ, Boolean.valueOf(readAccess)); + attributes.put(ICWatchpoint.WRITE, Boolean.valueOf(writeAccess)); + } - /** - * Helper function for setting common watchpoint attributes. - * - * @param attributes - * Map to write the attributes into. - * @param sourceHandle - * the handle to the watchpoint source - * @param resource - * the resource on which to create the associated watchpoint - * marker - * @param type - * a type constant from ICBreakpointType - * @param writeAccess - * whether this is write watchpoint - * @param readAccess - * whether this is read watchpoint - * @param expression - * the expression on which the watchpoint is set - * @param memorySpace - * the memory space in which the watchpoint is set - * @param range - * the range of the watchpoint in addressable units - * @param enabled - * whether to enable or disable this breakpoint - * @param ignoreCount - * the number of times this breakpoint will be ignored - * @param condition - * the breakpoint condition - * @param register - * whether to add this breakpoint to the breakpoint manager - * + /** + * Helper function for setting common watchpoint attributes. + * + * @param attributes + * Map to write the attributes into. + * @param sourceHandle + * the handle to the watchpoint source + * @param resource + * the resource on which to create the associated watchpoint + * marker + * @param type + * a type constant from ICBreakpointType + * @param writeAccess + * whether this is write watchpoint + * @param readAccess + * whether this is read watchpoint + * @param expression + * the expression on which the watchpoint is set + * @param memorySpace + * the memory space in which the watchpoint is set + * @param range + * the range of the watchpoint in addressable units + * @param enabled + * whether to enable or disable this breakpoint + * @param ignoreCount + * the number of times this breakpoint will be ignored + * @param condition + * the breakpoint condition + * @param register + * whether to add this breakpoint to the breakpoint manager + * * @since 7.3 */ - public static void setWatchPointAttributes(Map<String, Object> attributes, String sourceHandle, IResource resource, - int type, boolean writeAccess, boolean readAccess, String expression, String memorySpace, BigInteger range, - boolean enabled, int ignoreCount, String condition) { - setWatchPointAttributes(attributes, sourceHandle, resource, - writeAccess, readAccess, expression, memorySpace, range, enabled, ignoreCount, condition); - attributes.put(ICBreakpointType.TYPE, type); - } + public static void setWatchPointAttributes(Map<String, Object> attributes, String sourceHandle, IResource resource, + int type, boolean writeAccess, boolean readAccess, String expression, String memorySpace, BigInteger range, + boolean enabled, int ignoreCount, String condition) { + setWatchPointAttributes(attributes, sourceHandle, resource, writeAccess, readAccess, expression, memorySpace, + range, enabled, ignoreCount, condition); + attributes.put(ICBreakpointType.TYPE, type); + } - /** - * Creates and returns a breakpoint for the function defined by the given - * name. The marker associated with the breakpoint will be created on the - * specified resource. - * - * @param sourceHandle - * the handle to the breakpoint source - * @param resource - * the resource on which to create the associated breakpoint - * marker - * @param function - * the name of the function this breakpoint suspends execution in - * @param charStart - * the first character index associated with the breakpoint, or - * -1 if unspecified, in the source file in which the breakpoint - * is set - * @param charEnd - * the last character index associated with the breakpoint, or -1 - * if unspecified, in the source file in which the breakpoint is - * set - * @param lineNumber - * the lineNumber on which the breakpoint is set, or -1 if - * unspecified - line numbers are 1 based, associated with the - * source file in which the breakpoint is set - * @param enabled - * whether to enable or disable this breakpoint - * @param ignoreCount - * the number of times this breakpoint will be ignored - * @param condition - * the breakpoint condition - * @param register - * whether to add this breakpoint to the breakpoint manager - * @return an address breakpoint - * @throws CoreException - * if this method fails. Reasons include: - * <ul> - * <li>Failure creating underlying marker. The exception's - * status contains the underlying exception responsible for the - * failure.</li> - * </ul> - * @deprecated as of CDT 5.0 use - * {@link #createFunctionBreakpoint(String, IResource, int, String, int, int, int, boolean, int, String, boolean)} - */ - @Deprecated - public static ICFunctionBreakpoint createFunctionBreakpoint(String sourceHandle, IResource resource, - String function, int charStart, int charEnd, int lineNumber, boolean enabled, int ignoreCount, - String condition, boolean register) throws CoreException { - return createFunctionBreakpoint(sourceHandle, resource, ICBreakpointType.REGULAR, function, charStart, charEnd, - lineNumber, enabled, ignoreCount, condition, register); - } + /** + * Creates and returns a breakpoint for the function defined by the given + * name. The marker associated with the breakpoint will be created on the + * specified resource. + * + * @param sourceHandle + * the handle to the breakpoint source + * @param resource + * the resource on which to create the associated breakpoint + * marker + * @param function + * the name of the function this breakpoint suspends execution in + * @param charStart + * the first character index associated with the breakpoint, or + * -1 if unspecified, in the source file in which the breakpoint + * is set + * @param charEnd + * the last character index associated with the breakpoint, or -1 + * if unspecified, in the source file in which the breakpoint is + * set + * @param lineNumber + * the lineNumber on which the breakpoint is set, or -1 if + * unspecified - line numbers are 1 based, associated with the + * source file in which the breakpoint is set + * @param enabled + * whether to enable or disable this breakpoint + * @param ignoreCount + * the number of times this breakpoint will be ignored + * @param condition + * the breakpoint condition + * @param register + * whether to add this breakpoint to the breakpoint manager + * @return an address breakpoint + * @throws CoreException + * if this method fails. Reasons include: + * <ul> + * <li>Failure creating underlying marker. The exception's + * status contains the underlying exception responsible for the + * failure.</li> + * </ul> + * @deprecated as of CDT 5.0 use + * {@link #createFunctionBreakpoint(String, IResource, int, String, int, int, int, boolean, int, String, boolean)} + */ + @Deprecated + public static ICFunctionBreakpoint createFunctionBreakpoint(String sourceHandle, IResource resource, + String function, int charStart, int charEnd, int lineNumber, boolean enabled, int ignoreCount, + String condition, boolean register) throws CoreException { + return createFunctionBreakpoint(sourceHandle, resource, ICBreakpointType.REGULAR, function, charStart, charEnd, + lineNumber, enabled, ignoreCount, condition, register); + } - /** - * Creates and returns a breakpoint for the function defined by the given - * name. The marker associated with the breakpoint will be created on the - * specified resource. - * - * @param sourceHandle - * the handle to the breakpoint source - * @param resource - * the resource on which to create the associated breakpoint - * marker - * @param type - * a type constant from ICBreakpointType - * @param function - * the name of the function this breakpoint suspends execution in - * @param charStart - * the first character index associated with the breakpoint, or - * -1 if unspecified, in the source file in which the breakpoint - * is set - * @param charEnd - * the last character index associated with the breakpoint, or -1 - * if unspecified, in the source file in which the breakpoint is - * set - * @param lineNumber - * the lineNumber on which the breakpoint is set, or -1 if - * unspecified - line numbers are 1 based, associated with the - * source file in which the breakpoint is set - * @param enabled - * whether to enable or disable this breakpoint - * @param ignoreCount - * the number of times this breakpoint will be ignored - * @param condition - * the breakpoint condition - * @param register - * whether to add this breakpoint to the breakpoint manager - * @return an address breakpoint - * @throws CoreException - * if this method fails. Reasons include: - * <ul> - * <li>Failure creating underlying marker. The exception's - * status contains the underlying exception responsible for the - * failure.</li> - * </ul> - */ - public static ICFunctionBreakpoint createFunctionBreakpoint(String sourceHandle, IResource resource, int type, - String function, int charStart, int charEnd, int lineNumber, boolean enabled, int ignoreCount, - String condition, boolean register) throws CoreException { - HashMap<String, Object> attributes = new HashMap<String, Object>(10); - setFunctionBreakpointAttributes(attributes, sourceHandle, type, function, charStart, charEnd, lineNumber, - enabled, ignoreCount, condition); - return new CFunctionBreakpoint(resource, attributes, register); - } + /** + * Creates and returns a breakpoint for the function defined by the given + * name. The marker associated with the breakpoint will be created on the + * specified resource. + * + * @param sourceHandle + * the handle to the breakpoint source + * @param resource + * the resource on which to create the associated breakpoint + * marker + * @param type + * a type constant from ICBreakpointType + * @param function + * the name of the function this breakpoint suspends execution in + * @param charStart + * the first character index associated with the breakpoint, or + * -1 if unspecified, in the source file in which the breakpoint + * is set + * @param charEnd + * the last character index associated with the breakpoint, or -1 + * if unspecified, in the source file in which the breakpoint is + * set + * @param lineNumber + * the lineNumber on which the breakpoint is set, or -1 if + * unspecified - line numbers are 1 based, associated with the + * source file in which the breakpoint is set + * @param enabled + * whether to enable or disable this breakpoint + * @param ignoreCount + * the number of times this breakpoint will be ignored + * @param condition + * the breakpoint condition + * @param register + * whether to add this breakpoint to the breakpoint manager + * @return an address breakpoint + * @throws CoreException + * if this method fails. Reasons include: + * <ul> + * <li>Failure creating underlying marker. The exception's + * status contains the underlying exception responsible for the + * failure.</li> + * </ul> + */ + public static ICFunctionBreakpoint createFunctionBreakpoint(String sourceHandle, IResource resource, int type, + String function, int charStart, int charEnd, int lineNumber, boolean enabled, int ignoreCount, + String condition, boolean register) throws CoreException { + HashMap<String, Object> attributes = new HashMap<String, Object>(10); + setFunctionBreakpointAttributes(attributes, sourceHandle, type, function, charStart, charEnd, lineNumber, + enabled, ignoreCount, condition); + return new CFunctionBreakpoint(resource, attributes, register); + } - /** - * Creates a function breakpoint without associated marker. - * <p> - * Note: Before a breakpoint created using this method can be used, the - * client must first create a marker and register the breakpoint. The former - * is accomplished using {@link IBreakpoint#setMarker(IMarker)}, the latter - * using {@link IBreakpointManager#addBreakpoint(IBreakpoint)}. - * - * @since 7.2 - */ - public static ICFunctionBreakpoint createBlankFunctionBreakpoint() { - return new CFunctionBreakpoint(); - } + /** + * Creates a function breakpoint without associated marker. + * <p> + * Note: Before a breakpoint created using this method can be used, the + * client must first create a marker and register the breakpoint. The former + * is accomplished using {@link IBreakpoint#setMarker(IMarker)}, the latter + * using {@link IBreakpointManager#addBreakpoint(IBreakpoint)}. + * + * @since 7.2 + */ + public static ICFunctionBreakpoint createBlankFunctionBreakpoint() { + return new CFunctionBreakpoint(); + } - /** - * Creates and returns a tracepoint for the function defined by the given - * name. The marker associated with the breakpoint will be created on the - * specified resource. - * - * @param sourceHandle - * the handle to the breakpoint source - * @param resource - * the resource on which to create the associated breakpoint - * marker - * @param type - * a type constant from ICBreakpointType - * @param function - * the name of the function this breakpoint suspends execution in - * @param charStart - * the first character index associated with the breakpoint, or - * -1 if unspecified, in the source file in which the breakpoint - * is set - * @param charEnd - * the last character index associated with the breakpoint, or -1 - * if unspecified, in the source file in which the breakpoint is - * set - * @param lineNumber - * the lineNumber on which the breakpoint is set, or -1 if - * unspecified - line numbers are 1 based, associated with the - * source file in which the breakpoint is set - * @param enabled - * whether to enable or disable this breakpoint - * @param ignoreCount - * the number of times this breakpoint will be ignored - * @param condition - * the breakpoint condition - * @param register - * whether to add this breakpoint to the breakpoint manager - * @return an address breakpoint - * @throws CoreException - * if this method fails. Reasons include: - * <ul> - * <li>Failure creating underlying marker. The exception's - * status contains the underlying exception responsible for the - * failure.</li> - * </ul> - * @since 7.0 - */ - public static ICFunctionBreakpoint createFunctionTracepoint(String sourceHandle, IResource resource, int type, - String function, int charStart, int charEnd, int lineNumber, boolean enabled, int ignoreCount, - String condition, boolean register) throws CoreException { - HashMap<String, Object> attributes = new HashMap<String, Object>(10); - setFunctionBreakpointAttributes(attributes, sourceHandle, type, function, charStart, charEnd, lineNumber, - enabled, ignoreCount, condition); - return new CFunctionTracepoint(resource, attributes, register); - } + /** + * Creates and returns a tracepoint for the function defined by the given + * name. The marker associated with the breakpoint will be created on the + * specified resource. + * + * @param sourceHandle + * the handle to the breakpoint source + * @param resource + * the resource on which to create the associated breakpoint + * marker + * @param type + * a type constant from ICBreakpointType + * @param function + * the name of the function this breakpoint suspends execution in + * @param charStart + * the first character index associated with the breakpoint, or + * -1 if unspecified, in the source file in which the breakpoint + * is set + * @param charEnd + * the last character index associated with the breakpoint, or -1 + * if unspecified, in the source file in which the breakpoint is + * set + * @param lineNumber + * the lineNumber on which the breakpoint is set, or -1 if + * unspecified - line numbers are 1 based, associated with the + * source file in which the breakpoint is set + * @param enabled + * whether to enable or disable this breakpoint + * @param ignoreCount + * the number of times this breakpoint will be ignored + * @param condition + * the breakpoint condition + * @param register + * whether to add this breakpoint to the breakpoint manager + * @return an address breakpoint + * @throws CoreException + * if this method fails. Reasons include: + * <ul> + * <li>Failure creating underlying marker. The exception's + * status contains the underlying exception responsible for the + * failure.</li> + * </ul> + * @since 7.0 + */ + public static ICFunctionBreakpoint createFunctionTracepoint(String sourceHandle, IResource resource, int type, + String function, int charStart, int charEnd, int lineNumber, boolean enabled, int ignoreCount, + String condition, boolean register) throws CoreException { + HashMap<String, Object> attributes = new HashMap<String, Object>(10); + setFunctionBreakpointAttributes(attributes, sourceHandle, type, function, charStart, charEnd, lineNumber, + enabled, ignoreCount, condition); + return new CFunctionTracepoint(resource, attributes, register); + } - /** - * Creates a function tracepoint without associated marker. - * <p> - * Note: Before a tracepoint created using this method can be used, the - * client must first create a marker and register the breakpoint. The former - * is accomplished using {@link IBreakpoint#setMarker(IMarker)}, the latter - * using {@link IBreakpointManager#addBreakpoint(IBreakpoint)}. - * - * @since 7.2 - */ - public static ICFunctionBreakpoint createBlankFunctionTracepoint() { - return new CFunctionTracepoint(); - } + /** + * Creates a function tracepoint without associated marker. + * <p> + * Note: Before a tracepoint created using this method can be used, the + * client must first create a marker and register the breakpoint. The former + * is accomplished using {@link IBreakpoint#setMarker(IMarker)}, the latter + * using {@link IBreakpointManager#addBreakpoint(IBreakpoint)}. + * + * @since 7.2 + */ + public static ICFunctionBreakpoint createBlankFunctionTracepoint() { + return new CFunctionTracepoint(); + } - /** - * @since 7.5 - */ - public static ICFunctionBreakpoint createFunctionDynamicPrintf(String sourceHandle, IResource resource, int type, - String function, int charStart, int charEnd, int lineNumber, boolean enabled, int ignoreCount, - String condition, String printfStr, boolean register) throws CoreException { - HashMap<String, Object> attributes = new HashMap<String, Object>(10); - setFunctionBreakpointAttributes(attributes, sourceHandle, type, function, charStart, charEnd, lineNumber, - enabled, ignoreCount, condition); - attributes.put(ICDynamicPrintf.PRINTF_STRING, printfStr); - return new CFunctionDynamicPrintf(resource, attributes, register); - } + /** + * @since 7.5 + */ + public static ICFunctionBreakpoint createFunctionDynamicPrintf(String sourceHandle, IResource resource, int type, + String function, int charStart, int charEnd, int lineNumber, boolean enabled, int ignoreCount, + String condition, String printfStr, boolean register) throws CoreException { + HashMap<String, Object> attributes = new HashMap<String, Object>(10); + setFunctionBreakpointAttributes(attributes, sourceHandle, type, function, charStart, charEnd, lineNumber, + enabled, ignoreCount, condition); + attributes.put(ICDynamicPrintf.PRINTF_STRING, printfStr); + return new CFunctionDynamicPrintf(resource, attributes, register); + } - /** - * Creates a function dynamic printf without associated marker. - * <p> - * Note: Before a dynamic printf created using this method can be used, the - * client must first create a marker and register the breakpoint. The former - * is accomplished using {@link IBreakpoint#setMarker(IMarker)}, the latter - * using {@link IBreakpointManager#addBreakpoint(IBreakpoint)}. - * - * @since 7.5 - */ - public static ICFunctionBreakpoint createBlankFunctionDynamicPrintf() { - return new CFunctionDynamicPrintf(); - } + /** + * Creates a function dynamic printf without associated marker. + * <p> + * Note: Before a dynamic printf created using this method can be used, the + * client must first create a marker and register the breakpoint. The former + * is accomplished using {@link IBreakpoint#setMarker(IMarker)}, the latter + * using {@link IBreakpointManager#addBreakpoint(IBreakpoint)}. + * + * @since 7.5 + */ + public static ICFunctionBreakpoint createBlankFunctionDynamicPrintf() { + return new CFunctionDynamicPrintf(); + } - /** - * Helper function for setting common address breakpoint attributes. - * - * @param attributes - * Map to write the attributes into. - * @param sourceHandle - * the handle to the breakpoint source - * @param resource - * the resource on which to create the associated breakpoint - * marker - * @param type - * a type constant from ICBreakpointType - * @param function - * the name of the function this breakpoint suspends execution in - * @param charStart - * the first character index associated with the breakpoint, or - * -1 if unspecified, in the source file in which the breakpoint - * is set - * @param charEnd - * the last character index associated with the breakpoint, or -1 - * if unspecified, in the source file in which the breakpoint is - * set - * @param lineNumber - * the lineNumber on which the breakpoint is set, or -1 if - * unspecified - line numbers are 1 based, associated with the - * source file in which the breakpoint is set - * @param enabled - * whether to enable or disable this breakpoint - * @param ignoreCount - * the number of times this breakpoint will be ignored - * @param condition - * the breakpoint condition - * @param register - * whether to add this breakpoint to the breakpoint manager - * - * @since 7.2 - */ - public static void setFunctionBreakpointAttributes(Map<String, Object> attributes, String sourceHandle, int type, - String function, int charStart, int charEnd, int lineNumber, boolean enabled, int ignoreCount, String condition) { - setLineBreakpointAttributes(attributes, sourceHandle, type, lineNumber, enabled, ignoreCount, condition); - attributes.put(IMarker.CHAR_START, Integer.valueOf(charStart)); - attributes.put(IMarker.CHAR_END, Integer.valueOf(charEnd)); - attributes.put(ICLineBreakpoint.FUNCTION, function); - } + /** + * Helper function for setting common address breakpoint attributes. + * + * @param attributes + * Map to write the attributes into. + * @param sourceHandle + * the handle to the breakpoint source + * @param resource + * the resource on which to create the associated breakpoint + * marker + * @param type + * a type constant from ICBreakpointType + * @param function + * the name of the function this breakpoint suspends execution in + * @param charStart + * the first character index associated with the breakpoint, or + * -1 if unspecified, in the source file in which the breakpoint + * is set + * @param charEnd + * the last character index associated with the breakpoint, or -1 + * if unspecified, in the source file in which the breakpoint is + * set + * @param lineNumber + * the lineNumber on which the breakpoint is set, or -1 if + * unspecified - line numbers are 1 based, associated with the + * source file in which the breakpoint is set + * @param enabled + * whether to enable or disable this breakpoint + * @param ignoreCount + * the number of times this breakpoint will be ignored + * @param condition + * the breakpoint condition + * @param register + * whether to add this breakpoint to the breakpoint manager + * + * @since 7.2 + */ + public static void setFunctionBreakpointAttributes(Map<String, Object> attributes, String sourceHandle, int type, + String function, int charStart, int charEnd, int lineNumber, boolean enabled, int ignoreCount, + String condition) { + setLineBreakpointAttributes(attributes, sourceHandle, type, lineNumber, enabled, ignoreCount, condition); + attributes.put(IMarker.CHAR_START, Integer.valueOf(charStart)); + attributes.put(IMarker.CHAR_END, Integer.valueOf(charEnd)); + attributes.put(ICLineBreakpoint.FUNCTION, function); + } - /** - * Returns the line breakpoint that is already registered with the - * breakpoint manager for a source with the given handle and the given - * resource at the given line number. - * - * @param sourceHandle - * the source handle - * @param resource - * the breakpoint resource - * @param lineNumber - * the line number - * @return the line breakpoint that is already registered with the - * breakpoint manager or <code>null</code> if no such breakpoint is - * registered - * @exception CoreException - * if unable to retrieve the associated marker attributes - * (line number). - */ - public static ICLineBreakpoint lineBreakpointExists(String sourceHandle, IResource resource, int lineNumber) - throws CoreException { - String modelId = getPluginIdentifier(); - IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager(); - IBreakpoint[] breakpoints = manager.getBreakpoints(modelId); - for (int i = 0; i < breakpoints.length; i++) { - if (!(breakpoints[i] instanceof ICLineBreakpoint)) { - continue; - } - ICLineBreakpoint breakpoint = (ICLineBreakpoint) breakpoints[i]; - if (sameSourceHandle(sourceHandle, breakpoint.getSourceHandle())) { - if (breakpoint.getLineNumber() == lineNumber) { - return breakpoint; - } - } - } - return null; - } + /** + * Returns the line breakpoint that is already registered with the + * breakpoint manager for a source with the given handle and the given + * resource at the given line number. + * + * @param sourceHandle + * the source handle + * @param resource + * the breakpoint resource + * @param lineNumber + * the line number + * @return the line breakpoint that is already registered with the + * breakpoint manager or <code>null</code> if no such breakpoint is + * registered + * @exception CoreException + * if unable to retrieve the associated marker attributes + * (line number). + */ + public static ICLineBreakpoint lineBreakpointExists(String sourceHandle, IResource resource, int lineNumber) + throws CoreException { + String modelId = getPluginIdentifier(); + IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager(); + IBreakpoint[] breakpoints = manager.getBreakpoints(modelId); + for (int i = 0; i < breakpoints.length; i++) { + if (!(breakpoints[i] instanceof ICLineBreakpoint)) { + continue; + } + ICLineBreakpoint breakpoint = (ICLineBreakpoint) breakpoints[i]; + if (sameSourceHandle(sourceHandle, breakpoint.getSourceHandle())) { + if (breakpoint.getLineNumber() == lineNumber) { + return breakpoint; + } + } + } + return null; + } - /** - * Returns the watchpoint that is already registered with the breakpoint - * manager for a source with the given handle and the given resource at the - * given expression. - * - * @param sourceHandle - * the source handle - * @param resource - * the breakpoint resource - * @param expression - * the expression - * @return the watchpoint that is already registered with the breakpoint - * manager or <code>null</code> if no such watchpoint is registered - * @exception CoreException - * if unable to retrieve the associated marker attributes - * (line number). - */ - public static ICWatchpoint watchpointExists(String sourceHandle, IResource resource, String expression) - throws CoreException { - String modelId = getPluginIdentifier(); - String markerType = ICWatchpoint.C_WATCHPOINT_MARKER; - IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager(); - IBreakpoint[] breakpoints = manager.getBreakpoints(modelId); - for (int i = 0; i < breakpoints.length; i++) { - if (!(breakpoints[i] instanceof ICWatchpoint)) { - continue; - } - ICWatchpoint breakpoint = (ICWatchpoint) breakpoints[i]; - if (breakpoint.getMarker().getType().equals(markerType)) { - if (sameSourceHandle(sourceHandle, breakpoint.getSourceHandle())) { - if (breakpoint.getMarker().getResource().equals(resource)) { - if (breakpoint.getExpression().equals(expression)) { - return breakpoint; - } - } - } - } - } - return null; - } + /** + * Returns the watchpoint that is already registered with the breakpoint + * manager for a source with the given handle and the given resource at the + * given expression. + * + * @param sourceHandle + * the source handle + * @param resource + * the breakpoint resource + * @param expression + * the expression + * @return the watchpoint that is already registered with the breakpoint + * manager or <code>null</code> if no such watchpoint is registered + * @exception CoreException + * if unable to retrieve the associated marker attributes + * (line number). + */ + public static ICWatchpoint watchpointExists(String sourceHandle, IResource resource, String expression) + throws CoreException { + String modelId = getPluginIdentifier(); + String markerType = ICWatchpoint.C_WATCHPOINT_MARKER; + IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager(); + IBreakpoint[] breakpoints = manager.getBreakpoints(modelId); + for (int i = 0; i < breakpoints.length; i++) { + if (!(breakpoints[i] instanceof ICWatchpoint)) { + continue; + } + ICWatchpoint breakpoint = (ICWatchpoint) breakpoints[i]; + if (breakpoint.getMarker().getType().equals(markerType)) { + if (sameSourceHandle(sourceHandle, breakpoint.getSourceHandle())) { + if (breakpoint.getMarker().getResource().equals(resource)) { + if (breakpoint.getExpression().equals(expression)) { + return breakpoint; + } + } + } + } + } + return null; + } - /** - * Returns the function breakpoint that is already registered with the - * breakpoint manager for a source with the given handle and the given - * resource with the given function name. - * - * @param sourceHandle - * the source handle - * @param resource - * the breakpoint resource - * @param function - * the fully qualified function name - * @return the breakpoint that is already registered with the breakpoint - * manager or <code>null</code> if no such breakpoint is registered - * @exception CoreException - * if unable to retrieve the associated marker attributes - * (line number). - */ - public static ICFunctionBreakpoint functionBreakpointExists(String sourceHandle, IResource resource, String function) - throws CoreException { - String modelId = getPluginIdentifier(); - IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager(); - IBreakpoint[] breakpoints = manager.getBreakpoints(modelId); - for (int i = 0; i < breakpoints.length; i++) { - if (!(breakpoints[i] instanceof ICFunctionBreakpoint)) { - continue; - } - ICFunctionBreakpoint breakpoint = (ICFunctionBreakpoint) breakpoints[i]; - if (sameSourceHandle(sourceHandle, breakpoint.getSourceHandle())) { - if (breakpoint.getMarker().getResource().equals(resource)) { - if (breakpoint.getFunction() != null && breakpoint.getFunction().equals(function)) { - return breakpoint; - } - } - } - } - return null; - } + /** + * Returns the function breakpoint that is already registered with the + * breakpoint manager for a source with the given handle and the given + * resource with the given function name. + * + * @param sourceHandle + * the source handle + * @param resource + * the breakpoint resource + * @param function + * the fully qualified function name + * @return the breakpoint that is already registered with the breakpoint + * manager or <code>null</code> if no such breakpoint is registered + * @exception CoreException + * if unable to retrieve the associated marker attributes + * (line number). + */ + public static ICFunctionBreakpoint functionBreakpointExists(String sourceHandle, IResource resource, + String function) throws CoreException { + String modelId = getPluginIdentifier(); + IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager(); + IBreakpoint[] breakpoints = manager.getBreakpoints(modelId); + for (int i = 0; i < breakpoints.length; i++) { + if (!(breakpoints[i] instanceof ICFunctionBreakpoint)) { + continue; + } + ICFunctionBreakpoint breakpoint = (ICFunctionBreakpoint) breakpoints[i]; + if (sameSourceHandle(sourceHandle, breakpoint.getSourceHandle())) { + if (breakpoint.getMarker().getResource().equals(resource)) { + if (breakpoint.getFunction() != null && breakpoint.getFunction().equals(function)) { + return breakpoint; + } + } + } + } + return null; + } - private static boolean sameSourceHandle(String handle1, String handle2) { - if (handle1 == null || handle2 == null) - return false; - IPath path1 = new Path(handle1); - IPath path2 = new Path(handle2); - if (path1.isValidPath(handle1) && path2.isValidPath(handle2)) { - return path1.equals(path2); - } - // If handles are not file names ???? - return handle1.equals(handle2); - } + private static boolean sameSourceHandle(String handle1, String handle2) { + if (handle1 == null || handle2 == null) + return false; + IPath path1 = new Path(handle1); + IPath path2 = new Path(handle2); + if (path1.isValidPath(handle1) && path2.isValidPath(handle2)) { + return path1.equals(path2); + } + // If handles are not file names ???? + return handle1.equals(handle2); + } - /** - * Checks whether an event breakpoint with given type and argument already - * exists. If multiple event breakpoints exist that match given parameters, - * only one of them will be returned. - * - * @param type - * Event type. - * @param arg - * Event argument. - * @return Event breakpoint, if found. - * @throws CoreException - * Exception in reading breakpoint properties. - */ - public static ICEventBreakpoint eventBreakpointExists(String type, String arg) throws CoreException { - String modelId = getPluginIdentifier(); + /** + * Checks whether an event breakpoint with given type and argument already + * exists. If multiple event breakpoints exist that match given parameters, + * only one of them will be returned. + * + * @param type + * Event type. + * @param arg + * Event argument. + * @return Event breakpoint, if found. + * @throws CoreException + * Exception in reading breakpoint properties. + */ + public static ICEventBreakpoint eventBreakpointExists(String type, String arg) throws CoreException { + String modelId = getPluginIdentifier(); - IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager(); - IBreakpoint[] breakpoints = manager.getBreakpoints(modelId); - for (int i = 0; i < breakpoints.length; i++) { - if (!(breakpoints[i] instanceof ICEventBreakpoint)) { - continue; - } - ICEventBreakpoint breakpoint = (ICEventBreakpoint) breakpoints[i]; + IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager(); + IBreakpoint[] breakpoints = manager.getBreakpoints(modelId); + for (int i = 0; i < breakpoints.length; i++) { + if (!(breakpoints[i] instanceof ICEventBreakpoint)) { + continue; + } + ICEventBreakpoint breakpoint = (ICEventBreakpoint) breakpoints[i]; - if (breakpoint.getEventType().equals(type)) { - String arg1 = breakpoint.getEventArgument(); - if (arg1 == null) - arg1 = ""; //$NON-NLS-1$ - String arg2 = arg == null ? "" : arg; //$NON-NLS-1$ - if (arg1.equals(arg2)) - return breakpoint; - } + if (breakpoint.getEventType().equals(type)) { + String arg1 = breakpoint.getEventArgument(); + if (arg1 == null) + arg1 = ""; //$NON-NLS-1$ + String arg2 = arg == null ? "" : arg; //$NON-NLS-1$ + if (arg1.equals(arg2)) + return breakpoint; + } - } - return null; - } + } + return null; + } - /** - * Creates and registers a new event breakpoint. - * - * @param attributes - * Map to write the attributes into. - * @param type - * Event breakpoint type. - * @param arg - * Event-specific argument value. - * @param register - * whether to add this breakpoint to the breakpoint manager - * @return an event breakpoint - * - * @throws CoreException - * if this method fails. Reasons include: - * <ul> - * <li>Failure creating underlying marker. The exception's - * status contains the underlying exception responsible for the - * failure.</li> - * </ul> - */ - public static ICEventBreakpoint createEventBreakpoint(String type, String arg, boolean register) - throws CoreException { - final IResource resource = ResourcesPlugin.getWorkspace().getRoot(); - final Map<String, Object> attributes = new HashMap<String, Object>(); - setEventBreakpointAttributes(attributes, type, arg); - return new CEventBreakpoint(resource, attributes, register); + /** + * Creates and registers a new event breakpoint. + * + * @param attributes + * Map to write the attributes into. + * @param type + * Event breakpoint type. + * @param arg + * Event-specific argument value. + * @param register + * whether to add this breakpoint to the breakpoint manager + * @return an event breakpoint + * + * @throws CoreException + * if this method fails. Reasons include: + * <ul> + * <li>Failure creating underlying marker. The exception's + * status contains the underlying exception responsible for the + * failure.</li> + * </ul> + */ + public static ICEventBreakpoint createEventBreakpoint(String type, String arg, boolean register) + throws CoreException { + final IResource resource = ResourcesPlugin.getWorkspace().getRoot(); + final Map<String, Object> attributes = new HashMap<String, Object>(); + setEventBreakpointAttributes(attributes, type, arg); + return new CEventBreakpoint(resource, attributes, register); - } + } - /** - * Helper function for setting common event breakpoint attributes. - * - * @param attributes - * Map to write the attributes into. - * @param type - * Event breakpoint type. - * @param arg - * Event-specific argument value. - * @param register - * whether to add this breakpoint to the breakpoint manager - * - * @since 7.2 - */ - public static void setEventBreakpointAttributes(Map<String, Object> attributes, String type, String arg) { - attributes.put(IBreakpoint.ID, CDIDebugModel.getPluginIdentifier()); - attributes.put(IBreakpoint.ENABLED, true); - attributes.put(ICBreakpoint.IGNORE_COUNT, 0); - attributes.put(ICBreakpoint.CONDITION, ""); //$NON-NLS-1$ - attributes.put(ICEventBreakpoint.EVENT_TYPE_ID, type); - attributes.put(ICEventBreakpoint.EVENT_ARG, arg); - } + /** + * Helper function for setting common event breakpoint attributes. + * + * @param attributes + * Map to write the attributes into. + * @param type + * Event breakpoint type. + * @param arg + * Event-specific argument value. + * @param register + * whether to add this breakpoint to the breakpoint manager + * + * @since 7.2 + */ + public static void setEventBreakpointAttributes(Map<String, Object> attributes, String type, String arg) { + attributes.put(IBreakpoint.ID, CDIDebugModel.getPluginIdentifier()); + attributes.put(IBreakpoint.ENABLED, true); + attributes.put(ICBreakpoint.IGNORE_COUNT, 0); + attributes.put(ICBreakpoint.CONDITION, ""); //$NON-NLS-1$ + attributes.put(ICEventBreakpoint.EVENT_TYPE_ID, type); + attributes.put(ICEventBreakpoint.EVENT_ARG, arg); + } - /** - * Creates an event breakpoint without associated marker. - * <p> - * Note: Before an event breakpoint created using this method can be used, the - * client must first create a marker and register the breakpoint. The former - * is accomplished using {@link IBreakpoint#setMarker(IMarker)}, the latter - * using {@link IBreakpointManager#addBreakpoint(IBreakpoint)}. - * - * @since 7.2 - */ - public static ICEventBreakpoint createBlankEventBreakpoint() { - return new CEventBreakpoint(); - } + /** + * Creates an event breakpoint without associated marker. + * <p> + * Note: Before an event breakpoint created using this method can be used, the + * client must first create a marker and register the breakpoint. The former + * is accomplished using {@link IBreakpoint#setMarker(IMarker)}, the latter + * using {@link IBreakpointManager#addBreakpoint(IBreakpoint)}. + * + * @since 7.2 + */ + public static ICEventBreakpoint createBlankEventBreakpoint() { + return new CEventBreakpoint(); + } - /** - * Creates a marker for given C breakpoint. - * - * @param breakpoint - * Breakpoint to create the marker for. - * @param resource - * Resource to create the marker on. - * @param attributes - * Marker attributes to use. - * @param add - * Whether to register the breakpoint with breakpoint manager. - * @throws CoreException - * Error thrown while creating marker. - * - * @since 7.2 - */ - public static void createBreakpointMarker(final ICBreakpoint breakpoint, final IResource resource, - final Map<String, Object> attributes, final boolean add) throws CoreException { - if (breakpoint.getMarker() != null) { - throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID, - "Cannot create breakpoint marker breakpoint given breakpoint already has an assotiated maker")); //$NON-NLS-1$ - } + /** + * Creates a marker for given C breakpoint. + * + * @param breakpoint + * Breakpoint to create the marker for. + * @param resource + * Resource to create the marker on. + * @param attributes + * Marker attributes to use. + * @param add + * Whether to register the breakpoint with breakpoint manager. + * @throws CoreException + * Error thrown while creating marker. + * + * @since 7.2 + */ + public static void createBreakpointMarker(final ICBreakpoint breakpoint, final IResource resource, + final Map<String, Object> attributes, final boolean add) throws CoreException { + if (breakpoint.getMarker() != null) { + throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID, + "Cannot create breakpoint marker breakpoint given breakpoint already has an assotiated maker")); //$NON-NLS-1$ + } - IWorkspaceRunnable wr = new IWorkspaceRunnable() { - @Override - public void run(IProgressMonitor monitor) throws CoreException { - // create the marker - IMarker marker = resource.createMarker(calculateMarkerType(breakpoint)); - breakpoint.setMarker(marker); + IWorkspaceRunnable wr = new IWorkspaceRunnable() { + @Override + public void run(IProgressMonitor monitor) throws CoreException { + // create the marker + IMarker marker = resource.createMarker(calculateMarkerType(breakpoint)); + breakpoint.setMarker(marker); - // set attributes - marker.setAttributes(attributes); + // set attributes + marker.setAttributes(attributes); - // set the marker message - if (breakpoint instanceof ICBreakpoint2) { - ((ICBreakpoint2) breakpoint).refreshMessage(); - } + // set the marker message + if (breakpoint instanceof ICBreakpoint2) { + ((ICBreakpoint2) breakpoint).refreshMessage(); + } - // add to breakpoint manager if requested - if (add) { - DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(breakpoint); - } - } - }; - ResourcesPlugin.getWorkspace().run(wr, null); - } + // add to breakpoint manager if requested + if (add) { + DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(breakpoint); + } + } + }; + ResourcesPlugin.getWorkspace().run(wr, null); + } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java index 9ff52dee319..b59a4c325cb 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java @@ -60,7 +60,7 @@ public class CDebugCorePlugin extends Plugin { /** * The plug-in identifier (value <code>"org.eclipse.cdt.debug.core"</code>). */ - public static final String PLUGIN_ID = "org.eclipse.cdt.debug.core" ; //$NON-NLS-1$ + public static final String PLUGIN_ID = "org.eclipse.cdt.debug.core"; //$NON-NLS-1$ /** * Status code indicating an unexpected internal error. @@ -76,24 +76,23 @@ public class CDebugCorePlugin extends Plugin { * Breakpoint listener list. */ private ListenerList fBreakpointListeners; - + /** * Breakpoint action manager. */ private BreakpointActionManager breakpointActionManager; - private DisassemblyContextService fDisassemblyContextService; + private DisassemblyContextService fDisassemblyContextService; public static final String CDEBUGGER_EXTENSION_POINT_ID = "CDebugger"; //$NON-NLS-1$ public static final String DEBUGGER_ELEMENT = "debugger"; //$NON-NLS-1$ - + public static final String BREAKPOINT_ACTION_EXTENSION_POINT_ID = "BreakpointActionType"; //$NON-NLS-1$ - public static final String ACTION_TYPE_ELEMENT = "actionType"; //$NON-NLS-1$ - - public static final String BREAKPOINT_EXTENSION_EXTENSION_POINT_ID = "BreakpointExtension"; //$NON-NLS-1$ - public static final String BREAKPOINT_EXTENSION_ELEMENT = "breakpointExtension"; //$NON-NLS-1$ - - + public static final String ACTION_TYPE_ELEMENT = "actionType"; //$NON-NLS-1$ + + public static final String BREAKPOINT_EXTENSION_EXTENSION_POINT_ID = "BreakpointExtension"; //$NON-NLS-1$ + public static final String BREAKPOINT_EXTENSION_ELEMENT = "breakpointExtension"; //$NON-NLS-1$ + /** * Dummy source lookup director needed to manage common source containers. */ @@ -111,7 +110,7 @@ public class CDebugCorePlugin extends Plugin { /** * Returns the shared instance. - * + * * @return the shared instance */ public static CDebugCorePlugin getDefault() { @@ -120,7 +119,7 @@ public class CDebugCorePlugin extends Plugin { /** * Returns the workspace instance. - * + * * @return the workspace instance */ public static IWorkspace getWorkspace() { @@ -129,7 +128,7 @@ public class CDebugCorePlugin extends Plugin { /** * Convenience method which returns the unique identifier of this plugin. - * + * * @return the unique identifier of this plugin */ public static String getUniqueIdentifier() { @@ -138,13 +137,13 @@ public class CDebugCorePlugin extends Plugin { /** * Logs the specified throwable with this plug-in's log. - * - * @param t throwable to log + * + * @param t throwable to log */ public static void log(Throwable t) { Throwable top = t; if (t instanceof DebugException) { - DebugException de = (DebugException)t; + DebugException de = (DebugException) t; IStatus status = de.getStatus(); if (status.getException() != null) { top = status.getException(); @@ -152,12 +151,13 @@ public class CDebugCorePlugin extends Plugin { } // this message is intentionally not internationalized, as an exception may // be due to the resource bundle itself - log(new Status(IStatus.ERROR, getUniqueIdentifier(), INTERNAL_ERROR, "Internal error logged from CDI Debug: ", top)); //$NON-NLS-1$ + log(new Status(IStatus.ERROR, getUniqueIdentifier(), INTERNAL_ERROR, "Internal error logged from CDI Debug: ", //$NON-NLS-1$ + top)); } /** * Logs the specified status with this plug-in's log. - * + * * @param status status to log */ public static void log(IStatus status) { @@ -166,24 +166,27 @@ public class CDebugCorePlugin extends Plugin { /** * Logs the specified message with this plug-in's log. - * + * * @param status status to log */ public static void log(String message) { - getDefault().getLog().log(new Status(IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), INTERNAL_ERROR, message, null)); + getDefault().getLog() + .log(new Status(IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), INTERNAL_ERROR, message, null)); } public void saveCommonSourceLocations(ICSourceLocation[] locations) { - CDebugCorePlugin.getDefault().getPluginPreferences().setValue(ICDebugConstants.PREF_SOURCE_LOCATIONS, SourceUtils.getCommonSourceLocationsMemento(locations)); + CDebugCorePlugin.getDefault().getPluginPreferences().setValue(ICDebugConstants.PREF_SOURCE_LOCATIONS, + SourceUtils.getCommonSourceLocationsMemento(locations)); } public ICSourceLocation[] getCommonSourceLocations() { - return SourceUtils.getCommonSourceLocationsFromMemento(CDebugCorePlugin.getDefault().getPluginPreferences().getString(ICDebugConstants.PREF_SOURCE_LOCATIONS)); + return SourceUtils.getCommonSourceLocationsFromMemento( + CDebugCorePlugin.getDefault().getPluginPreferences().getString(ICDebugConstants.PREF_SOURCE_LOCATIONS)); } /** * Adds the given breakpoint listener to the debug model. - * + * * @param listener breakpoint listener */ public void addCBreakpointListener(ICBreakpointListener listener) { @@ -192,7 +195,7 @@ public class CDebugCorePlugin extends Plugin { /** * Removes the given breakpoint listener from the debug model. - * + * * @param listener breakpoint listener */ public void removeCBreakpointListener(ICBreakpointListener listener) { @@ -201,7 +204,7 @@ public class CDebugCorePlugin extends Plugin { /** * Returns the list of breakpoint listeners registered with this plugin. - * + * * @return the list of breakpoint listeners registered with this plugin */ public Object[] getCBreakpointListeners() { @@ -223,7 +226,7 @@ public class CDebugCorePlugin extends Plugin { * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) */ @Override - public void start(BundleContext context) throws Exception { + public void start(BundleContext context) throws Exception { super.start(context); Trace.init(); @@ -232,7 +235,7 @@ public class CDebugCorePlugin extends Plugin { createBreakpointListenersList(); createDisassemblyContextService(); setDefaultLaunchDelegates(); - + Platform.getAdapterManager().registerAdapters(new DebugModelProvider(), ICDebugElement.class); // Add core build launch bar listener @@ -245,7 +248,7 @@ public class CDebugCorePlugin extends Plugin { * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) */ @Override - public void stop(BundleContext context) throws Exception { + public void stop(BundleContext context) throws Exception { ILaunchBarManager launchBarManager = getService(ILaunchBarManager.class); launchBarManager.removeListener(coreBuildLaunchBarTracker); coreBuildLaunchBarTracker = null; @@ -266,18 +269,20 @@ public class CDebugCorePlugin extends Plugin { } private void createCommandAdapterFactory() { - IAdapterManager manager= Platform.getAdapterManager(); - CCommandAdapterFactory actionFactory = new CCommandAdapterFactory(); - manager.registerAdapters(actionFactory, IRestart.class); + IAdapterManager manager = Platform.getAdapterManager(); + CCommandAdapterFactory actionFactory = new CCommandAdapterFactory(); + manager.registerAdapters(actionFactory, IRestart.class); } - + private void initializeCommonSourceLookupDirector() { if (fCommonSourceLookupDirector == null) { fCommonSourceLookupDirector = new CommonSourceLookupDirector(); boolean convertingFromLegacyFormat = false; - String newMemento = CDebugCorePlugin.getDefault().getPluginPreferences().getString(ICDebugInternalConstants.PREF_DEFAULT_SOURCE_CONTAINERS); + String newMemento = CDebugCorePlugin.getDefault().getPluginPreferences() + .getString(ICDebugInternalConstants.PREF_DEFAULT_SOURCE_CONTAINERS); if (newMemento.isEmpty()) { - newMemento = CDebugCorePlugin.getDefault().getPluginPreferences().getString(ICDebugInternalConstants.PREF_COMMON_SOURCE_CONTAINERS); + newMemento = CDebugCorePlugin.getDefault().getPluginPreferences() + .getString(ICDebugInternalConstants.PREF_COMMON_SOURCE_CONTAINERS); convertingFromLegacyFormat = true; } if (newMemento.isEmpty()) { @@ -285,7 +290,7 @@ public class CDebugCorePlugin extends Plugin { // initializeFromMemento(), but since we're not calling it, we // need to do this explicitly. See 299583. fCommonSourceLookupDirector.initializeParticipants(); - + // Convert source locations to source containers convertSourceLocations(fCommonSourceLookupDirector); } else { @@ -296,7 +301,7 @@ public class CDebugCorePlugin extends Plugin { } } if (convertingFromLegacyFormat) { - // Add three source containers that used to be present implicitly. + // Add three source containers that used to be present implicitly. ISourceContainer[] oldContainers = fCommonSourceLookupDirector.getSourceContainers(); ISourceContainer[] containers = new ISourceContainer[oldContainers.length + 3]; int i = 0; @@ -321,39 +326,41 @@ public class CDebugCorePlugin extends Plugin { private void convertSourceLocations(CommonSourceLookupDirector director) { director.setSourceContainers(SourceUtils.convertSourceLocations(getCommonSourceLocations())); } - + public BreakpointActionManager getBreakpointActionManager() { if (breakpointActionManager == null) breakpointActionManager = new BreakpointActionManager(); return breakpointActionManager; } - private void createDisassemblyContextService() { - fDisassemblyContextService = new DisassemblyContextService(); - } + private void createDisassemblyContextService() { + fDisassemblyContextService = new DisassemblyContextService(); + } + + public IDisassemblyContextService getDisassemblyContextService() { + return fDisassemblyContextService; + } - public IDisassemblyContextService getDisassemblyContextService() { - return fDisassemblyContextService; - } + private void disposeDisassemblyContextService() { + if (fDisassemblyContextService != null) + fDisassemblyContextService.dispose(); + } - private void disposeDisassemblyContextService() { - if (fDisassemblyContextService != null) - fDisassemblyContextService.dispose(); - } - private void setDefaultLaunchDelegates() { - // Set the default launch delegates as early as possible, and do it only once (Bug 312997) + // Set the default launch delegates as early as possible, and do it only once (Bug 312997) ILaunchManager launchMgr = DebugPlugin.getDefault().getLaunchManager(); HashSet<String> debugSet = new HashSet<>(); debugSet.add(ILaunchManager.DEBUG_MODE); - ILaunchConfigurationType localCfg = launchMgr.getLaunchConfigurationType(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_APP); + ILaunchConfigurationType localCfg = launchMgr + .getLaunchConfigurationType(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_APP); try { if (localCfg.getPreferredDelegate(debugSet) == null) { ILaunchDelegate[] delegates = localCfg.getDelegates(debugSet); for (ILaunchDelegate delegate : delegates) { - if (ICDTLaunchConfigurationConstants.PREFERRED_DEBUG_LOCAL_LAUNCH_DELEGATE.equals(delegate.getId())) { + if (ICDTLaunchConfigurationConstants.PREFERRED_DEBUG_LOCAL_LAUNCH_DELEGATE + .equals(delegate.getId())) { localCfg.setPreferredDelegate(debugSet, delegate); break; } @@ -362,12 +369,14 @@ public class CDebugCorePlugin extends Plugin { } catch (CoreException e) { } - ILaunchConfigurationType remoteCfg = launchMgr.getLaunchConfigurationType(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_REMOTE_APP); + ILaunchConfigurationType remoteCfg = launchMgr + .getLaunchConfigurationType(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_REMOTE_APP); try { if (remoteCfg.getPreferredDelegate(debugSet) == null) { ILaunchDelegate[] delegates = remoteCfg.getDelegates(debugSet); for (ILaunchDelegate delegate : delegates) { - if (ICDTLaunchConfigurationConstants.PREFERRED_DEBUG_REMOTE_LAUNCH_DELEGATE.equals(delegate.getId())) { + if (ICDTLaunchConfigurationConstants.PREFERRED_DEBUG_REMOTE_LAUNCH_DELEGATE + .equals(delegate.getId())) { remoteCfg.setPreferredDelegate(debugSet, delegate); break; } @@ -375,13 +384,15 @@ public class CDebugCorePlugin extends Plugin { } } catch (CoreException e) { } - - ILaunchConfigurationType attachCfg = launchMgr.getLaunchConfigurationType(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_ATTACH); + + ILaunchConfigurationType attachCfg = launchMgr + .getLaunchConfigurationType(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_ATTACH); try { if (attachCfg.getPreferredDelegate(debugSet) == null) { ILaunchDelegate[] delegates = attachCfg.getDelegates(debugSet); for (ILaunchDelegate delegate : delegates) { - if (ICDTLaunchConfigurationConstants.PREFERRED_DEBUG_ATTACH_LAUNCH_DELEGATE.equals(delegate.getId())) { + if (ICDTLaunchConfigurationConstants.PREFERRED_DEBUG_ATTACH_LAUNCH_DELEGATE + .equals(delegate.getId())) { attachCfg.setPreferredDelegate(debugSet, delegate); break; } @@ -390,12 +401,14 @@ public class CDebugCorePlugin extends Plugin { } catch (CoreException e) { } - ILaunchConfigurationType postMortemCfg = launchMgr.getLaunchConfigurationType(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_POST_MORTEM); + ILaunchConfigurationType postMortemCfg = launchMgr + .getLaunchConfigurationType(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_POST_MORTEM); try { if (postMortemCfg.getPreferredDelegate(debugSet) == null) { ILaunchDelegate[] delegates = postMortemCfg.getDelegates(debugSet); for (ILaunchDelegate delegate : delegates) { - if (ICDTLaunchConfigurationConstants.PREFERRED_DEBUG_POSTMORTEM_LAUNCH_DELEGATE.equals(delegate.getId())) { + if (ICDTLaunchConfigurationConstants.PREFERRED_DEBUG_POSTMORTEM_LAUNCH_DELEGATE + .equals(delegate.getId())) { postMortemCfg.setPreferredDelegate(debugSet, delegate); break; } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java index faf21306f45..a719b6ca825 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java @@ -76,7 +76,7 @@ public class CDebugUtils { IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status); if (handler != null) { try { - result = (Boolean)handler.handleStatus(status, source); + result = (Boolean) handler.handleStatus(status, source); } catch (CoreException e) { } } @@ -104,7 +104,7 @@ public class CDebugUtils { } public static char[] getByteText(byte b) { - return new char[]{ charFromByte((byte)((b >>> 4) & 0x0f)), charFromByte((byte)(b & 0x0f)) }; + return new char[] { charFromByte((byte) ((b >>> 4) & 0x0f)), charFromByte((byte) (b & 0x0f)) }; } public static byte textToByte(char[] text) { @@ -139,7 +139,7 @@ public class CDebugUtils { public static char bytesToChar(byte[] bytes) { try { - return (char)Short.parseShort(new String(bytes), 16); + return (char) Short.parseShort(new String(bytes), 16); } catch (RuntimeException e) { } return 0; @@ -148,31 +148,31 @@ public class CDebugUtils { public static byte toByte(char[] bytes, boolean le) { if (bytes.length != 2) return 0; - return (byte)Long.parseLong(bytesToString(bytes, le, true), 16); + return (byte) Long.parseLong(bytesToString(bytes, le, true), 16); } public static short toUnsignedByte(char[] bytes, boolean le) { if (bytes.length != 2) return 0; - return (short)Long.parseLong(bytesToString(bytes, le, false), 16); + return (short) Long.parseLong(bytesToString(bytes, le, false), 16); } public static short toShort(char[] bytes, boolean le) { if (bytes.length != 4) return 0; - return (short)Long.parseLong(bytesToString(bytes, le, true), 16); + return (short) Long.parseLong(bytesToString(bytes, le, true), 16); } public static int toUnsignedShort(char[] bytes, boolean le) { if (bytes.length != 4) return 0; - return (int)Long.parseLong(bytesToString(bytes, le, false), 16); + return (int) Long.parseLong(bytesToString(bytes, le, false), 16); } public static int toInt(char[] bytes, boolean le) { if (bytes.length != 8) return 0; - return (int)Long.parseLong(bytesToString(bytes, le, true), 16); + return (int) Long.parseLong(bytesToString(bytes, le, true), 16); } public static long toUnsignedInt(char[] bytes, boolean le) { @@ -220,10 +220,10 @@ public class CDebugUtils { /** * Serializes a XML document into a string - encoded in UTF8 format, with platform line separators. - * + * * @param doc document to serialize * @param indent if the xml text should be indented. - * + * * @return the document as a string */ public static String serializeDocument(Document doc, boolean indent) throws IOException, TransformerException { @@ -235,12 +235,12 @@ public class CDebugUtils { DOMSource source = new DOMSource(doc); StreamResult outputTarget = new StreamResult(s); transformer.transform(source, outputTarget); - return s.toString("UTF8"); //$NON-NLS-1$ + return s.toString("UTF8"); //$NON-NLS-1$ } /** * Serializes a XML document into a string - encoded in UTF8 format, with platform line separators. - * + * * @param doc document to serialize * @return the document as a string */ @@ -304,7 +304,8 @@ public class CDebugUtils { } catch (CoreException e) { } for (int i = 0; i < refs.length; ++i) { - if (!list.contains(refs[i]) && refs[i] != null && !refs[i].equals(root) && refs[i].exists() && refs[i].isOpen()) { + if (!list.contains(refs[i]) && refs[i] != null && !refs[i].equals(root) && refs[i].exists() + && refs[i].isOpen()) { list.add(refs[i]); getReferencedProjects(root, refs[i], list); } @@ -315,16 +316,16 @@ public class CDebugUtils { public static String getBreakpointText(IBreakpoint breakpoint, boolean qualified) throws CoreException { try { if (breakpoint instanceof ICAddressBreakpoint) { - return getAddressBreakpointText((ICAddressBreakpoint)breakpoint, qualified); + return getAddressBreakpointText((ICAddressBreakpoint) breakpoint, qualified); } if (breakpoint instanceof ICFunctionBreakpoint) { - return getFunctionBreakpointText((ICFunctionBreakpoint)breakpoint, qualified); + return getFunctionBreakpointText((ICFunctionBreakpoint) breakpoint, qualified); } if (breakpoint instanceof ICLineBreakpoint) { - return getLineBreakpointText((ICLineBreakpoint)breakpoint, qualified); + return getLineBreakpointText((ICLineBreakpoint) breakpoint, qualified); } if (breakpoint instanceof ICWatchpoint) { - return getWatchpointText((ICWatchpoint)breakpoint, qualified); + return getWatchpointText((ICWatchpoint) breakpoint, qualified); } // This allows to create a new breakpoint without implementing one of the interfaces above and still see a label Object message = breakpoint.getMarker().getAttribute(IMarker.MESSAGE); @@ -347,7 +348,7 @@ public class CDebugUtils { appendSourceName(breakpoint, label, qualified); appendLineNumber(breakpoint, label); if (breakpoint instanceof ICDynamicPrintf) { - appendPrintfString((ICDynamicPrintf)breakpoint, label); + appendPrintfString((ICDynamicPrintf) breakpoint, label); } appendBreakpointType(breakpoint, label); appendExtensionMessage(breakpoint, label); @@ -361,7 +362,7 @@ public class CDebugUtils { appendSourceName(watchpoint, label, qualified); appendWatchExpression(watchpoint, label); if (watchpoint instanceof ICWatchpoint2) { - ICWatchpoint2 wp2 = (ICWatchpoint2)watchpoint; + ICWatchpoint2 wp2 = (ICWatchpoint2) watchpoint; appendWatchMemorySpace(wp2, label); appendWatchRange(wp2, label); } @@ -372,12 +373,13 @@ public class CDebugUtils { return label.toString(); } - protected static String getAddressBreakpointText(ICAddressBreakpoint breakpoint, boolean qualified) throws CoreException { + protected static String getAddressBreakpointText(ICAddressBreakpoint breakpoint, boolean qualified) + throws CoreException { StringBuffer label = new StringBuffer(); appendSourceName(breakpoint, label, qualified); appendAddress(breakpoint, label); if (breakpoint instanceof ICDynamicPrintf) { - appendPrintfString((ICDynamicPrintf)breakpoint, label); + appendPrintfString((ICDynamicPrintf) breakpoint, label); } appendBreakpointType(breakpoint, label); appendExtensionMessage(breakpoint, label); @@ -386,12 +388,13 @@ public class CDebugUtils { return label.toString(); } - protected static String getFunctionBreakpointText(ICFunctionBreakpoint breakpoint, boolean qualified) throws CoreException { + protected static String getFunctionBreakpointText(ICFunctionBreakpoint breakpoint, boolean qualified) + throws CoreException { StringBuffer label = new StringBuffer(); appendSourceName(breakpoint, label, qualified); appendFunction(breakpoint, label); if (breakpoint instanceof ICDynamicPrintf) { - appendPrintfString((ICDynamicPrintf)breakpoint, label); + appendPrintfString((ICDynamicPrintf) breakpoint, label); } appendBreakpointType(breakpoint, label); appendExtensionMessage(breakpoint, label); @@ -402,7 +405,7 @@ public class CDebugUtils { /** * Append the Breakpoint Extension message to the breakpoint text in buffer. - * + * * @param breakpoint C Breakpoint * @param buffer buffer to append message to * @see {@link ICBreakpointExtension#getExtensionMessage() @@ -421,7 +424,8 @@ public class CDebugUtils { } } - protected static StringBuffer appendSourceName(ICBreakpoint breakpoint, StringBuffer label, boolean qualified) throws CoreException { + protected static StringBuffer appendSourceName(ICBreakpoint breakpoint, StringBuffer label, boolean qualified) + throws CoreException { String handle = breakpoint.getSourceHandle(); if (!isEmpty(handle)) { IPath path = new Path(handle); @@ -432,29 +436,35 @@ public class CDebugUtils { return label; } - protected static StringBuffer appendLineNumber(ICLineBreakpoint breakpoint, StringBuffer label) throws CoreException { + protected static StringBuffer appendLineNumber(ICLineBreakpoint breakpoint, StringBuffer label) + throws CoreException { int lineNumber = breakpoint.getLineNumber(); if (lineNumber > 0) { label.append(' '); - label.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.0"), (Object[])new String[]{ Integer.toString(lineNumber) })); //$NON-NLS-1$ + label.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.0"), //$NON-NLS-1$ + (Object[]) new String[] { Integer.toString(lineNumber) })); } return label; } - protected static StringBuffer appendAddress(ICAddressBreakpoint breakpoint, StringBuffer label) throws CoreException { + protected static StringBuffer appendAddress(ICAddressBreakpoint breakpoint, StringBuffer label) + throws CoreException { try { label.append(' '); - label.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.1"), (Object[])new String[]{ breakpoint.getAddress() })); //$NON-NLS-1$ + label.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.1"), //$NON-NLS-1$ + (Object[]) new String[] { breakpoint.getAddress() })); } catch (NumberFormatException e) { } return label; } - protected static StringBuffer appendFunction(ICFunctionBreakpoint breakpoint, StringBuffer label) throws CoreException { + protected static StringBuffer appendFunction(ICFunctionBreakpoint breakpoint, StringBuffer label) + throws CoreException { String function = breakpoint.getFunction(); if (function != null && function.trim().length() > 0) { label.append(' '); - label.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.2"), (Object[])new String[]{ function.trim() })); //$NON-NLS-1$ + label.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.2"), //$NON-NLS-1$ + (Object[]) new String[] { function.trim() })); } return label; } @@ -466,7 +476,8 @@ public class CDebugUtils { String printfStr = dprintf.getPrintfString(); if (printfStr != null && printfStr.length() > 0) { buffer.append(' '); - buffer.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.printfString"), (Object[])new String[] { printfStr })); //$NON-NLS-1$ + buffer.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.printfString"), //$NON-NLS-1$ + (Object[]) new String[] { printfStr })); } } @@ -474,7 +485,8 @@ public class CDebugUtils { int ignoreCount = breakpoint.getIgnoreCount(); if (ignoreCount > 0) { label.append(' '); - label.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.3"), (Object[])new String[]{ Integer.toString(ignoreCount) })); //$NON-NLS-1$ + label.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.3"), //$NON-NLS-1$ + (Object[]) new String[] { Integer.toString(ignoreCount) })); } return label; } @@ -483,7 +495,8 @@ public class CDebugUtils { String condition = breakpoint.getCondition(); if (condition != null && condition.length() > 0) { buffer.append(' '); - buffer.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.4"), (Object[])new String[] { condition })); //$NON-NLS-1$ + buffer.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.4"), //$NON-NLS-1$ + (Object[]) new String[] { condition })); } } @@ -491,7 +504,8 @@ public class CDebugUtils { String expression = watchpoint.getExpression(); if (expression != null && expression.length() > 0) { label.append(' '); - label.append(MessageFormat.format( DebugCoreMessages.getString("CDebugUtils.5"), (Object[])new String[] { expression })); //$NON-NLS-1$ + label.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.5"), //$NON-NLS-1$ + (Object[]) new String[] { expression })); } } @@ -499,7 +513,8 @@ public class CDebugUtils { String memorySpace = watchpoint.getMemorySpace(); if (memorySpace != null && memorySpace.length() > 0) { label.append(' '); - label.append(MessageFormat.format( DebugCoreMessages.getString("CDebugUtils.6"), (Object[])new String[] { memorySpace })); //$NON-NLS-1$ + label.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.6"), //$NON-NLS-1$ + (Object[]) new String[] { memorySpace })); } } @@ -507,11 +522,13 @@ public class CDebugUtils { String range = watchpoint.getRange().toString(); if (range.length() > 0 && !range.equals("0")) { //$NON-NLS-1$ label.append(' '); - label.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.7"), (Object[])new String[]{ range })); //$NON-NLS-1$ + label.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.7"), //$NON-NLS-1$ + (Object[]) new String[] { range })); } } - - protected static StringBuffer appendBreakpointType(ICBreakpoint breakpoint, StringBuffer label) throws CoreException { + + protected static StringBuffer appendBreakpointType(ICBreakpoint breakpoint, StringBuffer label) + throws CoreException { if (breakpoint instanceof ICBreakpointType) { String typeString = ""; //$NON-NLS-1$ int type = ((ICBreakpointType) breakpoint).getType(); @@ -526,21 +543,21 @@ public class CDebugUtils { typeString = DebugCoreMessages.getString("CDebugUtils.Software"); //$NON-NLS-1$ break; } - + // Now factor in the TEMPORARY qualifier to form, .e.,g "Hardware/Temporary" // Thing is, a temporary breakpoint should never show in the GUI, so this is // here as a just-in-case. if ((type & ICBreakpointType.TEMPORARY) != 0) { if (typeString.length() > 0) { - typeString += "/"; //$NON-NLS-1$ + typeString += "/"; //$NON-NLS-1$ } typeString += DebugCoreMessages.getString("CDebugUtils.Temporary"); //$NON-NLS-1$ } - + if (typeString.length() > 0) { label.append(' '); - label.append(MessageFormat.format( - DebugCoreMessages.getString("CDebugUtils.8"), (Object[])new String[] { typeString })); //$NON-NLS-1$ + label.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.8"), //$NON-NLS-1$ + (Object[]) new String[] { typeString })); } } return label; @@ -549,11 +566,12 @@ public class CDebugUtils { private static boolean isEmpty(String string) { return (string == null || string.trim().length() == 0); } - + private static CharsetDecoder fDecoder; public static CharsetDecoder getCharsetDecoder() { - String charsetName = CDebugCorePlugin.getDefault().getPluginPreferences().getString(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET); + String charsetName = CDebugCorePlugin.getDefault().getPluginPreferences() + .getString(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET); if (fDecoder == null || !fDecoder.charset().name().equals(charsetName)) { Charset charset = Charset.forName(charsetName); fDecoder = charset.newDecoder(); @@ -562,62 +580,64 @@ public class CDebugUtils { } /** - * Note: Moved from AbstractCLaunchDelegate - * @since 6.0 + * Note: Moved from AbstractCLaunchDelegate + * @since 6.0 */ - public static ICProject getCProject(ILaunchConfiguration configuration) throws CoreException { - String projectName = getProjectName(configuration); - if (projectName != null) { - projectName = projectName.trim(); - if (projectName.length() > 0) { - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); - ICProject cProject = CCorePlugin.getDefault().getCoreModel().create(project); - if (cProject != null && cProject.exists()) { - return cProject; - } - } - } - return null; - } - - /** - * Note: Moved from AbstractCLaunchDelegate - * @since 6.0 - */ - public static String getProjectName(ILaunchConfiguration configuration) throws CoreException { - return configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null); - } - - /** - * Note: Moved from AbstractCLaunchDelegate - * @since 6.0 - */ - public static String getProgramName(ILaunchConfiguration configuration) throws CoreException { - String programName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String) null); - if (programName != null) { - programName = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(programName); - } - return programName; - } - - /** - * Note: Moved from AbstractCLaunchDelegate - * @since 6.0 - */ - public static IPath getProgramPath(ILaunchConfiguration configuration) throws CoreException { - String path = getProgramName(configuration); - if (path == null || path.trim().length() == 0) { - return null; - } - return new Path(path); - } + public static ICProject getCProject(ILaunchConfiguration configuration) throws CoreException { + String projectName = getProjectName(configuration); + if (projectName != null) { + projectName = projectName.trim(); + if (projectName.length() > 0) { + IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); + ICProject cProject = CCorePlugin.getDefault().getCoreModel().create(project); + if (cProject != null && cProject.exists()) { + return cProject; + } + } + } + return null; + } + + /** + * Note: Moved from AbstractCLaunchDelegate + * @since 6.0 + */ + public static String getProjectName(ILaunchConfiguration configuration) throws CoreException { + return configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String) null); + } + + /** + * Note: Moved from AbstractCLaunchDelegate + * @since 6.0 + */ + public static String getProgramName(ILaunchConfiguration configuration) throws CoreException { + String programName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, + (String) null); + if (programName != null) { + programName = VariablesPlugin.getDefault().getStringVariableManager() + .performStringSubstitution(programName); + } + return programName; + } + + /** + * Note: Moved from AbstractCLaunchDelegate + * @since 6.0 + */ + public static IPath getProgramPath(ILaunchConfiguration configuration) throws CoreException { + String path = getProgramName(configuration); + if (path == null || path.trim().length() == 0) { + return null; + } + return new Path(path); + } /** * Returns the ICProject associated with the project setting in the Main tab * of a CDT launch configuration, or throws a CoreException providing a * reason (e.g., the setting is empty, the project no longer exists, the * isn't a CDT one, etc). - * + * * @param config * the launch configuration * @return an ICProject; never null. @@ -627,20 +647,21 @@ public class CDebugUtils { public static ICProject verifyCProject(ILaunchConfiguration config) throws CoreException { String name = CDebugUtils.getProjectName(config); if (name == null) { - throwCoreException(DebugCoreMessages.getString("CDebugUtils.C_Project_not_specified"), //$NON-NLS-1$ + throwCoreException(DebugCoreMessages.getString("CDebugUtils.C_Project_not_specified"), //$NON-NLS-1$ ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROJECT); } ICProject cproject = CDebugUtils.getCProject(config); if (cproject == null) { IProject proj = ResourcesPlugin.getWorkspace().getRoot().getProject(name); if (!proj.exists()) { - throwCoreException(DebugCoreMessages.getFormattedString("CDebugUtils.Project_NAME_does_not_exist", name), //$NON-NLS-1$ + throwCoreException( + DebugCoreMessages.getFormattedString("CDebugUtils.Project_NAME_does_not_exist", name), //$NON-NLS-1$ ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT); } else if (!proj.isOpen()) { throwCoreException(DebugCoreMessages.getFormattedString("CDebugUtils.Project_NAME_is_closed", name), //$NON-NLS-1$ ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT); } - throwCoreException(DebugCoreMessages.getString("CDebugUtils.Not_a_C_CPP_project"), //$NON-NLS-1$ + throwCoreException(DebugCoreMessages.getString("CDebugUtils.Not_a_C_CPP_project"), //$NON-NLS-1$ ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT); } return cproject; @@ -655,7 +676,7 @@ public class CDebugUtils { * such possible reasons (a problem with the <i>Project</i> setting, an * empty <i>C/C++ Application</i> setting, the combined settings doesn't * resolve to an existing file, etc). - * + * * @param config * the launch configuration * @param ignoreProjectSetting @@ -666,23 +687,24 @@ public class CDebugUtils { * @throws CoreException * @since 7.0 */ - public static IPath verifyProgramPath(ILaunchConfiguration config, boolean ignoreProjectSetting) throws CoreException { + public static IPath verifyProgramPath(ILaunchConfiguration config, boolean ignoreProjectSetting) + throws CoreException { ICProject cproject = null; if (!ignoreProjectSetting) { - cproject = verifyCProject(config); // will throw exception if project setting not valid + cproject = verifyCProject(config); // will throw exception if project setting not valid } IPath programPath = CDebugUtils.getProgramPath(config); if (programPath == null || programPath.isEmpty()) { throwCoreException(DebugCoreMessages.getString("CDebugUtils.Program_file_not_specified"), //$NON-NLS-1$ ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROGRAM); } - - if (programPath != null) { // this check is here only to avoid warning; compiler can't tell we'll throw an exception above + + if (programPath != null) { // this check is here only to avoid warning; compiler can't tell we'll throw an exception above if (!programPath.isAbsolute() && (cproject != null)) { // See if we can brute-force append the program path to the // project location. This allows us to support the program file // being outside the project, even outside the workspace, without - // requiring a linked resource (e.g., the setting could be + // requiring a linked resource (e.g., the setting could be // "..\..\some\dir\myprogram.exe") IPath location = cproject.getProject().getLocation(); if (location != null) { @@ -694,8 +716,8 @@ public class CDebugUtils { try { projFile = cproject.getProject().getFile(CDebugUtils.getProgramPath(config)); } catch (IllegalArgumentException exc) { - // thrown if relative path that resolves to a root file (e.g., "..\somefile") - } + // thrown if relative path that resolves to a root file (e.g., "..\somefile") + } if (projFile != null && projFile.exists()) { programPath = projFile.getLocation(); } @@ -703,10 +725,9 @@ public class CDebugUtils { } } if (!programPath.toFile().exists()) { - throwCoreException( - DebugCoreMessages.getString("CDebugUtils.Program_file_does_not_exist"), //$NON-NLS-1$ - new FileNotFoundException( - DebugCoreMessages.getFormattedString("CDebugUtils.PROGRAM_PATH_not_found", programPath.toOSString())), //$NON-NLS-1$ + throwCoreException(DebugCoreMessages.getString("CDebugUtils.Program_file_does_not_exist"), //$NON-NLS-1$ + new FileNotFoundException(DebugCoreMessages + .getFormattedString("CDebugUtils.PROGRAM_PATH_not_found", programPath.toOSString())), //$NON-NLS-1$ ICDTLaunchConfigurationConstants.ERR_PROGRAM_NOT_EXIST); } } @@ -717,13 +738,13 @@ public class CDebugUtils { * Variant that expects (requires) the launch configuration to have a valid * <i>Project</i> setting. See * {@link #verifyProgramPath(ILaunchConfiguration, boolean)} - * + * * @since 7.0 */ public static IPath verifyProgramPath(ILaunchConfiguration config) throws CoreException { - return verifyProgramPath(config, false); + return verifyProgramPath(config, false); } - + /** Throws a CoreException. Clutter-reducing utility method. */ private static void throwCoreException(String msg, int code) throws CoreException { throwCoreException(msg, null, code); @@ -731,14 +752,15 @@ public class CDebugUtils { /** Throws a CoreException. Clutter-reducing utility method. */ private static void throwCoreException(String msg, Exception innerException, int code) throws CoreException { - throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), code, msg, innerException)); + throw new CoreException( + new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), code, msg, innerException)); } - + /** * Generic method to fetch an attribute from a Map that has keys of type String. The defaultValue * parameter will be returned if the map does not contain the key, or if the matching value is not * of the correct type. - * + * * @param <V> The type of the value we are looking for. Specified by the type of defaultValue. * @param attributes The map with keys of type String, and values of any type. Cannot be null. * @param key They key for which we want the value. @@ -755,13 +777,13 @@ public class CDebugUtils { } return defaultValue; } - + /** - * Overrides the standard project ICBreakpoint toggle breakpoint factory with - * a custom toggle breakpoint factory. The ICBreakpoint toggle breakpoint factory - * will be disabled and it is up to the client to contribute it's own toggle - * breakpoint factory. - * + * Overrides the standard project ICBreakpoint toggle breakpoint factory with + * a custom toggle breakpoint factory. The ICBreakpoint toggle breakpoint factory + * will be disabled and it is up to the client to contribute it's own toggle + * breakpoint factory. + * * @param project a project * @param factoryId a breakpoint toggle factory identifier * @since 7.1 @@ -773,12 +795,12 @@ public class CDebugUtils { pref.flush(); } catch (BackingStoreException e) { CDebugCorePlugin.log(e); - } + } } - + /** * Returns the toggle breakpoint factory identifier for the project - * + * * @param project the project * @return the toggle breakpoint factory identifier, can be {@code null} * @since 7.1 @@ -787,10 +809,10 @@ public class CDebugUtils { IEclipsePreferences pref = new ProjectScope(project.getProject()).getNode(CDebugCorePlugin.PLUGIN_ID); return pref.get(ICDebugConstants.PREF_TOGGLE_BREAKPOINT_MODEL_IDENTIFIER, null); } - + /** * Returns whether the project uses the standard ICBreakpoint toggle breakpoint factory. - * + * * @param project the project * @return {@code true} if the project uses the standard ICBreakpoint breakpoint toggle factory * @since 7.1 @@ -800,9 +822,9 @@ public class CDebugUtils { } /** - * Returns whether the custom toggle breakpoint factory should be consider when evaluating the + * Returns whether the custom toggle breakpoint factory should be consider when evaluating the * enablement of the standard ICBreakpoint toggle breakpoint factory. - * + * * @return true if the custom model breakpoint system property is set * @since 7.1 * @see ICDebugConstants#PREF_TOGGLE_BREAKPOINT_MODEL_IDENTIFIER @@ -824,7 +846,7 @@ public class CDebugUtils { /** * Returns the containing folder of the input file. Can be empty if the * input file was a filename. - * + * * @return containing folder */ public String getFolder() { @@ -834,7 +856,7 @@ public class CDebugUtils { /** * Returns the filename (after last slash) of the input file. Can be * empty if input ended with a slash. - * + * * @return file name */ public String getFileName() { @@ -843,7 +865,7 @@ public class CDebugUtils { /** * Returns the extension of {@link #getFileName()} - * + * * @return the extension */ public String getExtension() { @@ -853,19 +875,20 @@ public class CDebugUtils { /** * CDebugUtils.getFileParts(String) should be called to create FileParts. */ - private FileParts() {} + private FileParts() { + } } /** * Split a Windows or Unix style path into its constituent parts. - * + * * The split does not modify or canonicalize the individual parts of the * file name. Nor does it convert between platforms. - * + * * This method is useful for dealing with Windows paths when running on * Linux and vice versa, it is also useful for non-canonical paths (ones * with .. in them). - * + * * @param file * file name * @return parts of a file diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/DebugCoreMessages.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/DebugCoreMessages.java index 372ab076532..8de8801dbe3 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/DebugCoreMessages.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/DebugCoreMessages.java @@ -22,24 +22,23 @@ public class DebugCoreMessages { private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.core.DebugCoreMessages";//$NON-NLS-1$ - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); private DebugCoreMessages() { } static String getFormattedString(String key, String arg) { - return MessageFormat.format(getString(key), new Object[]{arg}); + return MessageFormat.format(getString(key), new Object[] { arg }); } 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 ) { + 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.core/src/org/eclipse/cdt/debug/core/ICBreakpointListener.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICBreakpointListener.java index 940f1221191..0cf300278d1 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICBreakpointListener.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICBreakpointListener.java @@ -29,43 +29,42 @@ import org.eclipse.debug.core.model.IDebugTarget; * Provides event and error notification for C/C++ breakpoints. * Listeners register with the <code>CDebugModel</code>. */ -public interface ICBreakpointListener -{ +public interface ICBreakpointListener { /** * Notification that the given breakpoint is about to be installed in - * the specified target. Returns whether the installation should proceed. - * If any registered listener returns <code>false</code> the breakpoint is + * the specified target. Returns whether the installation should proceed. + * If any registered listener returns <code>false</code> the breakpoint is * not installed in the given target. - * + * * @param target debug target * @param breakpoint breakpoint being installed * @return whether the the breakpoint should be installed in the given target */ - public boolean installingBreakpoint( IDebugTarget target, IBreakpoint breakpoint ); - + public boolean installingBreakpoint(IDebugTarget target, IBreakpoint breakpoint); + /** * Notification that the given breakpoint has been installed in the specified target. - * + * * @param target debug target * @param breakpoint breakpoint being installed */ - public void breakpointInstalled( IDebugTarget target, IBreakpoint breakpoint ); + public void breakpointInstalled(IDebugTarget target, IBreakpoint breakpoint); /** - * Notification that the attributes of the given breakpoint have been changed + * Notification that the attributes of the given breakpoint have been changed * from the specified target. - * + * * @param target debug target * @param breakpoint breakpoint * @param attributes a map of changed attributes */ - public void breakpointChanged( IDebugTarget target, IBreakpoint breakpoint, Map attributes ); + public void breakpointChanged(IDebugTarget target, IBreakpoint breakpoint, Map attributes); /** * Notification that the given breakpoints have been removed from the specified target. - * + * * @param target debug target * @param breakpoints the breakpoints being removed */ - public void breakpointsRemoved( IDebugTarget target, IBreakpoint[] breakpoints ); + public void breakpointsRemoved(IDebugTarget target, IBreakpoint[] breakpoints); } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDTLaunchConfigurationConstants.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDTLaunchConfigurationConstants.java index 5bb29c4debb..7471b90dfd0 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDTLaunchConfigurationConstants.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDTLaunchConfigurationConstants.java @@ -38,62 +38,61 @@ public interface ICDTLaunchConfigurationConstants { * @since 7.1 */ public static final String ID_LAUNCH_C_REMOTE_APP = "org.eclipse.cdt.launch.remoteApplicationLaunchType"; //$NON-NLS-1$ - - /** - * This is the attach launch type id. - * - * @since 6.0 - */ - public static final String ID_LAUNCH_C_ATTACH = "org.eclipse.cdt.launch.attachLaunchType"; //$NON-NLS-1$ - - /** - * This is the post-mortem launch type id. - * - * @since 6.0 - */ - public static final String ID_LAUNCH_C_POST_MORTEM = "org.eclipse.cdt.launch.postmortemLaunchType"; //$NON-NLS-1$ - - /** + + /** + * This is the attach launch type id. + * + * @since 6.0 + */ + public static final String ID_LAUNCH_C_ATTACH = "org.eclipse.cdt.launch.attachLaunchType"; //$NON-NLS-1$ + + /** + * This is the post-mortem launch type id. + * + * @since 6.0 + */ + public static final String ID_LAUNCH_C_POST_MORTEM = "org.eclipse.cdt.launch.postmortemLaunchType"; //$NON-NLS-1$ + + /** * Specifies the default launch delegate for a Local Debug session * @since 7.0 */ - public static final String PREFERRED_DEBUG_LOCAL_LAUNCH_DELEGATE = "org.eclipse.cdt.dsf.gdb.launch.localCLaunch"; //$NON-NLS-1$ + public static final String PREFERRED_DEBUG_LOCAL_LAUNCH_DELEGATE = "org.eclipse.cdt.dsf.gdb.launch.localCLaunch"; //$NON-NLS-1$ - /** + /** * Specifies the default launch delegate for a Remote Debug session. * This default is part of the optional plugin org.eclipse.cdt.launch.remote. If that plugin is not installed - * then we won't set a default, which is ok since we only have one other delegate + * then we won't set a default, which is ok since we only have one other delegate * (which is org.eclipse.cdt.dsf.gdb.launch.remoteCLaunch). * @since 7.1 */ - public static final String PREFERRED_DEBUG_REMOTE_LAUNCH_DELEGATE = "org.eclipse.rse.remotecdt.dsf.debug"; //$NON-NLS-1$ + public static final String PREFERRED_DEBUG_REMOTE_LAUNCH_DELEGATE = "org.eclipse.rse.remotecdt.dsf.debug"; //$NON-NLS-1$ - - /** + /** * Specifies the default launch delegate for an Attach Debug session * @since 7.0 */ - public static final String PREFERRED_DEBUG_ATTACH_LAUNCH_DELEGATE = "org.eclipse.cdt.dsf.gdb.launch.attachCLaunch"; //$NON-NLS-1$ + public static final String PREFERRED_DEBUG_ATTACH_LAUNCH_DELEGATE = "org.eclipse.cdt.dsf.gdb.launch.attachCLaunch"; //$NON-NLS-1$ - /** + /** * Specifies the default launch delegate for a Post Mortem Debug session * @since 7.0 */ - public static final String PREFERRED_DEBUG_POSTMORTEM_LAUNCH_DELEGATE = "org.eclipse.cdt.dsf.gdb.launch.coreCLaunch"; //$NON-NLS-1$ + public static final String PREFERRED_DEBUG_POSTMORTEM_LAUNCH_DELEGATE = "org.eclipse.cdt.dsf.gdb.launch.coreCLaunch"; //$NON-NLS-1$ - /** - * Specifies the default launch delegate for a Run mode session + /** + * Specifies the default launch delegate for a Run mode session * @since 7.0 */ - public static final String PREFERRED_RUN_LAUNCH_DELEGATE = "org.eclipse.cdt.cdi.launch.localCLaunch"; //$NON-NLS-1$ - + public static final String PREFERRED_RUN_LAUNCH_DELEGATE = "org.eclipse.cdt.cdi.launch.localCLaunch"; //$NON-NLS-1$ + /** * Identifier for the C/C++ program process type, which is annotated on processes created * by the C/C++ application launch delegate. - * + * * (value <code>"C/C++"</code>). */ - public static final String ID_PROGRAM_PROCESS_TYPE = "C/C++"; //$NON-NLS-1$ + public static final String ID_PROGRAM_PROCESS_TYPE = "C/C++"; //$NON-NLS-1$ /** * Launch configuration attribute key. The value is a name of a C/C++ @@ -103,7 +102,7 @@ public interface ICDTLaunchConfigurationConstants { /** * Launch configuration attribute value constants for build before launch. - * + * * @since 7.0 */ public static final int BUILD_BEFORE_LAUNCH_DISABLED = 0; @@ -167,7 +166,7 @@ public interface ICDTLaunchConfigurationConstants { /** * Launch configuration attribute key. The value is a Map specifying the * environment to use when launching a C/C++ application. - * + * * @deprecated - see ILaunchManager.ATTR_ENVIRONMENT_VARIABLES */ @Deprecated @@ -206,13 +205,13 @@ public interface ICDTLaunchConfigurationConstants { public static final String ATTR_DEBUGGER_STOP_AT_MAIN = CDT_LAUNCH_ID + ".DEBUGGER_STOP_AT_MAIN"; //$NON-NLS-1$ /** - * Launch configuration attribute key. The value is a String specifying + * Launch configuration attribute key. The value is a String specifying * the symbol to use for the main breakpoint. */ public static final String ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL = CDT_LAUNCH_ID + ".DEBUGGER_STOP_AT_MAIN_SYMBOL"; //$NON-NLS-1$ /** - * Launch configuration attribute key. The value is a String specifying + * Launch configuration attribute key. The value is a String specifying * the register groups memento. */ public static final String ATTR_DEBUGGER_REGISTER_GROUPS = CDT_LAUNCH_ID + ".DEBUGGER_REGISTER_GROUPS"; //$NON-NLS-1$ @@ -247,13 +246,15 @@ public interface ICDTLaunchConfigurationConstants { * Launch configuration attribute key. The value is a boolean specifying * whether to enable variable bookkeeping. */ - public static final String ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING = CDT_LAUNCH_ID + ".ENABLE_VARIABLE_BOOKKEEPING"; //$NON-NLS-1$ + public static final String ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING = CDT_LAUNCH_ID + + ".ENABLE_VARIABLE_BOOKKEEPING"; //$NON-NLS-1$ /** * Launch configuration attribute key. The value is a boolean specifying * whether to enable register bookkeeping. */ - public static final String ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING = CDT_LAUNCH_ID + ".ENABLE_REGISTER_BOOKKEEPING"; //$NON-NLS-1$ + public static final String ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING = CDT_LAUNCH_ID + + ".ENABLE_REGISTER_BOOKKEEPING"; //$NON-NLS-1$ /** * launch configuration attribute key. The value is a string specifying the protocol to @@ -268,7 +269,7 @@ public interface ICDTLaunchConfigurationConstants { * memento. */ public static final String ATTR_DEBUGGER_GLOBAL_VARIABLES = CDT_LAUNCH_ID + ".GLOBAL_VARIABLES"; //$NON-NLS-1$ - + /** * Launch configuration attribute key. The value is a format list' * memento. @@ -280,12 +281,12 @@ public interface ICDTLaunchConfigurationConstants { */ public static final String ATTR_DEBUGGER_MEMORY_BLOCKS = CDT_LAUNCH_ID + ".MEMORY_BLOCKS"; //$NON-NLS-1$ - /** + /** * Launch configuration attribute key. The value is a String specifying the type of post mortem launch. * Note that we use the prefix "org.eclipse.cdt.dsf.gdb" for backwards-compatibility. * See bug 476589. * @since 7.7 - */ + */ public static final String ATTR_DEBUGGER_POST_MORTEM_TYPE = "org.eclipse.cdt.dsf.gdb" + ".POST_MORTEM_TYPE"; //$NON-NLS-1$ //$NON-NLS-2$ /** @@ -328,23 +329,23 @@ public interface ICDTLaunchConfigurationConstants { */ public static String DEBUGGER_MODE_CORE = "core"; //$NON-NLS-1$ - /** + /** * Possible attribute value for the key is ATTR_DEBUGGER_POST_MORTEM_TYPE. * Indicates a core file. - * + * * @since 7.7 - */ + */ public static final String DEBUGGER_POST_MORTEM_CORE_FILE = "CORE_FILE"; //$NON-NLS-1$ /** * Possible attribute value for the key is ATTR_DEBUGGER_POST_MORTEM_TYPE. * Indicates a trace data file. - * + * * @since 7.7 - */ + */ public static final String DEBUGGER_POST_MORTEM_TRACE_FILE = "TRACE_FILE"; //$NON-NLS-1$ - /** + /** * Launch configuration attribute value. The key is ATTR_DEBUGGER_POST_MORTEM_TYPE. * @since 7.7 */ diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDebugConstants.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDebugConstants.java index 2860bb6fe0c..6bbb58b04e3 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDebugConstants.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDebugConstants.java @@ -40,7 +40,7 @@ public interface ICDebugConstants { * view */ public static final String PREF_DEFAULT_REGISTER_FORMAT = PLUGIN_ID + "cDebug.default_register_format"; //$NON-NLS-1$ - + /** * The charset to use for decoding char type strings. We however can't use the ID * "character_set" here because that would break backwards compatibility as it was @@ -102,17 +102,17 @@ public interface ICDebugConstants { */ public static final int MAX_NUMBER_OF_INSTRUCTIONS = 999; - /** - * Preference that saves the default debugger type - * @since 3.1 - */ - public static final String PREF_DEFAULT_DEBUGGER_TYPE = PLUGIN_ID + ".cDebug.defaultDebugger"; //$NON-NLS-1$ + /** + * Preference that saves the default debugger type + * @since 3.1 + */ + public static final String PREF_DEFAULT_DEBUGGER_TYPE = PLUGIN_ID + ".cDebug.defaultDebugger"; //$NON-NLS-1$ - /** - * Preference that saves the deactivated debugger types - * @since 3.1 - */ - public static final String PREF_FILTERED_DEBUGGERS = PLUGIN_ID + ".cDebug.filteredDebuggers"; //$NON-NLS-1$ + /** + * Preference that saves the deactivated debugger types + * @since 3.1 + */ + public static final String PREF_FILTERED_DEBUGGERS = PLUGIN_ID + ".cDebug.filteredDebuggers"; //$NON-NLS-1$ /** * Boolean preference used to persist the instruction-stepping mode. The @@ -120,7 +120,7 @@ public interface ICDebugConstants { * persisted global value when a debug session ends, using the mode that * session is in at that time. In other words, the most recently terminated * debug session dictates the initial mode of the next new debug session. - * + * * Temporary. See bugs 79872 and 80323. */ public static final String PREF_INSTRUCTION_STEP_MODE_ON = PLUGIN_ID + "cDebug.Disassembly.instructionStepOn"; //$NON-NLS-1$ @@ -132,23 +132,23 @@ public interface ICDebugConstants { */ @Deprecated public static final String DEF_CHARSET = "UTF-16"; //$NON-NLS-1$ - - /** - * Specifies the stepping mode (context/source/instruction) - */ - public static final String PREF_STEP_MODE = PLUGIN_ID + ".steppingMode"; //$NON-NLS-1$ - - public static final String PREF_VALUE_STEP_MODE_CONTEXT = "context"; //$NON-NLS-1$ - public static final String PREF_VALUE_STEP_MODE_SOURCE = "source"; //$NON-NLS-1$ - public static final String PREF_VALUE_STEP_MODE_INSTRUCTION = "instruction"; //$NON-NLS-1$ - - /** - * Preference key for toggle breakpoint model identifier. Debugger that contribute custom - * CBreakpoint should set the system property with this key to true. when this system property - * is set to true, the standard ICBreakpoint toggle breakpoint factory enablement will take - * into account for non-standard ICElement input. - * - * @since 7.1 - */ - public static final String PREF_TOGGLE_BREAKPOINT_MODEL_IDENTIFIER = PLUGIN_ID + ".toggleBreakpointModel"; //$NON-NLS-1$ + + /** + * Specifies the stepping mode (context/source/instruction) + */ + public static final String PREF_STEP_MODE = PLUGIN_ID + ".steppingMode"; //$NON-NLS-1$ + + public static final String PREF_VALUE_STEP_MODE_CONTEXT = "context"; //$NON-NLS-1$ + public static final String PREF_VALUE_STEP_MODE_SOURCE = "source"; //$NON-NLS-1$ + public static final String PREF_VALUE_STEP_MODE_INSTRUCTION = "instruction"; //$NON-NLS-1$ + + /** + * Preference key for toggle breakpoint model identifier. Debugger that contribute custom + * CBreakpoint should set the system property with this key to true. when this system property + * is set to true, the standard ICBreakpoint toggle breakpoint factory enablement will take + * into account for non-standard ICElement input. + * + * @since 7.1 + */ + public static final String PREF_TOGGLE_BREAKPOINT_MODEL_IDENTIFIER = PLUGIN_ID + ".toggleBreakpointModel"; //$NON-NLS-1$ } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICWatchpointTarget.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICWatchpointTarget.java index 5dd162c11df..314a5eccd0d 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICWatchpointTarget.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICWatchpointTarget.java @@ -19,7 +19,7 @@ import org.eclipse.debug.core.IRequest; * View model types for which the "Add Watchpoint (C/C++)" action is applicable * should implement this interface. The action is a popupMenu/objectContribution * that targets this type. - * + * * @since 7.2 */ public interface ICWatchpointTarget { @@ -27,11 +27,13 @@ public interface ICWatchpointTarget { /** IRequest object used in the asynchronous method {@link ICWatchpointTarget#getSize()} */ interface GetSizeRequest extends IRequest { int getSize(); // returns -1 if size not available + void setSize(int size); }; - + interface CanCreateWatchpointRequest extends IRequest { boolean getCanCreate(); + void setCanCreate(boolean value); }; @@ -44,7 +46,7 @@ public interface ICWatchpointTarget { * supports watchpoints (at all or at that particular location). */ void canSetWatchpoint(CanCreateWatchpointRequest request); - + /** * Get the expression or the name of the variable */ @@ -53,7 +55,7 @@ public interface ICWatchpointTarget { /** * Asynchronous method to retrieve the size of the variable/expression, in * bytes. - * + * * @param request * the async request object */ diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/BreakpointActionManager.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/BreakpointActionManager.java index f71238ee567..7977271b034 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/BreakpointActionManager.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/BreakpointActionManager.java @@ -62,7 +62,8 @@ public class BreakpointActionManager { private IBreakpointAction createActionFromClassName(String name, String className) { IBreakpointAction action = null; - IExtension[] actionExtensions = CDebugCorePlugin.getDefault().getBreakpointActionManager().getBreakpointActionExtensions(); + IExtension[] actionExtensions = CDebugCorePlugin.getDefault().getBreakpointActionManager() + .getBreakpointActionExtensions(); try { @@ -99,15 +100,15 @@ public class BreakpointActionManager { } return false; } - + public void executeActions(final IBreakpoint breakpoint, final IAdaptable context) { if (breakpoint != null) { IMarker marker = breakpoint.getMarker(); String actionNames = marker.getAttribute(BREAKPOINT_ACTION_ATTRIBUTE, ""); //$NON-NLS-1$ - if (actionNames.length() > 0 ) { + if (actionNames.length() > 0) { final String[] actions = actionNames.split(","); //$NON-NLS-1$ - if (actions.length > 0){ - Job job = new Job("Execute breakpoint actions") { //$NON-NLS-1$ + if (actions.length > 0) { + Job job = new Job("Execute breakpoint actions") { //$NON-NLS-1$ @Override public IStatus run(final IProgressMonitor monitor) { return doExecuteActions(breakpoint, context, actions, monitor); @@ -117,8 +118,7 @@ public class BreakpointActionManager { try { // wait for actions to execute job.join(); - }catch (InterruptedException e) - { + } catch (InterruptedException e) { e.printStackTrace(); } } @@ -126,7 +126,8 @@ public class BreakpointActionManager { } } - private IStatus doExecuteActions(final IBreakpoint breakpoint, final IAdaptable context, String[] actions, IProgressMonitor monitor) { + private IStatus doExecuteActions(final IBreakpoint breakpoint, final IAdaptable context, String[] actions, + IProgressMonitor monitor) { try { for (int i = 0; i < actions.length && !monitor.isCanceled(); i++) { String actionName = actions[i]; @@ -134,7 +135,7 @@ public class BreakpointActionManager { if (action != null) { monitor.setTaskName(action.getSummary()); IStatus status = action.execute(breakpoint, context, monitor); - if (status.getCode() != IStatus.OK) { + if (status.getCode() != IStatus.OK) { // do not log status if user canceled. if (status.getCode() != IStatus.CANCEL) CDebugCorePlugin.log(status); @@ -144,7 +145,8 @@ public class BreakpointActionManager { monitor.worked(1); } } catch (Exception e) { - return new Status( IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), CDebugCorePlugin.INTERNAL_ERROR, "Internal Error", e ); //$NON-NLS-1$ + return new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), CDebugCorePlugin.INTERNAL_ERROR, + "Internal Error", e); //$NON-NLS-1$ } return monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS; } @@ -159,7 +161,8 @@ public class BreakpointActionManager { public IExtension[] getBreakpointActionExtensions() { if (breakpointActionExtensions == null) { - IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CDebugCorePlugin.PLUGIN_ID, CDebugCorePlugin.BREAKPOINT_ACTION_EXTENSION_POINT_ID); + IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CDebugCorePlugin.PLUGIN_ID, + CDebugCorePlugin.BREAKPOINT_ACTION_EXTENSION_POINT_ID); if (point == null) breakpointActionExtensions = new IExtension[0]; else { @@ -253,8 +256,8 @@ public class BreakpointActionManager { for (IBreakpointAction action : getBreakpointActions()) { Element element = doc.createElement("actionEntry"); //$NON-NLS-1$ - element.setAttribute("name", action.getName()); //$NON-NLS-1$ - element.setAttribute("class", action.getClass().getName()); //$NON-NLS-1$ + element.setAttribute("name", action.getName()); //$NON-NLS-1$ + element.setAttribute("class", action.getClass().getName()); //$NON-NLS-1$ element.setAttribute("value", action.getMemento()); //$NON-NLS-1$ rootElement.appendChild(element); } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/IBreakpointAction.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/IBreakpointAction.java index d08bb8bae71..570fdaa0883 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/IBreakpointAction.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/IBreakpointAction.java @@ -20,11 +20,11 @@ import org.eclipse.debug.core.model.IBreakpoint; /** * Interface implemented by plug-ins that wish to contribute breakpoint actions. - * + * * THIS INTERFACE IS PROVISIONAL AND WILL CHANGE IN THE FUTURE BREAKPOINT ACTION * CONTRIBUTIONS USING THIS INTERFACE WILL NEED TO BE REVISED TO WORK WITH * FUTURE VERSIONS OF CDT. - * + * */ public interface IBreakpointAction { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/ILogActionEnabler.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/ILogActionEnabler.java index 21de8e1686f..0336bdccabb 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/ILogActionEnabler.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/ILogActionEnabler.java @@ -14,10 +14,10 @@ package org.eclipse.cdt.debug.core.breakpointactions; /** - * + * * 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. - * + * */ public interface ILogActionEnabler { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/IResumeActionEnabler.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/IResumeActionEnabler.java index c6cbedc13d5..4dda915f346 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/IResumeActionEnabler.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/IResumeActionEnabler.java @@ -15,10 +15,10 @@ package org.eclipse.cdt.debug.core.breakpointactions; /** - * + * * 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. - * + * */ public interface IResumeActionEnabler { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/IReverseDebugEnabler.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/IReverseDebugEnabler.java index b12a104ce6c..ffa1f1d939b 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/IReverseDebugEnabler.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/IReverseDebugEnabler.java @@ -18,23 +18,23 @@ package org.eclipse.cdt.debug.core.breakpointactions; * @since 7.3 */ public interface IReverseDebugEnabler { - + /** * Toggles the state of the reverse debugging mode. * @throws Exception */ void toggle() throws Exception; - + /** * Enables the reverse debugging mode. No effect if already enabled. * @throws Exception */ void enable() throws Exception; - + /** * Disables the reverse debugging mode. No effect if it's not enabled. * @throws Exception */ void disable() throws Exception; - + } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/CCommandAdapterFactory.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/CCommandAdapterFactory.java index c728ce3bcd0..7c539d26024 100755 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/CCommandAdapterFactory.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/CCommandAdapterFactory.java @@ -20,9 +20,9 @@ import org.eclipse.debug.core.commands.IRestartHandler; /** * Adapter factory for debug commands. - * + * * @see org.eclipse.debug.core.command - * + * * @since 7.0 * */ @@ -42,9 +42,7 @@ public class CCommandAdapterFactory implements IAdapterFactory { @Override public Class<?>[] getAdapterList() { - return new Class[] { - IRestartHandler.class - }; + return new Class[] { IRestartHandler.class }; } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/CForEachCommand.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/CForEachCommand.java index 194ef29c194..2da000fc316 100755 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/CForEachCommand.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/CForEachCommand.java @@ -39,14 +39,15 @@ public abstract class CForEachCommand extends AbstractDebugCommand { monitor.worked(1); } } - + protected abstract void execute(Object target) throws CoreException; /* (non-Javadoc) * @see org.eclipse.debug.internal.core.commands.DebugCommand#isExecutable(java.lang.Object[], org.eclipse.core.runtime.IProgressMonitor, org.eclipse.debug.core.commands.IEnabledStateRequest) */ @Override - protected boolean isExecutable(Object[] targets, IProgressMonitor monitor, IEnabledStateRequest request) throws CoreException { + protected boolean isExecutable(Object[] targets, IProgressMonitor monitor, IEnabledStateRequest request) + throws CoreException { for (int i = 0; i < targets.length; i++) { if (!isExecutable(targets[i])) { return false; @@ -55,7 +56,7 @@ public abstract class CForEachCommand extends AbstractDebugCommand { } return true; } - + protected abstract boolean isExecutable(Object target); } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/RestartCommand.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/RestartCommand.java index f0c8441a3be..4ffe99c9a72 100755 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/RestartCommand.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/RestartCommand.java @@ -21,7 +21,7 @@ import org.eclipse.debug.core.commands.IRestartHandler; /** * Default restart command for CDI - * + * * @since 7.0 */ public class RestartCommand extends CForEachCommand implements IRestartHandler { @@ -33,12 +33,12 @@ public class RestartCommand extends CForEachCommand implements IRestartHandler { @Override protected void execute(Object target) throws CoreException { - ((IRestart)target).restart(); + ((IRestart) target).restart(); } - + @Override protected boolean isExecutable(Object target) { - return ((IRestart)target).canRestart(); + return ((IRestart) target).canRestart(); } /* (non-Javadoc) diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/disassembly/IDisassemblyContextListener.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/disassembly/IDisassemblyContextListener.java index 16e85d97578..67d392b0400 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/disassembly/IDisassemblyContextListener.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/disassembly/IDisassemblyContextListener.java @@ -15,8 +15,8 @@ package org.eclipse.cdt.debug.core.disassembly; /** - * The instances of this interface are notified when - * a disassembly context is registered or unregistered + * The instances of this interface are notified when + * a disassembly context is registered or unregistered * with <code>IDisassemblyContextService</code>. * <p> * This interface is used by the disassembly UI components. @@ -27,20 +27,20 @@ package org.eclipse.cdt.debug.core.disassembly; * This interface is experimental. */ public interface IDisassemblyContextListener { - - /** - * Indicates that <code>context</code> has been registered - * with <code>IDisassemblyContextService</code>. - * - * @param context the disassembly context that is registered - */ - public void contextAdded( Object context ); - /** - * Indicates that <code>context</code> has been unregistered - * with <code>IDisassemblyContextService</code>. - * - * @param context the disassembly context that is unregistered - */ - public void contextRemoved( Object context ); + /** + * Indicates that <code>context</code> has been registered + * with <code>IDisassemblyContextService</code>. + * + * @param context the disassembly context that is registered + */ + public void contextAdded(Object context); + + /** + * Indicates that <code>context</code> has been unregistered + * with <code>IDisassemblyContextService</code>. + * + * @param context the disassembly context that is unregistered + */ + public void contextRemoved(Object context); } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/disassembly/IDisassemblyContextProvider.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/disassembly/IDisassemblyContextProvider.java index 4e277b12eaa..3a4a79533b9 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/disassembly/IDisassemblyContextProvider.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/disassembly/IDisassemblyContextProvider.java @@ -24,13 +24,13 @@ package org.eclipse.cdt.debug.core.disassembly; */ public interface IDisassemblyContextProvider { - /** - * Returns the disassembly context object for <code>element</code> - * - * @param element the element being queried for disassembly context - * @return an object that represents the disassembly context - * for the given element, or <code>null</code> if the given element - * doesn't provide a disassembly context - */ - public Object getDisassemblyContext( Object element ); + /** + * Returns the disassembly context object for <code>element</code> + * + * @param element the element being queried for disassembly context + * @return an object that represents the disassembly context + * for the given element, or <code>null</code> if the given element + * doesn't provide a disassembly context + */ + public Object getDisassemblyContext(Object element); } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/disassembly/IDisassemblyContextService.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/disassembly/IDisassemblyContextService.java index f63b9740dea..7e3b4c0ec56 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/disassembly/IDisassemblyContextService.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/disassembly/IDisassemblyContextService.java @@ -15,52 +15,52 @@ package org.eclipse.cdt.debug.core.disassembly; /** - * Interface for registering the disassembly context objects. + * Interface for registering the disassembly context objects. * <p> - * Clients interested in the context change notifications + * Clients interested in the context change notifications * may register a listener. * </p> * <p> - * This interface is not intended to be implemented by clients. + * This interface is not intended to be implemented by clients. * It can be accessed from <code>CDebugCorePlugin</code>. * </p> * @see org.eclipse.cdt.debug.core.IDisassemblyContextListener - * + * * This interface is experimental. */ public interface IDisassemblyContextService { - /** - * Adds the given listener to the collection of registered listeners. - * Has no effect if an identical listener is already registered. - * - * @param listener the listener to add - */ - public void addDisassemblyContextListener( IDisassemblyContextListener listener ); + /** + * Adds the given listener to the collection of registered listeners. + * Has no effect if an identical listener is already registered. + * + * @param listener the listener to add + */ + public void addDisassemblyContextListener(IDisassemblyContextListener listener); - /** - * Removes the given listener from the collection of registered listeners. - * Has no effect if an identical listener is not already registered. - * - * @param listener the listener to remove - */ - public void removeDisassemblyContextListener( IDisassemblyContextListener listener ); + /** + * Removes the given listener from the collection of registered listeners. + * Has no effect if an identical listener is not already registered. + * + * @param listener the listener to remove + */ + public void removeDisassemblyContextListener(IDisassemblyContextListener listener); - /** - * Registers the given context with this service. - * Has no effect if an identical context has already been registered. - * The corresponding notifications will be sent to all registered listeners. - * - * @param disassemblyContext the context to register. - */ - public void register( Object disassemblyContext ); + /** + * Registers the given context with this service. + * Has no effect if an identical context has already been registered. + * The corresponding notifications will be sent to all registered listeners. + * + * @param disassemblyContext the context to register. + */ + public void register(Object disassemblyContext); - /** - * Unregisters the given context with this service. - * Has no effect if an identical context has not been registered. - * The corresponding notifications will be sent to all registered listeners. - * - * @param disassemblyContext the context to unregister. - */ - public void unregister( Object disassemblyContext ); + /** + * Unregisters the given context with this service. + * Has no effect if an identical context has not been registered. + * The corresponding notifications will be sent to all registered listeners. + * + * @param disassemblyContext the context to unregister. + */ + public void unregister(Object disassemblyContext); } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/Executable.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/Executable.java index c2f34899049..fa76df42d0c 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/Executable.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/Executable.java @@ -47,8 +47,8 @@ public class Executable extends PlatformObject { /** * Poorly named. This does not determine if the the file is an executable - * but rather a binary. Use {@link #isBinaryFile(IPath)} instead. - * + * but rather a binary. Use {@link #isBinaryFile(IPath)} instead. + * * @deprecated use {@link #isBinaryFile(IPath)} */ @Deprecated @@ -62,7 +62,7 @@ public class Executable extends PlatformObject { * shared library. A binary can be an executable but it can also be an * instruction-containing artifact of a build, which typically is linked to * make an executable (.e.,g .o and .obj files) - * + * * @param path * @return * @since 7.1 @@ -101,9 +101,8 @@ public class Executable extends PlatformObject { @Override public boolean equals(Object arg0) { - if (arg0 instanceof Executable) - { - Executable exe = (Executable)arg0; + if (arg0 instanceof Executable) { + Executable exe = (Executable) arg0; return exe.getPath().equals(this.getPath()); } return super.equals(arg0); @@ -139,7 +138,7 @@ public class Executable extends PlatformObject { this.project = project; this.name = new File(path.toOSString()).getName(); this.resource = resource; - this.remappers = sourceFileRemappings; + this.remappers = sourceFileRemappings; remappedPaths = new HashMap<ITranslationUnit, String>(); sourceFiles = new ArrayList<ITranslationUnit>(); refreshSourceFiles = true; @@ -169,7 +168,7 @@ public class Executable extends PlatformObject { return (T) this.getProject(); return super.getAdapter(adapter); } - + private String remapSourceFile(String filename) { for (ISourceFileRemapping remapper : remappers) { String remapped = remapper.remapSourceFile(this.getPath(), filename); @@ -179,20 +178,21 @@ public class Executable extends PlatformObject { } return filename; } - /** * @noreference This method is not intended to be referenced by clients. * @since 6.0 */ public synchronized ITranslationUnit[] getSourceFiles(IProgressMonitor monitor) { - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().traceEntry(null); - + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().traceEntry(null); + if (!refreshSourceFiles && !remapSourceFiles) { - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "returning cached result"); //$NON-NLS-1$ - return sourceFiles.toArray(new TranslationUnit[sourceFiles.size()]) ; + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().trace(null, "returning cached result"); //$NON-NLS-1$ + return sourceFiles.toArray(new TranslationUnit[sourceFiles.size()]); } - + // Try to get the list of source files used to build the binary from the // symbol information. @@ -204,8 +204,7 @@ public class Executable extends PlatformObject { ICProject cproject = factory.create(project); - if (refreshSourceFiles) - { + if (refreshSourceFiles) { symReaderSources = ExecutablesManager.getExecutablesManager().getSourceFiles(this, monitor); } if (symReaderSources != null && symReaderSources.length > 0) { @@ -253,7 +252,8 @@ public class Executable extends PlatformObject { if (sourceFile.exists()) wkspFile = sourceFile; else { - IFile[] filesInWP = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(URIUtil.toURI(sourcePath)); + IFile[] filesInWP = ResourcesPlugin.getWorkspace().getRoot() + .findFilesForLocationURI(URIUtil.toURI(sourcePath)); for (IFile fileInWP : filesInWP) { if (fileInWP.isAccessible()) { wkspFile = fileInWP; @@ -276,7 +276,8 @@ public class Executable extends PlatformObject { // Be careful not to convert a unix path like // "/src/home" to "c:\source\home" on Windows. See // bugzilla 297781 - URI uri = (isNativeAbsPath && sourcePath.toFile().exists()) ? URIUtil.toURI(sourcePath) : URIUtil.toURI(filename, true); + URI uri = (isNativeAbsPath && sourcePath.toFile().exists()) ? URIUtil.toURI(sourcePath) + : URIUtil.toURI(filename, true); tu = new ExternalTranslationUnit(cproject, uri, id); } @@ -290,10 +291,10 @@ public class Executable extends PlatformObject { } } } - + refreshSourceFiles = false; remapSourceFiles = false; - return sourceFiles.toArray(new TranslationUnit[sourceFiles.size()]) ; + return sourceFiles.toArray(new TranslationUnit[sourceFiles.size()]); } /** @@ -302,16 +303,17 @@ public class Executable extends PlatformObject { * source files referenced in the executable. Digging into the binary for * that list can be expensive, so we cache the results. However, if the * executable is rebuilt, the cache can no longer be trusted. - * + * * Note that calling this also invalidates any mappings we have cached, so * there is no need to call both this method and * {@link #setRemapSourceFiles(boolean)}. That latter is automatic. - * + * * @since 6.0 */ public void setRefreshSourceFiles(boolean refreshSourceFiles) { - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().traceEntry(null, refreshSourceFiles); - + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().traceEntry(null, refreshSourceFiles); + this.refreshSourceFiles = refreshSourceFiles; } @@ -331,23 +333,24 @@ public class Executable extends PlatformObject { * in an executable to a usable path on the local machine. E.g., a user * debugging an executable built by someone else likely needs to configure * source locator(s) to point Eclipse to his local copy of the sources. - * + * * <p> * Remapping source paths is expensive, so we cache the results. However, if * applicable source locators have been added, removed or changed, then the * cache can no longer be trusted. - * + * * <p> * Note that we separately cache the (unmapped) file specifications * referenced in the executable, as that is also expensive to fetch. Calling * this method does not invalidate that cache. However, that cache can be * invalidated via {@link #setRefreshSourceFiles(boolean)}, which also ends * up invalidating any mappings we have cached. - * + * * @since 7.0 */ public void setRemapSourceFiles(boolean remapSourceFiles) { - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().traceEntry(null, remapSourceFiles); + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().traceEntry(null, remapSourceFiles); this.remapSourceFiles = remapSourceFiles; } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ExecutablesManager.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ExecutablesManager.java index ab306a322eb..803eab9b2c4 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ExecutablesManager.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ExecutablesManager.java @@ -71,32 +71,32 @@ import org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant; * The Executables Manager maintains a collection of executables built by all of * the projects in the workspace. Executables are contributed by instances of * IExecutablesProvider. - * + * * @author Ken Ryall - * + * */ -public class ExecutablesManager extends PlatformObject implements ICProjectDescriptionListener, IElementChangedListener, IResourceChangeListener { +public class ExecutablesManager extends PlatformObject + implements ICProjectDescriptionListener, IElementChangedListener, IResourceChangeListener { private Map<IProject, IProjectExecutablesProvider> executablesProviderMap = new HashMap<IProject, IProjectExecutablesProvider>(); - private List<IExecutablesChangeListener> changeListeners = Collections.synchronizedList(new ArrayList<IExecutablesChangeListener>()); + private List<IExecutablesChangeListener> changeListeners = Collections + .synchronizedList(new ArrayList<IExecutablesChangeListener>()); private List<IProjectExecutablesProvider> executableProviders; private List<ISourceFilesProvider> sourceFileProviders; private List<ISourceFileRemappingFactory> sourceFileRemappingFactories; private List<IExecutableImporter> executableImporters; - - + /** * Map of launch config names to the path locator memento string in the * launch config, recorded in the most recent launch config change * notification. We use this to ensure we flush source file mappings only * when the launch config change involves a change to the source locators. */ - private Map<String, String> locatorMementos = new HashMap<String,String>(); - + private Map<String, String> locatorMementos = new HashMap<String, String>(); /** - * A cache of the executables in the workspace, categorized by project. - * + * A cache of the executables in the workspace, categorized by project. + * * <p> * This cache is updated by scheduling an asynchronous search. SearchJob is * the only class that should <i>modify</i> this collection, including the @@ -107,16 +107,16 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr * The same Executable may appear more than once. */ private Map<IProject, List<Executable>> executablesMap = new HashMap<IProject, List<Executable>>(); - + /** * Provide a flat list of the executables in {@link #executablesMap}, with * duplicates removed. That is effectively the list of all executables in * the workspace that we know of as of now. - * + * * @return */ private List<Executable> flattenExecutablesMap() { - List<Executable> result = new ArrayList<Executable>(executablesMap.size() * 5); // most projects will have less than five executables + List<Executable> result = new ArrayList<Executable>(executablesMap.size() * 5); // most projects will have less than five executables synchronized (executablesMap) { for (List<Executable> exes : executablesMap.values()) { for (Executable exe : exes) { @@ -128,7 +128,7 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr } return result; } - + /** * Job which searches through CDT projects for executables. Only one thread * should be running this job at any one time. Running job should be @@ -139,37 +139,36 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr super("Executables Search"); //$NON-NLS-1$ } - /** * The projects given to us when scheduled. If null, flush our entire * cache and search all projects */ private IProject[] projectsToRefresh; - + @Override public IStatus run(IProgressMonitor monitor) { - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "Search for executables started"); //$NON-NLS-1$ - + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().trace(null, "Search for executables started"); //$NON-NLS-1$ + IStatus status = Status.OK_STATUS; // The executables we know of now. We'll compare the search results // to this and see if we need to notify change listeners List<Executable> before = flattenExecutablesMap(); - - // Get the CDT projects in the workspace that we have no cached + + // Get the CDT projects in the workspace that we have no cached // results for (are not in 'executablesMap'). Also, we may have been // asked to refresh the cache for some projects we've search before List<IProject> projects = new ArrayList<IProject>(); synchronized (executablesMap) { if (projectsToRefresh == null) { executablesMap.clear(); - } - else { + } else { for (IProject project : projectsToRefresh) { executablesMap.remove(project); } } - + // Get the list of projects we plan to search for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) { if (!executablesMap.containsKey(project) && CoreModel.hasCNature(project)) { @@ -178,24 +177,27 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr } } - SubMonitor subMonitor = SubMonitor.convert(monitor, projects.size()); for (IProject project : projects) { if (subMonitor.isCanceled()) { - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "Search for executables canceled"); //$NON-NLS-1$ + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().trace(null, "Search for executables canceled"); //$NON-NLS-1$ status = Status.CANCEL_STATUS; break; // we've already changed our model; stop searching but proceed to notify listeners that the model changed } - + subMonitor.subTask("Checking project: " + project.getName()); //$NON-NLS-1$ // get the executables provider for this project IProjectExecutablesProvider provider = getExecutablesProviderForProject(project); if (provider != null) { - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "Getting executables for project: " + project.getName() + " using " + provider.toString()); //$NON-NLS-1$ //$NON-NLS-2$ + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().trace(null, "Getting executables for project: " + project.getName() + " using " //$NON-NLS-1$//$NON-NLS-2$ + + provider.toString()); - List<Executable> executables = provider.getExecutables(project, subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE)); + List<Executable> executables = provider.getExecutables(project, + subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE)); // store the list of executables for this project synchronized (executablesMap) { executablesMap.put(project, executables); @@ -203,7 +205,6 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr } } - // See if, after all that work, there's a net change in the // executables list. If so, notify listeners. List<Executable> after = flattenExecutablesMap(); @@ -221,10 +222,10 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr // New interface if (listener instanceof IExecutablesChangeListener2) { if (removed.size() > 0) { - ((IExecutablesChangeListener2)listener).executablesRemoved(removed); + ((IExecutablesChangeListener2) listener).executablesRemoved(removed); } if (added.size() > 0) { - ((IExecutablesChangeListener2)listener).executablesAdded(added); + ((IExecutablesChangeListener2) listener).executablesAdded(added); } } // Old interface @@ -233,7 +234,8 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr } } - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "Search for executables finished"); //$NON-NLS-1$ + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().trace(null, "Search for executables finished"); //$NON-NLS-1$ return status; } @@ -241,7 +243,7 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr /** * Schedules the search job. Use this, not the standard Job.schedule() * method. - * + * * @param projectsToRefresh * if null, all CDT projects in the workspace are searched. * If not null, we search only newly present projects and the @@ -253,7 +255,7 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr super.schedule(); } }; - + /** The search job. We only let one of these run at any one time */ private SearchJob searchJob = new SearchJob(); @@ -274,103 +276,122 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr public ExecutablesManager() { searchJob.setPriority(Job.SHORT); - + // load the extension points loadExecutableProviderExtensions(); loadSoureFileProviderExtensions(); loadSoureRemappingExtensions(); loadExecutableImporterExtensions(); - + // add the standard providers executableProviders.add(0, new StandardExecutableProvider()); sourceFileProviders.add(0, new StandardSourceFilesProvider()); sourceFileRemappingFactories.add(0, new StandardSourceFileRemappingFactory()); executableImporters.add(0, new StandardExecutableImporter()); - + // listen for events we're interested in CModelManager.getDefault().addElementChangedListener(this); CoreModel.getDefault().getProjectDescriptionManager().addCProjectDescriptionListener(this, CProjectDescriptionEvent.APPLIED); - + // Listen for changes to the global source locators. These locators // affect how source files are found locally. The Executable objects // cache their local source file paths and rely on us to tell them to // flush those caches when applicable locators change. - CDebugCorePlugin.getDefault().getCommonSourceLookupDirector().addParticipants(new ISourceLookupParticipant[] { new ISourceLookupParticipant(){ + CDebugCorePlugin.getDefault().getCommonSourceLookupDirector() + .addParticipants(new ISourceLookupParticipant[] { new ISourceLookupParticipant() { + + @Override + public void init(ISourceLookupDirector director) { + } + + @Override + public Object[] findSourceElements(Object object) { + return new Object[0]; + } + + @Override + public String getSourceName(Object object) throws CoreException { + return ""; //$NON-NLS-1$ + } + + @Override + public void dispose() { + } + + @Override + public void sourceContainersChanged(ISourceLookupDirector director) { + // Unfortunately, it would be extremely difficult/costly to + // determine which binaries are effected by the source locator + // change, so we have to tell all Executables to flush + flushExecutablesSourceMappings(); + } + } }); - @Override - public void init(ISourceLookupDirector director) {} - @Override - public Object[] findSourceElements(Object object) { return new Object[0]; } - @Override - public String getSourceName(Object object) throws CoreException { return ""; } //$NON-NLS-1$ - @Override - public void dispose() {} - @Override - public void sourceContainersChanged(ISourceLookupDirector director) { - // Unfortunately, it would be extremely difficult/costly to - // determine which binaries are effected by the source locator - // change, so we have to tell all Executables to flush - flushExecutablesSourceMappings(); - } - } }); - // Source locators are also in launch configurations, and those too come // into play when an Executable looks for a source file locally. So, // listen for changes in those locators, too. DebugPlugin.getDefault().getLaunchManager().addLaunchConfigurationListener(new ILaunchConfigurationListener() { @Override public void launchConfigurationChanged(ILaunchConfiguration configuration) { - // Expect lots of noise for working copies. We only care about + // Expect lots of noise for working copies. We only care about // changes to actual configs if (configuration.isWorkingCopy()) { return; } - - // If the source locators in the launch config were not modified, then no-op + + // If the source locators in the launch config were not modified, then no-op try { String configName = configuration.getName(); String mementoBefore = locatorMementos.get(configName); - String mementoNow = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, ""); //$NON-NLS-1$ + String mementoNow = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, + ""); //$NON-NLS-1$ if (mementoNow.equals(mementoBefore)) { return; // launch config change had no affect on source locators } - locatorMementos.put(configName, mementoNow); + locatorMementos.put(configName, mementoNow); } catch (CoreException e) { CDebugCorePlugin.log(e); } - // TODO: For now, just tell all Executables to flush. Look - // into identifying which binary the config is associated + // TODO: For now, just tell all Executables to flush. Look + // into identifying which binary the config is associated // with so we can flush only that Executable flushExecutablesSourceMappings(); } + @Override - public void launchConfigurationRemoved(ILaunchConfiguration configuration) { configAddedOrRemoved(configuration); } + public void launchConfigurationRemoved(ILaunchConfiguration configuration) { + configAddedOrRemoved(configuration); + } + @Override - public void launchConfigurationAdded(ILaunchConfiguration configuration) { configAddedOrRemoved(configuration); } + public void launchConfigurationAdded(ILaunchConfiguration configuration) { + configAddedOrRemoved(configuration); + } + private void configAddedOrRemoved(ILaunchConfiguration configuration) { - // Expect lots of noise for working copies. We only care about + // Expect lots of noise for working copies. We only care about // changes to actual configs if (configuration.isWorkingCopy()) { return; } - - // The addition or removal of a launch config could affect - // how files are found. It would be extremely costly to - // determine here whether it will or not, so assume it will. - - // TODO: For now, just tell all Executables to flush. Look - // into identifying which binary the config is associated + + // The addition or removal of a launch config could affect + // how files are found. It would be extremely costly to + // determine here whether it will or not, so assume it will. + + // TODO: For now, just tell all Executables to flush. Look + // into identifying which binary the config is associated // with so we can flush only that Executable flushExecutablesSourceMappings(); } }); - + // schedule a refresh so we get up to date scheduleExecutableSearch(null); } - + /** * Tell all Executable objects to flush their source file mappings, then * notify our listeners that the executables changed. Even though the @@ -379,7 +400,7 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr * information the Executable provided, that info can no longer be trusted. * The primary purpose of an Executable is to provide source file path * information--not only the compile paths burned into the executable but - * also the local mappings of those paths. + * also the local mappings of those paths. */ private void flushExecutablesSourceMappings() { List<Executable> exes = flattenExecutablesMap(); @@ -413,7 +434,7 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr * Gets the list of executables in the workspace. This method doesn't * initiate a search. It returns the cached results of the most recent * search, or waits for the ongoing search to complete. - * + * * @param wait * Whether or not to wait if the cache is in the process of being * updated when this method is called. When true, the call will @@ -428,19 +449,23 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr * @since 7.0 */ public Collection<Executable> getExecutables(boolean wait) { - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().traceEntry(null, Boolean.valueOf(wait)); - + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().traceEntry(null, Boolean.valueOf(wait)); + // Wait for running search to finish, if asked to if (wait && searchJob.getState() != Job.NONE) { - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "Waiting for executable search to finish..."); //$NON-NLS-1$ + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().trace(null, "Waiting for executable search to finish..."); //$NON-NLS-1$ try { searchJob.join(); } catch (InterruptedException e) { } - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "...executable search finished."); //$NON-NLS-1$ + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().trace(null, "...executable search finished."); //$NON-NLS-1$ } - - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().traceExit(null); + + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().traceExit(null); return flattenExecutablesMap(); } @@ -453,7 +478,7 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr public Collection<Executable> getExecutables() { return getExecutables(false); } - + /** * @since 7.0 * Gets the collection of executables for the given project @@ -498,7 +523,8 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr if (p0 > p1) return -1; return 0; - }}); + } + }); for (IExecutableImporter importer : executableImporters) { handled = importer.importExecutables(fileNames, new SubProgressMonitor(monitor, 1)); @@ -507,7 +533,7 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr } } } - + if (handled) scheduleExecutableSearch(null); } @@ -527,7 +553,7 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr } } } - + return false; } @@ -538,8 +564,9 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr * @return an array of source files which may be empty */ public String[] getSourceFiles(final Executable executable, IProgressMonitor monitor) { - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().traceEntry(null, executable); - + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().traceEntry(null, executable); + String[] result = new String[0]; synchronized (sourceFileProviders) { @@ -554,21 +581,25 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr if (p0 > p1) return -1; return 0; - }}); - + } + }); + monitor.beginTask("Finding source files in " + executable.getName(), sourceFileProviders.size() * 1000); //$NON-NLS-1$ for (ISourceFilesProvider provider : sourceFileProviders) { String[] sourceFiles = provider.getSourceFiles(executable, new SubProgressMonitor(monitor, 1000)); if (sourceFiles.length > 0) { result = sourceFiles; - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "Got " + sourceFiles.length + " files from " + provider.toString()); //$NON-NLS-1$ //$NON-NLS-2$ + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().trace(null, + "Got " + sourceFiles.length + " files from " + provider.toString()); //$NON-NLS-1$ //$NON-NLS-2$ break; } } monitor.done(); } - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().traceExit(null, result); + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().traceExit(null, result); return result; } @@ -577,15 +608,16 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr * @param executables the array of executables to be removed * @param monitor progress monitor * @return IStatus of the operation - * + * * @since 6.0 */ public IStatus removeExecutables(Executable[] executables, IProgressMonitor monitor) { - MultiStatus status = new MultiStatus(CDebugCorePlugin.PLUGIN_ID, IStatus.WARNING, "Couldn't remove all of the selected executables", null); //$NON-NLS-1$ - + MultiStatus status = new MultiStatus(CDebugCorePlugin.PLUGIN_ID, IStatus.WARNING, + "Couldn't remove all of the selected executables", null); //$NON-NLS-1$ + monitor.beginTask("Remove Executables", executables.length); //$NON-NLS-1$ for (Executable executable : executables) { - + IProjectExecutablesProvider provider = getExecutablesProviderForProject(executable.getProject()); if (provider != null) { IStatus result = provider.removeExecutable(executable, new SubProgressMonitor(monitor, 1)); @@ -594,11 +626,11 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr } } } - + // We don't need to directly call our listeners. The file removal will // cause a C model change, which we will react to by then calling the // listeners - + return status; } @@ -606,12 +638,12 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr * Initiates an asynchronous search of workspace CDT projects for * executables. If a search is ongoing, it's cancelled and a new one is * started. In all cases, this method returns quickly (does not wait/block). - * + * * <p> * Listeners are notified when the search is complete and there is a change * in the collection of found executables. The results of the search can be * obtained by calling {@link #getExecutables(boolean)}. - * + * * @param projectsToRefresh * if null, we discard our entire Executables cache and search * all CDT projects in the workspace. If not null, we purge our @@ -621,11 +653,12 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr * executables in any newly available projects. This parameter is * simply a way to get us to <i>not</i> skip one or more projects * we already have the executables list for. - * + * * @since 7.0 */ public void refresh(List<IProject> projectsToRefresh) { - scheduleExecutableSearch(projectsToRefresh != null ? projectsToRefresh.toArray(new IProject[projectsToRefresh.size()]) : null); + scheduleExecutableSearch( + projectsToRefresh != null ? projectsToRefresh.toArray(new IProject[projectsToRefresh.size()]) : null); } /** @@ -636,21 +669,23 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr */ @Override @Deprecated - public void resourceChanged(IResourceChangeEvent event) {} + public void resourceChanged(IResourceChangeEvent event) { + } /** * @since 7.0 */ @Override public void handleEvent(CProjectDescriptionEvent event) { - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().traceEntry(null, event); - + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().traceEntry(null, event); + // this handles the cases where the active build configuration changes, // and when new projects are created or loaded at startup. int eventType = event.getEventType(); if (eventType == CProjectDescriptionEvent.APPLIED) { - + // see if the active build config has changed ICProjectDescription newDesc = event.getNewCProjectDescription(); ICProjectDescription oldDesc = event.getOldCProjectDescription(); @@ -658,13 +693,16 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr String newConfigName = newDesc.getActiveConfiguration().getName(); String oldConfigName = oldDesc.getActiveConfiguration().getName(); if (!newConfigName.equals(oldConfigName)) { - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "Scheduling refresh because active build configuration changed"); //$NON-NLS-1$ - scheduleExecutableSearch(new IProject[]{newDesc.getProject()}); + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().trace(null, "Scheduling refresh because active build configuration changed"); //$NON-NLS-1$ + scheduleExecutableSearch(new IProject[] { newDesc.getProject() }); } } else if (newDesc != null && oldDesc == null) { // project just created scheduleExecutableSearch(null); - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "Scheduling refresh because project " + newDesc.getProject().getName() + " created"); //$NON-NLS-1$//$NON-NLS-2$ + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().trace(null, + "Scheduling refresh because project " + newDesc.getProject().getName() + " created"); //$NON-NLS-1$//$NON-NLS-2$ } } } @@ -676,7 +714,8 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr * takes an array instead of a list */ private void scheduleExecutableSearch(final IProject[] projectsToRefresh) { - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().traceEntry(null, projectsToRefresh); + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().traceEntry(null, projectsToRefresh); // Don't schedule multiple search jobs simultaneously. If one is // running, cancel it, wait for it to terminate, then schedule a new @@ -690,18 +729,20 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr searchJob.cancel(); if (searchJob.getState() != Job.NONE) { try { - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "Waiting for canceled job to terminate"); //$NON-NLS-1$ + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().trace(null, "Waiting for canceled job to terminate"); //$NON-NLS-1$ searchJob.join(); } catch (InterruptedException e) { } } - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "Scheduling new search job"); //$NON-NLS-1$ + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().trace(null, "Scheduling new search job"); //$NON-NLS-1$ searchJob.schedule(projectsToRefresh); } - + return Status.OK_STATUS; } - + }; job.setPriority(Job.SHORT); job.schedule(); @@ -724,7 +765,7 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr naturesMatched++; } } - + if (naturesMatched > mostNaturesMatched) { provider = exeProvider; mostNaturesMatched = naturesMatched; @@ -738,72 +779,75 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr e.printStackTrace(); } } - + return provider; } - + ISourceFileRemappingFactory[] getSourceFileRemappingFactories() { - return sourceFileRemappingFactories.toArray(new ISourceFileRemappingFactory[sourceFileRemappingFactories.size()]); + return sourceFileRemappingFactories + .toArray(new ISourceFileRemappingFactory[sourceFileRemappingFactories.size()]); } private void loadExecutableProviderExtensions() { executableProviders = Collections.synchronizedList(new ArrayList<IProjectExecutablesProvider>()); IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); - IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(CDebugCorePlugin.PLUGIN_ID + ".ExecutablesProvider"); //$NON-NLS-1$ + IExtensionPoint extensionPoint = extensionRegistry + .getExtensionPoint(CDebugCorePlugin.PLUGIN_ID + ".ExecutablesProvider"); //$NON-NLS-1$ IExtension[] extensions = extensionPoint.getExtensions(); - + for (int i = 0; i < extensions.length; i++) { IExtension extension = extensions[i]; IConfigurationElement[] elements = extension.getConfigurationElements(); IConfigurationElement element = elements[0]; - + boolean failed = false; try { Object extObject = element.createExecutableExtension("class"); //$NON-NLS-1$ if (extObject instanceof IProjectExecutablesProvider) { - executableProviders.add((IProjectExecutablesProvider)extObject); + executableProviders.add((IProjectExecutablesProvider) extObject); } else { failed = true; } - } - catch (CoreException e) { + } catch (CoreException e) { failed = true; } - + if (failed) { - CDebugCorePlugin.log("Unable to load ExecutablesProvider extension from " + extension.getContributor().getName()); //$NON-NLS-1$ + CDebugCorePlugin.log( + "Unable to load ExecutablesProvider extension from " + extension.getContributor().getName()); //$NON-NLS-1$ } } } - + private void loadSoureFileProviderExtensions() { sourceFileProviders = Collections.synchronizedList(new ArrayList<ISourceFilesProvider>()); IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); - IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(CDebugCorePlugin.PLUGIN_ID + ".SourceFilesProvider"); //$NON-NLS-1$ + IExtensionPoint extensionPoint = extensionRegistry + .getExtensionPoint(CDebugCorePlugin.PLUGIN_ID + ".SourceFilesProvider"); //$NON-NLS-1$ IExtension[] extensions = extensionPoint.getExtensions(); - + for (int i = 0; i < extensions.length; i++) { IExtension extension = extensions[i]; IConfigurationElement[] elements = extension.getConfigurationElements(); IConfigurationElement element = elements[0]; - + boolean failed = false; try { Object extObject = element.createExecutableExtension("class"); //$NON-NLS-1$ if (extObject instanceof ISourceFilesProvider) { - sourceFileProviders.add((ISourceFilesProvider)extObject); + sourceFileProviders.add((ISourceFilesProvider) extObject); } else { failed = true; } - } - catch (CoreException e) { + } catch (CoreException e) { failed = true; } - + if (failed) { - CDebugCorePlugin.log("Unable to load SourceFilesProvider extension from " + extension.getContributor().getName()); //$NON-NLS-1$ + CDebugCorePlugin.log( + "Unable to load SourceFilesProvider extension from " + extension.getContributor().getName()); //$NON-NLS-1$ } } } @@ -812,29 +856,30 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr sourceFileRemappingFactories = Collections.synchronizedList(new ArrayList<ISourceFileRemappingFactory>()); IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); - IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(CDebugCorePlugin.PLUGIN_ID + ".SourceRemappingProvider"); //$NON-NLS-1$ + IExtensionPoint extensionPoint = extensionRegistry + .getExtensionPoint(CDebugCorePlugin.PLUGIN_ID + ".SourceRemappingProvider"); //$NON-NLS-1$ IExtension[] extensions = extensionPoint.getExtensions(); - + for (int i = 0; i < extensions.length; i++) { IExtension extension = extensions[i]; IConfigurationElement[] elements = extension.getConfigurationElements(); IConfigurationElement element = elements[0]; - + boolean failed = false; try { Object extObject = element.createExecutableExtension("class"); //$NON-NLS-1$ if (extObject instanceof ISourceFileRemappingFactory) { - sourceFileRemappingFactories.add((ISourceFileRemappingFactory)extObject); + sourceFileRemappingFactories.add((ISourceFileRemappingFactory) extObject); } else { failed = true; } - } - catch (CoreException e) { + } catch (CoreException e) { failed = true; } - + if (failed) { - CDebugCorePlugin.log("Unable to load SourceRemappingProvider extension from " + extension.getContributor().getName()); //$NON-NLS-1$ + CDebugCorePlugin.log("Unable to load SourceRemappingProvider extension from " //$NON-NLS-1$ + + extension.getContributor().getName()); } } } @@ -843,29 +888,30 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr executableImporters = Collections.synchronizedList(new ArrayList<IExecutableImporter>()); IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); - IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(CDebugCorePlugin.PLUGIN_ID + ".ExecutablesImporter"); //$NON-NLS-1$ + IExtensionPoint extensionPoint = extensionRegistry + .getExtensionPoint(CDebugCorePlugin.PLUGIN_ID + ".ExecutablesImporter"); //$NON-NLS-1$ IExtension[] extensions = extensionPoint.getExtensions(); - + for (int i = 0; i < extensions.length; i++) { IExtension extension = extensions[i]; IConfigurationElement[] elements = extension.getConfigurationElements(); IConfigurationElement element = elements[0]; - + boolean failed = false; try { Object extObject = element.createExecutableExtension("class"); //$NON-NLS-1$ if (extObject instanceof IExecutableImporter) { - executableImporters.add((IExecutableImporter)extObject); + executableImporters.add((IExecutableImporter) extObject); } else { failed = true; } - } - catch (CoreException e) { + } catch (CoreException e) { failed = true; } - + if (failed) { - CDebugCorePlugin.log("Unable to load ExecutablesImporter extension from " + extension.getContributor().getName()); //$NON-NLS-1$ + CDebugCorePlugin.log( + "Unable to load ExecutablesImporter extension from " + extension.getContributor().getName()); //$NON-NLS-1$ } } } @@ -874,36 +920,44 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr * We listen to C model changes and see if they affect what executables are * in the workspace, and/or if the executables we already know of have * changed. - * + * * @since 7.1 */ @Override public void elementChanged(ElementChangedEvent event) { - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().traceEntry(null); - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "event = \n" + event); // must be done separately because of traceEntry() limitation //$NON-NLS-1$ - + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().traceEntry(null); + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().trace(null, "event = \n" + event); // must be done separately because of traceEntry() limitation //$NON-NLS-1$ + // Examine the event and figure out what needs to be done - Set<IProject> refreshProjects = new HashSet<IProject>(5); + Set<IProject> refreshProjects = new HashSet<IProject>(5); Set<Executable> executablesChanged = new HashSet<Executable>(5); Set<Executable> executablesRemoved = new HashSet<Executable>(5); - processDeltas(event.getDelta().getAddedChildren(), null, refreshProjects, executablesRemoved, executablesChanged); - processDeltas(event.getDelta().getChangedChildren(), null, refreshProjects, executablesRemoved, executablesChanged); - processDeltas(event.getDelta().getRemovedChildren(), null, refreshProjects, executablesRemoved, executablesChanged); - - // Schedule executable searches in projects + processDeltas(event.getDelta().getAddedChildren(), null, refreshProjects, executablesRemoved, + executablesChanged); + processDeltas(event.getDelta().getChangedChildren(), null, refreshProjects, executablesRemoved, + executablesChanged); + processDeltas(event.getDelta().getRemovedChildren(), null, refreshProjects, executablesRemoved, + executablesChanged); + + // Schedule executable searches in projects if (refreshProjects.size() > 0) { - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "One or more projects need to be re-searched"); //$NON-NLS-1$ + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().trace(null, "One or more projects need to be re-searched"); //$NON-NLS-1$ scheduleExecutableSearch(refreshProjects.toArray(new IProject[refreshProjects.size()])); } - + // Invalidate the source file cache in changed Executables and inform // listeners if (executablesChanged.size() > 0) { - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "One or more executables changed"); //$NON-NLS-1$ + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().trace(null, "One or more executables changed"); //$NON-NLS-1$ for (Executable exec : executablesChanged) { exec.setRefreshSourceFiles(true); } - List<Executable> list = Arrays.asList(executablesChanged.toArray(new Executable[executablesChanged.size()])); + List<Executable> list = Arrays + .asList(executablesChanged.toArray(new Executable[executablesChanged.size()])); synchronized (changeListeners) { for (IExecutablesChangeListener listener : changeListeners) { listener.executablesChanged(list); @@ -912,7 +966,8 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr } if (executablesRemoved.size() > 0) { // Update our model (i.e., our collection of Executables) and inform listeners - if (Trace.DEBUG_EXECUTABLES) Trace.getTrace().trace(null, "One or more executables were removed"); //$NON-NLS-1$ + if (Trace.DEBUG_EXECUTABLES) + Trace.getTrace().trace(null, "One or more executables were removed"); //$NON-NLS-1$ synchronized (executablesMap) { for (Executable executableRemoved : executablesRemoved) { List<Executable> execs = executablesMap.get(executableRemoved.getProject()); @@ -922,12 +977,13 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr } } } - List<Executable> list = Arrays.asList(executablesRemoved.toArray(new Executable[executablesRemoved.size()])); + List<Executable> list = Arrays + .asList(executablesRemoved.toArray(new Executable[executablesRemoved.size()])); synchronized (changeListeners) { for (IExecutablesChangeListener listener : changeListeners) { // call newer interface if supported if (listener instanceof IExecutablesChangeListener2) { - ((IExecutablesChangeListener2)listener).executablesRemoved(list); + ((IExecutablesChangeListener2) listener).executablesRemoved(list); } // and call older interface, which is less informative listener.executablesListChanged(); @@ -936,11 +992,11 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr } return; } - + /** * Drills down a hierarchy of CDT model change events to determine the * course of action. - * + * * @param deltas * CDT model events received by the viewer * @param cproject @@ -961,13 +1017,14 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr * Executable objects that have changed, requiring listeners to * be notified. */ - private void processDeltas(ICElementDelta[] deltas, ICProject cproject, final Set<IProject> projectsToRefresh, final Set<Executable> removedExecutables, final Set<Executable> changedExecutables) { + private void processDeltas(ICElementDelta[] deltas, ICProject cproject, final Set<IProject> projectsToRefresh, + final Set<Executable> removedExecutables, final Set<Executable> changedExecutables) { for (ICElementDelta delta : deltas) { ICElement element = delta.getElement(); if (element instanceof ICProject) { // When a project is deleted, we get a REMOVED delta for the - // project only--none for the elements in the project. - IProject project = ((ICProject)element).getProject(); + // project only--none for the elements in the project. + IProject project = ((ICProject) element).getProject(); if (delta.getKind() == ICElementDelta.REMOVED) { projectsToRefresh.add(project); List<Executable> execs = null; @@ -977,37 +1034,35 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr if (execs != null) { for (Executable exec : execs) { if (exec.getResource().equals(delta.getElement().getResource())) { - removedExecutables.add(exec); + removedExecutables.add(exec); break; } } } - // Note that it's not our job to update 'executablesMap'. - // The async exec search job will do that. + // Note that it's not our job to update 'executablesMap'. + // The async exec search job will do that. } - } - else if (element instanceof IBinary) { + } else if (element instanceof IBinary) { IProject project = cproject.getProject(); int deltaKind = delta.getKind(); switch (deltaKind) { case ICElementDelta.ADDED: projectsToRefresh.add(project); break; - case ICElementDelta.REMOVED: + case ICElementDelta.REMOVED: case ICElementDelta.CHANGED: { List<Executable> execs = null; synchronized (executablesMap) { execs = executablesMap.get(project); if (execs == null) { - // Somehow, we missed the addition of the project. - // Request that the project be researched for + // Somehow, we missed the addition of the project. + // Request that the project be researched for // executables projectsToRefresh.add(project); - } - else { + } else { // See if it's one of the executables we already know - // is in the project. If so, we'll update our + // is in the project. If so, we'll update our // executables map (if removed) and notifying // listeners for (Executable exec : execs) { @@ -1026,10 +1081,11 @@ public class ExecutablesManager extends PlatformObject implements ICProjectDescr } } if (element instanceof ICProject) { - cproject = (ICProject)element; + cproject = (ICProject) element; } // recursively call ourselves to handle this delta's children - processDeltas(delta.getAffectedChildren(), cproject, projectsToRefresh, removedExecutables, changedExecutables); + processDeltas(delta.getAffectedChildren(), cproject, projectsToRefresh, removedExecutables, + changedExecutables); } } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IExecutableImporter.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IExecutableImporter.java index b8940cc48c1..fc46a12b690 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IExecutableImporter.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IExecutableImporter.java @@ -29,13 +29,13 @@ public interface IExecutableImporter { * @since 6.0 */ public static final int HIGH_PRIORITY = 75; - + /** * Gets the priority to be used when importing these executables. * The priority is used by the Executables Manager when multiple IExecutableImporters are available. - * IExecutableImporter.importExecutables will be called for each one in priority order and will + * IExecutableImporter.importExecutables will be called for each one in priority order and will * stop with the first one that returns TRUE. - * + * * @param executable * @return the priority level to be used for this ISourceFilesProvider * @since 6.0 diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IExecutablesChangeListener.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IExecutablesChangeListener.java index c78a2cca46c..8d2db61d6a1 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IExecutablesChangeListener.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IExecutablesChangeListener.java @@ -20,14 +20,14 @@ import java.util.List; /** * Listener interface for finding out when the list of Executable objects in the * workspace changes or when the objects themselves change. - * + * * <p> * Executable objects are ephemeral representations of Eclipse workspace model * elements. A particular executable in the workspace is typically represented * by many Executable objects. For example, an executable in the workspace that * changes twice can cause the listener's {@link #executablesChanged(List)} to * be called with a different Executable instance each of the two times it's invoked. - * + * */ public interface IExecutablesChangeListener extends EventListener { @@ -40,9 +40,9 @@ public interface IExecutablesChangeListener extends EventListener { * cleaned * <li>user deletes one or more executables * </ul> - * + * * Clients can get the list by calling {@link ExecutablesManager#getExecutables()} - * + * * @since 7.0 */ public void executablesListChanged(); @@ -54,7 +54,7 @@ public interface IExecutablesChangeListener extends EventListener { * object provides has changed. One such case is when there's a change in * the source locators, as such locators guide the Executable in finding the * local path for the compile path. - * + * * <p> * The Executable instances in the given list have had their caches flushed * by ExecutableManager. Clients that keep references to Executable objects @@ -62,7 +62,7 @@ public interface IExecutablesChangeListener extends EventListener { * managed by ExecutableManager and as such it is the client's * responsibility to tell those instances to flush when this listener method * is called. E.g., - * + * * <p><pre> * public void executablesChanged(List<Executable> executables) { * for (Executable e : executables) { @@ -72,10 +72,10 @@ public interface IExecutablesChangeListener extends EventListener { * } * } * </pre> - * + * * <p> * This is not called when an executable is added or removed - * + * * @param executables * @since 7.0 */ diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IExecutablesChangeListener2.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IExecutablesChangeListener2.java index 39e022ec164..a3873c618b3 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IExecutablesChangeListener2.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IExecutablesChangeListener2.java @@ -16,11 +16,10 @@ package org.eclipse.cdt.debug.core.executables; import java.util.List; - /** * Extension of IExecutablesChangeListener which allows listeners to more * precisely find out when an Executable is added or removed from the workspace - * + * * @since 7.1 */ public interface IExecutablesChangeListener2 extends IExecutablesChangeListener { @@ -30,11 +29,11 @@ public interface IExecutablesChangeListener2 extends IExecutablesChangeListener * workspace */ public void executablesAdded(List<Executable> executables); - + /** * Called when one or more Executable objects have been removed from the * workspace */ - public void executablesRemoved(List<Executable> executables); + public void executablesRemoved(List<Executable> executables); }
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IProjectExecutablesProvider.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IProjectExecutablesProvider.java index 01bc0d786ee..5e75281913f 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IProjectExecutablesProvider.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IProjectExecutablesProvider.java @@ -22,10 +22,10 @@ import org.eclipse.core.runtime.IStatus; /** * IProjectExecutablesProvider supplies a list of executables for a project * to the Executables Manager. - * + * * @author Warren Paul * @since 7.0 - * + * */ public interface IProjectExecutablesProvider { @@ -36,8 +36,8 @@ public interface IProjectExecutablesProvider { * project natures the closest will be chosen. * @return the list of project nature id's */ - List<String> getProjectNatures(); - + List<String> getProjectNatures(); + /** * Get the list of executables for the active configuration of the given * project diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ISourceFileRemapping.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ISourceFileRemapping.java index b7b596dba37..9d02af52807 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ISourceFileRemapping.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ISourceFileRemapping.java @@ -18,9 +18,9 @@ import org.eclipse.core.runtime.IPath; /** * ISourceFileRemapping is used by the Executables Manager when finding missing * source files. - * + * * @author Ken Ryall - * + * */ public interface ISourceFileRemapping { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ISourceFileRemappingFactory.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ISourceFileRemappingFactory.java index be97fc25ef6..39ae7e6f2ce 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ISourceFileRemappingFactory.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ISourceFileRemappingFactory.java @@ -18,7 +18,7 @@ import org.eclipse.cdt.core.model.IBinary; /** * Factory that creates an ISourceFileRemapping instance for a particular binary * object - * + * * @since 7.0 */ public interface ISourceFileRemappingFactory { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ISourceFilesProvider.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ISourceFilesProvider.java index f05e32b3f09..ae31fdd33dd 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ISourceFilesProvider.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ISourceFilesProvider.java @@ -17,29 +17,29 @@ import org.eclipse.core.runtime.IProgressMonitor; /** * ISourceFileProvider supplies a list of source files used by a given Executable. - * + * * @author Ken Ryall * @since 6.0 - * + * */ public interface ISourceFilesProvider { - + public static final int LOW_PRIORITY = 25; public static final int NORMAL_PRIORITY = 50; public static final int HIGH_PRIORITY = 75; - + /** * Gets the priority to be used for this executable. * The priority is used by the Executables Manager when multiple ISourceFilesProviders are available. * ISourceFilesProvider.getSourceFiles will be called for each one in priority order and will use the * first one that returns a non empty result. - * + * * @param executable * @return the priority level to be used for this ISourceFilesProvider */ int getPriority(Executable executable); - + /** * Returns a list of source files used by an executable. * @param executable diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/StandardExecutableProvider.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/StandardExecutableProvider.java index 68dc6d348ba..19455417697 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/StandardExecutableProvider.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/StandardExecutableProvider.java @@ -44,12 +44,12 @@ import org.eclipse.debug.core.DebugPlugin; public class StandardExecutableProvider implements IProjectExecutablesProvider { List<String> supportedNatureIds = new ArrayList<String>(); - + public StandardExecutableProvider() { supportedNatureIds.add(CProjectNature.C_NATURE_ID); supportedNatureIds.add(CCProjectNature.CC_NATURE_ID); } - + @Override public List<String> getProjectNatures() { return supportedNatureIds; @@ -58,7 +58,7 @@ public class StandardExecutableProvider implements IProjectExecutablesProvider { @Override public List<Executable> getExecutables(IProject project, IProgressMonitor monitor) { List<Executable> executables = new ArrayList<Executable>(); - + ICProject cproject = CModelManager.getDefault().create(project); try { // Start out by getting all binaries in all build configurations. If @@ -68,18 +68,19 @@ public class StandardExecutableProvider implements IProjectExecutablesProvider { if (allBinaries.length == 0) { return executables; // save ourselves a lot of pointless busy work } - + // Get the output directories of the active build configuration then // go through the list of all binaries and pick only the ones that // are in these output directories List<IBinary> binaries = null; - ICProjectDescription projDesc = CProjectDescriptionManager.getInstance().getProjectDescription(project, false); + ICProjectDescription projDesc = CProjectDescriptionManager.getInstance().getProjectDescription(project, + false); if (projDesc != null) { ICConfigurationDescription cfg = projDesc.getActiveConfiguration(); if (cfg != null) { binaries = new ArrayList<IBinary>(allBinaries.length); ICOutputEntry[] cfgOutDirs = cfg.getBuildSetting().getOutputDirectories(); - for (IBinary allBinary : allBinaries) { + for (IBinary allBinary : allBinaries) { for (ICOutputEntry outdir : cfgOutDirs) { if (outdir.getFullPath().isPrefixOf(allBinary.getPath())) { binaries.add(allBinary); @@ -108,22 +109,24 @@ public class StandardExecutableProvider implements IProjectExecutablesProvider { if (exePath == null) exePath = binary.getPath(); List<ISourceFileRemapping> srcRemappers = new ArrayList<ISourceFileRemapping>(2); - ISourceFileRemappingFactory[] factories = ExecutablesManager.getExecutablesManager().getSourceFileRemappingFactories(); + ISourceFileRemappingFactory[] factories = ExecutablesManager.getExecutablesManager() + .getSourceFileRemappingFactories(); for (ISourceFileRemappingFactory factory : factories) { ISourceFileRemapping remapper = factory.createRemapper(binary); if (remapper != null) { srcRemappers.add(remapper); } } - executables.add(new Executable(exePath, project, binary.getResource(), srcRemappers.toArray(new ISourceFileRemapping[srcRemappers.size()]))); + executables.add(new Executable(exePath, project, binary.getResource(), + srcRemappers.toArray(new ISourceFileRemapping[srcRemappers.size()]))); } - + progress.worked(1); } } catch (CoreException e) { CDebugCorePlugin.log(e); } - + return executables; } @@ -134,10 +137,11 @@ public class StandardExecutableProvider implements IProjectExecutablesProvider { try { exeResource.delete(true, monitor); } catch (CoreException e) { - DebugPlugin.log( e ); + DebugPlugin.log(e); } return Status.OK_STATUS; } - return new Status(IStatus.WARNING, CDebugCorePlugin.PLUGIN_ID, "Can't remove " + executable.getName() + ": it is built by project \"" + executable.getProject().getName() + "\""); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$ + return new Status(IStatus.WARNING, CDebugCorePlugin.PLUGIN_ID, "Can't remove " + executable.getName() //$NON-NLS-1$ + + ": it is built by project \"" + executable.getProject().getName() + "\""); //$NON-NLS-1$//$NON-NLS-2$ } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildGenericLaunchConfigDelegate.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildGenericLaunchConfigDelegate.java index bc41cb2c6ce..0d58c3018ff 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildGenericLaunchConfigDelegate.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildGenericLaunchConfigDelegate.java @@ -31,7 +31,7 @@ import org.eclipse.debug.core.ILaunchConfiguration; /** * Delegate for Generic Launches over the Generic Launch Target. Can be * overriden to support launch customization for similar targets. - * + * * @since 8.3 */ public class CoreBuildGenericLaunchConfigDelegate extends CoreBuildLaunchConfigDelegate { @@ -55,7 +55,7 @@ public class CoreBuildGenericLaunchConfigDelegate extends CoreBuildLaunchConfigD } location = substLocation; } - + if (!new File(location).canExecute()) { throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID, String.format(Messages.CoreBuildGenericLaunchConfigDelegate_CommandNotValid, location))); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildGenericLaunchConfigProvider.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildGenericLaunchConfigProvider.java index 24439e69d5d..4f23d237552 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildGenericLaunchConfigProvider.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildGenericLaunchConfigProvider.java @@ -19,7 +19,7 @@ import org.eclipse.launchbar.core.target.ILaunchTargetManager; /** * Core launch configuration provider used by generic target types. - * + * * @since 8.3 */ public class CoreBuildGenericLaunchConfigProvider extends AbstractLaunchConfigProvider { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchBarTracker.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchBarTracker.java index bcd0e231060..99791dc2465 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchBarTracker.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchBarTracker.java @@ -42,7 +42,7 @@ import org.eclipse.launchbar.core.target.ILaunchTarget; /** * A launchbar listener that attempts to set the active core build configuration * on the project adapted from the launch descriptor. - * + * * @since 8.3 */ public class CoreBuildLaunchBarTracker implements ILaunchBarListener { @@ -70,7 +70,7 @@ public class CoreBuildLaunchBarTracker implements ILaunchBarListener { if (!projectName.isEmpty()) { project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); } - + if (project == null) { // Try the mapped resources IResource[] mappedResources = configuration.getMappedResources(); @@ -134,7 +134,7 @@ public class CoreBuildLaunchBarTracker implements ILaunchBarListener { desc.setActiveBuildConfig(buildConfig.getBuildConfiguration().getName()); finalProject.setDescription(desc, monitor); // notify the active build config that it is active - ((ICBuildConfiguration2)buildConfig).setActive(); + ((ICBuildConfiguration2) buildConfig).setActive(); } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchConfigDelegate.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchConfigDelegate.java index e9b5abbf80b..8c29617c243 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchConfigDelegate.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchConfigDelegate.java @@ -33,7 +33,7 @@ import org.eclipse.launchbar.core.target.launch.LaunchConfigurationTargetedDeleg /** * Common launch delegate code for core build launches. - * + * * @since 8.1 */ public abstract class CoreBuildLaunchConfigDelegate extends LaunchConfigurationTargetedDelegate { @@ -111,11 +111,12 @@ public abstract class CoreBuildLaunchConfigDelegate extends LaunchConfigurationT } } if (exeFile == null) { - throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID, InternalDebugCoreMessages.CoreBuildLaunchConfigDelegate_noBinaries)); + throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID, + InternalDebugCoreMessages.CoreBuildLaunchConfigDelegate_noBinaries)); } return exeFile; } - + @Override protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) throws CoreException { // 1. Extract project from configuration diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/GenericTargetTypeProvider.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/GenericTargetTypeProvider.java index 3807c9cffd5..9e1a29056db 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/GenericTargetTypeProvider.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/GenericTargetTypeProvider.java @@ -16,7 +16,7 @@ import org.eclipse.launchbar.core.target.ILaunchTargetProvider; import org.eclipse.launchbar.core.target.TargetStatus; /** - * + * * @since 8.3 */ public class GenericTargetTypeProvider implements ILaunchTargetProvider { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/NullProcess.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/NullProcess.java index 5421632bf8e..b4164db4e08 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/NullProcess.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/NullProcess.java @@ -22,7 +22,7 @@ import org.eclipse.debug.core.model.IStreamsProxy; /** * A simple process that only spits out a message then terminates. - * + * * @since 8.3 */ public class NullProcess extends PlatformObject implements IProcess { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/CDebugElementState.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/CDebugElementState.java index c1a28221d5e..01143359371 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/CDebugElementState.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/CDebugElementState.java @@ -17,29 +17,29 @@ package org.eclipse.cdt.debug.core.model; * The state of a debug element. */ public class CDebugElementState { - + private final String fName; - - private CDebugElementState( String name ) { + + private CDebugElementState(String name) { this.fName = name; } - + @Override public String toString() { return this.fName; } - public static final CDebugElementState UNDEFINED = new CDebugElementState( "undefined" ); //$NON-NLS-1$ - public static final CDebugElementState TERMINATING = new CDebugElementState( "terminating" ); //$NON-NLS-1$ - public static final CDebugElementState TERMINATED = new CDebugElementState( "terminated" ); //$NON-NLS-1$ - public static final CDebugElementState DISCONNECTING = new CDebugElementState( "disconnecting" ); //$NON-NLS-1$ - public static final CDebugElementState DISCONNECTED = new CDebugElementState( "disconnected" ); //$NON-NLS-1$ - public static final CDebugElementState RESUMING = new CDebugElementState( "resuming" ); //$NON-NLS-1$ - public static final CDebugElementState RESUMED = new CDebugElementState( "resumed" ); //$NON-NLS-1$ - public static final CDebugElementState STEPPING = new CDebugElementState( "stepping" ); //$NON-NLS-1$ - public static final CDebugElementState STEPPED = new CDebugElementState( "stepped" ); //$NON-NLS-1$ - public static final CDebugElementState SUSPENDING = new CDebugElementState( "suspending" ); //$NON-NLS-1$ - public static final CDebugElementState SUSPENDED = new CDebugElementState( "suspended" ); //$NON-NLS-1$ - public static final CDebugElementState RESTARTING = new CDebugElementState( "restarting" ); //$NON-NLS-1$ - public static final CDebugElementState EXITED = new CDebugElementState( "exited" ); //$NON-NLS-1$ + public static final CDebugElementState UNDEFINED = new CDebugElementState("undefined"); //$NON-NLS-1$ + public static final CDebugElementState TERMINATING = new CDebugElementState("terminating"); //$NON-NLS-1$ + public static final CDebugElementState TERMINATED = new CDebugElementState("terminated"); //$NON-NLS-1$ + public static final CDebugElementState DISCONNECTING = new CDebugElementState("disconnecting"); //$NON-NLS-1$ + public static final CDebugElementState DISCONNECTED = new CDebugElementState("disconnected"); //$NON-NLS-1$ + public static final CDebugElementState RESUMING = new CDebugElementState("resuming"); //$NON-NLS-1$ + public static final CDebugElementState RESUMED = new CDebugElementState("resumed"); //$NON-NLS-1$ + public static final CDebugElementState STEPPING = new CDebugElementState("stepping"); //$NON-NLS-1$ + public static final CDebugElementState STEPPED = new CDebugElementState("stepped"); //$NON-NLS-1$ + public static final CDebugElementState SUSPENDING = new CDebugElementState("suspending"); //$NON-NLS-1$ + public static final CDebugElementState SUSPENDED = new CDebugElementState("suspended"); //$NON-NLS-1$ + public static final CDebugElementState RESTARTING = new CDebugElementState("restarting"); //$NON-NLS-1$ + public static final CDebugElementState EXITED = new CDebugElementState("exited"); //$NON-NLS-1$ } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IAsmInstruction.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IAsmInstruction.java index c267761fca7..9bc70255b15 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IAsmInstruction.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IAsmInstruction.java @@ -22,43 +22,43 @@ public interface IAsmInstruction { /** * Returns the address of this instruction. - * + * * @return the address of this instruction */ IAddress getAdress(); - + /** - * Returns the function name of this instruction, + * Returns the function name of this instruction, * or empty string if function is not available. - * + * * @return the function name of this instruction */ String getFunctionName(); - + /** * Returns the instruction's text. - * + * * @return the instruction's text. */ String getInstructionText(); - + /** * Returns the opcode of this instruction. - * + * * @return the opcode of this instruction */ String getOpcode(); /** * Returns the arguments to the opcode. - * + * * @return the arguments to the opcode */ String getArguments(); /** * Returns the offset of this machine instruction. - * + * * @return the offset of this machine instruction */ long getOffset(); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IAsmSourceLine.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IAsmSourceLine.java index 5a0c7333418..41aed25198d 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IAsmSourceLine.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IAsmSourceLine.java @@ -20,14 +20,14 @@ public interface IAsmSourceLine { /** * Returns the array of the disassembly instructions associated with this source line. - * + * * @return the array of the disassembly instructions associated with this source line */ - IAsmInstruction[] getInstructions(); + IAsmInstruction[] getInstructions(); /** * Returns the number of this line in the source file - * + * * @return the line number */ int getLineNumber(); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICAddressBreakpoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICAddressBreakpoint.java index d83a68623f1..49537b061dd 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICAddressBreakpoint.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICAddressBreakpoint.java @@ -17,11 +17,11 @@ package org.eclipse.cdt.debug.core.model; * A breakpoint that suspend the execution when a particular address is reached. */ public interface ICAddressBreakpoint extends ICLineBreakpoint { - - /** - * Breakpoint marker type for this breakpoint type. - * @since 7.2 - */ - public static final String C_ADDRESS_BREAKPOINT_MARKER = "org.eclipse.cdt.debug.core.cAddressBreakpointMarker"; //$NON-NLS-1$ + + /** + * Breakpoint marker type for this breakpoint type. + * @since 7.2 + */ + public static final String C_ADDRESS_BREAKPOINT_MARKER = "org.eclipse.cdt.debug.core.cAddressBreakpointMarker"; //$NON-NLS-1$ } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICBreakpoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICBreakpoint.java index 568ca59cd75..9735b502cec 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICBreakpoint.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICBreakpoint.java @@ -29,28 +29,28 @@ import org.eclipse.debug.core.model.IBreakpoint; */ public interface ICBreakpoint extends IBreakpoint { - /** - * Breakpoint marker type for this breakpoint type. - * @since 7.2 - */ - public static final String C_BREAKPOINT_MARKER = "org.eclipse.cdt.debug.core.cBreakpointMarker"; //$NON-NLS-1$ - - /** - * This debug model identifier can be returned by a debug implementation - * to indicate that a given debugger integration is using C Breakpoints. - * This model ID will allow toggle breakpoint actions to configure their - * default selection. - * - * @since 7.0 - */ - public static final String C_BREAKPOINTS_DEBUG_MODEL_ID = CDIDebugModel.getPluginIdentifier() + ".cbreakpoints"; //$NON-NLS-1$ - + /** + * Breakpoint marker type for this breakpoint type. + * @since 7.2 + */ + public static final String C_BREAKPOINT_MARKER = "org.eclipse.cdt.debug.core.cBreakpointMarker"; //$NON-NLS-1$ + + /** + * This debug model identifier can be returned by a debug implementation + * to indicate that a given debugger integration is using C Breakpoints. + * This model ID will allow toggle breakpoint actions to configure their + * default selection. + * + * @since 7.0 + */ + public static final String C_BREAKPOINTS_DEBUG_MODEL_ID = CDIDebugModel.getPluginIdentifier() + ".cbreakpoints"; //$NON-NLS-1$ + /** * Breakpoint attribute storing the number of debug targets a breakpoint is * installed in (value * <code>"org.eclipse.cdt.debug.core.installCount"</code>). This * attribute is an <code>int</code>. - * + * * Note: this attribute is used only for notifying listeners * (IBreakpointListener) of a change in the install count. The attribute is * not used by the CDT breakpoint object to manage the install count, since @@ -61,49 +61,49 @@ public interface ICBreakpoint extends IBreakpoint { * time, there are no installed breakpoints). At that time, the attribute * means absolutely nothing. */ - public static final String INSTALL_COUNT = "org.eclipse.cdt.debug.core.installCount"; //$NON-NLS-1$ + public static final String INSTALL_COUNT = "org.eclipse.cdt.debug.core.installCount"; //$NON-NLS-1$ /** * Breakpoint attribute storing the conditional expression associated with - * this breakpoint (value <code>"org.eclipse.cdt.debug.core.condition"</code>). + * this breakpoint (value <code>"org.eclipse.cdt.debug.core.condition"</code>). * This attribute is a <code>String</code>. */ - public static final String CONDITION = "org.eclipse.cdt.debug.core.condition"; //$NON-NLS-1$ + public static final String CONDITION = "org.eclipse.cdt.debug.core.condition"; //$NON-NLS-1$ /** * Breakpoint attribute storing a breakpoint's ignore count value (value * <code>"org.eclipse.cdt.debug.core.ignoreCount"</code>). This attribute * is an <code>int</code>. */ - public static final String IGNORE_COUNT = "org.eclipse.cdt.debug.core.ignoreCount"; //$NON-NLS-1$ + public static final String IGNORE_COUNT = "org.eclipse.cdt.debug.core.ignoreCount"; //$NON-NLS-1$ /** * Breakpoint attribute storing an identifier of the thread this breakpoint - * is restricted in (value <code>"org.eclipse.cdt.debug.core.threadId"</code>). + * is restricted in (value <code>"org.eclipse.cdt.debug.core.threadId"</code>). * This attribute is a <code>String</code>. */ - public static final String THREAD_ID = "org.eclipse.cdt.debug.core.threadId"; //$NON-NLS-1$ + public static final String THREAD_ID = "org.eclipse.cdt.debug.core.threadId"; //$NON-NLS-1$ /** * Breakpoint attribute storing the source handle of the file this breakpoint - * is set in (value <code>"org.eclipse.cdt.debug.core.sourceHandle"</code>). + * is set in (value <code>"org.eclipse.cdt.debug.core.sourceHandle"</code>). * This attribute is a <code>String</code>. */ - public static final String SOURCE_HANDLE = "org.eclipse.cdt.debug.core.sourceHandle"; //$NON-NLS-1$ + public static final String SOURCE_HANDLE = "org.eclipse.cdt.debug.core.sourceHandle"; //$NON-NLS-1$ /** * Breakpoint attribute storing the module name this breakpoint - * is set in (value <code>"org.eclipse.cdt.debug.core.module"</code>). + * is set in (value <code>"org.eclipse.cdt.debug.core.module"</code>). * This attribute is a <code>String</code>. - * + * * @since 3.0 */ - public static final String MODULE = "org.eclipse.cdt.debug.core.module"; //$NON-NLS-1$ + public static final String MODULE = "org.eclipse.cdt.debug.core.module"; //$NON-NLS-1$ /** * Returns whether this breakpoint is installed in at least one debug * target. - * + * * @return whether this breakpoint is installed * @exception CoreException if unable to access the property on this breakpoint's * underlying marker @@ -112,7 +112,7 @@ public interface ICBreakpoint extends IBreakpoint { /** * Returns whether this breakpoint is conditional. - * + * * @return whether this breakpoint is conditional * @exception CoreException if unable to access the property on this breakpoint's * underlying marker @@ -121,7 +121,7 @@ public interface ICBreakpoint extends IBreakpoint { /** * Returns the conditional expression associated with this breakpoint. - * + * * @return this breakpoint's conditional expression * @exception CoreException if unable to access the property on this breakpoint's * underlying marker @@ -130,16 +130,16 @@ public interface ICBreakpoint extends IBreakpoint { /** * Sets the condition associated with this breakpoint. - * + * * @param condition the conditional expression * @exception CoreException if unable to access the property on this breakpoint's * underlying marker */ - public void setCondition( String condition ) throws CoreException; + public void setCondition(String condition) throws CoreException; /** * Returns the ignore count used by this breakpoint. - * + * * @return the ignore count used by this breakpoint * @exception CoreException if unable to access the property on this breakpoint's * underlying marker @@ -148,16 +148,16 @@ public interface ICBreakpoint extends IBreakpoint { /** * Sets the ignore count attribute for this breakpoint. - * + * * @param ignoreCount the new ignore count * @exception CoreException if unable to access the property on this breakpoint's * underlying marker */ - public void setIgnoreCount( int ignoreCount ) throws CoreException; + public void setIgnoreCount(int ignoreCount) throws CoreException; /** * Returns the identifier of the thread this breakpoint is restricted in. - * + * * @return the thread identifier * @exception CoreException if unable to access the property on this breakpoint's * underlying marker @@ -167,16 +167,16 @@ public interface ICBreakpoint extends IBreakpoint { /** * Restricts this breakpoint to suspend only in the given thread when * encounterd in the given thread's target. - * + * * @param threadId the thread identifier * @exception CoreException if unable to access the property on this breakpoint's * underlying marker */ - public void setThreadId( String threadId ) throws CoreException; + public void setThreadId(String threadId) throws CoreException; /** * Returns the module name this breakpoint is set in. - * + * * @return the module name * @exception CoreException if unable to access the property on this breakpoint's * underlying marker @@ -185,16 +185,16 @@ public interface ICBreakpoint extends IBreakpoint { /** * Sets the module name of this breakpoint. - * + * * @param module the module name * @exception CoreException if unable to access the property on this breakpoint's * underlying marker */ - public void setModule( String module ) throws CoreException; + public void setModule(String module) throws CoreException; /** * Returns the source handle this breakpoint is set in. - * + * * @return the source handle * @exception CoreException if unable to access the property on this breakpoint's * underlying marker @@ -203,47 +203,48 @@ public interface ICBreakpoint extends IBreakpoint { /** * Sets the source handle of this breakpoint. - * + * * @param sourceHandle the source handle * @exception CoreException if unable to access the property on this breakpoint's * underlying marker */ - public void setSourceHandle( String sourceHandle ) throws CoreException; + public void setSourceHandle(String sourceHandle) throws CoreException; /** * Increments the install count of this breakpoint - * + * * @return the new install count value - * @throws CoreException if unable to access the property + * @throws CoreException if unable to access the property * on this breakpoint's underlying marker */ public int incrementInstallCount() throws CoreException; /** * Decrements the install count of this breakpoint. - * + * * @return the new install caount value - * @throws CoreException if unable to access the property + * @throws CoreException if unable to access the property * on this breakpoint's underlying marker */ public int decrementInstallCount() throws CoreException; /** * Resets the install count of this breakpoint - * - * @throws CoreException if unable to access the property + * + * @throws CoreException if unable to access the property * on this breakpoint's underlying marker */ public void resetInstallCount() throws CoreException; /** - * Returns a breakpoint extension registered for the given debug model - * and of the given type. - * + * Returns a breakpoint extension registered for the given debug model + * and of the given type. + * * @param debugModelId Debug model ID of the extension. * @param extensionType Type of the extension. * @return Extension instance. * @throws CoreException Throws exception in case the extension doesn't exist or cannot be initialized. */ - public <V extends ICBreakpointExtension> V getExtension(String debugModelId, Class<V> extensionType) throws CoreException; + public <V extends ICBreakpointExtension> V getExtension(String debugModelId, Class<V> extensionType) + throws CoreException; } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICBreakpoint2.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICBreakpoint2.java index bfa374617f7..c1c1db75ae4 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICBreakpoint2.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICBreakpoint2.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 *******************************************************************************/ @@ -17,38 +17,38 @@ import org.eclipse.core.runtime.CoreException; /** * Extension that allows client to force breakpoint message to refresh. - * + * * @since 7.2 * @noimplement This interface is not intended to be implemented by clients. * @noextend This interface is not intended to be extended by clients. */ public interface ICBreakpoint2 extends ICBreakpoint { - /** - * Refresh the marker message for the breakpoint. - * <p> - * Many of breakpoint settings are backed by marker attributes and it is - * sometimes more convenient to modify those attributes in the marker - * directly rather than through accessor methods of the breakpoint. This - * method allows the client to force the breakpoint to refresh its - * {@link org.eclipse.core.resources.IMarker#MESSAGE} attribute to reflect - * its current attribute values. - * </p> - * - * @throws CoreException if unable to access the property - * on this breakpoint's underlying marker - */ - public void refreshMessage() throws CoreException; + /** + * Refresh the marker message for the breakpoint. + * <p> + * Many of breakpoint settings are backed by marker attributes and it is + * sometimes more convenient to modify those attributes in the marker + * directly rather than through accessor methods of the breakpoint. This + * method allows the client to force the breakpoint to refresh its + * {@link org.eclipse.core.resources.IMarker#MESSAGE} attribute to reflect + * its current attribute values. + * </p> + * + * @throws CoreException if unable to access the property + * on this breakpoint's underlying marker + */ + public void refreshMessage() throws CoreException; - /** - * Returns the marker type of the given CDT Breakpoint. - * @return marker type ID - */ - public String getMarkerType(); + /** + * Returns the marker type of the given CDT Breakpoint. + * @return marker type ID + */ + public String getMarkerType(); /** * Obtain the combined message from all installed extensions on the * breakpoint. See {@link ICBreakpointExtension#getExtensionMessage} - * + * * @return extension message, or empty-string ({@code ""}) for no message * @since 8.2 */ diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICBreakpointExtension.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICBreakpointExtension.java index 5276d2cfff3..0f26369e81f 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICBreakpointExtension.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICBreakpointExtension.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 *******************************************************************************/ @@ -16,38 +16,38 @@ package org.eclipse.cdt.debug.core.model; import org.eclipse.core.runtime.CoreException; /** - * An extension to {@link ICBreakpoint} with model-specific breakpoint - * attributes. Different debug models can use the standard C breakpoints that - * extend the basic <code>ICBreakpiont</code>. The can use this extension - * mechanism to edit and store model-specific data in the original breakpoint + * An extension to {@link ICBreakpoint} with model-specific breakpoint + * attributes. Different debug models can use the standard C breakpoints that + * extend the basic <code>ICBreakpiont</code>. The can use this extension + * mechanism to edit and store model-specific data in the original breakpoint * object. - * - * A breakpoint extension is defined by an extension of kind + * + * A breakpoint extension is defined by an extension of kind * <code>"org.eclipse.cdt.debug.core.BreakpointExtension"</code></li>. - * The <code>ICBreakpoint</code> implementation instantiates breakpoint + * The <code>ICBreakpoint</code> implementation instantiates breakpoint * extensions registered for its specific marker type when a client requests - * extensions for a given debug model type. Thus the extension classes and - * plugins that declare them are not loaded unless requested by a client. - * + * extensions for a given debug model type. Thus the extension classes and + * plugins that declare them are not loaded unless requested by a client. + * * @see ICBreakpoint#getExtension(String, Class) */ public interface ICBreakpointExtension { - - /** - * Initializes the extension with the given breakpoint instance. - * The breakpoint extension may initialize its data using attributes - * stored in the breakpoint marker. - * - * @param breakpoint Breakpoint instance that this extension belongs to. - * @throws CoreException Thrown in case of errors reading the breakpoint - * marker. - */ - public void initialize(ICBreakpoint breakpoint) throws CoreException; + + /** + * Initializes the extension with the given breakpoint instance. + * The breakpoint extension may initialize its data using attributes + * stored in the breakpoint marker. + * + * @param breakpoint Breakpoint instance that this extension belongs to. + * @throws CoreException Thrown in case of errors reading the breakpoint + * marker. + */ + public void initialize(ICBreakpoint breakpoint) throws CoreException; /** * Return the message associated with this breakpoint extension. This * message will form part of the marker's message in the Eclipse UI. - * + * * @return custom message, or empty-string ({@code ""}) for no message * @since 8.2 */ diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICBreakpointType.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICBreakpointType.java index 90e6c71209b..ac94799d1c6 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICBreakpointType.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICBreakpointType.java @@ -19,10 +19,10 @@ import org.eclipse.core.runtime.CoreException; public interface ICBreakpointType { /** * Breakpoint attribute storing the type of the breakpoint - * This attribute is a <code>int</code>. Strictly speaking, - * types are even values, but the least-significant bit - * is used to qualify it as temporary. See {@link #TEMPORARY} - * + * This attribute is a <code>int</code>. Strictly speaking, + * types are even values, but the least-significant bit + * is used to qualify it as temporary. See {@link #TEMPORARY} + * * @since 5.0 */ public static final String TYPE = "org.eclipse.cdt.debug.core.breakpointType"; //$NON-NLS-1$ @@ -41,13 +41,13 @@ public interface ICBreakpointType { * installation mechanism (hardware vs software) is up to the discretion of * the debugger backend A common backend approach is to try one way first * and then the other if the first attempt fails. - * + * * <p> * In the future, we will expose a preference that lets the user dictate his * preference to the backend. That is, the user will be able to say "I want * the backend to install regular breakpoints using hardware breakpoint * capabilities on the target." - * + * * <p> * It's important to realize that how a backend ends up installing the * breakpoint does not alter the type of the breakpoint in the Eclipse/CDT @@ -56,12 +56,12 @@ public interface ICBreakpointType { * hardware). */ final static public int REGULAR = 0x0 << 1; - + /** * A HARDWARE breakpoint is a line, function or address breakpoint that the * user wants installed using a hardware breakpoint facility on the target. * If it cannot be installed that way, it should not be installed at all. - * + * * For example, the hardware may have a breakpoint register where an address * can be set. The target will halt itself when the PC matches that register * value. Hardware breakpoints have several advantages. They're @@ -78,12 +78,12 @@ public interface ICBreakpointType { * user wants installed by swapping out instructions in the target code * memory with an opcode that causes the target to halt. If it cannot be * installed that way, it should not be installed at all. - * + * * The only advantage to software breakpoints is that there is no limit to * how many can be set. The disadvantages are that they are intrusive and * thus more difficult to install/uninstall/manage and, of course, they * can't be set in ROM code. - * + * */ final static public int SOFTWARE = 0x2 << 1; @@ -91,30 +91,30 @@ public interface ICBreakpointType { // ALL FUTURE ADDITIONS MUST HAVE EVEN VALUES. The lease-significant // bit is reserved. // ------------------------------------------------------------------------ - + /** * Returns the type of this breakpoint - * + * * @return type of breakpoint. Defaults to REGULAR if property does not * exists in the underlying marker. * @exception CoreException * if unable to access the property on this breakpoint's * underlying marker - * + * * @since 5.0 */ public int getType() throws CoreException; - + /** * Sets the type of this breakpoint. - * + * * @param type * breakpoint type * @exception CoreException * if unable to access the property on this breakpoint's * underlying marker - * + * * @since 5.0 */ - public void setType( int type ) throws CoreException; + public void setType(int type) throws CoreException; } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICDebugElement.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICDebugElement.java index bdb1fb07860..c53f7039257 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICDebugElement.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICDebugElement.java @@ -22,15 +22,14 @@ public interface ICDebugElement extends IDebugElement { /** * Returns the current state of this element. - * + * * @return the current state */ public CDebugElementState getState(); - /** * Returns the info object associated with the current state. - * + * * @return the info object associated with the current state */ public Object getCurrentStateInfo(); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICDebugElementStatus.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICDebugElementStatus.java index 61dc6d0bc24..652b879f3e3 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICDebugElementStatus.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICDebugElementStatus.java @@ -19,25 +19,25 @@ package org.eclipse.cdt.debug.core.model; public interface ICDebugElementStatus { /** - * Status severity constant (value 0) indicating this status represents + * Status severity constant (value 0) indicating this status represents * the nominal case. */ public static final int OK = 0; /** - * Status severity constant (value 1) indicating indicating this status + * Status severity constant (value 1) indicating indicating this status * represents a warning. */ public static final int WARNING = 1; /** - * Status severity constant (value 2) indicating indicating this status + * Status severity constant (value 2) indicating indicating this status * represents an error. */ public static final int ERROR = 2; /** - * Returns whether this status indicates everything is okay + * Returns whether this status indicates everything is okay * (neither warning, nor error). * * @return <code>true</code> if this status has severity @@ -53,7 +53,7 @@ public interface ICDebugElementStatus { * <li><code>OK</code> - everything is just fine</li> * </ul> * - * @return the severity: one of <code>OK</code>, <code>ERROR</code>, + * @return the severity: one of <code>OK</code>, <code>ERROR</code>, * or <code>WARNING</code> */ int getSeverity(); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICDynamicPrintf.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICDynamicPrintf.java index 151bcb334a9..d7d439b3bf5 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICDynamicPrintf.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICDynamicPrintf.java @@ -17,40 +17,40 @@ import org.eclipse.core.runtime.CoreException; /** * A dynamic printf specific to the C/C++ debug model. - * + * * @since 7.5 */ public interface ICDynamicPrintf extends ICLineBreakpoint { - /** - * Breakpoint marker type for this breakpoint type. - */ - public static final String C_DYNAMICPRINTF_MARKER = "org.eclipse.cdt.debug.core.cDynamicPrintfMarker"; //$NON-NLS-1$ + /** + * Breakpoint marker type for this breakpoint type. + */ + public static final String C_DYNAMICPRINTF_MARKER = "org.eclipse.cdt.debug.core.cDynamicPrintfMarker"; //$NON-NLS-1$ - /** - * Breakpoint marker type for this breakpoint type. - */ - public static final String C_LINE_DYNAMICPRINTF_MARKER = "org.eclipse.cdt.debug.core.cLineDynamicPrintfMarker"; //$NON-NLS-1$ - - /** - * Breakpoint marker type for this breakpoint type. - */ - public static final String C_ADDRESS_DYNAMICPRINTF_MARKER = "org.eclipse.cdt.debug.core.cAddressDynamicPrintfMarker"; //$NON-NLS-1$ + /** + * Breakpoint marker type for this breakpoint type. + */ + public static final String C_LINE_DYNAMICPRINTF_MARKER = "org.eclipse.cdt.debug.core.cLineDynamicPrintfMarker"; //$NON-NLS-1$ - /** - * Breakpoint marker type for this breakpoint type. - */ - public static final String C_FUNCTION_DYNAMICPRINTF_MARKER = "org.eclipse.cdt.debug.core.cFunctionDynamicPrintfMarker"; //$NON-NLS-1$ + /** + * Breakpoint marker type for this breakpoint type. + */ + public static final String C_ADDRESS_DYNAMICPRINTF_MARKER = "org.eclipse.cdt.debug.core.cAddressDynamicPrintfMarker"; //$NON-NLS-1$ - /** + /** + * Breakpoint marker type for this breakpoint type. + */ + public static final String C_FUNCTION_DYNAMICPRINTF_MARKER = "org.eclipse.cdt.debug.core.cFunctionDynamicPrintfMarker"; //$NON-NLS-1$ + + /** * Dynamic printf attribute storing the string to be printed (value * <code>"org.eclipse.cdt.debug.core.printf_string"</code>). This attribute * is a <code>String</code>. */ - public static final String PRINTF_STRING = "org.eclipse.cdt.debug.core.printf_string"; //$NON-NLS-1$ + public static final String PRINTF_STRING = "org.eclipse.cdt.debug.core.printf_string"; //$NON-NLS-1$ /** * Returns the string used by this dynamic printf. - * + * * @return the string used by this dynamic printf * @exception CoreException if unable to access the property on this dynamic printf's * underlying marker @@ -59,7 +59,7 @@ public interface ICDynamicPrintf extends ICLineBreakpoint { /** * Sets the string attribute for this dynamic printf - * + * * @param message The new string * @exception CoreException if unable to access the property on this dynamic printf's * underlying marker diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICEventBreakpoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICEventBreakpoint.java index 7a508b0d101..8f08ab614b5 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICEventBreakpoint.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICEventBreakpoint.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 @@ -20,27 +20,27 @@ import org.eclipse.core.runtime.CoreException; /** * Interface for debugger event breakpoints. Example of event breakpoint * is break on raising exception in C++, or break on receiving signal. - * + * * @sinse 5.0 * @since 7.0 */ public interface ICEventBreakpoint extends ICBreakpoint { - /** - * Breakpoint marker type for this breakpoint type. - * @since 7.2 - */ - public static final String C_EVENT_BREAKPOINT_MARKER = "org.eclipse.cdt.debug.core.cEventBreakpointMarker"; //$NON-NLS-1$; - + /** + * Breakpoint marker type for this breakpoint type. + * @since 7.2 + */ + public static final String C_EVENT_BREAKPOINT_MARKER = "org.eclipse.cdt.debug.core.cEventBreakpointMarker"; //$NON-NLS-1$; + /** * Breakpoint attribute storing the event breakpoint event id. Basically, * this indicates what type of event the breakpoint catches--e.g., a C++ * exception throw, a library load, a thread exit, etc. Event types are * contributed via the "breakpointContribution" extension point. - * + * * <p> * This attribute is a <code>String</code>. - * + * */ public static final String EVENT_TYPE_ID = "org.eclipse.cdt.debug.core.eventbreakpoint_event_id"; //$NON-NLS-1$ @@ -50,12 +50,12 @@ public interface ICEventBreakpoint extends ICBreakpoint { * representation of another type (it may be a number, for example). * Currently, an event type can have only one argument */ - public static final String EVENT_ARG = "org.eclipse.cdt.debug.core.eventbreakpoint_event_arg"; //$NON-NLS-1$ + public static final String EVENT_ARG = "org.eclipse.cdt.debug.core.eventbreakpoint_event_arg"; //$NON-NLS-1$ /** * Get the event breakpoint type. Same as querying the property * {@link #EVENT_TYPE_ID} - * + * * @return event breakpoint type id (not null) * @throws CoreException */ @@ -65,7 +65,7 @@ public interface ICEventBreakpoint extends ICBreakpoint { * Get the event argument, if the type has one. Currently, an event type can * have at most one argument. Same as querying the property * {@link #EVENT_ARG} - * + * * @return event argument, or null if not applicable * @throws CoreException */ diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICFunctionBreakpoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICFunctionBreakpoint.java index 0e3542d8989..7b2e3c4cb78 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICFunctionBreakpoint.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICFunctionBreakpoint.java @@ -13,15 +13,14 @@ *******************************************************************************/ package org.eclipse.cdt.debug.core.model; - /** * A breakpoint that suspends the execution when a function is entered. */ public interface ICFunctionBreakpoint extends ICLineBreakpoint { - /** - * Breakpoint marker type for this breakpoint type. - * @since 7.2 - */ - public static final String C_FUNCTION_BREAKPOINT_MARKER = "org.eclipse.cdt.debug.core.cFunctionBreakpointMarker"; //$NON-NLS-1$ + /** + * Breakpoint marker type for this breakpoint type. + * @since 7.2 + */ + public static final String C_FUNCTION_BREAKPOINT_MARKER = "org.eclipse.cdt.debug.core.cFunctionBreakpointMarker"; //$NON-NLS-1$ } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICLineBreakpoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICLineBreakpoint.java index 78215bc7bf6..ef75403243b 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICLineBreakpoint.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICLineBreakpoint.java @@ -22,29 +22,29 @@ import org.eclipse.debug.core.model.ILineBreakpoint; */ public interface ICLineBreakpoint extends ICBreakpoint, ILineBreakpoint { - /** - * Breakpoint marker type for this breakpoint type. - * @since 7.2 - */ - public static final String C_LINE_BREAKPOINT_MARKER = "org.eclipse.cdt.debug.core.cLineBreakpointMarker"; //$NON-NLS-1$ - + /** + * Breakpoint marker type for this breakpoint type. + * @since 7.2 + */ + public static final String C_LINE_BREAKPOINT_MARKER = "org.eclipse.cdt.debug.core.cLineBreakpointMarker"; //$NON-NLS-1$ + /** * Breakpoint attribute storing the function this breakpoint suspends * execution at (value <code>"org.eclipse.cdt.debug.core.function"</code>). * This attribute is a <code>String</code>. */ - public static final String FUNCTION = "org.eclipse.cdt.debug.core.function"; //$NON-NLS-1$ + public static final String FUNCTION = "org.eclipse.cdt.debug.core.function"; //$NON-NLS-1$ /** * Breakpoint attribute storing the address this breakpoint suspends * execution at (value <code>"org.eclipse.cdt.debug.core.address"</code>). * This attribute is a <code>String</code>. */ - public static final String ADDRESS = "org.eclipse.cdt.debug.core.address"; //$NON-NLS-1$ + public static final String ADDRESS = "org.eclipse.cdt.debug.core.address"; //$NON-NLS-1$ /** * Returns the address this breakpoint suspends execution at. - * + * * @return the address this breakpoint suspends execution at * @exception CoreException if unable to access the property on this breakpoint's * underlying marker @@ -53,16 +53,16 @@ public interface ICLineBreakpoint extends ICBreakpoint, ILineBreakpoint { /** * Sets the address this breakpoint suspends execution at. - * + * * @param address the address this breakpoint suspends execution at * @exception CoreException if unable to access the property on this breakpoint's * underlying marker */ - public void setAddress( String address ) throws CoreException; + public void setAddress(String address) throws CoreException; /** * Returns the function this breakpoint suspends execution in. - * + * * @return the function this breakpoint suspends execution in * @exception CoreException if unable to access the property on this breakpoint's * underlying marker @@ -71,16 +71,16 @@ public interface ICLineBreakpoint extends ICBreakpoint, ILineBreakpoint { /** * Sets the function this breakpoint suspends execution in. - * + * * @param function the function this breakpoint suspends execution in * @exception CoreException if unable to access the property on this breakpoint's * underlying marker */ - public void setFunction( String function ) throws CoreException; + public void setFunction(String function) throws CoreException; /** * Returns the source file (if available) of this breakpoint. - * + * * @return the source file of this breakpoint * @throws CoreException if unable to access the property on this breakpoint's * underlying marker diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICLineBreakpoint2.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICLineBreakpoint2.java index 0d1d7c09c36..69519d8c432 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICLineBreakpoint2.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICLineBreakpoint2.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 *******************************************************************************/ @@ -17,177 +17,176 @@ import org.eclipse.core.resources.IMarker; import org.eclipse.core.runtime.CoreException; /** - * Line breakpoint extension that allows a breakpoint to be relocated by a - * debugger to a valid source line. - * <p>Clients which can determine a valid source based on debuggers symbol - * information should call the various <code>setInstalled...</code> methods with - * the corrected location attributes. Note, there is no <code>setInstalledSourceHandle</code>, + * Line breakpoint extension that allows a breakpoint to be relocated by a + * debugger to a valid source line. + * <p>Clients which can determine a valid source based on debuggers symbol + * information should call the various <code>setInstalled...</code> methods with + * the corrected location attributes. Note, there is no <code>setInstalledSourceHandle</code>, * clients should call {@link ICBreakpoint#setSourceHandle(String)}. If multiple - * clients try to change the installed breakpoint location, the last call will - * take precedence. This way debuggers may update the location upon active debug + * clients try to change the installed breakpoint location, the last call will + * take precedence. This way debuggers may update the location upon active debug * context change. <br/> - * The original breakpoint location as configured by the user can always be + * The original breakpoint location as configured by the user can always be * retrieved using the <code>getRequested...</code> methods. - * </p> + * </p> * @since 7.2 * @noimplement This interface is not intended to be implemented by clients. * @noextend This interface is not intended to be extended by clients. */ public interface ICLineBreakpoint2 extends ICLineBreakpoint, ICBreakpoint2 { - /** - * Breakpoint attribute storing the original requested line for this breakpoint - * This attribute is a <code>int</code>. - */ - public static final String REQUESTED_LINE = "requestedLine"; //$NON-NLS-1$ - - /** - * Breakpoint attribute storing the original requested column for this breakpoint - * This attribute is a <code>int</code>. - */ - public static final String REQUESTED_CHAR_START = "requestedCharStart"; //$NON-NLS-1$ - - /** - * Breakpoint attribute storing the original requested column for this breakpoint - * This attribute is a <code>int</code>. - */ - public static final String REQUESTED_CHAR_END = "requestedCharEnd"; //$NON-NLS-1$ - - /** - * Breakpoint attribute storing the original requested file name this breakpoint - * is set in. - * This attribute is a <code>String</code>. - */ - public static final String REQUESTED_SOURCE_HANDLE = "requestedSourceHandle"; //$NON-NLS-1$ - - /** - * Breakpoint attribute which is set if the installed line number of a - * breakpoint is changed. - * - * Triggers an update of the installed location, if set. - * - * This attribute is a <code>Boolean</code>. - * - * @since 8.0 - */ - public static final String RESET_INSTALLED_LOCATION = "resetInstalledLocation"; //$NON-NLS-1$ - - /** - * Returns the line number where the breakpoint was set before it was relocated to a - * valid source line. - * - * @return Returns the requested line number attribute. - * @exception CoreException if unable to access the property on this breakpoint's - * underlying marker - */ - public int getRequestedLine() throws CoreException; - - /** - * Sets the line number where the breakpoint should be set. - * - * @param The requested line number attribute. - * @exception CoreException if unable to access the property on this breakpoint's - * underlying marker - */ - public void setRequestedLine(int line) throws CoreException; - - /** - * Returns starting source index where the breakpoint was set before it - * was moved to a valid source location. - * - * @return Returns the requested start index attribute. - * @exception CoreException if unable to access the property on this breakpoint's - * underlying marker - */ - public int getRequestedCharStart() throws CoreException; - - - /** - * Sets the starting source index where the breakpoint should be set. - * - * @param The requested start index attribute. - * @exception CoreException if unable to access the property on this breakpoint's - * underlying marker - */ - public void setRequestedCharStart(int charStart) throws CoreException; - - /** - * Returns ending source index where the breakpoint was set before it - * was moved to a valid source location. - * - * @return Returns the requested end index attribute. - * @exception CoreException if unable to access the property on this breakpoint's - * underlying marker - */ - public int getRequestedCharEnd() throws CoreException; - - /** - * Sets the staring source index where the breakpoint should be set. - * - * @param The requested end index attribute. - * @exception CoreException if unable to access the property on this breakpoint's - * underlying marker - */ - public void setRequestedCharEnd(int charEnd) throws CoreException; - - /** - * Returns the file name where the breakpoint was set before it was relocated to a - * valid file. - * - * @return Returns the requested file name. - * @exception CoreException if unable to access the property on this breakpoint's - * underlying marker - */ - public String getRequestedSourceHandle() throws CoreException; - - /** - * Sets the file name where the breakpoint should be set. May be an empty string - * if the file is not known. - * - * @param Requested file name. - * @exception CoreException if unable to access the property on this breakpoint's - * underlying marker - */ - public void setRequestedSourceHandle(String fileName) throws CoreException; - - /** - * Sets the line number where the breakpoint is actually installed. This - * method only updates the {@link IMarker#LINE_NUMBER} attribute and the - * breakpoint message. - * - * @param line Installed line number - * @throws CoreException if unable to access the property - * on this breakpoint's underlying marker - */ - public void setInstalledLineNumber(int line) throws CoreException; - - /** - * Sets the start index where the breakpoint is actually installed. This method - * only updates the {@link IMarker#CHAR_START} attribute and the breakpoint - * message. - * - * @param charStart Installed char start - * @throws CoreException - */ - public void setInstalledCharStart(int charStart) throws CoreException; - - /** - * Sets the end index where the breakpoint is actually installed. This method - * only updates the {@link IMarker#CHAR_END} attribute and the breakpoint - * message. - * - * @param charEnd Installed char start - * @throws CoreException - */ - public void setInstalledCharEnd(int charStart) throws CoreException; - - /** - * Resets the breakpoint location back to the values specified by the - * REQUESTED_* attributes. This operation should be called automatically - * by the implementation when the install count is reset to 0, and does - * not need to be called by the client at that time. - * - * @throws CoreException - */ - public void resetInstalledLocation() throws CoreException; + /** + * Breakpoint attribute storing the original requested line for this breakpoint + * This attribute is a <code>int</code>. + */ + public static final String REQUESTED_LINE = "requestedLine"; //$NON-NLS-1$ + + /** + * Breakpoint attribute storing the original requested column for this breakpoint + * This attribute is a <code>int</code>. + */ + public static final String REQUESTED_CHAR_START = "requestedCharStart"; //$NON-NLS-1$ + + /** + * Breakpoint attribute storing the original requested column for this breakpoint + * This attribute is a <code>int</code>. + */ + public static final String REQUESTED_CHAR_END = "requestedCharEnd"; //$NON-NLS-1$ + + /** + * Breakpoint attribute storing the original requested file name this breakpoint + * is set in. + * This attribute is a <code>String</code>. + */ + public static final String REQUESTED_SOURCE_HANDLE = "requestedSourceHandle"; //$NON-NLS-1$ + + /** + * Breakpoint attribute which is set if the installed line number of a + * breakpoint is changed. + * + * Triggers an update of the installed location, if set. + * + * This attribute is a <code>Boolean</code>. + * + * @since 8.0 + */ + public static final String RESET_INSTALLED_LOCATION = "resetInstalledLocation"; //$NON-NLS-1$ + + /** + * Returns the line number where the breakpoint was set before it was relocated to a + * valid source line. + * + * @return Returns the requested line number attribute. + * @exception CoreException if unable to access the property on this breakpoint's + * underlying marker + */ + public int getRequestedLine() throws CoreException; + + /** + * Sets the line number where the breakpoint should be set. + * + * @param The requested line number attribute. + * @exception CoreException if unable to access the property on this breakpoint's + * underlying marker + */ + public void setRequestedLine(int line) throws CoreException; + + /** + * Returns starting source index where the breakpoint was set before it + * was moved to a valid source location. + * + * @return Returns the requested start index attribute. + * @exception CoreException if unable to access the property on this breakpoint's + * underlying marker + */ + public int getRequestedCharStart() throws CoreException; + + /** + * Sets the starting source index where the breakpoint should be set. + * + * @param The requested start index attribute. + * @exception CoreException if unable to access the property on this breakpoint's + * underlying marker + */ + public void setRequestedCharStart(int charStart) throws CoreException; + + /** + * Returns ending source index where the breakpoint was set before it + * was moved to a valid source location. + * + * @return Returns the requested end index attribute. + * @exception CoreException if unable to access the property on this breakpoint's + * underlying marker + */ + public int getRequestedCharEnd() throws CoreException; + + /** + * Sets the staring source index where the breakpoint should be set. + * + * @param The requested end index attribute. + * @exception CoreException if unable to access the property on this breakpoint's + * underlying marker + */ + public void setRequestedCharEnd(int charEnd) throws CoreException; + + /** + * Returns the file name where the breakpoint was set before it was relocated to a + * valid file. + * + * @return Returns the requested file name. + * @exception CoreException if unable to access the property on this breakpoint's + * underlying marker + */ + public String getRequestedSourceHandle() throws CoreException; + + /** + * Sets the file name where the breakpoint should be set. May be an empty string + * if the file is not known. + * + * @param Requested file name. + * @exception CoreException if unable to access the property on this breakpoint's + * underlying marker + */ + public void setRequestedSourceHandle(String fileName) throws CoreException; + + /** + * Sets the line number where the breakpoint is actually installed. This + * method only updates the {@link IMarker#LINE_NUMBER} attribute and the + * breakpoint message. + * + * @param line Installed line number + * @throws CoreException if unable to access the property + * on this breakpoint's underlying marker + */ + public void setInstalledLineNumber(int line) throws CoreException; + + /** + * Sets the start index where the breakpoint is actually installed. This method + * only updates the {@link IMarker#CHAR_START} attribute and the breakpoint + * message. + * + * @param charStart Installed char start + * @throws CoreException + */ + public void setInstalledCharStart(int charStart) throws CoreException; + + /** + * Sets the end index where the breakpoint is actually installed. This method + * only updates the {@link IMarker#CHAR_END} attribute and the breakpoint + * message. + * + * @param charEnd Installed char start + * @throws CoreException + */ + public void setInstalledCharEnd(int charStart) throws CoreException; + + /** + * Resets the breakpoint location back to the values specified by the + * REQUESTED_* attributes. This operation should be called automatically + * by the implementation when the install count is reset to 0, and does + * not need to be called by the client at that time. + * + * @throws CoreException + */ + public void resetInstalledLocation() throws CoreException; } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICModule.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICModule.java index 6989e8c5eac..93b4458a0c9 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICModule.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICModule.java @@ -11,16 +11,16 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.core.model; +package org.eclipse.cdt.debug.core.model; import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.core.IAddressFactory; import org.eclipse.core.runtime.IPath; import org.eclipse.debug.core.DebugException; - + /** * Represents a module in the process being debugged. - * + * * @since 3.0 */ public interface ICModule extends ICDebugElement { @@ -37,104 +37,104 @@ public interface ICModule extends ICDebugElement { /** * Returns the type of this module. - * The returned value will be one of <code>EXECUTABLE</code>, + * The returned value will be one of <code>EXECUTABLE</code>, * <code>SHARED_LIBRARY</code>, <code>CORE</code>. - * + * * @return the type of this module */ public int getType(); /** * Returns the name of this module. - * + * * @return the name of this module */ public String getName(); /** - * Returns the image name of this module. The name may or may not + * Returns the image name of this module. The name may or may not * contain a full path. - * + * * @return the image name of this module */ public IPath getImageName(); /** * Returns the full path of the file from which symbols to be loaded. - * + * * @return the full path of the file from which symbols to be loaded */ public IPath getSymbolsFileName(); /** * Associate the specified file as a symbol provider for this module. - * If <code>null</code> is passed as a file name the internal symbols + * If <code>null</code> is passed as a file name the internal symbols * search mechanism will be used. - * + * * @param symbolsFile the symbol provider for this module. * @throws DebugException if this method fails. Reasons include: */ - public void setSymbolsFileName( IPath symbolsFile ) throws DebugException; + public void setSymbolsFileName(IPath symbolsFile) throws DebugException; /** * Returns the base address of this module. - * + * * @return the base address of this module */ public IAddress getBaseAddress(); /** * Returns the size of this module. - * + * * @return the size of this module */ public long getSize(); /** * Returns whether the symbols of this module are read. - * + * * @return whether the symbols of this module are read */ public boolean areSymbolsLoaded(); /** * Returns whether the module's symbols can be loaded or reloaded. - * + * * @return whether the module's symbols can be loaded or reloaded */ public boolean canLoadSymbols(); /** * Loads the module symbols from the specified file. - * + * * @throws DebugException if this method fails. Reasons include: */ public void loadSymbols() throws DebugException; /** * Returns the name of the platform. - * + * * @return the name of the platform */ public String getPlatform(); /** * Returns whether this module is little endian. - * + * * @return whether this module is little endian */ public boolean isLittleEndian(); /** * Returns the address factory associated with this module. - * + * * @return the address factory */ public IAddressFactory getAddressFactory(); /** * Returns the CPU identifier. - * + * * @return the CPU identifier */ public String getCPU(); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICSignal.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICSignal.java index ab6b746d9c7..03f26984eaf 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICSignal.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICSignal.java @@ -21,65 +21,65 @@ import org.eclipse.debug.core.DebugException; * @since: Mar 5, 2004 */ public interface ICSignal extends ICDebugElement { - + /** * Returns the name of this signal - * + * * @return this signal's name * @throws DebugException if this method fails. */ public String getName() throws DebugException; - + /** * Returns the description of this signal. - * + * * @return this signal's description * @throws DebugException if this method fails. */ public String getDescription() throws DebugException; - + /** * Returns whether "pass" is in effect for this signal. - * + * * @return whether "pass" is in effect for this signal * @throws DebugException if this method fails. */ public boolean isPassEnabled() throws DebugException; - + /** * Returns whether "stop" is in effect for this signal. - * + * * @return whether "stop" is in effect for this signal * @throws DebugException if this method fails. */ public boolean isStopEnabled() throws DebugException; - + /** * Enables/disables the "pass" flag of this signal. - * + * * @param enable the flag value to set * @throws DebugException if this method fails. */ - public void setPassEnabled( boolean enable ) throws DebugException; - + public void setPassEnabled(boolean enable) throws DebugException; + /** * Enables/disables the "stop" flag of this signal. - * + * * @param enable the flag value to set * @throws DebugException if this method fails. */ - public void setStopEnabled( boolean enable ) throws DebugException; + public void setStopEnabled(boolean enable) throws DebugException; /** * Resumes execution, but immediately gives the target this signal. - * + * * @throws DebugException if this method fails. */ public void signal() throws DebugException; - + /** * Returns whether modification is allowed for this signal's parameters. - * + * * @return whether modification is allowed for this signal's parameters */ public boolean canModify(); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICStackFrame.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICStackFrame.java index e1d245976d9..f0df391c8fb 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICStackFrame.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICStackFrame.java @@ -21,19 +21,20 @@ import org.eclipse.debug.core.model.IValue; /** * C/C++ specific extension of <code>IStackFrame</code>. */ -public interface ICStackFrame extends IRunToLine, IRunToAddress, IResumeAtLine, IResumeAtAddress, IStackFrame, ICDebugElement { +public interface ICStackFrame + extends IRunToLine, IRunToAddress, IResumeAtLine, IResumeAtAddress, IStackFrame, ICDebugElement { /** * Returns the address of this stack frame. - * + * * @return the address of this stack frame */ public IAddress getAddress(); - + /** * Returns the source file of this stack frame or <code>null</code> * if the source file is unknown. - * + * * @return the source file of this stack frame */ public String getFile(); @@ -41,7 +42,7 @@ public interface ICStackFrame extends IRunToLine, IRunToAddress, IResumeAtLine, /** * Returns the function of this stack frame or <code>null</code> * if the function is unknown. - * + * * @return the function of this stack frame */ public String getFunction(); @@ -49,40 +50,40 @@ public interface ICStackFrame extends IRunToLine, IRunToAddress, IResumeAtLine, /** * Returns the line number of this stack frame or <code>0</code> * if the line number is unknown. - * + * * @return the line number of this stack frame */ public int getFrameLineNumber(); /** * Returns the level of this stack frame. - * - * @return the level of this stack frame + * + * @return the level of this stack frame */ public int getLevel(); /** * Evaluates the given expression in the context of this stack frame. - * + * * @param expression expression to evaluate * @return the evaluation result * @throws DebugException if this method fails. */ - public IValue evaluateExpression( String expression ) throws DebugException; + public IValue evaluateExpression(String expression) throws DebugException; /** - * Evaluates the specified expression in the context of this stack frame + * Evaluates the specified expression in the context of this stack frame * and returns the evaluation result as a string. - * + * * @param expression the expression to evaluate * @return the evaluation result * @throws DebugException on failure. Reasons include: */ - public String evaluateExpressionToString( String expression ) throws DebugException; + public String evaluateExpressionToString(String expression) throws DebugException; /** * Returns whether this stack frame can currently evaluate an expression. - * + * * @return whether this stack frame can currently evaluate an expression */ boolean canEvaluate(); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICThread.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICThread.java index 7e10cafe73a..d1f95c4b639 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICThread.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICThread.java @@ -11,7 +11,7 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.core.model; +package org.eclipse.cdt.debug.core.model; import org.eclipse.debug.core.model.IThread; diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICTracepoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICTracepoint.java index c668d433a18..49871ae9ba1 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICTracepoint.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICTracepoint.java @@ -17,45 +17,45 @@ import org.eclipse.core.runtime.CoreException; /** * A tracepoint specific to the C/C++ debug model. - * + * * @since 7.0 */ public interface ICTracepoint extends ICLineBreakpoint { - /** - * Breakpoint marker type for this breakpoint type. - * @since 7.2 - */ - public static final String C_TRACEPOINT_MARKER = "org.eclipse.cdt.debug.core.cTracepointMarker"; //$NON-NLS-1$ + /** + * Breakpoint marker type for this breakpoint type. + * @since 7.2 + */ + public static final String C_TRACEPOINT_MARKER = "org.eclipse.cdt.debug.core.cTracepointMarker"; //$NON-NLS-1$ + + /** + * Breakpoint marker type for this breakpoint type. + * @since 7.2 + */ + public static final String C_LINE_TRACEPOINT_MARKER = "org.eclipse.cdt.debug.core.cLineTracepointMarker"; //$NON-NLS-1$ - /** - * Breakpoint marker type for this breakpoint type. - * @since 7.2 - */ - public static final String C_LINE_TRACEPOINT_MARKER = "org.eclipse.cdt.debug.core.cLineTracepointMarker"; //$NON-NLS-1$ - - /** - * Breakpoint marker type for this breakpoint type. - * @since 7.2 - */ - public static final String C_ADDRESS_TRACEPOINT_MARKER = "org.eclipse.cdt.debug.core.cAddressTracepointMarker"; //$NON-NLS-1$ + /** + * Breakpoint marker type for this breakpoint type. + * @since 7.2 + */ + public static final String C_ADDRESS_TRACEPOINT_MARKER = "org.eclipse.cdt.debug.core.cAddressTracepointMarker"; //$NON-NLS-1$ + + /** + * Breakpoint marker type for this breakpoint type. + * @since 7.2 + */ + public static final String C_FUNCTION_TRACEPOINT_MARKER = "org.eclipse.cdt.debug.core.cFunctionTracepointMarker"; //$NON-NLS-1$ - /** - * Breakpoint marker type for this breakpoint type. - * @since 7.2 - */ - public static final String C_FUNCTION_TRACEPOINT_MARKER = "org.eclipse.cdt.debug.core.cFunctionTracepointMarker"; //$NON-NLS-1$ - /** * Tracepoint attribute storing a tracepoint's pass count value (value * <code>"org.eclipse.cdt.debug.core.passCount"</code>). This attribute * is an <code>int</code>. */ - public static final String PASS_COUNT = "org.eclipse.cdt.debug.core.passCount"; //$NON-NLS-1$ + public static final String PASS_COUNT = "org.eclipse.cdt.debug.core.passCount"; //$NON-NLS-1$ /** * Returns the pass count used by this tracepoint. - * + * * @return the pass count used by this breakpoint * @exception CoreException if unable to access the property on this tracepoint's * underlying marker @@ -64,7 +64,7 @@ public interface ICTracepoint extends ICLineBreakpoint { /** * Sets the pass count attribute for this tracepoint. - * + * * @param passCount the new pass count * @exception CoreException if unable to access the property on this tracepoint's * underlying marker diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICType.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICType.java index cc729d99c2b..1dd4f2512a6 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICType.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICType.java @@ -14,78 +14,78 @@ package org.eclipse.cdt.debug.core.model; /** - * Represents a type of a varibale. + * Represents a type of a varibale. * Used by the UI responsible components for variable rendering. */ public interface ICType { /** * Returns the name of this type. - * + * * @return the name of this type */ String getName(); /** * Returns whether this is an array type. - * + * * @return whether this is an array type */ boolean isArray(); /** - * Returns the array dimensions for array types, + * Returns the array dimensions for array types, * otherwise returns an empty array. - * + * * @return the array dimensions */ int[] getArrayDimensions(); /** * Returns whether this is a structure or a class type. - * + * * @return whether this is a structure or a class type */ boolean isStructure(); /** * Returns whether this is a character type. - * + * * @return whether this is a character type */ boolean isCharacter(); /** * Returns whether this is a floating point type. - * + * * @return whether this is a floating point type */ boolean isFloatingPointType(); /** * Returns whether this is a pointer type. - * + * * @return whether this is a pointer type */ boolean isPointer(); /** * Returns whether this is a reference type. - * + * * @return whether this is a reference type */ boolean isReference(); /** * Returns whether this is an unsigned type. - * + * * @return whether this is an unsigned type */ boolean isUnsigned(); /** * Returns whether this is an integral type. - * + * * @return whether this is an integral type */ boolean isIntegralType(); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICValue.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICValue.java index 66004abe573..59b6d5e09f9 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICValue.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICValue.java @@ -20,8 +20,8 @@ import org.eclipse.debug.core.model.IValue; * Extends the IValue interface by C/C++ specific functionality. */ public interface ICValue extends IValue, ICDebugElement { - + ICType getType() throws DebugException; - String evaluateAsExpression( ICStackFrame frame ); + String evaluateAsExpression(ICStackFrame frame); } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICWatchpoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICWatchpoint.java index d2313f0a0d5..e7772a54740 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICWatchpoint.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICWatchpoint.java @@ -21,24 +21,24 @@ import org.eclipse.debug.core.model.ILineBreakpoint; */ public interface ICWatchpoint extends ICBreakpoint, ILineBreakpoint { - /** - * Breakpoint marker type for this breakpoint type. - * @since 7.2 - */ - public static final String C_WATCHPOINT_MARKER = "org.eclipse.cdt.debug.core.cWatchpointMarker"; //$NON-NLS-1$ - /** - * Watchpoint attribute storing the expression associated with this + * Breakpoint marker type for this breakpoint type. + * @since 7.2 + */ + public static final String C_WATCHPOINT_MARKER = "org.eclipse.cdt.debug.core.cWatchpointMarker"; //$NON-NLS-1$ + + /** + * Watchpoint attribute storing the expression associated with this * watchpoint (value <code>"org.eclipse.cdt.debug.core.expression"</code>). * This attribute is a <code>String</code>. */ - public static final String EXPRESSION = "org.eclipse.cdt.debug.core.expression"; //$NON-NLS-1$ + public static final String EXPRESSION = "org.eclipse.cdt.debug.core.expression"; //$NON-NLS-1$ /** * Write access watchpoint attribute (value <code>"org.eclipse.cdt.debug.core.write"</code>). * This attribute is a <code>boolean</code>. */ - public static final String WRITE = "org.eclipse.cdt.debug.core.write"; //$NON-NLS-1$ + public static final String WRITE = "org.eclipse.cdt.debug.core.write"; //$NON-NLS-1$ /** * Read access watchpoint attribute (value <code>"org.eclipse.cdt.debug.core.read"</code>). @@ -48,21 +48,21 @@ public interface ICWatchpoint extends ICBreakpoint, ILineBreakpoint { /** * Returns whether this watchppoint is a write watchpoint. - * + * * @return whether this watchppoint is a write watchpoint */ boolean isWriteType() throws CoreException; /** * Returns whether this watchppoint is a read watchpoint. - * + * * @return whether this watchppoint is a read watchpoint */ boolean isReadType() throws CoreException; /** * Returns the watchpoint's expression. - * + * * @return the expression of this watchpoint * @throws CDIException if this method fails. Reasons include: */ diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICWatchpoint2.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICWatchpoint2.java index 1afa2a2d294..a6be6cacdbc 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICWatchpoint2.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICWatchpoint2.java @@ -20,30 +20,30 @@ import org.eclipse.core.runtime.CoreException; public interface ICWatchpoint2 extends ICWatchpoint { /** - * Watchpoint attribute storing the memory space associated with this + * Watchpoint attribute storing the memory space associated with this * watchpoint (value <code>"org.eclipse.cdt.debug.core.memoryspace"</code>). * This attribute is a <code>String</code>. */ - public static final String MEMORYSPACE = "org.eclipse.cdt.debug.core.memoryspace"; //$NON-NLS-1$ + public static final String MEMORYSPACE = "org.eclipse.cdt.debug.core.memoryspace"; //$NON-NLS-1$ /** - * Watchpoint attribute storing the range associated with this + * Watchpoint attribute storing the range associated with this * watchpoint (value <code>"org.eclipse.cdt.debug.core.range"</code>). * This attribute is an <code>int</code>. */ - public static final String RANGE = "org.eclipse.cdt.debug.core.range"; //$NON-NLS-1$ + public static final String RANGE = "org.eclipse.cdt.debug.core.range"; //$NON-NLS-1$ /** * Returns the watchpoint's memory space. - * + * * @return the memory space of this watchpoint * @throws CDIException if this method fails. Reasons include: */ String getMemorySpace() throws CoreException; - + /** * Returns the watchpoint's range. - * + * * @return the range of this watchpoint * @throws CDIException if this method fails. Reasons include: */ diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICastToArray.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICastToArray.java index 79e3b8358c8..941c1da6239 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICastToArray.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICastToArray.java @@ -22,18 +22,18 @@ public interface ICastToArray extends ICastToType { /** * Returns whether this element can be currently casted to array. - * + * * @return whether this element can be currently casted to array */ boolean canCastToArray(); /** * Performs the casting. The element is transformed to the array of the same type. - * - * @param startIndex the index of the first element of the array. 0 means that - * the original element is the first member of the array. + * + * @param startIndex the index of the first element of the array. 0 means that + * the original element is the first member of the array. * @param length tha array size * @throws DebugException */ - void castToArray( int startIndex, int length ) throws DebugException; + void castToArray(int startIndex, int length) throws DebugException; } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICastToType.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICastToType.java index 0c541d7ae2d..218285bd63b 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICastToType.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICastToType.java @@ -23,36 +23,36 @@ public interface ICastToType extends IAdaptable { /** * Returns whether this element can currently be casted. - * + * * @return whether this element can currently be casted */ boolean canCast(); /** * Returns the string presentation of the current type. - * + * * @return the string presentation of the current type */ String getCurrentType(); /** * Performs the casting to the given type. - * + * * @param type a type to cast to. * @throws DebugException */ - void cast( String type ) throws DebugException; + void cast(String type) throws DebugException; /** * Restores the original type. - * + * * @throws DebugException */ void restoreOriginal() throws DebugException; /** * Returns whether this element is casted. - * + * * @return whether this element is casted */ boolean isCasted(); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IChangeReverseMethodHandler.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IChangeReverseMethodHandler.java index 8655c893f6e..10759123925 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IChangeReverseMethodHandler.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IChangeReverseMethodHandler.java @@ -25,25 +25,27 @@ public interface IChangeReverseMethodHandler extends IReverseToggleHandler, IDeb /** * List of different values for the reverse debugging method. */ - enum ReverseDebugMethod {OFF, SOFTWARE, HARDWARE, BRANCH_TRACE, PROCESSOR_TRACE, GDB_TRACE}; + enum ReverseDebugMethod { + OFF, SOFTWARE, HARDWARE, BRANCH_TRACE, PROCESSOR_TRACE, GDB_TRACE + }; - /** - * Sets the value for the reverse debugging method to be used when the button is toggled. - */ - void setReverseDebugMethod(ReverseDebugMethod traceMethod); + /** + * Sets the value for the reverse debugging method to be used when the button is toggled. + */ + void setReverseDebugMethod(ReverseDebugMethod traceMethod); - /** - * Return the reverse debugging method currently selected. - * - * @param context is the currently active context in the debug view - */ - ReverseDebugMethod getReverseDebugMethod(Object context); + /** + * Return the reverse debugging method currently selected. + * + * @param context is the currently active context in the debug view + */ + ReverseDebugMethod getReverseDebugMethod(Object context); - /** - * Return the reverse debugging method that was selected before the - * currently selected one. - * - * @param context is the currently active context in the debug view - */ - ReverseDebugMethod getPreviousReverseDebugMethod(Object context); + /** + * Return the reverse debugging method that was selected before the + * currently selected one. + * + * @param context is the currently active context in the debug view + */ + ReverseDebugMethod getPreviousReverseDebugMethod(Object context); } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IConnectHandler.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IConnectHandler.java index ceb0591682c..22dfdf97d95 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IConnectHandler.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IConnectHandler.java @@ -17,7 +17,7 @@ import org.eclipse.debug.core.commands.IDebugCommandHandler; /** * Handler interface to for the connect command - * + * * @since 7.3 */ public interface IConnectHandler extends IDebugCommandHandler { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDebugNewExecutableHandler.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDebugNewExecutableHandler.java index 44c398e8cae..d16e7c59e40 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDebugNewExecutableHandler.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDebugNewExecutableHandler.java @@ -18,7 +18,7 @@ import org.eclipse.debug.core.commands.IDebugCommandHandler; /** * Command handler for the "Debug New Executable" command. - * + * * @since 7.3 */ public interface IDebugNewExecutableHandler extends IDebugCommandHandler { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDebuggerProcessSupport.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDebuggerProcessSupport.java index 153f43a37f2..e732b2588e7 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDebuggerProcessSupport.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDebuggerProcessSupport.java @@ -15,14 +15,13 @@ package org.eclipse.cdt.debug.core.model; /** * Provides the functionality to support debugger console. - * + * * @since: Oct 23, 2002 */ -public interface IDebuggerProcessSupport -{ +public interface IDebuggerProcessSupport { boolean supportsDebuggerProcess(); - + boolean isDebuggerProcessDefault(); - - void setDebuggerProcessDefault( boolean value ); + + void setDebuggerProcessDefault(boolean value); } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassembly.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassembly.java index 2df32b4d80f..8a6c6d8b4e5 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassembly.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassembly.java @@ -24,26 +24,26 @@ public interface IDisassembly extends ICDebugElement { /** * Returns the disassembly block for given stack frame. - * + * * @param frame the stack frame for which the disassembly is required * @return the disassembly block for given stack frame * @throws DebugException if this method fails. */ - IDisassemblyBlock getDisassemblyBlock( ICStackFrame frame ) throws DebugException; + IDisassemblyBlock getDisassemblyBlock(ICStackFrame frame) throws DebugException; /** * Returns the disassembly block for given stack frame. - * + * * @param address the address from which the disassembly starts * @return the disassembly block for given memory address * @throws DebugException if this method fails. * @since 6.0 */ - IDisassemblyBlock getDisassemblyBlock( IAddress address ) throws DebugException; - + IDisassemblyBlock getDisassemblyBlock(IAddress address) throws DebugException; + /** * Returns the address factory associated with this element. - * + * * @return the address factory */ IAddressFactory getAddressFactory(); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassemblyBlock.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassemblyBlock.java index 1f567b91d14..0627c5bea13 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassemblyBlock.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassemblyBlock.java @@ -17,49 +17,48 @@ package org.eclipse.cdt.debug.core.model; * Represents a contiguous segment of disassembly in an execution context. */ public interface IDisassemblyBlock { - + /** * Returns the parent disassembly object. - * + * * @return the parent disassembly object */ IDisassembly getDisassembly(); /** - * Returns the platform-dependent path of the executable associated + * Returns the platform-dependent path of the executable associated * with this segment. - * + * * @return the platform-dependent path of the executable */ String getModuleFile(); - /** - * Returns the source element (<code>IFile</code> or <code>File></code>) + * Returns the source element (<code>IFile</code> or <code>File></code>) * of the source file associated with this segment or null if no source file is associated. - * + * * @return the source element */ Object getSourceElement(); /** * Returns whether this block contains given stack frame. - * + * * @param frame the stack frame * @return whether this block contains given stack frame */ - boolean contains( ICStackFrame frame ); + boolean contains(ICStackFrame frame); /** * Return the array of source lines associated with this block. - * + * * @return the array of source lines associated with this block */ IAsmSourceLine[] getSourceLines(); /** * Returns whether this block contains mixed source/disassembly information. - * + * * @return whether this block contains mixed source/disassembly information */ boolean isMixedMode(); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassemblyLine.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassemblyLine.java index 42483f5003c..fd6cbe06cc7 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassemblyLine.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassemblyLine.java @@ -15,7 +15,7 @@ package org.eclipse.cdt.debug.core.model; /** - * org.eclipse.cdt.debug.core.model.IDisassemblyLine: + * org.eclipse.cdt.debug.core.model.IDisassemblyLine: * //TODO Add description. */ public interface IDisassemblyLine extends ICDebugElement { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassemblySourceLine.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassemblySourceLine.java index 9e6f4c396a5..9972d540bbd 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassemblySourceLine.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassemblySourceLine.java @@ -20,6 +20,6 @@ import java.io.File; * Represents a source line in disassembly. */ public interface IDisassemblySourceLine extends IAsmSourceLine, IDisassemblyLine { - - public File getFile(); + + public File getFile(); } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDummyStackFrame.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDummyStackFrame.java index 21a4c3c452e..d1a8f783f37 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDummyStackFrame.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDummyStackFrame.java @@ -14,7 +14,7 @@ package org.eclipse.cdt.debug.core.model; /** - * Represents a dummy stack frame used to indicate that the stack depth is greater + * Represents a dummy stack frame used to indicate that the stack depth is greater * than the number of displayed frames. */ public interface IDummyStackFrame { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IEditRegisterGroupHandler.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IEditRegisterGroupHandler.java index a4c246e25da..6c2f627993d 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IEditRegisterGroupHandler.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IEditRegisterGroupHandler.java @@ -21,4 +21,3 @@ import org.eclipse.debug.core.commands.IDebugCommandHandler; */ public interface IEditRegisterGroupHandler extends IDebugCommandHandler { } - diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IEnableDisableTarget.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IEnableDisableTarget.java index cf6bb71f577..a5c3f8e9f29 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IEnableDisableTarget.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IEnableDisableTarget.java @@ -11,10 +11,10 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.core.model; +package org.eclipse.cdt.debug.core.model; import org.eclipse.debug.core.DebugException; - + /** * Provides support for enable/disable actions. */ @@ -22,24 +22,24 @@ public interface IEnableDisableTarget { /** * Returns whether this object supports enable/disable operations. - * + * * @return whether this object supports enable/disable operations */ boolean canEnableDisable(); - + /** * Returns whether this object is enabled. - * - * @return <code>true</code> if this obvject is enabled, + * + * @return <code>true</code> if this obvject is enabled, * or <code>false</code> otherwise. */ boolean isEnabled(); /** * Enables/disables this object - * + * * @param enabled enablement flag value * @throws DebugException */ - void setEnabled( boolean enabled ) throws DebugException; + void setEnabled(boolean enabled) throws DebugException; } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IGlobalVariableDescriptor.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IGlobalVariableDescriptor.java index 38a0066f06d..5fa24093695 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IGlobalVariableDescriptor.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IGlobalVariableDescriptor.java @@ -22,15 +22,15 @@ public interface IGlobalVariableDescriptor { /** * Returns the name of the global variable - * + * * @return the name of the global variable */ public String getName(); /** - * Returns the path of the source file that contains + * Returns the path of the source file that contains * the definition of the global variable. - * + * * @return the path of the source file */ public IPath getPath(); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IGroupDebugContextsHandler.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IGroupDebugContextsHandler.java index 36cb2d8b0ea..cd28259da88 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IGroupDebugContextsHandler.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IGroupDebugContextsHandler.java @@ -16,9 +16,9 @@ package org.eclipse.cdt.debug.core.model; import org.eclipse.debug.core.commands.IDebugCommandHandler; /** - * Handler interface to perform grouping of debug contexts. - * - * @since 7.1 + * Handler interface to perform grouping of debug contexts. + * + * @since 7.1 */ public interface IGroupDebugContextsHandler extends IDebugCommandHandler { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IMemoryBlockAddressInfoRetrieval.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IMemoryBlockAddressInfoRetrieval.java index 63c491d7353..98b6a4f6a5f 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IMemoryBlockAddressInfoRetrieval.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IMemoryBlockAddressInfoRetrieval.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 *******************************************************************************/ @@ -22,12 +22,11 @@ import org.eclipse.debug.core.model.IMemoryBlock; * An interface that offers the possibility to request information related to addresses for a given memory block * and within a specific context. It also offers the possibility to register listeners, listeners that can receive * notifications of changes/updates to the address information - * + * * @since 8.0 */ public interface IMemoryBlockAddressInfoRetrieval { - /** * An indication of the type of change which may render the current memory address information out of date */ @@ -116,7 +115,7 @@ public interface IMemoryBlockAddressInfoRetrieval { */ public interface IAddressInfoUpdateListener { /** - * This method will be called for each registered listener, when there is a session change that may render + * This method will be called for each registered listener, when there is a session change that may render * previous memory address information out of date * @param update optional General purpose update object to e.g. determine changed values */ @@ -124,25 +123,25 @@ public interface IMemoryBlockAddressInfoRetrieval { } /** - * Triggers an asynchronous request for Memory block address information - * + * Triggers an asynchronous request for Memory block address information + * * @param context A reference to a session context * @param memoryBlock The memory block to be used in conjunction with the requested Address information - * @param request This is the async request instance. Overriding its method "done()" allows to read and - * use the information items collected + * @param request This is the async request instance. Overriding its method "done()" allows to read and + * use the information items collected */ void getMemoryBlockAddressInfo(Object context, IMemoryBlock memoryBlock, IGetMemoryBlockAddressInfoReq request); /** * Register a listener so it can receive notifications of changes to address information items - * + * * @param listener */ void addAddressInfoUpdateListener(IAddressInfoUpdateListener listener); /** * Removes a listener so it no longer receives notifications - * + * * @param The listener to remove. Nothing will happen if that listener is not registered already */ void removeAddressInfoUpdateListener(IAddressInfoUpdateListener listener); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IModuleRetrieval.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IModuleRetrieval.java index 8fa36f20f0a..20ca0e33881 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IModuleRetrieval.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IModuleRetrieval.java @@ -11,27 +11,27 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.core.model; +package org.eclipse.cdt.debug.core.model; import org.eclipse.debug.core.DebugException; - + /** * Comment for . */ public interface IModuleRetrieval { - + /** * Returns whether there are modules currently loaded in this debug target. - * + * * @return whether there are modules currently loaded in this debug target - * + * * @throws DebugException */ public boolean hasModules() throws DebugException; /** * Returns the array of the currently loaded modules. - * + * * @return the array of the currently loaded modules * @throws DebugException if this method fails. Reasons include: */ @@ -39,7 +39,7 @@ public interface IModuleRetrieval { /** * Load symbols for all currently loaded modules. - * + * * @throws DebugException if this method fails. Reasons include: */ public void loadSymbolsForAllModules() throws DebugException; diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IMoveToAddress.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IMoveToAddress.java index 4abd5f78b15..0e88eed633e 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IMoveToAddress.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IMoveToAddress.java @@ -27,12 +27,12 @@ public interface IMoveToAddress { * * @return whether this operation is currently available */ - public boolean canMoveToAddress( IAddress address ); + public boolean canMoveToAddress(IAddress address); /** * Causes this element can move the instruction pointer to the specified address. * * @exception DebugException on failure. Reasons include: */ - public void moveToAddress( IAddress address ) throws DebugException; + public void moveToAddress(IAddress address) throws DebugException; } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IMoveToLine.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IMoveToLine.java index fcbccfd3b0e..bf7eb93ab14 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IMoveToLine.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IMoveToLine.java @@ -23,15 +23,15 @@ public interface IMoveToLine { /** * Returns whether this operation is currently available for this file and line number. - * + * * @return whether this operation is currently available */ - public boolean canMoveToLine( String fileName, int lineNumber ); + public boolean canMoveToLine(String fileName, int lineNumber); /** * Causes this element to move the instruction pointer to the specified line. - * + * * @exception DebugException on failure. Reasons include: */ - public void moveToLine( String fileName, int lineNumber ) throws DebugException; + public void moveToLine(String fileName, int lineNumber) throws DebugException; } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IPersistableRegisterGroup.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IPersistableRegisterGroup.java index d3af56d154a..45ec7f5daad 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IPersistableRegisterGroup.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IPersistableRegisterGroup.java @@ -11,46 +11,46 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.core.model; +package org.eclipse.cdt.debug.core.model; import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.model.IRegisterGroup; - + /** - * A register group to be persisted and restored. + * A register group to be persisted and restored. * To be used for the user-defined register groups. - * + * * @since 3.0 */ public interface IPersistableRegisterGroup extends IRegisterGroup { /** * Returns a memento that can be used to reconstruct this group - * + * * @return a memento that can be used to reconstruct this group * @exception CoreException if unable to construct a memento */ public String getMemento() throws CoreException; - + /** * Initializes this group based on the given memento. - * + * * @param memento a memento to initialize this group - * @exception CoreException on failure to initialize + * @exception CoreException on failure to initialize */ - public void initializeFromMemento( String memento ) throws CoreException; + public void initializeFromMemento(String memento) throws CoreException; /** * Returns the array of group's register descriptors. - * + * * @return the array of group's register descriptors */ public IRegisterDescriptor[] getRegisterDescriptors(); /** * Replaces the group register descriptors by the specified descriptors. - * + * * @param the array of register descriptors */ - public void setRegisterDescriptors( IRegisterDescriptor[] registerDescriptors ); + public void setRegisterDescriptors(IRegisterDescriptor[] registerDescriptors); } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IRegisterDescriptor.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IRegisterDescriptor.java index ac2e0e70b4b..a0b3a8ef5af 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IRegisterDescriptor.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IRegisterDescriptor.java @@ -11,25 +11,25 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.core.model; +package org.eclipse.cdt.debug.core.model; /** * Describes a register. - * + * * @since 3.0 */ public interface IRegisterDescriptor { /** * Returns the regiser's name - * + * * @return the register's name */ public String getName(); /** * Returns the name of the hardware register group this register belongs to - * + * * @return the name of the hardware register group */ public String getGroupName(); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IRestart.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IRestart.java index df7c6b28a6b..51b99207d0b 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IRestart.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IRestart.java @@ -16,21 +16,21 @@ package org.eclipse.cdt.debug.core.model; import org.eclipse.debug.core.DebugException; + /** - * Provides the ability to restart a debug target. + * Provides the ability to restart a debug target. * <p> * Note: Debug elements which support restart should implement this interface. - * Adopting to this interface is not enough. + * Adopting to this interface is not enough. * </p> * <p> - * Note 2: Debugger can also implement the asynchronous + * Note 2: Debugger can also implement the asynchronous * {@link org.eclipse.debug.core.commands.IRestartHandler}. * </p> - * + * * @see org.eclipse.debug.core.commands.IRestartHandler */ -public interface IRestart -{ +public interface IRestart { /** * Returns whether this element can currently be restarted. * @@ -45,4 +45,3 @@ public interface IRestart */ public void restart() throws DebugException; } - diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IResumeAtAddress.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IResumeAtAddress.java index 78cb1606cf4..da7122a5576 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IResumeAtAddress.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IResumeAtAddress.java @@ -24,15 +24,15 @@ public interface IResumeAtAddress { /** * Returns whether this operation is currently available for this element. - * + * * @return whether this operation is currently available */ - public boolean canResumeAtAddress( IAddress address ); + public boolean canResumeAtAddress(IAddress address); /** * Causes this element to resume the execution at the specified address. - * + * * @exception DebugException on failure. Reasons include: */ - public void resumeAtAddress( IAddress address ) throws DebugException; + public void resumeAtAddress(IAddress address) throws DebugException; } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IResumeAtLine.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IResumeAtLine.java index abd0b2a683d..b1231ee3259 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IResumeAtLine.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IResumeAtLine.java @@ -24,30 +24,30 @@ public interface IResumeAtLine { /** * Returns whether this operation is currently available for this file and line number. - * + * * @return whether this operation is currently available */ - public boolean canResumeAtLine( IFile file, int lineNumber ); + public boolean canResumeAtLine(IFile file, int lineNumber); /** * Causes this element to resume the execution at the specified line. - * + * * @exception DebugException * on failure. Reasons include: */ - public void resumeAtLine( IFile file, int lineNumber ) throws DebugException; + public void resumeAtLine(IFile file, int lineNumber) throws DebugException; /** * Returns whether this operation is currently available for this file and line number. - * + * * @return whether this operation is currently available */ - public boolean canResumeAtLine( String fileName, int lineNumber ); + public boolean canResumeAtLine(String fileName, int lineNumber); /** * Causes this element to resume the execution at the specified line. - * + * * @exception DebugException on failure. Reasons include: */ - public void resumeAtLine( String fileName, int lineNumber ) throws DebugException; + public void resumeAtLine(String fileName, int lineNumber) throws DebugException; } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IResumeWithoutSignal.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IResumeWithoutSignal.java index 7049609ee82..41bc5731a7a 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IResumeWithoutSignal.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IResumeWithoutSignal.java @@ -16,18 +16,17 @@ package org.eclipse.cdt.debug.core.model; import org.eclipse.debug.core.DebugException; /** - * Provides the ability to resume execution without giving a signal. - * This is useful when the program stopped on account of a signal and would + * Provides the ability to resume execution without giving a signal. + * This is useful when the program stopped on account of a signal and would * ordinary see the signal when resumed. - * + * * @since: Feb 4, 2003 */ -public interface IResumeWithoutSignal -{ +public interface IResumeWithoutSignal { /** * Causes this element to resume its execution ignoring a signal. * Has no effect on an element that is not suspended because of a signal. - * + * * @exception DebugException on failure. Reasons include: */ public void resumeWithoutSignal() throws DebugException; diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IResumeWithoutSignalHandler.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IResumeWithoutSignalHandler.java index 006ee24eb8b..e9f980c3977 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IResumeWithoutSignalHandler.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IResumeWithoutSignalHandler.java @@ -17,7 +17,7 @@ import org.eclipse.debug.core.commands.IDebugCommandHandler; /** * Handler interface to perform a resume without signal operation - * + * * @since 7.0 */ public interface IResumeWithoutSignalHandler extends IDebugCommandHandler { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IReverseResumeHandler.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IReverseResumeHandler.java index 9879722aede..51cb8642205 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IReverseResumeHandler.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IReverseResumeHandler.java @@ -17,7 +17,7 @@ import org.eclipse.debug.core.commands.IDebugCommandHandler; /** * Handler interface to perform a reverse Resume operation - * + * * @since 7.0 */ public interface IReverseResumeHandler extends IDebugCommandHandler { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IReverseStepIntoHandler.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IReverseStepIntoHandler.java index 1d1b04e8e1a..2ff92e1363d 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IReverseStepIntoHandler.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IReverseStepIntoHandler.java @@ -17,7 +17,7 @@ import org.eclipse.debug.core.commands.IDebugCommandHandler; /** * Handler interface to perform a reverse StepInto operation - * + * * @since 7.0 */ public interface IReverseStepIntoHandler extends IDebugCommandHandler { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IReverseStepOverHandler.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IReverseStepOverHandler.java index bc600ee1857..7ab3b00cb87 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IReverseStepOverHandler.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IReverseStepOverHandler.java @@ -17,7 +17,7 @@ import org.eclipse.debug.core.commands.IDebugCommandHandler; /** * Handler interface to perform a reverse StepOver operation - * + * * @since 7.0 */ public interface IReverseStepOverHandler extends IDebugCommandHandler { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IReverseToggleHandler.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IReverseToggleHandler.java index 79371c1a092..2a31b66ff49 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IReverseToggleHandler.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IReverseToggleHandler.java @@ -17,7 +17,7 @@ import org.eclipse.debug.core.commands.IDebugCommandHandler; /** * Handler interface to toggle reverse debugging - * + * * @since 7.0 */ public interface IReverseToggleHandler extends IDebugCommandHandler { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IRunToAddress.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IRunToAddress.java index 8b1057b10ee..f0603e01319 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IRunToAddress.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IRunToAddress.java @@ -23,15 +23,15 @@ public interface IRunToAddress { /** * Returns whether this operation is currently available for this element. - * + * * @return whether this operation is currently available */ - public boolean canRunToAddress( IAddress address ); + public boolean canRunToAddress(IAddress address); /** * Causes this element to run to specified address. - * + * * @exception DebugException on failure. Reasons include: */ - public void runToAddress( IAddress address, boolean skipBreakpoints ) throws DebugException; + public void runToAddress(IAddress address, boolean skipBreakpoints) throws DebugException; } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IRunToLine.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IRunToLine.java index a8a4b51e386..fb511ccbe67 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IRunToLine.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IRunToLine.java @@ -23,29 +23,29 @@ public interface IRunToLine { /** * Returns whether this operation is currently available for this file and line number. - * + * * @return whether this operation is currently available */ - public boolean canRunToLine( IFile file, int lineNumber ); + public boolean canRunToLine(IFile file, int lineNumber); /** * Causes this element to run to specified location. - * + * * @exception DebugException on failure. Reasons include: */ - public void runToLine( IFile file, int lineNumber, boolean skipBreakpoints ) throws DebugException; + public void runToLine(IFile file, int lineNumber, boolean skipBreakpoints) throws DebugException; /** * Returns whether this operation is currently available for this file and line number. - * + * * @return whether this operation is currently available */ - public boolean canRunToLine( String fileName, int lineNumber ); + public boolean canRunToLine(String fileName, int lineNumber); /** * Causes this element to run to specified location. - * + * * @exception DebugException on failure. Reasons include: */ - public void runToLine( String fileName, int lineNumber, boolean skipBreakpoints ) throws DebugException; + public void runToLine(String fileName, int lineNumber, boolean skipBreakpoints) throws DebugException; } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ISaveTraceDataHandler.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ISaveTraceDataHandler.java index 020bf8b5486..4e47ff21922 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ISaveTraceDataHandler.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ISaveTraceDataHandler.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 *******************************************************************************/ diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IStartTracingHandler.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IStartTracingHandler.java index bcd9f1bcdd7..2d552ab2487 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IStartTracingHandler.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IStartTracingHandler.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 *******************************************************************************/ diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IStepIntoSelectionHandler.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IStepIntoSelectionHandler.java index 4f24f4a4f2a..a7084435148 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IStepIntoSelectionHandler.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IStepIntoSelectionHandler.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Alvaro Sanchez-Leon (Ericsson AB) - Support for Step into selection (bug 244865) *******************************************************************************/ diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ISteppingModeTarget.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ISteppingModeTarget.java index 6d27595d659..41e526e54e9 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ISteppingModeTarget.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ISteppingModeTarget.java @@ -27,15 +27,15 @@ public interface ISteppingModeTarget { /** * Sets whether the instruction stepping are enabled in this debug target. - * + * * @param enabled whether the instruction stepping are enabled in this debug target */ - void enableInstructionStepping( boolean enabled ); - + void enableInstructionStepping(boolean enabled); + /** * Returns whether the instruction stepping are currently enabled in this * debug target. - * + * * @return whether the instruction stepping are currently enabled in this * debug target */ diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IStopTracingHandler.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IStopTracingHandler.java index dacd5ce5de0..25b71750de4 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IStopTracingHandler.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IStopTracingHandler.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 *******************************************************************************/ diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ITargetProperties.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ITargetProperties.java index 4bff30488e0..52bf6363421 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ITargetProperties.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ITargetProperties.java @@ -28,7 +28,7 @@ public interface ITargetProperties { * * @param listener a property change listener */ - void addPropertyChangeListener( Preferences.IPropertyChangeListener listener ); + void addPropertyChangeListener(Preferences.IPropertyChangeListener listener); /** * Removes the given listener from this target. @@ -36,5 +36,5 @@ public interface ITargetProperties { * * @param listener a property change listener */ - void removePropertyChangeListener( Preferences.IPropertyChangeListener listener ); + void removePropertyChangeListener(Preferences.IPropertyChangeListener listener); } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IUncallHandler.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IUncallHandler.java index 417c9119429..0dd649337c8 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IUncallHandler.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IUncallHandler.java @@ -17,7 +17,7 @@ import org.eclipse.debug.core.commands.IDebugCommandHandler; /** * Handler interface to perform an Uncall operation (reverse debugging) - * + * * @since 7.0 */ public interface IUncallHandler extends IDebugCommandHandler { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IUngroupDebugContextsHandler.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IUngroupDebugContextsHandler.java index bafddaf3d67..fb4f936b8fc 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IUngroupDebugContextsHandler.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IUngroupDebugContextsHandler.java @@ -16,9 +16,9 @@ package org.eclipse.cdt.debug.core.model; import org.eclipse.debug.core.commands.IDebugCommandHandler; /** - * Handler interface to perform ungrouping of debug contexts. - * - * @since 7.1 + * Handler interface to perform ungrouping of debug contexts. + * + * @since 7.1 */ public interface IUngroupDebugContextsHandler extends IDebugCommandHandler { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IViewInMemory.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IViewInMemory.java index 87a80b084dc..a3fa8b2ce2c 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IViewInMemory.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IViewInMemory.java @@ -23,11 +23,11 @@ public interface IViewInMemory extends IAdaptable { /** * Returns whether this element can currently be viewed in the memory view. - * + * * @return whether this element can currently be viewed in the memory view. */ boolean canViewInMemory(); - + /** * Displays the element in the memory view. */ diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/provisional/IMemoryRenderingViewportProvider.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/provisional/IMemoryRenderingViewportProvider.java index db7e440dc32..3e9f540579c 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/provisional/IMemoryRenderingViewportProvider.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/provisional/IMemoryRenderingViewportProvider.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Freescale Semiconductor - initial API and implementation *******************************************************************************/ @@ -21,7 +21,7 @@ import java.math.BigInteger; * changes. */ public interface IMemoryRenderingViewportProvider { - + /** * Return the first address being shown in the rendering. Subject to scrolling. */ diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/provisional/IMemorySpaceAwareMemoryBlock.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/provisional/IMemorySpaceAwareMemoryBlock.java index e543dc28918..3b34fab77bd 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/provisional/IMemorySpaceAwareMemoryBlock.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/provisional/IMemorySpaceAwareMemoryBlock.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Texas Instruments, Freescale Semiconductor - initial API and implementation *******************************************************************************/ @@ -19,14 +19,14 @@ import org.eclipse.debug.core.model.IMemoryBlockExtension; * An extension of IMemoryBlockExtension that supports memory spaces. An * instance of this is returned from IMemorySpaceAwareMemoryBlockRetrieval. The * memory space interface is provisional, thus this class cannot yet be API. - * + * * @author Alain Lee and John Cortell */ public interface IMemorySpaceAwareMemoryBlock extends IMemoryBlockExtension { /** * Returns the memory space associated with this block - * + * * @return a memory space ID, or null if the block was created without a * memory space identifier. These IDs originate from the backend. See * {@link IMemorySpaceAwareMemoryBlockRetrieval#getMemorySpaces(Object, IRequestListener)} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/provisional/IMemorySpaceAwareMemoryBlockRetrieval.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/provisional/IMemorySpaceAwareMemoryBlockRetrieval.java index 47fd5327d79..c6474cca32b 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/provisional/IMemorySpaceAwareMemoryBlockRetrieval.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/provisional/IMemorySpaceAwareMemoryBlockRetrieval.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Texas Instruments, Freescale Semiconductor - initial API and implementation *******************************************************************************/ @@ -22,7 +22,7 @@ import org.eclipse.debug.core.model.IMemoryBlockRetrievalExtension; * An extension of the IMemoryBlockRetrievalExtension interface that supports * memory spaces. The memory space interface is provisional, thus this class * cannot yet be API. - * + * * @author Alain Lee and John Cortell */ public interface IMemorySpaceAwareMemoryBlockRetrieval extends IMemoryBlockRetrievalExtension { @@ -34,6 +34,7 @@ public interface IMemorySpaceAwareMemoryBlockRetrieval extends IMemoryBlockRetri */ interface GetMemorySpacesRequest extends IRequest { String[] getMemorySpaces(); + void setMemorySpaces(String[] memorySpaceIds); } @@ -41,7 +42,7 @@ public interface IMemorySpaceAwareMemoryBlockRetrieval extends IMemoryBlockRetri * Provides the string encoding of a memory space qualified address. This * method is called when having to represent a memory-space qualified * address as a single string. - * + * * @param expression * the expression representing a location within a memory space. * This can be a simple numeric expression like "0x10000" or @@ -55,7 +56,7 @@ public interface IMemorySpaceAwareMemoryBlockRetrieval extends IMemoryBlockRetri /** * The inverse of {@link #encodeAddress(String, String)}. - * + * * @param str * the encoded string * @return the result of decoding the string into its components; never null @@ -66,12 +67,13 @@ public interface IMemorySpaceAwareMemoryBlockRetrieval extends IMemoryBlockRetri interface DecodeResult { String getMemorySpaceId(); + String getExpression(); } - + /** * Provides the memory spaces available for the given debug context. - * + * * @param context * a debug context * @param request @@ -82,7 +84,7 @@ public interface IMemorySpaceAwareMemoryBlockRetrieval extends IMemoryBlockRetri /** * Retrieves and returns a memory block. - * + * * @param expression * expression to be evaluated to an address * @param context @@ -94,7 +96,8 @@ public interface IMemorySpaceAwareMemoryBlockRetrieval extends IMemoryBlockRetri * @throws DebugException * if unable to retrieve the specified memory */ - public IMemorySpaceAwareMemoryBlock getMemoryBlock(String expression, Object context, String memorySpaceID) throws DebugException; + public IMemorySpaceAwareMemoryBlock getMemoryBlock(String expression, Object context, String memorySpaceID) + throws DebugException; /** * Return true if creating a memory block with a null memory space ID is NOT diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/provisional/IRecurringDebugContext.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/provisional/IRecurringDebugContext.java index 072933988f2..db1c6c4cb28 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/provisional/IRecurringDebugContext.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/provisional/IRecurringDebugContext.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Texas Instruments - initial API and implementation *******************************************************************************/ @@ -27,11 +27,11 @@ import org.eclipse.debug.core.DebugException; * identifiers that are assigned by the underlying runtime system (e.g., PIDs * and TIDs), since such IDs are often assigned and reused in non-deterministic * ways. - * + * * @author Alain Lee */ public interface IRecurringDebugContext { - + /** * Returns the unique identifier associated with this recurring context. If * this context re-appears in a future debug session, it should return the diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/AbsolutePathSourceContainer.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/AbsolutePathSourceContainer.java index 375d8040abc..34d797c1a7f 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/AbsolutePathSourceContainer.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/AbsolutePathSourceContainer.java @@ -28,16 +28,16 @@ public class AbsolutePathSourceContainer extends AbstractSourceContainer { * Unique identifier for the absolute source container type * (value <code>org.eclipse.cdt.debug.core.containerType.absolutePath</code>). */ - public static final String TYPE_ID = CDebugCorePlugin.getUniqueIdentifier() + ".containerType.absolutePath"; //$NON-NLS-1$ + public static final String TYPE_ID = CDebugCorePlugin.getUniqueIdentifier() + ".containerType.absolutePath"; //$NON-NLS-1$ public boolean isValidAbsoluteFilePath(String name) { - return isValidAbsoluteFilePath(new File(name)); + return isValidAbsoluteFilePath(new File(name)); } public boolean isValidAbsoluteFilePath(File file) { - return file.isAbsolute() && file.exists() && file.isFile(); + return file.isAbsolute() && file.exists() && file.isFile(); } - + @Override public Object[] findSourceElements(String name) throws CoreException { if (name != null) { @@ -66,11 +66,11 @@ public class AbsolutePathSourceContainer extends AbstractSourceContainer { public int hashCode() { return TYPE_ID.hashCode(); } - + @Override public boolean equals(Object obj) { - if (!(obj instanceof AbsolutePathSourceContainer)) - return false; - return true; - } + if (!(obj instanceof AbsolutePathSourceContainer)) + return false; + return true; + } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/CProjectSourceContainer.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/CProjectSourceContainer.java index fbee8afb064..a767873f698 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/CProjectSourceContainer.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/CProjectSourceContainer.java @@ -43,7 +43,7 @@ import org.eclipse.debug.core.sourcelookup.containers.FolderSourceContainer; * A project in the workspace. Source is searched for in the root project * folder and all folders within the project recursively. Optionally, * referenced projects may be searched as well. - * + * * Source elements returned from <code>findSourceElements(...)</code> are instances of * <code>IFile</code>. * <p> @@ -57,9 +57,8 @@ public class CProjectSourceContainer extends CompositeSourceContainer { * Unique identifier for the project source container type * (value <code>org.eclipse.cdt.debug.core.containerType.project</code>). */ - public static final String TYPE_ID = - CDebugCorePlugin.getUniqueIdentifier() + ".containerType.project"; //$NON-NLS-1$ - private final IProject fOwnProject; // Project assigned to this container at construction time. + public static final String TYPE_ID = CDebugCorePlugin.getUniqueIdentifier() + ".containerType.project"; //$NON-NLS-1$ + private final IProject fOwnProject; // Project assigned to this container at construction time. private IProject fProject; private boolean fSearchReferencedProjects; private URI fRootURI; @@ -68,7 +67,7 @@ public class CProjectSourceContainer extends CompositeSourceContainer { /** * Constructs a project source container. - * + * * @param project the project to search for source in * @param referenced whether referenced projects should be considered */ @@ -80,7 +79,7 @@ public class CProjectSourceContainer extends CompositeSourceContainer { /** * Returns the project this source container references. - * + * * @return the project this source container references */ public IProject getProject() { @@ -121,11 +120,11 @@ public class CProjectSourceContainer extends CompositeSourceContainer { ArrayList<Object> sources = new ArrayList<Object>(); - // An IllegalArgumentException is thrown from the "getFile" method - // if the path created by appending the file name to the container + // An IllegalArgumentException is thrown from the "getFile" method + // if the path created by appending the file name to the container // path doesn't conform with Eclipse resource restrictions. - // To prevent the interruption of the search procedure we check - // if the path is valid before passing it to "getFile". + // To prevent the interruption of the search procedure we check + // if the path is valid before passing it to "getFile". if (validateFile(name)) { IFile file = fProject.getFile(new Path(name)); if (file.exists()) { @@ -147,12 +146,12 @@ public class CProjectSourceContainer extends CompositeSourceContainer { } } else if (files.length > 0) { sources.add(files[0]); - } + } } } } - // Check sub-folders + // Check sub-folders if ((isFindDuplicates() && true) || (sources.isEmpty() && true)) { ISourceContainer[] containers = getSourceContainers(); for (int i = 0; i < containers.length; i++) { @@ -168,18 +167,18 @@ public class CProjectSourceContainer extends CompositeSourceContainer { break; } } - } - + } + if (sources.isEmpty()) return EMPTY; return sources.toArray(); } - + /* (non-Javadoc) * @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainer#getName() */ @Override - public String getName() { + public String getName() { return fProject != null ? fProject.getName() : InternalSourceLookupMessages.CProjectSourceContainer_0; } @@ -191,10 +190,10 @@ public class CProjectSourceContainer extends CompositeSourceContainer { if (obj != null && obj instanceof CProjectSourceContainer) { CProjectSourceContainer loc = (CProjectSourceContainer) obj; return fProject == null ? loc.fProject == null : fProject.equals(loc.fProject); - } + } return false; - } - + } + /* (non-Javadoc) * @see java.lang.Object#hashCode() */ @@ -229,7 +228,7 @@ public class CProjectSourceContainer extends CompositeSourceContainer { } } return containers.toArray(new ISourceContainer[containers.size()]); - } + } return createFolderSourceContainers(fProject); } return new ISourceContainer[0]; @@ -246,13 +245,13 @@ public class CProjectSourceContainer extends CompositeSourceContainer { ISourceContainer[] containers = list.toArray(new ISourceContainer[list.size()]); for (ISourceContainer container : containers) { container.init(getDirector()); - } + } return containers; } /** - * Validates the given string as a path for a file in this container. - * + * Validates the given string as a path for a file in this container. + * * @param name path name */ private boolean validateFile(String name) { @@ -265,7 +264,7 @@ public class CProjectSourceContainer extends CompositeSourceContainer { /** * Returns whether referenced projects are considered. - * + * * @return whether referenced projects are considered */ public boolean isSearchReferencedProjects() { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/ICSourceLocation.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/ICSourceLocation.java index 65b5fe1a06c..e8219007772 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/ICSourceLocation.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/ICSourceLocation.java @@ -17,7 +17,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; /** - * + * * A source location defines the location of a repository * of source code. A source location is capable of retrieving * source elements. @@ -25,56 +25,55 @@ import org.eclipse.core.runtime.IAdaptable; * For example, a source location could be a project, zip/archive * file, or a directory in the file system. * </p> - * + * * @since Sep 23, 2002 */ -public interface ICSourceLocation extends IAdaptable -{ +public interface ICSourceLocation extends IAdaptable { /** * Returns an object representing the source code * for a file with the specified name, or <code>null</code> - * if none could be found. The source element + * if none could be found. The source element * returned is implementation specific - for example, a * resource, a local file, a zip file entry, etc. - * + * * @param name the name of the object for which source is being searched for - * + * * @return source element * @exception CoreException if an exception occurs while searching for the specified source element */ - Object findSourceElement( String name ) throws CoreException; + Object findSourceElement(String name) throws CoreException; /** * Returns a memento for this source location from which this * source location can be reconstructed. - * + * * @return a memento for this source location * @exception CoreException if unable to create a memento */ String getMemento() throws CoreException; - + /** * Initializes this source location from the given memento. - * + * * @param memento a memento generated by this source location * @exception CoreException if unable to initialize this source * location */ - void initializeFrom( String memento ) throws CoreException; + void initializeFrom(String memento) throws CoreException; /** * Returns whether to search for all source elements, or just the first match. - * + * * @return whether to search for all source elements, or just the first match */ boolean searchForDuplicateFiles(); /** * Sets the value of the 'search for duplicate source files' flag. - * + * * @param search - a value to set */ - void setSearchForDuplicateFiles( boolean search ); + void setSearchForDuplicateFiles(boolean search); void dispose(); } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/ICSourceLocator.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/ICSourceLocator.java index f844b0d319b..6506ab2d22c 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/ICSourceLocator.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/ICSourceLocator.java @@ -19,78 +19,77 @@ import org.eclipse.debug.core.model.ISourceLocator; import org.eclipse.debug.core.model.IStackFrame; /** - * - * A C/C++ extension of <code>ISourceLocator</code>. + * + * A C/C++ extension of <code>ISourceLocator</code>. * Provides constants and methods to manage different source modes. - * + * * @since Aug 19, 2002 */ -public interface ICSourceLocator extends ISourceLocator -{ +public interface ICSourceLocator extends ISourceLocator { /** * Returns the project this source locator is associated with or <code>null</code>. - * + * * @return project this source locator is associated with or <code>null</code> */ IProject getProject(); /** - * Returns the line number of the instruction pointer in the specified - * stack frame that corresponds to a line in an associated source element, + * Returns the line number of the instruction pointer in the specified + * stack frame that corresponds to a line in an associated source element, * or -1 if line number information is unavailable. - * + * * @param frameInfo the frame data - * @return line number of instruction pointer in this stack frame, + * @return line number of instruction pointer in this stack frame, * or -1 if line number information is unavailable */ - int getLineNumber( IStackFrame stackFrame ); + int getLineNumber(IStackFrame stackFrame); /** * Returns the source locations of this locator. - * + * * @return the source locations of this locator */ ICSourceLocation[] getSourceLocations(); - + /** * Sets the source locations of this locator. - * + * * @param location - an array of source locations */ - void setSourceLocations( ICSourceLocation[] locations ); + void setSourceLocations(ICSourceLocation[] locations); /** * Returns whether this locator is able to locate the given resource. - * + * * @param resource the resource to locate * @return whether this locator is able to locate the given resource */ - boolean contains( IResource resource ); - + boolean contains(IResource resource); + /** * Returns an object representing the source code * for a type with the specified name, or <code>null</code> - * if none could be found. The source element + * if none could be found. The source element * returned is implementation specific - for example, a * resource, a local file, a zip file entry, etc. - * + * * @param name the name of the object for which source is being searched for - * + * * @return source element */ - Object findSourceElement( String fileName ); + Object findSourceElement(String fileName); /** * Returns whether to search for all source elements, or just the first match. - * + * * @return whether to search for all source elements, or just the first match */ boolean searchForDuplicateFiles(); /** * Sets the value of the 'search for duplicate source files' flag. - * + * * @param search - a value to set */ - void setSearchForDuplicateFiles( boolean search ); + void setSearchForDuplicateFiles(boolean search); } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/IDirectorySourceLocation.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/IDirectorySourceLocation.java index 36244a230ac..f60faeb101c 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/IDirectorySourceLocation.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/IDirectorySourceLocation.java @@ -16,13 +16,12 @@ package org.eclipse.cdt.debug.core.sourcelookup; import org.eclipse.core.runtime.IPath; /** - * + * * Enter type comment. - * + * * @since Dec 24, 2002 */ -public interface IDirectorySourceLocation extends ICSourceLocation -{ +public interface IDirectorySourceLocation extends ICSourceLocation { IPath getDirectory(); IPath getAssociation(); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/IMappingSourceContainer.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/IMappingSourceContainer.java index 2f75ef54aee..bed577d2647 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/IMappingSourceContainer.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/IMappingSourceContainer.java @@ -25,7 +25,7 @@ public interface IMappingSourceContainer extends ISourceContainer { /** * Returns path to the file as it appears in the debug information generated by the C/C++ * compiler. - * @param sourceName absolute filesystem path to a source or header file. + * @param sourceName absolute filesystem path to a source or header file. * @return path to the file as it appears in the debug information generated by the compiler. */ public IPath getCompilationPath(String sourceName); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/IProjectSourceLocation.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/IProjectSourceLocation.java index 49f6b5684d8..dea38e5b124 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/IProjectSourceLocation.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/IProjectSourceLocation.java @@ -16,13 +16,12 @@ package org.eclipse.cdt.debug.core.sourcelookup; import org.eclipse.core.resources.IProject; /** - * + * * Enter type comment. - * + * * @since Dec 24, 2002 */ -public interface IProjectSourceLocation extends ICSourceLocation -{ +public interface IProjectSourceLocation extends ICSourceLocation { IProject getProject(); boolean isGeneric(); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/ISourceLookupChangeListener.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/ISourceLookupChangeListener.java index afc8ac12459..9576db9b92c 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/ISourceLookupChangeListener.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/ISourceLookupChangeListener.java @@ -11,17 +11,17 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.core.sourcelookup; +package org.eclipse.cdt.debug.core.sourcelookup; import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; - /** - * A source lookup change listener is notified of changes in the source lookup path. - */ +/** +* A source lookup change listener is notified of changes in the source lookup path. +*/ public interface ISourceLookupChangeListener { /** * Notification that the source lookup containers have changed. */ - public void sourceContainersChanged( ISourceLookupDirector director ); + public void sourceContainersChanged(ISourceLookupDirector director); } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/MappingSourceContainer.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/MappingSourceContainer.java index ee15bacbbd0..4970a011730 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/MappingSourceContainer.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/MappingSourceContainer.java @@ -12,7 +12,7 @@ * QNX Software Systems - Initial API and implementation * Sergey Prigogin (Google) *******************************************************************************/ -package org.eclipse.cdt.debug.core.sourcelookup; +package org.eclipse.cdt.debug.core.sourcelookup; import java.util.ArrayList; import java.util.Arrays; @@ -30,7 +30,7 @@ import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.sourcelookup.ISourceContainer; import org.eclipse.debug.core.sourcelookup.ISourceContainerType; import org.eclipse.debug.core.sourcelookup.containers.AbstractSourceContainer; - + /** * The source container for path mappings. */ @@ -39,14 +39,14 @@ public class MappingSourceContainer extends AbstractSourceContainer implements I * Unique identifier for the mapping source container type * (value <code>org.eclipse.cdt.debug.core.containerType.mapping</code>). */ - public static final String TYPE_ID = CDebugCorePlugin.getUniqueIdentifier() + ".containerType.mapping"; //$NON-NLS-1$ + public static final String TYPE_ID = CDebugCorePlugin.getUniqueIdentifier() + ".containerType.mapping"; //$NON-NLS-1$ private String fName; private ArrayList<MapEntrySourceContainer> fContainers; private boolean fIsMappingWithBackendEnabled = true; - /** - * Constructor for MappingSourceContainer. + /** + * Constructor for MappingSourceContainer. */ public MappingSourceContainer(String name) { fName = name; @@ -106,16 +106,15 @@ public class MappingSourceContainer extends AbstractSourceContainer implements I if (objects.length == 1) { return objects; } - return new Object[]{ objects[0] }; + return new Object[] { objects[0] }; } } } catch (CoreException e) { if (single == null) { single = e; } else if (multiStatus == null) { - multiStatus = new MultiStatus(DebugPlugin.getUniqueIdentifier(), - DebugPlugin.INTERNAL_ERROR, new IStatus[] { single.getStatus() }, - SourceLookupMessages.MappingSourceContainer_0, null); + multiStatus = new MultiStatus(DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, + new IStatus[] { single.getStatus() }, SourceLookupMessages.MappingSourceContainer_0, null); multiStatus.add(e.getStatus()); } else { multiStatus.add(e.getStatus()); @@ -187,7 +186,7 @@ public class MappingSourceContainer extends AbstractSourceContainer implements I } return copy; } - + public void setName(String name) { fName = name; } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/ProgramRelativePathSourceContainer.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/ProgramRelativePathSourceContainer.java index b61b8fc0f6e..5edaffcacd9 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/ProgramRelativePathSourceContainer.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/ProgramRelativePathSourceContainer.java @@ -34,16 +34,16 @@ import org.eclipse.debug.core.ILaunchConfiguration; * A source container that converts relative paths to absolute ones using the * program (executable) location as the reference point. The conversion is * successful only if such a file actually exists. - * + * * @since 7.0 */ -public class ProgramRelativePathSourceContainer extends AbstractSourceContainer{ +public class ProgramRelativePathSourceContainer extends AbstractSourceContainer { /** * Unique identifier for the relative path source container type * (value <code>org.eclipse.cdt.debug.core.containerType.programRelativePath</code>). */ public static final String TYPE_ID = CDebugCorePlugin.getUniqueIdentifier() + ".containerType.programRelativePath"; //$NON-NLS-1$ - + /** * The program's path. */ @@ -54,7 +54,7 @@ public class ProgramRelativePathSourceContainer extends AbstractSourceContainer{ */ public ProgramRelativePathSourceContainer() { } - + /** * Special constructor used when trying to locate a source file without a * launch or launch configuration context, but when a Binary context is @@ -66,7 +66,7 @@ public class ProgramRelativePathSourceContainer extends AbstractSourceContainer{ * launch/launch-configuration context, it can explicitly create an instance * using this constructor and call our {@link #findSourceElements(String)} * method. - * + * * @param program * the executable context. Calling this with null is equivalent * to calling the default constructor. @@ -76,13 +76,13 @@ public class ProgramRelativePathSourceContainer extends AbstractSourceContainer{ fProgramPath = program.getPath(); } } - + /** * If [sourceName] is a relative path, and applying it to the location of * the program (executable) produces an absolute path that points to an * actual file, then we return a LocalFileStorage for that file. Otherwise * we return an empty array. We always return at most one element. - * + * * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#findSourceElements(java.lang.String) */ @Override @@ -90,13 +90,13 @@ public class ProgramRelativePathSourceContainer extends AbstractSourceContainer{ if (sourceName == null) { return new Object[0]; } - + // check if source path is a relative path IPath sourcePath = new Path(sourceName); if (sourcePath.isAbsolute()) { return new Object[0]; } - + // get program (executable) absolute path IPath programPath = getProgramLocation(); if (programPath == Path.EMPTY) { @@ -104,7 +104,7 @@ public class ProgramRelativePathSourceContainer extends AbstractSourceContainer{ } // remove the name of the program from the program path - programPath = programPath.removeLastSegments(1); + programPath = programPath.removeLastSegments(1); // append the relative source path to the absolute location of the program sourcePath = programPath.append(sourcePath); @@ -145,25 +145,28 @@ public class ProgramRelativePathSourceContainer extends AbstractSourceContainer{ if (configuration == null) { return fProgramPath; // return empty path } - + // Get current project. Unlike CDI, DSF supports debugging // executables that are not in an Eclipse project, so this may be // null or empty for a DSF session. See bugzilla 304433 and 344408. ICProject project = null; - String projectName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String) null); + String projectName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, + (String) null); if (projectName != null && projectName.length() != 0) { project = CoreModel.getDefault().getCModel().getCProject(projectName); if (project == null || !project.exists()) { return fProgramPath; // return empty path } } - + // get program name - String programName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String)null); + String programName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, + (String) null); if (programName == null) { return fProgramPath; // return empty path } - programName = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(programName); + programName = VariablesPlugin.getDefault().getStringVariableManager() + .performStringSubstitution(programName); // get executable file IFile exeFile = null; diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/SourceLookupFactory.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/SourceLookupFactory.java index 35023e4ccb1..d112f7d3ae7 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/SourceLookupFactory.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/SourceLookupFactory.java @@ -23,28 +23,24 @@ import org.eclipse.core.runtime.IPath; /** * Enter type comment. - * + * * @since Jul 14, 2003 */ -public class SourceLookupFactory -{ - public static IProjectSourceLocation createProjectSourceLocation( IProject project ) - { - return new CProjectSourceLocation( project ); +public class SourceLookupFactory { + public static IProjectSourceLocation createProjectSourceLocation(IProject project) { + return new CProjectSourceLocation(project); } - public static IProjectSourceLocation createProjectSourceLocation( IProject project, boolean generated ) - { - return new CProjectSourceLocation( project, generated ); + public static IProjectSourceLocation createProjectSourceLocation(IProject project, boolean generated) { + return new CProjectSourceLocation(project, generated); } - public static IDirectorySourceLocation createDirectorySourceLocation( IPath directory, IPath association, boolean searchSubfolders ) - { - return new CDirectorySourceLocation( directory, association, searchSubfolders ); + public static IDirectorySourceLocation createDirectorySourceLocation(IPath directory, IPath association, + boolean searchSubfolders) { + return new CDirectorySourceLocation(directory, association, searchSubfolders); } - public static ICSourceLocator createSourceLocator( IProject project ) - { - return new CSourceManager( new CSourceLocator( project ) ); + public static ICSourceLocator createSourceLocator(IProject project) { + return new CSourceManager(new CSourceLocator(project)); } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointNotifier.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointNotifier.java index 2f0b0f9bf74..756445aae91 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointNotifier.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointNotifier.java @@ -24,7 +24,7 @@ public class CBreakpointNotifier implements ICBreakpointListener { private static CBreakpointNotifier fInstance; public static CBreakpointNotifier getInstance() { - if ( fInstance == null ) { + if (fInstance == null) { fInstance = new CBreakpointNotifier(); } return fInstance; @@ -32,16 +32,16 @@ public class CBreakpointNotifier 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) { boolean result = true; Object[] listeners = CDebugCorePlugin.getDefault().getCBreakpointListeners(); - for( int i = 0; i < listeners.length; ++i ) { - if ( !((ICBreakpointListener)listeners[i]).installingBreakpoint( target, breakpoint ) ) + for (int i = 0; i < listeners.length; ++i) { + if (!((ICBreakpointListener) listeners[i]).installingBreakpoint(target, breakpoint)) result = false; } return result; @@ -49,40 +49,40 @@ public class CBreakpointNotifier implements ICBreakpointListener { /* * (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( IDebugTarget target, IBreakpoint breakpoint ) { + public void breakpointInstalled(IDebugTarget target, IBreakpoint breakpoint) { Object[] listeners = CDebugCorePlugin.getDefault().getCBreakpointListeners(); - for( int i = 0; i < listeners.length; ++i ) - ((ICBreakpointListener)listeners[i]).breakpointInstalled( target, breakpoint ); + for (int i = 0; i < listeners.length; ++i) + ((ICBreakpointListener) listeners[i]).breakpointInstalled(target, breakpoint); } /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.debug.core.ICBreakpointListener#breakpointChanged(org.eclipse.debug.core.model.IDebugTarget, * org.eclipse.debug.core.model.IBreakpoint) */ @Override - public void breakpointChanged( IDebugTarget target, IBreakpoint breakpoint, Map attributes ) { + public void breakpointChanged(IDebugTarget target, IBreakpoint breakpoint, Map attributes) { Object[] listeners = CDebugCorePlugin.getDefault().getCBreakpointListeners(); - for( int i = 0; i < listeners.length; ++i ) - ((ICBreakpointListener)listeners[i]).breakpointChanged( target, breakpoint, attributes ); + for (int i = 0; i < listeners.length; ++i) + ((ICBreakpointListener) listeners[i]).breakpointChanged(target, breakpoint, attributes); } /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.debug.core.ICBreakpointListener#breakpointsRemoved(org.eclipse.debug.core.model.IDebugTarget, * org.eclipse.debug.core.model.IBreakpoint[]) */ @Override - public void breakpointsRemoved( IDebugTarget target, IBreakpoint[] breakpoints ) { + public void breakpointsRemoved(IDebugTarget target, IBreakpoint[] breakpoints) { Object[] listeners = CDebugCorePlugin.getDefault().getCBreakpointListeners(); - for( int i = 0; i < listeners.length; ++i ) - ((ICBreakpointListener)listeners[i]).breakpointsRemoved( target, breakpoints ); + for (int i = 0; i < listeners.length; ++i) + ((ICBreakpointListener) listeners[i]).breakpointsRemoved(target, breakpoints); } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugCorePreferenceInitializer.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugCorePreferenceInitializer.java index 53596f29360..2ac19c0bcd0 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugCorePreferenceInitializer.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugCorePreferenceInitializer.java @@ -13,7 +13,7 @@ * Ken Ryall (Nokia) - 207675 * Mathias Kunter - Using adequate default charsets (bug 370462) *******************************************************************************/ -package org.eclipse.cdt.debug.internal.core; +package org.eclipse.cdt.debug.internal.core; import java.nio.charset.Charset; @@ -23,14 +23,14 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; import org.eclipse.core.runtime.preferences.DefaultScope; import org.eclipse.core.runtime.preferences.IEclipsePreferences; - + /** * Default preference value initializer for <code>CDebugCorePlugin</code>. */ public class CDebugCorePreferenceInitializer extends AbstractPreferenceInitializer { - /** - * Constructor for CDebugCorePreferenceInitializer. + /** + * Constructor for CDebugCorePreferenceInitializer. */ public CDebugCorePreferenceInitializer() { super(); @@ -42,8 +42,9 @@ public class CDebugCorePreferenceInitializer extends AbstractPreferenceInitializ @Override public void initializeDefaultPreferences() { IEclipsePreferences defaultPreferences = DefaultScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID); - - defaultPreferences.putInt(ICDebugConstants.PREF_MAX_NUMBER_OF_INSTRUCTIONS, ICDebugConstants.DEF_NUMBER_OF_INSTRUCTIONS); + + defaultPreferences.putInt(ICDebugConstants.PREF_MAX_NUMBER_OF_INSTRUCTIONS, + ICDebugConstants.DEF_NUMBER_OF_INSTRUCTIONS); defaultPreferences.put(ICDebugConstants.PREF_DEBUG_CHARSET, Charset.defaultCharset().name()); if (Platform.getOS().equals(Platform.OS_WIN32)) { defaultPreferences.put(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET, "UTF-16"); //$NON-NLS-1$ diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CRequest.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CRequest.java index e3f834b22d1..c6567221822 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CRequest.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CRequest.java @@ -26,12 +26,13 @@ import org.eclipse.debug.core.IRequest; public class CRequest implements IRequest { private IStatus fStatus; private boolean fCanceled; + /* * @see org.eclipse.debug.core.IRequest#cancel() */ @Override public void cancel() { - fCanceled= true; + fCanceled = true; } /* @@ -62,7 +63,7 @@ public class CRequest implements IRequest { */ @Override public void setStatus(IStatus status) { - fStatus= status; + fStatus = status; } /** @@ -72,8 +73,8 @@ public class CRequest implements IRequest { * ERROR or CANCEL), it is considered a failure. Note that as per IRequest * documentation, a null status object is equivalent to IStatu#OK. */ - public boolean isSuccess() { - IStatus status = getStatus(); - return !isCanceled() && (status == null || status.getSeverity() <= IStatus.INFO); - } + public boolean isSuccess() { + IStatus status = getStatus(); + return !isCanceled() && (status == null || status.getSeverity() <= IStatus.INFO); + } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/DebugModelProvider.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/DebugModelProvider.java index 02ad3350046..3be002a3846 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/DebugModelProvider.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/DebugModelProvider.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,32 +19,32 @@ import org.eclipse.core.runtime.IAdapterFactory; import org.eclipse.debug.core.model.IDebugModelProvider; /** - * Debug model provider returns additional model ID to use with + * Debug model provider returns additional model ID to use with * GDB event breakpoints. */ public class DebugModelProvider implements IDebugModelProvider, IAdapterFactory { - private final static Class<?>[] ADAPTER_LIST = new Class[] { IDebugModelProvider.class }; - private final static String GDB_MODEL_ID = "org.eclipse.cdt.gdb"; //$NON-NLS-1$ - private final static String[] MODEL_IDS = new String[] { CDIDebugModel.getPluginIdentifier(), GDB_MODEL_ID }; - - @Override - public String[] getModelIdentifiers() { - return MODEL_IDS; - } - - @SuppressWarnings("unchecked") + private final static Class<?>[] ADAPTER_LIST = new Class[] { IDebugModelProvider.class }; + private final static String GDB_MODEL_ID = "org.eclipse.cdt.gdb"; //$NON-NLS-1$ + private final static String[] MODEL_IDS = new String[] { CDIDebugModel.getPluginIdentifier(), GDB_MODEL_ID }; + + @Override + public String[] getModelIdentifiers() { + return MODEL_IDS; + } + + @SuppressWarnings("unchecked") @Override - public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) { - if ( adaptableObject instanceof ICDebugElement && IDebugModelProvider.class.equals(adapterType) ) { - return (T) this; - } - return null; - } - - @Override - public Class<?>[] getAdapterList() { - return ADAPTER_LIST; - } - + public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) { + if (adaptableObject instanceof ICDebugElement && IDebugModelProvider.class.equals(adapterType)) { + return (T) this; + } + return null; + } + + @Override + public Class<?>[] getAdapterList() { + return ADAPTER_LIST; + } + } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/DebugStringVariableSubstitutor.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/DebugStringVariableSubstitutor.java index 90e87cabf09..17c8db6bab7 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/DebugStringVariableSubstitutor.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/DebugStringVariableSubstitutor.java @@ -29,7 +29,7 @@ import org.eclipse.core.variables.VariablesPlugin; /** * String variable substitutor that resolves project_name, project_loc and project_path variables * in the context of the given project. Resolution of all other variables is delegated to - * the default string variable manager. + * the default string variable manager. */ public class DebugStringVariableSubstitutor implements IStringVariableManager { private static class ProjectVariable implements IDynamicVariable { @@ -102,7 +102,8 @@ public class DebugStringVariableSubstitutor implements IStringVariableManager { * selection. */ public DebugStringVariableSubstitutor(String projectName) { - this(projectName == null || projectName.isEmpty() ? null : ResourcesPlugin.getWorkspace().getRoot().getProject(projectName)); + this(projectName == null || projectName.isEmpty() ? null + : ResourcesPlugin.getWorkspace().getRoot().getProject(projectName)); } public IStringVariable[] getVariables() { @@ -154,10 +155,9 @@ public class DebugStringVariableSubstitutor implements IStringVariableManager { return performStringSubstitution(expression, true); } - public String performStringSubstitution(String expression, boolean reportUndefinedVariables) - throws CoreException { - return new StringSubstitutionEngine().performStringSubstitution(expression, - reportUndefinedVariables, true, this); + public String performStringSubstitution(String expression, boolean reportUndefinedVariables) throws CoreException { + return new StringSubstitutionEngine().performStringSubstitution(expression, reportUndefinedVariables, true, + this); } public void validateStringVariables(String expression) throws CoreException { @@ -168,8 +168,7 @@ public class DebugStringVariableSubstitutor implements IStringVariableManager { return variableManager.newValueVariable(name, description); } - public IValueVariable newValueVariable(String name, String description, boolean readOnly, - String value) { + public IValueVariable newValueVariable(String name, String description, boolean readOnly, String value) { return variableManager.newValueVariable(name, description, readOnly, value); } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/ICDebugInternalConstants.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/ICDebugInternalConstants.java index b0612da2132..762664e5423 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/ICDebugInternalConstants.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/ICDebugInternalConstants.java @@ -33,12 +33,14 @@ public class ICDebugInternalConstants { * This preference is superseded by PREF_DEFAULT_SOURCE_CONTAINERS. Kept for backward * compatibility only. */ - public static final String PREF_COMMON_SOURCE_CONTAINERS = CDebugCorePlugin.getUniqueIdentifier() + ".cDebug.common_source_containers"; //$NON-NLS-1$ + public static final String PREF_COMMON_SOURCE_CONTAINERS = CDebugCorePlugin.getUniqueIdentifier() + + ".cDebug.common_source_containers"; //$NON-NLS-1$ /** * String preference for the default source containers. */ - public static final String PREF_DEFAULT_SOURCE_CONTAINERS = CDebugCorePlugin.getUniqueIdentifier() + ".cDebug.default_source_containers"; //$NON-NLS-1$ + public static final String PREF_DEFAULT_SOURCE_CONTAINERS = CDebugCorePlugin.getUniqueIdentifier() + + ".cDebug.default_source_containers"; //$NON-NLS-1$ /** * Boolean preference indicating the on/off state of the Show Full Paths @@ -46,14 +48,14 @@ public class ICDebugInternalConstants { * state is preserved for each view, the full preference key is the view ID * plus this key */ - public static final String SHOW_FULL_PATHS_PREF_KEY = "org.eclipse.cdt.debug.ui.cDebug.show_full_paths"; //$NON-NLS-1$ - + public static final String SHOW_FULL_PATHS_PREF_KEY = "org.eclipse.cdt.debug.ui.cDebug.show_full_paths"; //$NON-NLS-1$ + /** - * An attribute set by a non-ICBreakpoint to support fullpath capability in the Breakpoints view. - * If this attribute exists, not <code>null</code>, in the breakpoint marker or the breakpoint is an - * ICBreakpoint type, then the show fullpath action in the Breakpoints view is enabled, otherwise - * disabled. The show fullpath action does not toggle the value of this breakpoint attribute, it is - * the breakpoint's responsibility to monitor the SHOW_FULL_PATHS_PREF_KEY value change and update + * An attribute set by a non-ICBreakpoint to support fullpath capability in the Breakpoints view. + * If this attribute exists, not <code>null</code>, in the breakpoint marker or the breakpoint is an + * ICBreakpoint type, then the show fullpath action in the Breakpoints view is enabled, otherwise + * disabled. The show fullpath action does not toggle the value of this breakpoint attribute, it is + * the breakpoint's responsibility to monitor the SHOW_FULL_PATHS_PREF_KEY value change and update * the breakpoint presentation in the Breakpoints view. */ public static final String ATTR_CAPABLE_OF_SHOW_FULL_PATHS = "org.eclipse.cdt.debug.ui.cDebug.capable_of_show_full_paths"; //$NON-NLS-1$ diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/ICWatchpointTarget.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/ICWatchpointTarget.java index dfca555c5e4..44a9e59278d 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/ICWatchpointTarget.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/ICWatchpointTarget.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 *******************************************************************************/ @@ -15,7 +15,7 @@ package org.eclipse.cdt.debug.internal.core; /** * @deprecated This interface has been moved to a public package. Use - * {@link org.eclipse.cdt.debug.core.ICWatchpointTarget} instead. + * {@link org.eclipse.cdt.debug.core.ICWatchpointTarget} instead. */ public interface ICWatchpointTarget extends org.eclipse.cdt.debug.core.ICWatchpointTarget { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/ListenerList.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/ListenerList.java index beed1584cb0..cd84d0771bc 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/ListenerList.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/ListenerList.java @@ -28,26 +28,26 @@ public class ListenerList { * to an array of size capacity the first time a listener is added. * Maintains invariant: listeners != null if and only if fSize != 0 */ - private Object[] fListeners= null; + private Object[] fListeners = null; /** * The empty array singleton instance, returned by getListeners() * when size == 0. */ - private static final Object[] EmptyArray= new Object[0]; + private static final Object[] EmptyArray = new Object[0]; /** * Creates a listener list with the given initial capacity. * - * @param capacity the number of listeners which this list can initially accept + * @param capacity the number of listeners which this list can initially accept * without growing its internal representation; must be at least 1 */ public ListenerList(int capacity) { if (capacity < 1) { throw new IllegalArgumentException(); } - fListeners= new Object[capacity]; - fSize= 0; + fListeners = new Object[capacity]; + fSize = 0; } /** @@ -61,18 +61,18 @@ public class ListenerList { throw new IllegalArgumentException(); } // check for duplicates using identity - for (int i= 0; i < fSize; ++i) { + for (int i = 0; i < fSize; ++i) { if (fListeners[i] == listener) { return; } } // grow array if necessary if (fSize == fListeners.length) { - Object[] temp= new Object[(fSize * 2) + 1]; + Object[] temp = new Object[(fSize * 2) + 1]; System.arraycopy(fListeners, 0, temp, 0, fSize); - fListeners= temp; + fListeners = temp; } - fListeners[fSize++]= listener; + fListeners[fSize++] = listener; } /** @@ -88,7 +88,7 @@ public class ListenerList { if (fSize == 0) { return EmptyArray; } - Object[] result= new Object[fSize]; + Object[] result = new Object[fSize]; System.arraycopy(fListeners, 0, result, 0, fSize); return result; } @@ -104,15 +104,15 @@ public class ListenerList { throw new IllegalArgumentException(); } - for (int i= 0; i < fSize; ++i) { + for (int i = 0; i < fSize; ++i) { if (fListeners[i] == listener) { if (--fSize == 0) { - fListeners= new Object[1]; + fListeners = new Object[1]; } else { if (i < fSize) { - fListeners[i]= fListeners[fSize]; + fListeners[i] = fListeners[fSize]; } - fListeners[fSize]= null; + fListeners[fSize] = null; } return; } @@ -123,8 +123,8 @@ public class ListenerList { * Removes all the listeners from the list. */ public void removeAll() { - fListeners= new Object[0]; - fSize= 0; + fListeners = new Object[0]; + fSize = 0; } /** @@ -136,4 +136,3 @@ public class ListenerList { return fSize; } } - diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/RegisterGroupsPersistance.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/RegisterGroupsPersistance.java index 33c7351008f..95e68ea958d 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/RegisterGroupsPersistance.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/RegisterGroupsPersistance.java @@ -88,7 +88,7 @@ public class RegisterGroupsPersistance { public boolean isEnabled() { return fEnabled; } - + @Override public String getContainerId() { return fContainerId; @@ -160,7 +160,7 @@ public class RegisterGroupsPersistance { return fLaunchConfigTargetAttribute; } - + /** * Parse register groups. * If given containerId is not null, the only returned register groups are the one @@ -169,41 +169,41 @@ public class RegisterGroupsPersistance { public IRegisterGroupDescriptor[] parseGroups(String containerId) throws CoreException { List<IRegisterGroupDescriptor> groups = new ArrayList<IRegisterGroupDescriptor>(); String memento; - + memento = fLaunchConfig.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_REGISTER_GROUPS, DEFAULT_ATTR_DEBUGGER_REGISTER_GROUPS_VALUE); - if (memento != null && memento.length() > 0) { - Node node = DebugPlugin.parseDocument(memento); + if (memento != null && memento.length() > 0) { + Node node = DebugPlugin.parseDocument(memento); - if (node.getNodeType() != Node.ELEMENT_NODE) { - abort("Unable to restore register groups - invalid memento.", null); //$NON-NLS-1$ - } - Element element = (Element) node; - if (!ELEMENT_REGISTER_GROUP_LIST.equals(element.getNodeName())) { - abort("Unable to restore register groups - expecting register group list element.", null); //$NON-NLS-1$ - } + if (node.getNodeType() != Node.ELEMENT_NODE) { + abort("Unable to restore register groups - invalid memento.", null); //$NON-NLS-1$ + } + Element element = (Element) node; + if (!ELEMENT_REGISTER_GROUP_LIST.equals(element.getNodeName())) { + abort("Unable to restore register groups - expecting register group list element.", null); //$NON-NLS-1$ + } - Node childNode = element.getFirstChild(); - while (childNode != null) { - if (childNode.getNodeType() == Node.ELEMENT_NODE) { - Element child = (Element) childNode; - if (ELEMENT_GROUP.equals(child.getNodeName())) { - String groupMemento = child.getAttribute(ATTR_REGISTER_GROUP_MEMENTO); - - IRegisterGroupDescriptor groupdesc = createGroupFromMemento(groupMemento); - if (groupdesc != null) { - if(containerId == null || containerId.equals(groupdesc.getContainerId())) { - groups.add(groupdesc); - } + Node childNode = element.getFirstChild(); + while (childNode != null) { + if (childNode.getNodeType() == Node.ELEMENT_NODE) { + Element child = (Element) childNode; + if (ELEMENT_GROUP.equals(child.getNodeName())) { + String groupMemento = child.getAttribute(ATTR_REGISTER_GROUP_MEMENTO); + + IRegisterGroupDescriptor groupdesc = createGroupFromMemento(groupMemento); + if (groupdesc != null) { + if (containerId == null || containerId.equals(groupdesc.getContainerId())) { + groups.add(groupdesc); } } } - childNode = childNode.getNextSibling(); } - + childNode = childNode.getNextSibling(); } + } + return groups.toArray(new IRegisterGroupDescriptor[groups.size()]); } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/StringSubstitutionEngine.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/StringSubstitutionEngine.java index 12d3dd9fce6..c925fa2ee40 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/StringSubstitutionEngine.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/StringSubstitutionEngine.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 * Sergey Prigogin (Google) @@ -35,47 +35,47 @@ import org.eclipse.osgi.util.NLS; public class StringSubstitutionEngine { // Delimiters. private static final String VARIABLE_START = "${"; //$NON-NLS-1$ - private static final char VARIABLE_END = '}'; - private static final char VARIABLE_ARG = ':'; + private static final char VARIABLE_END = '}'; + private static final char VARIABLE_ARG = ':'; // Parsing states. private static final int SCAN_FOR_START = 0; private static final int SCAN_FOR_END = 1; - + /** * Resulting string */ private StringBuilder fResult; - + /** * Whether substitutions were performed */ private boolean fSubs; - + /** * Stack of variables to resolve */ private Stack<VariableReference> fStack; - + class VariableReference { // The text inside the variable reference. private StringBuilder fText; - + public VariableReference() { fText = new StringBuilder(); } - + public void append(String text) { fText.append(text); } - + public String getText() { return fText.toString(); } } - + /** * Performs recursive string substitution and returns the resulting string. - * + * * @param expression expression to resolve * @param reportUndefinedVariables whether to report undefined variables as an error * @param resolveVariables if the variables should be resolved during the substitution @@ -89,8 +89,8 @@ public class StringSubstitutionEngine { substitute(expression, reportUndefinedVariables, resolveVariables, manager); List<HashSet<String>> resolvedVariableSets = new ArrayList<HashSet<String>>(); while (fSubs) { - HashSet<String> resolved = substitute(fResult.toString(), reportUndefinedVariables, true, manager); - + HashSet<String> resolved = substitute(fResult.toString(), reportUndefinedVariables, true, manager); + for (int i = resolvedVariableSets.size(); --i >= 0;) { HashSet<String> prevSet = resolvedVariableSets.get(i); @@ -99,24 +99,26 @@ public class StringSubstitutionEngine { for (HashSet<String> set : resolvedVariableSets) { conflictingSet.addAll(set); } - + StringBuilder problemVariableList = new StringBuilder(); for (String var : conflictingSet) { problemVariableList.append(var.toString()); problemVariableList.append(", "); //$NON-NLS-1$ } problemVariableList.setLength(problemVariableList.length() - 2); // Truncate the last ", " - throw new CoreException(new Status(IStatus.ERROR, - CDebugCorePlugin.getUniqueIdentifier(), CDebugCorePlugin.INTERNAL_ERROR, - NLS.bind(InternalDebugCoreMessages.StringSubstitutionEngine_undefined_variable, problemVariableList.toString()), null)); - } - } - - resolvedVariableSets.add(resolved); + throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), + CDebugCorePlugin.INTERNAL_ERROR, + NLS.bind(InternalDebugCoreMessages.StringSubstitutionEngine_undefined_variable, + problemVariableList.toString()), + null)); + } + } + + resolvedVariableSets.add(resolved); } return fResult.toString(); } - + /** * Performs recursive string validation to ensure that all of the variables * contained in the expression exist. @@ -126,15 +128,14 @@ public class StringSubstitutionEngine { * @exception CoreException if a referenced variable does not exist or if a cycle exists * in referenced variables */ - public void validateStringVariables(String expression, IStringVariableManager manager) - throws CoreException { + public void validateStringVariables(String expression, IStringVariableManager manager) throws CoreException { performStringSubstitution(expression, true, false, manager); } - + /** * Makes a substitution pass of the given expression returns a Set of the variables that were * resolved in this pass. - * + * * @param expression source expression * @param reportUndefinedVariables whether to report undefined variables as an error * @param resolveVariables whether to resolve the value of any variables @@ -142,79 +143,79 @@ public class StringSubstitutionEngine { * @return the set of {@link String}s resolved from the given expression * @exception CoreException if unable to resolve a variable */ - private HashSet<String> substitute(String expression, boolean reportUndefinedVariables, - boolean resolveVariables, IStringVariableManager manager) throws CoreException { + private HashSet<String> substitute(String expression, boolean reportUndefinedVariables, boolean resolveVariables, + IStringVariableManager manager) throws CoreException { fResult = new StringBuilder(expression.length()); fStack = new Stack<VariableReference>(); fSubs = false; - + HashSet<String> resolvedVariables = new HashSet<String>(); int pos = 0; int state = SCAN_FOR_START; while (pos < expression.length()) { switch (state) { - case SCAN_FOR_START: - int start = expression.indexOf(VARIABLE_START, pos); - if (start >= 0) { + case SCAN_FOR_START: + int start = expression.indexOf(VARIABLE_START, pos); + if (start >= 0) { + int length = start - pos; + // Copy non-variable text to the result. + if (length > 0) { + fResult.append(expression.substring(pos, start)); + } + pos = start + 2; + state = SCAN_FOR_END; + + fStack.push(new VariableReference()); + } else { + // Done - no more variables. + fResult.append(expression.substring(pos)); + pos = expression.length(); + } + break; + case SCAN_FOR_END: + // Be careful of nested variables. + start = expression.indexOf(VARIABLE_START, pos); + int end = expression.indexOf(VARIABLE_END, pos); + if (end < 0) { + // Variables are not completed. + VariableReference tos = fStack.peek(); + tos.append(expression.substring(pos)); + pos = expression.length(); + } else { + if (start >= 0 && start < end) { + // Start of a nested variable. int length = start - pos; - // Copy non-variable text to the result. if (length > 0) { - fResult.append(expression.substring(pos, start)); + VariableReference tos = fStack.peek(); + tos.append(expression.substring(pos, start)); } pos = start + 2; - state = SCAN_FOR_END; - - fStack.push(new VariableReference()); + fStack.push(new VariableReference()); } else { - // Done - no more variables. - fResult.append(expression.substring(pos)); - pos = expression.length(); - } - break; - case SCAN_FOR_END: - // Be careful of nested variables. - start = expression.indexOf(VARIABLE_START, pos); - int end = expression.indexOf(VARIABLE_END, pos); - if (end < 0) { - // Variables are not completed. - VariableReference tos = fStack.peek(); - tos.append(expression.substring(pos)); - pos = expression.length(); - } else { - if (start >= 0 && start < end) { - // Start of a nested variable. - int length = start - pos; - if (length > 0) { - VariableReference tos = fStack.peek(); - tos.append(expression.substring(pos, start)); - } - pos = start + 2; - fStack.push(new VariableReference()); + // End of variable reference. + VariableReference tos = fStack.pop(); + String substring = expression.substring(pos, end); + tos.append(substring); + resolvedVariables.add(substring); + + pos = end + 1; + String value = resolve(tos, reportUndefinedVariables, resolveVariables, manager); + if (value == null) { + value = ""; //$NON-NLS-1$ + } + if (fStack.isEmpty()) { + // Append to result. + fResult.append(value); + state = SCAN_FOR_START; } else { - // End of variable reference. - VariableReference tos = fStack.pop(); - String substring = expression.substring(pos, end); - tos.append(substring); - resolvedVariables.add(substring); - - pos = end + 1; - String value= resolve(tos, reportUndefinedVariables, resolveVariables, manager); - if (value == null) { - value = ""; //$NON-NLS-1$ - } - if (fStack.isEmpty()) { - // Append to result. - fResult.append(value); - state = SCAN_FOR_START; - } else { - // Append to previous variable. - tos = fStack.peek(); - tos.append(value); - } + // Append to previous variable. + tos = fStack.peek(); + tos.append(value); } } - break; + } + break; } } // Process incomplete variable references. @@ -229,14 +230,13 @@ public class StringSubstitutionEngine { var.append(tos.getText()); } } - return resolvedVariables; } /** - * Resolve and return the value of the given variable reference, possibly {@code null}. - * + * Resolve and return the value of the given variable reference, possibly {@code null}. + * * @param var the {@link VariableReference} to try and resolve * @param reportUndefinedVariables whether to report undefined variables as an error * @param resolveVariables whether to resolve the variables value or just to validate that @@ -245,8 +245,8 @@ public class StringSubstitutionEngine { * @return variable value, possibly {@code null} * @exception CoreException if unable to resolve a value */ - private String resolve(VariableReference var, boolean reportUndefinedVariables, - boolean resolveVariables, IStringVariableManager manager) throws CoreException { + private String resolve(VariableReference var, boolean reportUndefinedVariables, boolean resolveVariables, + IStringVariableManager manager) throws CoreException { String text = var.getText(); int pos = text.indexOf(VARIABLE_ARG); String name = null; @@ -256,7 +256,7 @@ public class StringSubstitutionEngine { pos++; if (pos < text.length()) { arg = text.substring(pos); - } + } } else { name = text; } @@ -266,35 +266,37 @@ public class StringSubstitutionEngine { if (dynamicVariable == null) { // No variables with the given name. if (reportUndefinedVariables) { - throw new CoreException(new Status(IStatus.ERROR, - CDebugCorePlugin.getUniqueIdentifier(), CDebugCorePlugin.INTERNAL_ERROR, - NLS.bind(InternalDebugCoreMessages.StringSubstitutionEngine_undefined_variable, name), null)); - } + throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), + CDebugCorePlugin.INTERNAL_ERROR, + NLS.bind(InternalDebugCoreMessages.StringSubstitutionEngine_undefined_variable, name), + null)); + } // Leave as is. return getOriginalVarText(var); - } - + } + if (resolveVariables) { fSubs = true; return dynamicVariable.getValue(arg); - } + } // Leave as is. return getOriginalVarText(var); - } - + } + if (arg == null) { if (resolveVariables) { fSubs = true; return valueVariable.getValue(); - } + } // Leave as is. return getOriginalVarText(var); - } + } // Error - an argument specified for a value variable. - throw new CoreException(new Status(IStatus.ERROR, - CDebugCorePlugin.getUniqueIdentifier(), CDebugCorePlugin.INTERNAL_ERROR, - NLS.bind(InternalDebugCoreMessages.StringSubstitutionEngine_unexpected_argument, - valueVariable.getName()), null)); + throw new CoreException( + new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), CDebugCorePlugin.INTERNAL_ERROR, + NLS.bind(InternalDebugCoreMessages.StringSubstitutionEngine_unexpected_argument, + valueVariable.getName()), + null)); } private String getOriginalVarText(VariableReference var) { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/Trace.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/Trace.java index 5b71208fcd9..c0e63372f10 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/Trace.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/Trace.java @@ -27,16 +27,16 @@ import org.osgi.util.tracker.ServiceTracker; * utility for troubleshooting race condition bugs. Each trace statement * contains the thread and the time (in millisecond granularity). The trace goes * to the file: {workspace}/.metadata/trace.log - * + * * <p> * For performance reasons, trace statements should explicitly check a trace * flag before calling into a DebugTrace method. E.g., - * + * * <p> * <code> * if (Trace.DEBUG_EXECUTABLES) DebugTrace.getTrace.trace(null, ...); * </code> - * + * * <p> * The alternative is to have DebugTrace check the debug option for you (i.e., * don't pass null for first param), but this incurs a relatively heavy price @@ -44,12 +44,12 @@ import org.osgi.util.tracker.ServiceTracker; * asking DebugTrace to do the check is that is that it supports trace options * changing during the workbench lifetime. However that's an unlikely and * esoteric scenario. - * + * * <p> * This class is also a central location for trace flags. They are public static * fields, so checking them in trace statements is very efficient. They are set * at plugin startup. - * + * * <p> * DebugTrace objects are particular to a plugin. Plugins can reuse most of this * class definition. However, since it's all based on static methods and fields, @@ -70,21 +70,36 @@ public class Trace { */ private static final DebugTrace NULL_TRACE = new DebugTrace() { @Override - public void trace(String option, String message) {} + public void trace(String option, String message) { + } + @Override - public void trace(String option, String message, Throwable error) {} + public void trace(String option, String message, Throwable error) { + } + @Override - public void traceDumpStack(String option) {} + public void traceDumpStack(String option) { + } + @Override - public void traceEntry(String option) {} + public void traceEntry(String option) { + } + @Override - public void traceEntry(String option, Object methodArgument) {} + public void traceEntry(String option, Object methodArgument) { + } + @Override - public void traceEntry(String option, Object[] methodArguments) {} + public void traceEntry(String option, Object[] methodArguments) { + } + @Override - public void traceExit(String option) {} + public void traceExit(String option) { + } + @Override - public void traceExit(String option, Object result) {} + public void traceExit(String option, Object result) { + } }; /** Should be called by plugin's startup method() */ @@ -94,13 +109,14 @@ public class Trace { String option = Platform.getDebugOption(CDebugCorePlugin.PLUGIN_ID + "/debug/executables"); //$NON-NLS-1$ DEBUG_EXECUTABLES = DEBUG && ((option != null) ? option.equalsIgnoreCase("true") : false); //$NON-NLS-1$ } + /** Singleton trace object */ private static DebugTrace trace; /** * Gets the singleton trace object, or a null trace object if a real one * isn't available - * + * * @return trace object; never null */ synchronized public static DebugTrace getTrace() { @@ -111,15 +127,15 @@ public class Trace { if (bundle != null) { BundleContext context = bundle.getBundleContext(); if (context != null) { - ServiceTracker<DebugOptions, DebugOptions> tracker = new ServiceTracker<DebugOptions, DebugOptions>(context, DebugOptions.class.getName(), null); + ServiceTracker<DebugOptions, DebugOptions> tracker = new ServiceTracker<DebugOptions, DebugOptions>( + context, DebugOptions.class.getName(), null); try { tracker.open(); DebugOptions debugOptions = tracker.getService(); if (debugOptions != null) { trace = debugOptions.newDebugTrace(bundle.getSymbolicName()); } - } - finally { + } finally { tracker.close(); } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/AbstractDynamicPrintf.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/AbstractDynamicPrintf.java index cec7bb86934..f6a59ff194d 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/AbstractDynamicPrintf.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/AbstractDynamicPrintf.java @@ -22,7 +22,7 @@ import org.eclipse.core.runtime.CoreException; /** * Base class for different types of location DynamicPrintf. - * + * * @since 7.5 */ public abstract class AbstractDynamicPrintf extends AbstractLineBreakpoint implements ICDynamicPrintf { @@ -31,25 +31,25 @@ public abstract class AbstractDynamicPrintf extends AbstractLineBreakpoint imple super(); } - public AbstractDynamicPrintf( IResource resource, Map<String, Object> attributes, boolean add ) throws CoreException { - super( resource, attributes, add ); + public AbstractDynamicPrintf(IResource resource, Map<String, Object> attributes, boolean add) throws CoreException { + super(resource, attributes, add); } - + /* * (non-Javadoc) * @see org.eclipse.cdt.debug.core.ICDynamicPrintf#getPrintfString() */ @Override public String getPrintfString() throws CoreException { - return ensureMarker().getAttribute( PRINTF_STRING, "" ); //$NON-NLS-1$ + return ensureMarker().getAttribute(PRINTF_STRING, ""); //$NON-NLS-1$ } /* * (non-Javadoc) * @see org.eclipse.cdt.debug.core.ICDynamicPrintf#setPrintfString(String) */ - public void setPrintfString( String str ) throws CoreException { - setAttribute( PRINTF_STRING, str ); - setAttribute( IMarker.MESSAGE, getMarkerMessage() ); + public void setPrintfString(String str) throws CoreException { + setAttribute(PRINTF_STRING, str); + setAttribute(IMarker.MESSAGE, getMarkerMessage()); } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/AbstractLineBreakpoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/AbstractLineBreakpoint.java index 8378073ffdd..7ebd76d5a59 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/AbstractLineBreakpoint.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/AbstractLineBreakpoint.java @@ -45,8 +45,9 @@ public abstract class AbstractLineBreakpoint extends CBreakpoint implements ICLi * @param add * @throws CoreException */ - public AbstractLineBreakpoint( IResource resource, Map<String, Object> attributes, boolean add ) throws CoreException { - super( resource, attributes, add ); + public AbstractLineBreakpoint(IResource resource, Map<String, Object> attributes, boolean add) + throws CoreException { + super(resource, attributes, add); } /*(non-Javadoc) @@ -54,7 +55,7 @@ public abstract class AbstractLineBreakpoint extends CBreakpoint implements ICLi */ @Override public int getLineNumber() throws CoreException { - return ensureMarker().getAttribute( IMarker.LINE_NUMBER, -1 ); + return ensureMarker().getAttribute(IMarker.LINE_NUMBER, -1); } /*(non-Javadoc) @@ -62,7 +63,7 @@ public abstract class AbstractLineBreakpoint extends CBreakpoint implements ICLi */ @Override public int getCharStart() throws CoreException { - return ensureMarker().getAttribute( IMarker.CHAR_START, -1 ); + return ensureMarker().getAttribute(IMarker.CHAR_START, -1); } /*(non-Javadoc) @@ -70,7 +71,7 @@ public abstract class AbstractLineBreakpoint extends CBreakpoint implements ICLi */ @Override public int getCharEnd() throws CoreException { - return ensureMarker().getAttribute( IMarker.CHAR_END, -1 ); + return ensureMarker().getAttribute(IMarker.CHAR_END, -1); } /* (non-Javadoc) @@ -78,159 +79,159 @@ public abstract class AbstractLineBreakpoint extends CBreakpoint implements ICLi */ @Override public String getAddress() throws CoreException { - return ensureMarker().getAttribute( ICLineBreakpoint.ADDRESS, "" ); //$NON-NLS-1$ + return ensureMarker().getAttribute(ICLineBreakpoint.ADDRESS, ""); //$NON-NLS-1$ } - + /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.model.ICLineBreakpoint#getFileName() */ @Override public String getFileName() throws CoreException { - String fileName = ensureMarker().getAttribute( ICBreakpoint.SOURCE_HANDLE, "" ); //$NON-NLS-1$ - IPath path = new Path( fileName ); - return ( path.isValidPath( fileName ) ) ? path.lastSegment() : null; + String fileName = ensureMarker().getAttribute(ICBreakpoint.SOURCE_HANDLE, ""); //$NON-NLS-1$ + IPath path = new Path(fileName); + return (path.isValidPath(fileName)) ? path.lastSegment() : null; } - + /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.model.ICLineBreakpoint#getFunction() */ @Override public String getFunction() throws CoreException { - return ensureMarker().getAttribute( ICLineBreakpoint.FUNCTION, "" ); //$NON-NLS-1$ + return ensureMarker().getAttribute(ICLineBreakpoint.FUNCTION, ""); //$NON-NLS-1$ } - + /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.model.ICLineBreakpoint#setAddress(java.lang.String) */ @Override - public void setAddress( String address ) throws CoreException { - setAttribute( ICLineBreakpoint.ADDRESS, address ); + public void setAddress(String address) throws CoreException { + setAttribute(ICLineBreakpoint.ADDRESS, address); } - + /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.model.ICLineBreakpoint#setFunction(java.lang.String) */ @Override - public void setFunction( String function ) throws CoreException { - setAttribute( ICLineBreakpoint.FUNCTION, function ); - } - - @Override - public int getRequestedLine() throws CoreException { - return ensureMarker().getAttribute( ICLineBreakpoint2.REQUESTED_LINE, -1 ); - } - - @Override - public void setRequestedLine(int line) throws CoreException { - setAttribute( ICLineBreakpoint2.REQUESTED_LINE, line ); - } - - @Override - public int getRequestedCharStart() throws CoreException { - return ensureMarker().getAttribute( ICLineBreakpoint2.REQUESTED_CHAR_START, -1 ); - } - - @Override - public void setRequestedCharStart(int charStart) throws CoreException { - setAttribute( ICLineBreakpoint2.REQUESTED_CHAR_START, charStart ); - } - - @Override - public int getRequestedCharEnd() throws CoreException { - return ensureMarker().getAttribute( ICLineBreakpoint2.REQUESTED_CHAR_END, -1 ); - } - - @Override - public void setRequestedCharEnd(int charEnd) throws CoreException { - setAttribute( ICLineBreakpoint2.REQUESTED_CHAR_END, charEnd ); - } - - @Override - public String getRequestedSourceHandle() throws CoreException { - return ensureMarker().getAttribute( ICLineBreakpoint2.REQUESTED_SOURCE_HANDLE, "" ); //$NON-NLS-1$ - } - - @Override - public void setRequestedSourceHandle(String fileName) throws CoreException { - setAttribute( ICLineBreakpoint2.REQUESTED_SOURCE_HANDLE, fileName ); - setAttribute(RESET_INSTALLED_LOCATION, Boolean.TRUE); - } - - @Override - public synchronized int decrementInstallCount() throws CoreException { - int count = super.decrementInstallCount(); - - if (count == 0) { - if (Boolean.TRUE.equals(this.getMarker().getAttribute(RESET_INSTALLED_LOCATION))) { - resetInstalledLocation(); - setAttribute(RESET_INSTALLED_LOCATION, Boolean.FALSE); - } - } - - return count; - } - - @Override - public void setInstalledLineNumber(int line) throws CoreException { - int existingValue = ensureMarker().getAttribute(IMarker.LINE_NUMBER, -1); - if (line != existingValue) { - setAttribute(IMarker.LINE_NUMBER, line); - setAttribute(RESET_INSTALLED_LOCATION, Boolean.TRUE); - setAttribute( IMarker.MESSAGE, getMarkerMessage() ); - } - } - - @Override - public void setInstalledCharStart(int charStart) throws CoreException { - int existingValue = ensureMarker().getAttribute(IMarker.CHAR_START, -1); - if (charStart != existingValue) { - setAttribute(IMarker.CHAR_START, charStart); - setAttribute(RESET_INSTALLED_LOCATION, Boolean.TRUE); - setAttribute( IMarker.MESSAGE, getMarkerMessage() ); - } - } - - @Override - public void setInstalledCharEnd(int charEnd) throws CoreException { - int existingValue = ensureMarker().getAttribute(IMarker.CHAR_END, -1); - if (charEnd != existingValue) { - setAttribute(IMarker.CHAR_END, charEnd); - setAttribute(RESET_INSTALLED_LOCATION, Boolean.TRUE); - setAttribute( IMarker.MESSAGE, getMarkerMessage() ); - } - } - - @Override - public void resetInstalledLocation() throws CoreException { - boolean locationReset = false; - if (this.getMarker().getAttribute(REQUESTED_LINE) != null) { - int line = this.getMarker().getAttribute(REQUESTED_LINE, -1); - setAttribute(IMarker.LINE_NUMBER, line); - locationReset = true; - } - if (this.getMarker().getAttribute(REQUESTED_CHAR_START) != null) { - int charStart = this.getMarker().getAttribute(REQUESTED_CHAR_START, -1); - setAttribute(IMarker.CHAR_START, charStart); - locationReset = true; - } - if (this.getMarker().getAttribute(REQUESTED_CHAR_END) != null) { - int charEnd = this.getMarker().getAttribute(REQUESTED_CHAR_END, -1); - setAttribute(IMarker.CHAR_END, charEnd); - locationReset = true; - } - if (this.getMarker().getAttribute(REQUESTED_SOURCE_HANDLE) != null) { - String file = this.getMarker().getAttribute(REQUESTED_SOURCE_HANDLE, ""); //$NON-NLS-1$ - setAttribute(ICBreakpoint.SOURCE_HANDLE, file); - locationReset = true; - } - if (locationReset) { - setAttribute( IMarker.MESSAGE, getMarkerMessage() ); - } - } - - @Override - public void refreshMessage() throws CoreException { - IMarker marker = ensureMarker(); - marker.setAttribute(IMarker.MESSAGE, getMarkerMessage()); - } + public void setFunction(String function) throws CoreException { + setAttribute(ICLineBreakpoint.FUNCTION, function); + } + + @Override + public int getRequestedLine() throws CoreException { + return ensureMarker().getAttribute(ICLineBreakpoint2.REQUESTED_LINE, -1); + } + + @Override + public void setRequestedLine(int line) throws CoreException { + setAttribute(ICLineBreakpoint2.REQUESTED_LINE, line); + } + + @Override + public int getRequestedCharStart() throws CoreException { + return ensureMarker().getAttribute(ICLineBreakpoint2.REQUESTED_CHAR_START, -1); + } + + @Override + public void setRequestedCharStart(int charStart) throws CoreException { + setAttribute(ICLineBreakpoint2.REQUESTED_CHAR_START, charStart); + } + + @Override + public int getRequestedCharEnd() throws CoreException { + return ensureMarker().getAttribute(ICLineBreakpoint2.REQUESTED_CHAR_END, -1); + } + + @Override + public void setRequestedCharEnd(int charEnd) throws CoreException { + setAttribute(ICLineBreakpoint2.REQUESTED_CHAR_END, charEnd); + } + + @Override + public String getRequestedSourceHandle() throws CoreException { + return ensureMarker().getAttribute(ICLineBreakpoint2.REQUESTED_SOURCE_HANDLE, ""); //$NON-NLS-1$ + } + + @Override + public void setRequestedSourceHandle(String fileName) throws CoreException { + setAttribute(ICLineBreakpoint2.REQUESTED_SOURCE_HANDLE, fileName); + setAttribute(RESET_INSTALLED_LOCATION, Boolean.TRUE); + } + + @Override + public synchronized int decrementInstallCount() throws CoreException { + int count = super.decrementInstallCount(); + + if (count == 0) { + if (Boolean.TRUE.equals(this.getMarker().getAttribute(RESET_INSTALLED_LOCATION))) { + resetInstalledLocation(); + setAttribute(RESET_INSTALLED_LOCATION, Boolean.FALSE); + } + } + + return count; + } + + @Override + public void setInstalledLineNumber(int line) throws CoreException { + int existingValue = ensureMarker().getAttribute(IMarker.LINE_NUMBER, -1); + if (line != existingValue) { + setAttribute(IMarker.LINE_NUMBER, line); + setAttribute(RESET_INSTALLED_LOCATION, Boolean.TRUE); + setAttribute(IMarker.MESSAGE, getMarkerMessage()); + } + } + + @Override + public void setInstalledCharStart(int charStart) throws CoreException { + int existingValue = ensureMarker().getAttribute(IMarker.CHAR_START, -1); + if (charStart != existingValue) { + setAttribute(IMarker.CHAR_START, charStart); + setAttribute(RESET_INSTALLED_LOCATION, Boolean.TRUE); + setAttribute(IMarker.MESSAGE, getMarkerMessage()); + } + } + + @Override + public void setInstalledCharEnd(int charEnd) throws CoreException { + int existingValue = ensureMarker().getAttribute(IMarker.CHAR_END, -1); + if (charEnd != existingValue) { + setAttribute(IMarker.CHAR_END, charEnd); + setAttribute(RESET_INSTALLED_LOCATION, Boolean.TRUE); + setAttribute(IMarker.MESSAGE, getMarkerMessage()); + } + } + + @Override + public void resetInstalledLocation() throws CoreException { + boolean locationReset = false; + if (this.getMarker().getAttribute(REQUESTED_LINE) != null) { + int line = this.getMarker().getAttribute(REQUESTED_LINE, -1); + setAttribute(IMarker.LINE_NUMBER, line); + locationReset = true; + } + if (this.getMarker().getAttribute(REQUESTED_CHAR_START) != null) { + int charStart = this.getMarker().getAttribute(REQUESTED_CHAR_START, -1); + setAttribute(IMarker.CHAR_START, charStart); + locationReset = true; + } + if (this.getMarker().getAttribute(REQUESTED_CHAR_END) != null) { + int charEnd = this.getMarker().getAttribute(REQUESTED_CHAR_END, -1); + setAttribute(IMarker.CHAR_END, charEnd); + locationReset = true; + } + if (this.getMarker().getAttribute(REQUESTED_SOURCE_HANDLE) != null) { + String file = this.getMarker().getAttribute(REQUESTED_SOURCE_HANDLE, ""); //$NON-NLS-1$ + setAttribute(ICBreakpoint.SOURCE_HANDLE, file); + locationReset = true; + } + if (locationReset) { + setAttribute(IMarker.MESSAGE, getMarkerMessage()); + } + } + + @Override + public void refreshMessage() throws CoreException { + IMarker marker = ensureMarker(); + marker.setAttribute(IMarker.MESSAGE, getMarkerMessage()); + } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/AbstractTracepoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/AbstractTracepoint.java index 4883f88c66e..c97962bc80f 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/AbstractTracepoint.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/AbstractTracepoint.java @@ -45,8 +45,8 @@ public abstract class AbstractTracepoint extends CBreakpoint implements ICTracep * @param add * @throws CoreException */ - public AbstractTracepoint( IResource resource, Map<String, Object> attributes, boolean add ) throws CoreException { - super( resource, attributes, add ); + public AbstractTracepoint(IResource resource, Map<String, Object> attributes, boolean add) throws CoreException { + super(resource, attributes, add); } /*(non-Javadoc) @@ -54,7 +54,7 @@ public abstract class AbstractTracepoint extends CBreakpoint implements ICTracep */ @Override public int getLineNumber() throws CoreException { - return ensureMarker().getAttribute( IMarker.LINE_NUMBER, -1 ); + return ensureMarker().getAttribute(IMarker.LINE_NUMBER, -1); } /*(non-Javadoc) @@ -62,7 +62,7 @@ public abstract class AbstractTracepoint extends CBreakpoint implements ICTracep */ @Override public int getCharStart() throws CoreException { - return ensureMarker().getAttribute( IMarker.CHAR_START, -1 ); + return ensureMarker().getAttribute(IMarker.CHAR_START, -1); } /*(non-Javadoc) @@ -70,7 +70,7 @@ public abstract class AbstractTracepoint extends CBreakpoint implements ICTracep */ @Override public int getCharEnd() throws CoreException { - return ensureMarker().getAttribute( IMarker.CHAR_END, -1 ); + return ensureMarker().getAttribute(IMarker.CHAR_END, -1); } /* (non-Javadoc) @@ -78,27 +78,27 @@ public abstract class AbstractTracepoint extends CBreakpoint implements ICTracep */ @Override public String getAddress() throws CoreException { - return ensureMarker().getAttribute( ICLineBreakpoint.ADDRESS, "" ); //$NON-NLS-1$ + return ensureMarker().getAttribute(ICLineBreakpoint.ADDRESS, ""); //$NON-NLS-1$ } - + /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.model.ICLineBreakpoint#getFileName() */ @Override public String getFileName() throws CoreException { - String fileName = ensureMarker().getAttribute( ICBreakpoint.SOURCE_HANDLE, "" ); //$NON-NLS-1$ - IPath path = new Path( fileName ); - return ( path.isValidPath( fileName ) ) ? path.lastSegment() : null; + String fileName = ensureMarker().getAttribute(ICBreakpoint.SOURCE_HANDLE, ""); //$NON-NLS-1$ + IPath path = new Path(fileName); + return (path.isValidPath(fileName)) ? path.lastSegment() : null; } - + /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.model.ICLineBreakpoint#getFunction() */ @Override public String getFunction() throws CoreException { - return ensureMarker().getAttribute( ICLineBreakpoint.FUNCTION, "" ); //$NON-NLS-1$ + return ensureMarker().getAttribute(ICLineBreakpoint.FUNCTION, ""); //$NON-NLS-1$ } - + /* * (non-Javadoc) * @see org.eclipse.cdt.debug.core.ICBreakpoint#isConditional() @@ -107,30 +107,30 @@ public abstract class AbstractTracepoint extends CBreakpoint implements ICTracep public boolean isConditional() throws CoreException { return (super.isConditional() || getPassCount() > 0); } - + /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.model.ICLineBreakpoint#setAddress(java.lang.String) */ @Override - public void setAddress( String address ) throws CoreException { - setAttribute( ICLineBreakpoint.ADDRESS, address ); + public void setAddress(String address) throws CoreException { + setAttribute(ICLineBreakpoint.ADDRESS, address); } - + /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.model.ICLineBreakpoint#setFunction(java.lang.String) */ @Override - public void setFunction( String function ) throws CoreException { - setAttribute( ICLineBreakpoint.FUNCTION, function ); + public void setFunction(String function) throws CoreException { + setAttribute(ICLineBreakpoint.FUNCTION, function); } - + /* * (non-Javadoc) * @see org.eclipse.cdt.debug.core.ICTracepoint#getPassCount() */ @Override public int getPassCount() throws CoreException { - return ensureMarker().getAttribute( PASS_COUNT, 0 ); + return ensureMarker().getAttribute(PASS_COUNT, 0); } /* @@ -138,8 +138,8 @@ public abstract class AbstractTracepoint extends CBreakpoint implements ICTracep * @see org.eclipse.cdt.debug.core.ICTracepoint#setPassCount(int) */ @Override - public void setPassCount( int passCount ) throws CoreException { - setAttribute( PASS_COUNT, passCount ); - setAttribute( IMarker.MESSAGE, getMarkerMessage() ); + public void setPassCount(int passCount) throws CoreException { + setAttribute(PASS_COUNT, passCount); + setAttribute(IMarker.MESSAGE, getMarkerMessage()); } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/BreakpointMessages.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/BreakpointMessages.java index 715d0759685..a55b66c4cfa 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/BreakpointMessages.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/BreakpointMessages.java @@ -20,16 +20,15 @@ public class BreakpointMessages { private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.core.breakpoints.BreakpointMessages";//$NON-NLS-1$ - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); private BreakpointMessages() { } - 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.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/BreakpointProblems.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/BreakpointProblems.java index 9bd54b6af7e..4075d4c4de9 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/BreakpointProblems.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/BreakpointProblems.java @@ -26,14 +26,14 @@ import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; public class BreakpointProblems { - + /** * The identifier for breakpoint problem markers. */ - public static final String BREAKPOINT_PROBLEM_MARKER_ID = CDebugCorePlugin.PLUGIN_ID + ".breakpointproblem" ; //$NON-NLS-1$ + public static final String BREAKPOINT_PROBLEM_MARKER_ID = CDebugCorePlugin.PLUGIN_ID + ".breakpointproblem"; //$NON-NLS-1$ /** * Breakpoint problem marker types. - */ + */ public static final String BREAKPOINT_PROBLEM_TYPE = "bp_problem_type"; //$NON-NLS-1$ public static final String UNRESOLVED = "unresolved"; //$NON-NLS-1$ public static final String BAD_CONDITION = "bad_condition"; //$NON-NLS-1$ @@ -41,108 +41,112 @@ public class BreakpointProblems { public static final String BREAKPOINT_CONTEXT_NAME = "bp_context_name"; //$NON-NLS-1$ public static final String BREAKPOINT_CONTEXT_ID = "bp_context_id"; //$NON-NLS-1$ - public static IMarker reportBreakpointMoved(ICBreakpoint breakpoint, int oldLineNumber, int newLineNumber, String contextName, String contextID) throws CoreException { - String message = MessageFormat.format(BreakpointMessages.getString("BreakpointProblems_Moved"), new Object[] { Integer.valueOf(oldLineNumber), Integer.valueOf(newLineNumber) }); //$NON-NLS-1$ - IMarker marker = BreakpointProblems.reportBreakpointProblem(breakpoint, message, IMarker.SEVERITY_INFO, MOVED, true, false, contextName, contextID); + public static IMarker reportBreakpointMoved(ICBreakpoint breakpoint, int oldLineNumber, int newLineNumber, + String contextName, String contextID) throws CoreException { + String message = MessageFormat.format(BreakpointMessages.getString("BreakpointProblems_Moved"), //$NON-NLS-1$ + new Object[] { Integer.valueOf(oldLineNumber), Integer.valueOf(newLineNumber) }); + IMarker marker = BreakpointProblems.reportBreakpointProblem(breakpoint, message, IMarker.SEVERITY_INFO, MOVED, + true, false, contextName, contextID); return marker; } - public static IMarker reportUnresolvedBreakpoint(ICBreakpoint breakpoint, String contextName, String contextID) throws CoreException { - IMarker marker = BreakpointProblems.reportBreakpointProblem(breakpoint, BreakpointMessages.getString("BreakpointProblems_Unresolved"), IMarker.SEVERITY_WARNING, UNRESOLVED, true, false, contextName, contextID); //$NON-NLS-1$ + public static IMarker reportUnresolvedBreakpoint(ICBreakpoint breakpoint, String contextName, String contextID) + throws CoreException { + IMarker marker = BreakpointProblems.reportBreakpointProblem(breakpoint, + BreakpointMessages.getString("BreakpointProblems_Unresolved"), IMarker.SEVERITY_WARNING, UNRESOLVED, //$NON-NLS-1$ + true, false, contextName, contextID); return marker; } - public static IMarker reportUnsupportedTracepoint(ICBreakpoint breakpoint, String contextName, String contextID) throws CoreException { - IMarker marker = BreakpointProblems.reportBreakpointProblem(breakpoint, BreakpointMessages.getString("BreakpointProblems_UnsupportedTracepoint"), IMarker.SEVERITY_WARNING, UNRESOLVED, true, false, contextName, contextID); //$NON-NLS-1$ + public static IMarker reportUnsupportedTracepoint(ICBreakpoint breakpoint, String contextName, String contextID) + throws CoreException { + IMarker marker = BreakpointProblems.reportBreakpointProblem(breakpoint, + BreakpointMessages.getString("BreakpointProblems_UnsupportedTracepoint"), IMarker.SEVERITY_WARNING, //$NON-NLS-1$ + UNRESOLVED, true, false, contextName, contextID); return marker; } - public static IMarker reportUnsupportedDynamicPrintf(ICBreakpoint breakpoint, String contextName, String contextID) throws CoreException { - IMarker marker = BreakpointProblems.reportBreakpointProblem(breakpoint, BreakpointMessages.getString("BreakpointProblems_UnsupportedDynamicPrintf"), IMarker.SEVERITY_WARNING, UNRESOLVED, true, false, contextName, contextID); //$NON-NLS-1$ + public static IMarker reportUnsupportedDynamicPrintf(ICBreakpoint breakpoint, String contextName, String contextID) + throws CoreException { + IMarker marker = BreakpointProblems.reportBreakpointProblem(breakpoint, + BreakpointMessages.getString("BreakpointProblems_UnsupportedDynamicPrintf"), IMarker.SEVERITY_WARNING, //$NON-NLS-1$ + UNRESOLVED, true, false, contextName, contextID); return marker; } public static void removeProblemsForBreakpoint(ICBreakpoint breakpoint) throws CoreException { IMarker marker = breakpoint.getMarker(); - if (marker != null) - { + if (marker != null) { int lineNumber = marker.getAttribute(IMarker.LINE_NUMBER, 0); IResource bpResource = marker.getResource(); - if (bpResource != null) - { - IMarker[] bpProblems = bpResource.findMarkers(BREAKPOINT_PROBLEM_MARKER_ID, true, IResource.DEPTH_INFINITE); + if (bpResource != null) { + IMarker[] bpProblems = bpResource.findMarkers(BREAKPOINT_PROBLEM_MARKER_ID, true, + IResource.DEPTH_INFINITE); for (int i = 0; i < bpProblems.length; i++) { - if (bpProblems[i].getAttribute(IMarker.LINE_NUMBER, 0) == lineNumber) - { + if (bpProblems[i].getAttribute(IMarker.LINE_NUMBER, 0) == lineNumber) { bpProblems[i].delete(); } } } } - + } - public static void removeProblemsForResolvedBreakpoint(ICBreakpoint breakpoint, String contextID) throws CoreException { + public static void removeProblemsForResolvedBreakpoint(ICBreakpoint breakpoint, String contextID) + throws CoreException { IMarker marker = breakpoint.getMarker(); - if (marker != null) - { + if (marker != null) { int lineNumber = marker.getAttribute(IMarker.LINE_NUMBER, 0); IResource bpResource = marker.getResource(); - if (bpResource != null) - { - IMarker[] bpProblems = bpResource.findMarkers(BREAKPOINT_PROBLEM_MARKER_ID, true, IResource.DEPTH_INFINITE); + if (bpResource != null) { + IMarker[] bpProblems = bpResource.findMarkers(BREAKPOINT_PROBLEM_MARKER_ID, true, + IResource.DEPTH_INFINITE); for (int i = 0; i < bpProblems.length; i++) { if (bpProblems[i].getAttribute(BREAKPOINT_PROBLEM_TYPE, "").equalsIgnoreCase(UNRESOLVED) && //$NON-NLS-1$ - bpProblems[i].getAttribute(IMarker.LINE_NUMBER, 0) == lineNumber && - bpProblems[i].getAttribute(BREAKPOINT_CONTEXT_ID, "").equals(contextID)) //$NON-NLS-1$ + bpProblems[i].getAttribute(IMarker.LINE_NUMBER, 0) == lineNumber + && bpProblems[i].getAttribute(BREAKPOINT_CONTEXT_ID, "").equals(contextID)) //$NON-NLS-1$ { bpProblems[i].delete(); } } } } - + } - public static IMarker reportBreakpointProblem(ICBreakpoint breakpoint, - String description, int severity, String problemType, boolean removePrevious, boolean removeOnly, String contextName, String contextID) { + public static IMarker reportBreakpointProblem(ICBreakpoint breakpoint, String description, int severity, + String problemType, boolean removePrevious, boolean removeOnly, String contextName, String contextID) { try { if (breakpoint instanceof ICLineBreakpoint) { ICLineBreakpoint lineBreakpoint = (ICLineBreakpoint) breakpoint; IMarker marker = null; - - if (removePrevious) - { + + if (removePrevious) { IMarker existingMarker = lineBreakpoint.getMarker(); - if (existingMarker != null) - { + if (existingMarker != null) { IResource bpResource = existingMarker.getResource(); - if (bpResource != null) - { + if (bpResource != null) { int lineNumber = existingMarker.getAttribute(IMarker.LINE_NUMBER, 0); - IMarker[] bpProblems = bpResource.findMarkers(BREAKPOINT_PROBLEM_MARKER_ID, true, IResource.DEPTH_INFINITE); + IMarker[] bpProblems = bpResource.findMarkers(BREAKPOINT_PROBLEM_MARKER_ID, true, + IResource.DEPTH_INFINITE); for (int i = 0; i < bpProblems.length; i++) { - if (bpProblems[i].getAttribute(BREAKPOINT_PROBLEM_TYPE, "").equalsIgnoreCase(problemType) && //$NON-NLS-1$ - bpProblems[i].getAttribute(IMarker.LINE_NUMBER, 0) == lineNumber) - { + if (bpProblems[i].getAttribute(BREAKPOINT_PROBLEM_TYPE, "") //$NON-NLS-1$ + .equalsIgnoreCase(problemType) + && bpProblems[i].getAttribute(IMarker.LINE_NUMBER, 0) == lineNumber) { bpProblems[i].delete(); } } - } - } + } + } } - - if (!removeOnly) - { - marker = reportBreakpointProblem(new ProblemMarkerInfo( - lineBreakpoint.getMarker().getResource(), - lineBreakpoint.getLineNumber(), description, severity, - "")); //$NON-NLS-1$ - if (marker != null) - { + + if (!removeOnly) { + marker = reportBreakpointProblem(new ProblemMarkerInfo(lineBreakpoint.getMarker().getResource(), + lineBreakpoint.getLineNumber(), description, severity, "")); //$NON-NLS-1$ + if (marker != null) { marker.setAttribute(BREAKPOINT_PROBLEM_TYPE, problemType); marker.setAttribute(BREAKPOINT_CONTEXT_NAME, contextName); - marker.setAttribute(BREAKPOINT_CONTEXT_ID, contextID); + marker.setAttribute(BREAKPOINT_CONTEXT_ID, contextID); } } return marker; @@ -151,16 +155,15 @@ public class BreakpointProblems { } return null; } - - public static IMarker reportBreakpointProblem(ProblemMarkerInfo problemMarkerInfo) - { - IResource markerResource = problemMarkerInfo.file ; - if (markerResource==null) { + + public static IMarker reportBreakpointProblem(ProblemMarkerInfo problemMarkerInfo) { + IResource markerResource = problemMarkerInfo.file; + if (markerResource == null) { return null; } try { IMarker[] cur = markerResource.findMarkers(BREAKPOINT_PROBLEM_MARKER_ID, true, IResource.DEPTH_ONE); - + /* * Try to find matching markers and don't put in duplicates */ @@ -169,7 +172,8 @@ public class BreakpointProblems { int line = ((Integer) cur[i].getAttribute(IMarker.LINE_NUMBER)).intValue(); int sev = ((Integer) cur[i].getAttribute(IMarker.SEVERITY)).intValue(); String mesg = (String) cur[i].getAttribute(IMarker.MESSAGE); - if (line == problemMarkerInfo.lineNumber && sev == problemMarkerInfo.severity && mesg.equals(problemMarkerInfo.description)) { + if (line == problemMarkerInfo.lineNumber && sev == problemMarkerInfo.severity + && mesg.equals(problemMarkerInfo.description)) { return cur[i]; } } @@ -185,12 +189,14 @@ public class BreakpointProblems { marker.setAttribute(ICModelMarker.C_MODEL_MARKER_VARIABLE, problemMarkerInfo.variableName); } if (problemMarkerInfo.externalPath != null) { - marker.setAttribute(ICModelMarker.C_MODEL_MARKER_EXTERNAL_LOCATION, problemMarkerInfo.externalPath.toOSString()); + marker.setAttribute(ICModelMarker.C_MODEL_MARKER_EXTERNAL_LOCATION, + problemMarkerInfo.externalPath.toOSString()); } - + return marker; - } catch (CoreException e) {} + } catch (CoreException e) { + } return null; } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CAddressBreakpoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CAddressBreakpoint.java index 574ac261137..ed0b8daedf8 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CAddressBreakpoint.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CAddressBreakpoint.java @@ -36,8 +36,8 @@ public class CAddressBreakpoint extends AbstractLineBreakpoint implements ICAddr /** * Constructor for CAddressBreakpoint. */ - public CAddressBreakpoint( IResource resource, Map<String, Object> attributes, boolean add ) throws CoreException { - super( resource, attributes, add ); + public CAddressBreakpoint(IResource resource, Map<String, Object> attributes, boolean add) throws CoreException { + super(resource, attributes, add); } /** @@ -49,11 +49,12 @@ public class CAddressBreakpoint extends AbstractLineBreakpoint implements ICAddr /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint#getMarkerMessage() */ @Override protected String getMarkerMessage() throws CoreException { - return MessageFormat.format( BreakpointMessages.getString( "CAddressBreakpoint.0" ), (Object[])new String[] { CDebugUtils.getBreakpointText( this, false ) } ); //$NON-NLS-1$ + return MessageFormat.format(BreakpointMessages.getString("CAddressBreakpoint.0"), //$NON-NLS-1$ + (Object[]) new String[] { CDebugUtils.getBreakpointText(this, false) }); } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CAddressDynamicPrintf.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CAddressDynamicPrintf.java index e02d4c723ac..71d2f044e0c 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CAddressDynamicPrintf.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CAddressDynamicPrintf.java @@ -33,8 +33,8 @@ public class CAddressDynamicPrintf extends AbstractDynamicPrintf implements ICAd public CAddressDynamicPrintf() { } - public CAddressDynamicPrintf( IResource resource, Map<String, Object> attributes, boolean add ) throws CoreException { - super( resource, attributes, add ); + public CAddressDynamicPrintf(IResource resource, Map<String, Object> attributes, boolean add) throws CoreException { + super(resource, attributes, add); } /** @@ -46,11 +46,12 @@ public class CAddressDynamicPrintf extends AbstractDynamicPrintf implements ICAd /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint#getMarkerMessage() */ @Override protected String getMarkerMessage() throws CoreException { - return MessageFormat.format( BreakpointMessages.getString( "CAddressDynamicPrintf.0" ), (Object[])new String[] { CDebugUtils.getBreakpointText( this, false ) } ); //$NON-NLS-1$ + return MessageFormat.format(BreakpointMessages.getString("CAddressDynamicPrintf.0"), //$NON-NLS-1$ + (Object[]) new String[] { CDebugUtils.getBreakpointText(this, false) }); } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CAddressTracepoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CAddressTracepoint.java index 501fe4c84a8..cab6b8c49ff 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CAddressTracepoint.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CAddressTracepoint.java @@ -39,8 +39,8 @@ public class CAddressTracepoint extends AbstractTracepoint implements ICAddressB /** * Constructor for CAddressTracepoint. */ - public CAddressTracepoint( IResource resource, Map<String, Object> attributes, boolean add ) throws CoreException { - super( resource, attributes, add ); + public CAddressTracepoint(IResource resource, Map<String, Object> attributes, boolean add) throws CoreException { + super(resource, attributes, add); } /** @@ -52,11 +52,12 @@ public class CAddressTracepoint extends AbstractTracepoint implements ICAddressB /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint#getMarkerMessage() */ @Override protected String getMarkerMessage() throws CoreException { - return MessageFormat.format( BreakpointMessages.getString( "CAddressTracepoint.0" ), (Object[])new String[] { CDebugUtils.getBreakpointText( this, false ) } ); //$NON-NLS-1$ + return MessageFormat.format(BreakpointMessages.getString("CAddressTracepoint.0"), //$NON-NLS-1$ + (Object[]) new String[] { CDebugUtils.getBreakpointText(this, false) }); } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CBreakpoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CBreakpoint.java index 30145c5d11f..ed3fcd902dc 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CBreakpoint.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CBreakpoint.java @@ -10,7 +10,7 @@ * * Contributors: * QNX Software Systems - Initial API and implementation - * Marc Khouzam (Ericsson) - Must synchronized creation of breakpoint creation (Bug 444395) + * Marc Khouzam (Ericsson) - Must synchronized creation of breakpoint creation (Bug 444395) *******************************************************************************/ package org.eclipse.cdt.debug.internal.core.breakpoints; @@ -49,51 +49,52 @@ import com.ibm.icu.text.MessageFormat; /** * The base class for all C/C++ specific breakpoints. */ -public abstract class CBreakpoint extends Breakpoint implements ICBreakpoint2, ICBreakpointType, IDebugEventSetListener { - - /** - * Map of breakpoint extensions. The keys to the map are debug model IDs - * and values are arrays of breakpoint extensions. - * - * This map is sorted to allow consistent iteration order so that extension - * message does not unexpectedly change order - */ +public abstract class CBreakpoint extends Breakpoint + implements ICBreakpoint2, ICBreakpointType, IDebugEventSetListener { + + /** + * Map of breakpoint extensions. The keys to the map are debug model IDs + * and values are arrays of breakpoint extensions. + * + * This map is sorted to allow consistent iteration order so that extension + * message does not unexpectedly change order + */ private SortedMap<String, ICBreakpointExtension[]> fExtensions = new TreeMap<String, ICBreakpointExtension[]>(); - + /** * The number of debug targets the breakpoint is installed in. We don't use * the INSTALL_COUNT attribute to manage this property (see bugzilla 218194) - * + * */ - private int fInstallCount = 0; - - /** - * Constructor for CBreakpoint. - */ - public CBreakpoint() { - } + private int fInstallCount = 0; + /** + * Constructor for CBreakpoint. + */ + public CBreakpoint() { + } /** * Constructor for CBreakpoint. */ - public CBreakpoint( final IResource resource, final Map<String, Object> attributes, final boolean add ) throws CoreException { - this(); + public CBreakpoint(final IResource resource, final Map<String, Object> attributes, final boolean add) + throws CoreException { + this(); IWorkspaceRunnable wr = new IWorkspaceRunnable() { @Override - public void run( IProgressMonitor monitor ) throws CoreException { + public void run(IProgressMonitor monitor) throws CoreException { // create the marker - setMarker( resource.createMarker( getMarkerType() ) ); + setMarker(resource.createMarker(getMarkerType())); // set attributes - ensureMarker().setAttributes( attributes ); + ensureMarker().setAttributes(attributes); //set the marker message - setAttribute( IMarker.MESSAGE, getMarkerMessage() ); + setAttribute(IMarker.MESSAGE, getMarkerMessage()); // add to breakpoint manager if requested - register( add ); + register(add); } }; - run( wr ); + run(wr); } @Override @@ -108,70 +109,69 @@ public abstract class CBreakpoint extends Breakpoint implements ICBreakpoint2, I @Override public String getCondition() throws CoreException { - return ensureMarker().getAttribute( CONDITION, "" ); //$NON-NLS-1$ + return ensureMarker().getAttribute(CONDITION, ""); //$NON-NLS-1$ } @Override - public void setCondition( String condition ) throws CoreException { - setAttribute( CONDITION, condition ); - setAttribute( IMarker.MESSAGE, getMarkerMessage() ); + public void setCondition(String condition) throws CoreException { + setAttribute(CONDITION, condition); + setAttribute(IMarker.MESSAGE, getMarkerMessage()); } @Override public int getIgnoreCount() throws CoreException { - return ensureMarker().getAttribute( IGNORE_COUNT, 0 ); + return ensureMarker().getAttribute(IGNORE_COUNT, 0); } @Override - public void setIgnoreCount( int ignoreCount ) throws CoreException { - setAttribute( IGNORE_COUNT, ignoreCount ); - setAttribute( IMarker.MESSAGE, getMarkerMessage() ); + public void setIgnoreCount(int ignoreCount) throws CoreException { + setAttribute(IGNORE_COUNT, ignoreCount); + setAttribute(IMarker.MESSAGE, getMarkerMessage()); } - + @Override public int getType() throws CoreException { - return ensureMarker().getAttribute( TYPE, 0 ); + return ensureMarker().getAttribute(TYPE, 0); } @Override public void setType(int type) throws CoreException { - setAttribute( TYPE, type ); - setAttribute( IMarker.MESSAGE, getMarkerMessage() ); + setAttribute(TYPE, type); + setAttribute(IMarker.MESSAGE, getMarkerMessage()); } @Override public String getThreadId() throws CoreException { - return ensureMarker().getAttribute( THREAD_ID, null ); + return ensureMarker().getAttribute(THREAD_ID, null); } @Override - public void setThreadId( String threadId ) throws CoreException { - setAttribute( THREAD_ID, threadId ); + public void setThreadId(String threadId) throws CoreException { + setAttribute(THREAD_ID, threadId); } @Override public String getSourceHandle() throws CoreException { - return ensureMarker().getAttribute( SOURCE_HANDLE, null ); + return ensureMarker().getAttribute(SOURCE_HANDLE, null); } @Override - public void setSourceHandle( String sourceHandle ) throws CoreException { - setAttribute( SOURCE_HANDLE, sourceHandle ); + public void setSourceHandle(String sourceHandle) throws CoreException { + setAttribute(SOURCE_HANDLE, sourceHandle); } @Override - public void handleDebugEvents( DebugEvent[] events ) { + public void handleDebugEvents(DebugEvent[] events) { } /** * Execute the given workspace runnable */ - protected void run( IWorkspaceRunnable wr ) throws DebugException { + protected void run(IWorkspaceRunnable wr) throws DebugException { try { - ResourcesPlugin.getWorkspace().run( wr, null ); - } - catch( CoreException e ) { - throw new DebugException( e.getStatus() ); + ResourcesPlugin.getWorkspace().run(wr, null); + } catch (CoreException e) { + throw new DebugException(e.getStatus()); } } @@ -179,9 +179,9 @@ public abstract class CBreakpoint extends Breakpoint implements ICBreakpoint2, I * Add this breakpoint to the breakpoint manager, or sets it as * unregistered. */ - public void register( boolean register ) throws CoreException { - if ( register ) { - DebugPlugin.getDefault().getBreakpointManager().addBreakpoint( this ); + public void register(boolean register) throws CoreException { + if (register) { + DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(this); } /* * else { setRegistered( false ); } @@ -193,11 +193,11 @@ public abstract class CBreakpoint extends Breakpoint implements ICBreakpoint2, I @Override public synchronized int incrementInstallCount() throws CoreException { ++fInstallCount; - + // cause the marker to update; will ultimately result in a blue checkmark // when install count > 0 setAttribute(INSTALL_COUNT, fInstallCount); - + return fInstallCount; } @@ -212,11 +212,11 @@ public abstract class CBreakpoint extends Breakpoint implements ICBreakpoint2, I @Override public synchronized int decrementInstallCount() throws CoreException { fInstallCount--; - + // cause the marker to update; will ultimately remove blue checkmark // when install count == 0 setAttribute(INSTALL_COUNT, fInstallCount); - + return fInstallCount; } @@ -227,7 +227,7 @@ public abstract class CBreakpoint extends Breakpoint implements ICBreakpoint2, I setAttribute(INSTALL_COUNT, fInstallCount); } } - + @Override public boolean isConditional() throws CoreException { return ((getCondition() != null && getCondition().trim().length() > 0) || getIgnoreCount() > 0); @@ -236,58 +236,60 @@ public abstract class CBreakpoint extends Breakpoint implements ICBreakpoint2, I protected String getConditionText() throws CoreException { StringBuilder sb = new StringBuilder(); int ignoreCount = getIgnoreCount(); - if ( ignoreCount > 0 ) { - sb.append( MessageFormat.format( BreakpointMessages.getString( "CBreakpoint.1" ), new Object[] { ignoreCount } ) ); //$NON-NLS-1$ + if (ignoreCount > 0) { + sb.append( + MessageFormat.format(BreakpointMessages.getString("CBreakpoint.1"), new Object[] { ignoreCount })); //$NON-NLS-1$ } String condition = getCondition(); - if ( condition != null && condition.length() > 0 ) { - sb.append( MessageFormat.format( BreakpointMessages.getString( "CBreakpoint.2" ), new Object[] { condition } ) ); //$NON-NLS-1$ + if (condition != null && condition.length() > 0) { + sb.append(MessageFormat.format(BreakpointMessages.getString("CBreakpoint.2"), new Object[] { condition })); //$NON-NLS-1$ } return sb.toString(); } - /** * Change notification when there are no marker changes. If the marker * does not exist, do not fire a change notificaiton (the marker may not * exist if the associated project was closed). */ public void fireChanged() { - if ( markerExists() ) { - DebugPlugin.getDefault().getBreakpointManager().fireBreakpointChanged( this ); + if (markerExists()) { + DebugPlugin.getDefault().getBreakpointManager().fireBreakpointChanged(this); } } @Override public String getModule() throws CoreException { - return ensureMarker().getAttribute( MODULE, null ); + return ensureMarker().getAttribute(MODULE, null); } @Override - public void setModule( String module ) throws CoreException { - setAttribute( MODULE, module ); + public void setModule(String module) throws CoreException { + setAttribute(MODULE, module); } - + @Override - public <V extends ICBreakpointExtension> V getExtension(String debugModelId, Class<V> extensionType) throws CoreException { - ICBreakpointExtension[] extensions = getExtensionsForModelId(debugModelId); - for (int i = 0; i < extensions.length; i++) { - if ( extensionType.isAssignableFrom(extensions[i].getClass()) ) { - @SuppressWarnings("unchecked") - V retVal = (V) extensions[i]; - return retVal; - } - } - throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), DebugPlugin.ERROR, "Extension " + extensionType + " not defined for breakpoint " + this, null)); //$NON-NLS-1$ //$NON-NLS-2$ + public <V extends ICBreakpointExtension> V getExtension(String debugModelId, Class<V> extensionType) + throws CoreException { + ICBreakpointExtension[] extensions = getExtensionsForModelId(debugModelId); + for (int i = 0; i < extensions.length; i++) { + if (extensionType.isAssignableFrom(extensions[i].getClass())) { + @SuppressWarnings("unchecked") + V retVal = (V) extensions[i]; + return retVal; + } + } + throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), DebugPlugin.ERROR, + "Extension " + extensionType + " not defined for breakpoint " + this, null)); //$NON-NLS-1$ //$NON-NLS-2$ } - + /** - * Reads platform extension registry for breakpoint extensions registered + * Reads platform extension registry for breakpoint extensions registered * for the given debug model. - * @param debugModelId Requested debug model that the extensions were + * @param debugModelId Requested debug model that the extensions were * registerd for. * @return Breakpoint extensions. - * @throws CoreException Throws exception in case the breakpoint marker + * @throws CoreException Throws exception in case the breakpoint marker * cannot be accessed. */ private ICBreakpointExtension[] getExtensionsForModelId(String debugModelId) throws CoreException { @@ -302,44 +304,64 @@ public abstract class CBreakpoint extends Breakpoint implements ICBreakpoint2, I // Read the extension registry and create applicable extensions. List<ICBreakpointExtension> extensions = new ArrayList<ICBreakpointExtension>(4); - IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint(CDebugCorePlugin.getUniqueIdentifier(), CDebugCorePlugin.BREAKPOINT_EXTENSION_EXTENSION_POINT_ID); + IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint( + CDebugCorePlugin.getUniqueIdentifier(), + CDebugCorePlugin.BREAKPOINT_EXTENSION_EXTENSION_POINT_ID); IConfigurationElement[] elements = ep.getConfigurationElements(); - for (int i= 0; i < elements.length; i++) { - if ( elements[i].getName().equals(CDebugCorePlugin.BREAKPOINT_EXTENSION_ELEMENT) ) { + for (int i = 0; i < elements.length; i++) { + if (elements[i].getName().equals(CDebugCorePlugin.BREAKPOINT_EXTENSION_ELEMENT)) { String elementDebugModelId = elements[i].getAttribute("debugModelId"); //$NON-NLS-1$ String elementMarkerType = elements[i].getAttribute("markerType"); //$NON-NLS-1$ if (elementDebugModelId == null) { - CDebugCorePlugin.log(new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, "Extension " + elements[i].getDeclaringExtension().getUniqueIdentifier() + " missing required attribute: markerType", null)); //$NON-NLS-1$ //$NON-NLS-2$ - } else if (elementMarkerType == null){ - CDebugCorePlugin.log(new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, "Extension " + elements[i].getDeclaringExtension().getUniqueIdentifier() + " missing required attribute: debugModelId", null)); //$NON-NLS-1$ //$NON-NLS-2$ - } else if ( debugModelId.equals(elementDebugModelId) && marker.isSubtypeOf(elementMarkerType)) { + CDebugCorePlugin.log(new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), + DebugPlugin.INTERNAL_ERROR, + "Extension " + elements[i].getDeclaringExtension().getUniqueIdentifier() //$NON-NLS-1$ + + " missing required attribute: markerType", //$NON-NLS-1$ + null)); + } else if (elementMarkerType == null) { + CDebugCorePlugin.log(new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), + DebugPlugin.INTERNAL_ERROR, + "Extension " + elements[i].getDeclaringExtension().getUniqueIdentifier() //$NON-NLS-1$ + + " missing required attribute: debugModelId", //$NON-NLS-1$ + null)); + } else if (debugModelId.equals(elementDebugModelId) + && marker.isSubtypeOf(elementMarkerType)) { String className = elements[i].getAttribute("class"); //$NON-NLS-1$ - if (className == null){ - CDebugCorePlugin.log(new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, "Extension " + elements[i].getDeclaringExtension().getUniqueIdentifier() + " missing required attribute: className", null)); //$NON-NLS-1$ //$NON-NLS-2$ + if (className == null) { + CDebugCorePlugin.log(new Status(IStatus.ERROR, + CDebugCorePlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, + "Extension " + elements[i].getDeclaringExtension().getUniqueIdentifier() //$NON-NLS-1$ + + " missing required attribute: className", //$NON-NLS-1$ + null)); } else { ICBreakpointExtension extension; try { - extension = (ICBreakpointExtension)elements[i].createExecutableExtension("class"); //$NON-NLS-1$ + extension = (ICBreakpointExtension) elements[i] + .createExecutableExtension("class"); //$NON-NLS-1$ extension.initialize(this); extensions.add(extension); } catch (CoreException e) { - CDebugCorePlugin.log(new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, "Extension " + elements[i].getDeclaringExtension().getUniqueIdentifier() + " contains an invalid value for attribute: className", e)); //$NON-NLS-1$ //$NON-NLS-2$ + CDebugCorePlugin.log(new Status(IStatus.ERROR, + CDebugCorePlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, + "Extension " + elements[i].getDeclaringExtension().getUniqueIdentifier() //$NON-NLS-1$ + + " contains an invalid value for attribute: className", //$NON-NLS-1$ + e)); } } } } - } + } fExtensions.put(debugModelId, extensions.toArray(new ICBreakpointExtension[extensions.size()])); - } + } } } return fExtensions.get(debugModelId); } - @Override + @Override public void refreshMessage() throws CoreException { - IMarker marker = ensureMarker(); - marker.setAttribute(IMarker.MESSAGE, getMarkerMessage()); + IMarker marker = ensureMarker(); + marker.setAttribute(IMarker.MESSAGE, getMarkerMessage()); } @Override diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CBreakpointImportParticipant.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CBreakpointImportParticipant.java index 97d991c832b..eb98688a85b 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CBreakpointImportParticipant.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CBreakpointImportParticipant.java @@ -29,13 +29,12 @@ import org.eclipse.debug.core.model.IBreakpointImportParticipant; public class CBreakpointImportParticipant implements IBreakpointImportParticipant { /* * (non-Javadoc) - * + * * @see * org.eclipse.debug.core.model.IBreakpointImportParticipant#matches(java * .util.Map, org.eclipse.debug.core.model.IBreakpoint) */ - public boolean matches(Map<String, Object> attributes, IBreakpoint breakpoint) - throws CoreException { + public boolean matches(Map<String, Object> attributes, IBreakpoint breakpoint) throws CoreException { if (attributes == null || breakpoint == null) { return false; } @@ -47,12 +46,10 @@ public class CBreakpointImportParticipant implements IBreakpointImportParticipan return false; } if (breakpoint instanceof AbstractLineBreakpoint) { - return matchesLineBreakpoint(attributes, - (AbstractLineBreakpoint) breakpoint); + return matchesLineBreakpoint(attributes, (AbstractLineBreakpoint) breakpoint); } if (breakpoint instanceof AbstractTracepoint) { - return matchesTracepoint(attributes, - (AbstractTracepoint) breakpoint); + return matchesTracepoint(attributes, (AbstractTracepoint) breakpoint); } if (breakpoint instanceof CEventBreakpoint) { return matchesEventBreakpoint(attributes, (CEventBreakpoint) breakpoint); @@ -68,12 +65,12 @@ public class CBreakpointImportParticipant implements IBreakpointImportParticipan * @see org.eclipse.debug.core.model.IBreakpointImportParticipant#verify(org.eclipse.debug.core.model.IBreakpoint) */ @Override - public void verify(IBreakpoint breakpoint) throws CoreException {} - + public void verify(IBreakpoint breakpoint) throws CoreException { + } /** * Compares two attributes in a <code>null</code> safe way - * + * * @param attr1 * the first attribute * @param attr2 @@ -91,7 +88,7 @@ public class CBreakpointImportParticipant implements IBreakpointImportParticipan /** * Returns if the given map of attributes matches the given breakpoint * Works for any breakpoint class that extends AbstractLineBreakpoint - * + * * @param attributes * @param breakpoint * @return true if the attributes match the breakpoint's attributes, false @@ -105,14 +102,16 @@ public class CBreakpointImportParticipant implements IBreakpointImportParticipan return breakpoint.getLineNumber() == lineNumber && attributesEqual(breakpoint.getType(), attributes.get(CBreakpoint.TYPE)) && attributesEqual(breakpoint.getSourceHandle(), attributes.get(ICBreakpoint.SOURCE_HANDLE)) - && attributesEqual(breakpoint.getMarker().getAttribute(ICLineBreakpoint.ADDRESS), attributes.get(ICLineBreakpoint.ADDRESS)) - && attributesEqual(breakpoint.getMarker().getAttribute(ICLineBreakpoint.FUNCTION), attributes.get(ICLineBreakpoint.FUNCTION)); + && attributesEqual(breakpoint.getMarker().getAttribute(ICLineBreakpoint.ADDRESS), + attributes.get(ICLineBreakpoint.ADDRESS)) + && attributesEqual(breakpoint.getMarker().getAttribute(ICLineBreakpoint.FUNCTION), + attributes.get(ICLineBreakpoint.FUNCTION)); } /** * Returns if the given map of attributes matches the given tracepoint * Works for any breakpoint class that extends AbstractTracepoint - * + * * @param attributes * @param tracepoint * @return true if the attributes match the tracepoint's attributes, false @@ -126,13 +125,15 @@ public class CBreakpointImportParticipant implements IBreakpointImportParticipan return tracepoint.getLineNumber() == lineNumber && attributesEqual(tracepoint.getType(), attributes.get(CBreakpoint.TYPE)) && attributesEqual(tracepoint.getSourceHandle(), attributes.get(ICBreakpoint.SOURCE_HANDLE)) - && attributesEqual(tracepoint.getMarker().getAttribute(ICLineBreakpoint.ADDRESS), attributes.get(ICLineBreakpoint.ADDRESS)) - && attributesEqual(tracepoint.getMarker().getAttribute(ICLineBreakpoint.FUNCTION), attributes.get(ICLineBreakpoint.FUNCTION)); + && attributesEqual(tracepoint.getMarker().getAttribute(ICLineBreakpoint.ADDRESS), + attributes.get(ICLineBreakpoint.ADDRESS)) + && attributesEqual(tracepoint.getMarker().getAttribute(ICLineBreakpoint.FUNCTION), + attributes.get(ICLineBreakpoint.FUNCTION)); } /** * Returns if the given map of attributes matches the given event breakpoint - * + * * @param attributes * @param breakpoint * @return true if the attributes match the event breakpoint's attributes, false @@ -141,27 +142,22 @@ public class CBreakpointImportParticipant implements IBreakpointImportParticipan */ private boolean matchesEventBreakpoint(Map<String, Object> attributes, CEventBreakpoint breakpoint) throws CoreException { - return breakpoint.getEventArgument().equals( - attributes.get(ICEventBreakpoint.EVENT_ARG)) - && attributesEqual(breakpoint.getEventType(), - attributes.get(ICEventBreakpoint.EVENT_TYPE_ID)); + return breakpoint.getEventArgument().equals(attributes.get(ICEventBreakpoint.EVENT_ARG)) + && attributesEqual(breakpoint.getEventType(), attributes.get(ICEventBreakpoint.EVENT_TYPE_ID)); } /** * Returns if the given map of attributes matches the given watchpoint - * + * * @param attributes * @param breakpoint * @return true if the attributes match the watchpoint's attributes, false * otherwise * @throws CoreException */ - private boolean matchesWatchpoint(Map<String, Object> attributes, CWatchpoint watchpoint) - throws CoreException { - return watchpoint.getExpression().equals( - attributes.get(CWatchpoint.EXPRESSION)) - && attributesEqual(watchpoint.getType(), - attributes.get(CBreakpoint.TYPE)); + private boolean matchesWatchpoint(Map<String, Object> attributes, CWatchpoint watchpoint) throws CoreException { + return watchpoint.getExpression().equals(attributes.get(CWatchpoint.EXPRESSION)) + && attributesEqual(watchpoint.getType(), attributes.get(CBreakpoint.TYPE)); } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CEventBreakpoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CEventBreakpoint.java index ceb712bf110..c42b5d54d09 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CEventBreakpoint.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CEventBreakpoint.java @@ -1,6 +1,6 @@ /******************************************************************************* * Copyright (c) 2008, 2018 QNX Software Systems and others. - * + * * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -38,13 +38,13 @@ public class CEventBreakpoint extends CBreakpoint implements ICEventBreakpoint { @Override public String getMarkerType() { - return C_EVENT_BREAKPOINT_MARKER; + return C_EVENT_BREAKPOINT_MARKER; } - + @Override protected String getMarkerMessage() throws CoreException { // default message, overridden by label provider, which would take care of translation - return "Event Breakpoint: " + getEventType(); //$NON-NLS-1$ + return "Event Breakpoint: " + getEventType(); //$NON-NLS-1$ } /** @@ -59,7 +59,7 @@ public class CEventBreakpoint extends CBreakpoint implements ICEventBreakpoint { * @see ICEventBreakpoint#getEventArgument() */ @Override - public String getEventArgument() throws CoreException { + public String getEventArgument() throws CoreException { return ensureMarker().getAttribute(EVENT_ARG, ""); //$NON-NLS-1$ } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CFunctionBreakpoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CFunctionBreakpoint.java index af12698fa1d..998f018c0d1 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CFunctionBreakpoint.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CFunctionBreakpoint.java @@ -36,8 +36,8 @@ public class CFunctionBreakpoint extends AbstractLineBreakpoint implements ICFun /** * Constructor for CFunctionBreakpoint. */ - public CFunctionBreakpoint( IResource resource, Map<String, Object> attributes, boolean add ) throws CoreException { - super( resource, attributes, add ); + public CFunctionBreakpoint(IResource resource, Map<String, Object> attributes, boolean add) throws CoreException { + super(resource, attributes, add); } /** @@ -52,6 +52,7 @@ public class CFunctionBreakpoint extends AbstractLineBreakpoint implements ICFun */ @Override protected String getMarkerMessage() throws CoreException { - return MessageFormat.format( BreakpointMessages.getString( "CFunctionBreakpoint.0" ), (Object[])new String[] { CDebugUtils.getBreakpointText( this, false ) } ); //$NON-NLS-1$ + return MessageFormat.format(BreakpointMessages.getString("CFunctionBreakpoint.0"), //$NON-NLS-1$ + (Object[]) new String[] { CDebugUtils.getBreakpointText(this, false) }); } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CFunctionDynamicPrintf.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CFunctionDynamicPrintf.java index 8aa648cb002..d401eb8fd1c 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CFunctionDynamicPrintf.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CFunctionDynamicPrintf.java @@ -32,8 +32,9 @@ public class CFunctionDynamicPrintf extends AbstractDynamicPrintf implements ICF public CFunctionDynamicPrintf() { } - public CFunctionDynamicPrintf( IResource resource, Map<String, Object> attributes, boolean add ) throws CoreException { - super( resource, attributes, add ); + public CFunctionDynamicPrintf(IResource resource, Map<String, Object> attributes, boolean add) + throws CoreException { + super(resource, attributes, add); } /** @@ -47,6 +48,7 @@ public class CFunctionDynamicPrintf extends AbstractDynamicPrintf implements ICF * @see org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint#getMarkerMessage() */ protected String getMarkerMessage() throws CoreException { - return MessageFormat.format( BreakpointMessages.getString( "CFunctionDynamicPrintf.0" ), (Object[])new String[] { CDebugUtils.getBreakpointText( this, false ) } ); //$NON-NLS-1$ + return MessageFormat.format(BreakpointMessages.getString("CFunctionDynamicPrintf.0"), //$NON-NLS-1$ + (Object[]) new String[] { CDebugUtils.getBreakpointText(this, false) }); } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CFunctionTracepoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CFunctionTracepoint.java index 6d00c441894..e0017fd0be1 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CFunctionTracepoint.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CFunctionTracepoint.java @@ -39,22 +39,23 @@ public class CFunctionTracepoint extends AbstractTracepoint implements ICFunctio /** * Constructor for CFunctionTracepoint. */ - public CFunctionTracepoint( IResource resource, Map<String, Object> attributes, boolean add ) throws CoreException { - super( resource, attributes, add ); + public CFunctionTracepoint(IResource resource, Map<String, Object> attributes, boolean add) throws CoreException { + super(resource, attributes, add); } /** - * Returns the type of marker associated with this type of breakpoints - */ - public String getMarkerType() { - return C_FUNCTION_TRACEPOINT_MARKER; - } + * Returns the type of marker associated with this type of breakpoints + */ + public String getMarkerType() { + return C_FUNCTION_TRACEPOINT_MARKER; + } /*(non-Javadoc) * @see org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint#getMarkerMessage() */ @Override protected String getMarkerMessage() throws CoreException { - return MessageFormat.format( BreakpointMessages.getString( "CFunctionTracepoint.0" ), (Object[])new String[] { CDebugUtils.getBreakpointText( this, false ) } ); //$NON-NLS-1$ + return MessageFormat.format(BreakpointMessages.getString("CFunctionTracepoint.0"), //$NON-NLS-1$ + (Object[]) new String[] { CDebugUtils.getBreakpointText(this, false) }); } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CLineBreakpoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CLineBreakpoint.java index 0439685a5d6..011feb78272 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CLineBreakpoint.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CLineBreakpoint.java @@ -39,13 +39,13 @@ public class CLineBreakpoint extends AbstractLineBreakpoint { /** * Constructor for CLineBreakpoint. */ - public CLineBreakpoint( IResource resource, Map<String, Object> attributes, boolean add ) throws CoreException { - super( resource, attributes, add ); + public CLineBreakpoint(IResource resource, Map<String, Object> attributes, boolean add) throws CoreException { + super(resource, attributes, add); } - + @Override public String getMarkerType() { - return C_LINE_BREAKPOINT_MARKER; + return C_LINE_BREAKPOINT_MARKER; } /*(non-Javadoc) @@ -58,22 +58,21 @@ public class CLineBreakpoint extends AbstractLineBreakpoint { int bp_request_line = 0; String bp_file = null; String bp_reqest_file = null; - + if (marker != null) { bp_line = marker.getAttribute(IMarker.LINE_NUMBER, -1); bp_request_line = marker.getAttribute(ICLineBreakpoint2.REQUESTED_LINE, -1); - bp_file = marker.getAttribute(ICBreakpoint.SOURCE_HANDLE, (String)null); - bp_reqest_file = marker.getAttribute(ICLineBreakpoint2.REQUESTED_SOURCE_HANDLE, (String)null); + bp_file = marker.getAttribute(ICBreakpoint.SOURCE_HANDLE, (String) null); + bp_reqest_file = marker.getAttribute(ICLineBreakpoint2.REQUESTED_SOURCE_HANDLE, (String) null); } - - if (bp_line != bp_request_line || - (bp_file == null && bp_reqest_file != null) || - (bp_file != null && !bp_file.equals(bp_reqest_file)) ) - { - return MessageFormat.format( BreakpointMessages.getString( "CLineBreakpoint.1" ), (Object[])new String[] { CDebugUtils.getBreakpointText( this, false ) } ); //$NON-NLS-1$ - } - else { - return MessageFormat.format( BreakpointMessages.getString( "CLineBreakpoint.0" ), (Object[])new String[] { CDebugUtils.getBreakpointText( this, false ) } ); //$NON-NLS-1$ + + if (bp_line != bp_request_line || (bp_file == null && bp_reqest_file != null) + || (bp_file != null && !bp_file.equals(bp_reqest_file))) { + return MessageFormat.format(BreakpointMessages.getString("CLineBreakpoint.1"), //$NON-NLS-1$ + (Object[]) new String[] { CDebugUtils.getBreakpointText(this, false) }); + } else { + return MessageFormat.format(BreakpointMessages.getString("CLineBreakpoint.0"), //$NON-NLS-1$ + (Object[]) new String[] { CDebugUtils.getBreakpointText(this, false) }); } } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CLineDynamicPrintf.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CLineDynamicPrintf.java index adf8996b7a9..4cb53aea36a 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CLineDynamicPrintf.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CLineDynamicPrintf.java @@ -35,15 +35,15 @@ public class CLineDynamicPrintf extends AbstractDynamicPrintf implements ICDynam public CLineDynamicPrintf() { } - public CLineDynamicPrintf( IResource resource, Map<String, Object> attributes, boolean add ) throws CoreException { - super( resource, attributes, add ); + public CLineDynamicPrintf(IResource resource, Map<String, Object> attributes, boolean add) throws CoreException { + super(resource, attributes, add); } @Override public String getMarkerType() { - return C_LINE_DYNAMICPRINTF_MARKER; + return C_LINE_DYNAMICPRINTF_MARKER; } - + /*(non-Javadoc) * @see org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint#getMarkerMessage() */ @@ -54,23 +54,22 @@ public class CLineDynamicPrintf extends AbstractDynamicPrintf implements ICDynam int bp_request_line = 0; String bp_file = null; String bp_reqest_file = null; - + if (marker != null) { bp_line = marker.getAttribute(IMarker.LINE_NUMBER, -1); bp_request_line = marker.getAttribute(ICLineBreakpoint2.REQUESTED_LINE, -1); - bp_file = marker.getAttribute(ICBreakpoint.SOURCE_HANDLE, (String)null); - bp_reqest_file = marker.getAttribute(ICLineBreakpoint2.REQUESTED_SOURCE_HANDLE, (String)null); - } - - if (bp_line != bp_request_line || - (bp_file == null && bp_reqest_file != null) || - (bp_file != null && !bp_file.equals(bp_reqest_file)) ) - { - return MessageFormat.format( BreakpointMessages.getString( "CLineDynamicPrintf.1" ), (Object[])new String[] { CDebugUtils.getBreakpointText( this, false ) } ); //$NON-NLS-1$ + bp_file = marker.getAttribute(ICBreakpoint.SOURCE_HANDLE, (String) null); + bp_reqest_file = marker.getAttribute(ICLineBreakpoint2.REQUESTED_SOURCE_HANDLE, (String) null); } - else { - return MessageFormat.format( BreakpointMessages.getString( "CLineDynamicPrintf.0" ), (Object[])new String[] { CDebugUtils.getBreakpointText( this, false ) } ); //$NON-NLS-1$ + + if (bp_line != bp_request_line || (bp_file == null && bp_reqest_file != null) + || (bp_file != null && !bp_file.equals(bp_reqest_file))) { + return MessageFormat.format(BreakpointMessages.getString("CLineDynamicPrintf.1"), //$NON-NLS-1$ + (Object[]) new String[] { CDebugUtils.getBreakpointText(this, false) }); + } else { + return MessageFormat.format(BreakpointMessages.getString("CLineDynamicPrintf.0"), //$NON-NLS-1$ + (Object[]) new String[] { CDebugUtils.getBreakpointText(this, false) }); } - } + } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CLineTracepoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CLineTracepoint.java index c88ae3b28e9..4abceb45771 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CLineTracepoint.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CLineTracepoint.java @@ -41,139 +41,140 @@ public class CLineTracepoint extends AbstractTracepoint implements ICTracepoint, /** * Constructor for CLineTracepoint. */ - public CLineTracepoint( IResource resource, Map<String, Object> attributes, boolean add ) throws CoreException { - super( resource, attributes, add ); + public CLineTracepoint(IResource resource, Map<String, Object> attributes, boolean add) throws CoreException { + super(resource, attributes, add); } @Override public String getMarkerType() { - return C_LINE_TRACEPOINT_MARKER; + return C_LINE_TRACEPOINT_MARKER; } - - @Override - public synchronized int decrementInstallCount() throws CoreException { - int count = super.decrementInstallCount(); - if (Boolean.TRUE.equals(this.getMarker().getAttribute(RESET_INSTALLED_LOCATION))) { - if (count == 0) { - resetInstalledLocation(); - setAttribute(RESET_INSTALLED_LOCATION, Boolean.FALSE); - } - } + @Override + public synchronized int decrementInstallCount() throws CoreException { + int count = super.decrementInstallCount(); + + if (Boolean.TRUE.equals(this.getMarker().getAttribute(RESET_INSTALLED_LOCATION))) { + if (count == 0) { + resetInstalledLocation(); + setAttribute(RESET_INSTALLED_LOCATION, Boolean.FALSE); + } + } - return count; - } + return count; + } /*(non-Javadoc) * @see org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint#getMarkerMessage() */ @Override protected String getMarkerMessage() throws CoreException { - return MessageFormat.format( BreakpointMessages.getString( "CLineTracepoint.0" ), (Object[])new String[] { CDebugUtils.getBreakpointText( this, false ) } ); //$NON-NLS-1$ - } - - @Override - public int getRequestedLine() throws CoreException { - return ensureMarker().getAttribute( ICLineBreakpoint2.REQUESTED_LINE, -1 ); - } - - @Override - public void setRequestedLine(int line) throws CoreException { - setAttribute( ICLineBreakpoint2.REQUESTED_LINE, line ); - } - - @Override - public int getRequestedCharStart() throws CoreException { - return ensureMarker().getAttribute( ICLineBreakpoint2.REQUESTED_CHAR_START, -1 ); - } - - @Override - public void setRequestedCharStart(int charStart) throws CoreException { - setAttribute( ICLineBreakpoint2.REQUESTED_CHAR_START, charStart ); - } - - @Override - public int getRequestedCharEnd() throws CoreException { - return ensureMarker().getAttribute( ICLineBreakpoint2.REQUESTED_CHAR_END, -1 ); - } - - @Override - public void setRequestedCharEnd(int charEnd) throws CoreException { - setAttribute( ICLineBreakpoint2.REQUESTED_CHAR_END, charEnd ); - } - - @Override - public String getRequestedSourceHandle() throws CoreException { - return ensureMarker().getAttribute( ICLineBreakpoint2.REQUESTED_SOURCE_HANDLE, "" ); //$NON-NLS-1$ - } - - @Override - public void setRequestedSourceHandle(String fileName) throws CoreException { - setAttribute( ICLineBreakpoint2.REQUESTED_SOURCE_HANDLE, fileName ); - setAttribute(RESET_INSTALLED_LOCATION, Boolean.FALSE); - } - - @Override - public void setInstalledLineNumber(int line) throws CoreException { - int existingValue = ensureMarker().getAttribute(IMarker.LINE_NUMBER, -1); - if (line != existingValue) { - setAttribute(IMarker.LINE_NUMBER, line); - setAttribute(RESET_INSTALLED_LOCATION, Boolean.TRUE); - setAttribute( IMarker.MESSAGE, getMarkerMessage() ); - } - } - - @Override - public void setInstalledCharStart(int charStart) throws CoreException { - int existingValue = ensureMarker().getAttribute(IMarker.CHAR_START, -1); - if (charStart != existingValue) { - setAttribute(IMarker.CHAR_START, charStart); - setAttribute(RESET_INSTALLED_LOCATION, Boolean.TRUE); - setAttribute( IMarker.MESSAGE, getMarkerMessage() ); - } - } - - @Override - public void setInstalledCharEnd(int charEnd) throws CoreException { - int existingValue = ensureMarker().getAttribute(IMarker.CHAR_END, -1); - if (charEnd != existingValue) { - setAttribute(IMarker.CHAR_END, charEnd); - setAttribute(RESET_INSTALLED_LOCATION, Boolean.TRUE); - setAttribute( IMarker.MESSAGE, getMarkerMessage() ); - } - } - - @Override - public void resetInstalledLocation() throws CoreException { - boolean locationReset = false; - if (this.getMarker().getAttribute(REQUESTED_LINE) != null) { - int line = this.getMarker().getAttribute(REQUESTED_LINE, -1); - setAttribute(IMarker.LINE_NUMBER, line); - locationReset = true; - } - if (this.getMarker().getAttribute(REQUESTED_CHAR_START) != null) { - int charStart = this.getMarker().getAttribute(REQUESTED_CHAR_START, -1); - setAttribute(IMarker.CHAR_START, charStart); - locationReset = true; - } - if (this.getMarker().getAttribute(REQUESTED_CHAR_END) != null) { - int charEnd = this.getMarker().getAttribute(REQUESTED_CHAR_END, -1); - setAttribute(IMarker.CHAR_END, charEnd); - locationReset = true; - } - if (this.getMarker().getAttribute(REQUESTED_SOURCE_HANDLE) != null) { - String file = this.getMarker().getAttribute(REQUESTED_SOURCE_HANDLE, ""); //$NON-NLS-1$ - setAttribute(ICBreakpoint.SOURCE_HANDLE, file); - locationReset = true; - } - if (locationReset) { - setAttribute( IMarker.MESSAGE, getMarkerMessage() ); - } - } - - @Override - public void refreshMessage() throws CoreException { - IMarker marker = ensureMarker(); - marker.setAttribute(IMarker.MESSAGE, getMarkerMessage()); - } + return MessageFormat.format(BreakpointMessages.getString("CLineTracepoint.0"), //$NON-NLS-1$ + (Object[]) new String[] { CDebugUtils.getBreakpointText(this, false) }); + } + + @Override + public int getRequestedLine() throws CoreException { + return ensureMarker().getAttribute(ICLineBreakpoint2.REQUESTED_LINE, -1); + } + + @Override + public void setRequestedLine(int line) throws CoreException { + setAttribute(ICLineBreakpoint2.REQUESTED_LINE, line); + } + + @Override + public int getRequestedCharStart() throws CoreException { + return ensureMarker().getAttribute(ICLineBreakpoint2.REQUESTED_CHAR_START, -1); + } + + @Override + public void setRequestedCharStart(int charStart) throws CoreException { + setAttribute(ICLineBreakpoint2.REQUESTED_CHAR_START, charStart); + } + + @Override + public int getRequestedCharEnd() throws CoreException { + return ensureMarker().getAttribute(ICLineBreakpoint2.REQUESTED_CHAR_END, -1); + } + + @Override + public void setRequestedCharEnd(int charEnd) throws CoreException { + setAttribute(ICLineBreakpoint2.REQUESTED_CHAR_END, charEnd); + } + + @Override + public String getRequestedSourceHandle() throws CoreException { + return ensureMarker().getAttribute(ICLineBreakpoint2.REQUESTED_SOURCE_HANDLE, ""); //$NON-NLS-1$ + } + + @Override + public void setRequestedSourceHandle(String fileName) throws CoreException { + setAttribute(ICLineBreakpoint2.REQUESTED_SOURCE_HANDLE, fileName); + setAttribute(RESET_INSTALLED_LOCATION, Boolean.FALSE); + } + + @Override + public void setInstalledLineNumber(int line) throws CoreException { + int existingValue = ensureMarker().getAttribute(IMarker.LINE_NUMBER, -1); + if (line != existingValue) { + setAttribute(IMarker.LINE_NUMBER, line); + setAttribute(RESET_INSTALLED_LOCATION, Boolean.TRUE); + setAttribute(IMarker.MESSAGE, getMarkerMessage()); + } + } + + @Override + public void setInstalledCharStart(int charStart) throws CoreException { + int existingValue = ensureMarker().getAttribute(IMarker.CHAR_START, -1); + if (charStart != existingValue) { + setAttribute(IMarker.CHAR_START, charStart); + setAttribute(RESET_INSTALLED_LOCATION, Boolean.TRUE); + setAttribute(IMarker.MESSAGE, getMarkerMessage()); + } + } + + @Override + public void setInstalledCharEnd(int charEnd) throws CoreException { + int existingValue = ensureMarker().getAttribute(IMarker.CHAR_END, -1); + if (charEnd != existingValue) { + setAttribute(IMarker.CHAR_END, charEnd); + setAttribute(RESET_INSTALLED_LOCATION, Boolean.TRUE); + setAttribute(IMarker.MESSAGE, getMarkerMessage()); + } + } + + @Override + public void resetInstalledLocation() throws CoreException { + boolean locationReset = false; + if (this.getMarker().getAttribute(REQUESTED_LINE) != null) { + int line = this.getMarker().getAttribute(REQUESTED_LINE, -1); + setAttribute(IMarker.LINE_NUMBER, line); + locationReset = true; + } + if (this.getMarker().getAttribute(REQUESTED_CHAR_START) != null) { + int charStart = this.getMarker().getAttribute(REQUESTED_CHAR_START, -1); + setAttribute(IMarker.CHAR_START, charStart); + locationReset = true; + } + if (this.getMarker().getAttribute(REQUESTED_CHAR_END) != null) { + int charEnd = this.getMarker().getAttribute(REQUESTED_CHAR_END, -1); + setAttribute(IMarker.CHAR_END, charEnd); + locationReset = true; + } + if (this.getMarker().getAttribute(REQUESTED_SOURCE_HANDLE) != null) { + String file = this.getMarker().getAttribute(REQUESTED_SOURCE_HANDLE, ""); //$NON-NLS-1$ + setAttribute(ICBreakpoint.SOURCE_HANDLE, file); + locationReset = true; + } + if (locationReset) { + setAttribute(IMarker.MESSAGE, getMarkerMessage()); + } + } + + @Override + public void refreshMessage() throws CoreException { + IMarker marker = ensureMarker(); + marker.setAttribute(IMarker.MESSAGE, getMarkerMessage()); + } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CWatchpoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CWatchpoint.java index 0549835de11..49781cca6f3 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CWatchpoint.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CWatchpoint.java @@ -37,21 +37,21 @@ public class CWatchpoint extends CBreakpoint implements ICWatchpoint2 { /** * Constructor for CWatchpoint. */ - public CWatchpoint( IResource resource, Map<String, Object> attributes, boolean add ) throws CoreException { - super( resource, attributes, add ); + public CWatchpoint(IResource resource, Map<String, Object> attributes, boolean add) throws CoreException { + super(resource, attributes, add); } @Override public String getMarkerType() { - return C_WATCHPOINT_MARKER; + return C_WATCHPOINT_MARKER; } - + /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.model.ICWatchpoint#isWriteType() */ @Override public boolean isWriteType() throws CoreException { - return ensureMarker().getAttribute( WRITE, true ); + return ensureMarker().getAttribute(WRITE, true); } /* (non-Javadoc) @@ -59,7 +59,7 @@ public class CWatchpoint extends CBreakpoint implements ICWatchpoint2 { */ @Override public boolean isReadType() throws CoreException { - return ensureMarker().getAttribute( READ, false ); + return ensureMarker().getAttribute(READ, false); } /* (non-Javadoc) @@ -67,7 +67,7 @@ public class CWatchpoint extends CBreakpoint implements ICWatchpoint2 { */ @Override public String getExpression() throws CoreException { - return ensureMarker().getAttribute( EXPRESSION, "" ); //$NON-NLS-1$ + return ensureMarker().getAttribute(EXPRESSION, ""); //$NON-NLS-1$ } /* (non-Javadoc) @@ -75,14 +75,14 @@ public class CWatchpoint extends CBreakpoint implements ICWatchpoint2 { */ @Override protected String getMarkerMessage() throws CoreException { - String format = BreakpointMessages.getString( "CWatchpoint.3" ); //$NON-NLS-1$ - if ( isWriteType() && !isReadType() ) - format = BreakpointMessages.getString( "CWatchpoint.0" ); //$NON-NLS-1$ - else if ( !isWriteType() && isReadType() ) - format = BreakpointMessages.getString( "CWatchpoint.1" ); //$NON-NLS-1$ - else if ( isWriteType() && isReadType() ) - format = BreakpointMessages.getString( "CWatchpoint.2" ); //$NON-NLS-1$ - return MessageFormat.format( format, new Object[] { CDebugUtils.getBreakpointText( this, false ) } ); + String format = BreakpointMessages.getString("CWatchpoint.3"); //$NON-NLS-1$ + if (isWriteType() && !isReadType()) + format = BreakpointMessages.getString("CWatchpoint.0"); //$NON-NLS-1$ + else if (!isWriteType() && isReadType()) + format = BreakpointMessages.getString("CWatchpoint.1"); //$NON-NLS-1$ + else if (isWriteType() && isReadType()) + format = BreakpointMessages.getString("CWatchpoint.2"); //$NON-NLS-1$ + return MessageFormat.format(format, new Object[] { CDebugUtils.getBreakpointText(this, false) }); } /* (non-Javadoc) @@ -90,7 +90,7 @@ public class CWatchpoint extends CBreakpoint implements ICWatchpoint2 { */ @Override public int getLineNumber() throws CoreException { - return ensureMarker().getAttribute( IMarker.LINE_NUMBER, -1 ); + return ensureMarker().getAttribute(IMarker.LINE_NUMBER, -1); } /* (non-Javadoc) @@ -98,7 +98,7 @@ public class CWatchpoint extends CBreakpoint implements ICWatchpoint2 { */ @Override public int getCharStart() throws CoreException { - return ensureMarker().getAttribute( IMarker.CHAR_START, -1 ); + return ensureMarker().getAttribute(IMarker.CHAR_START, -1); } /* (non-Javadoc) @@ -106,18 +106,18 @@ public class CWatchpoint extends CBreakpoint implements ICWatchpoint2 { */ @Override public int getCharEnd() throws CoreException { - return ensureMarker().getAttribute( IMarker.CHAR_END, -1 ); + return ensureMarker().getAttribute(IMarker.CHAR_END, -1); } @Override public String getMemorySpace() throws CoreException { - return ensureMarker().getAttribute( MEMORYSPACE, "" ); //$NON-NLS-1$ + return ensureMarker().getAttribute(MEMORYSPACE, ""); //$NON-NLS-1$ } @Override public BigInteger getRange() throws CoreException { - String attr = ensureMarker().getAttribute( RANGE, "0" ); //$NON-NLS-1$ - return new BigInteger( attr.length() > 0 ? attr : "0" ); //$NON-NLS-1$ + String attr = ensureMarker().getAttribute(RANGE, "0"); //$NON-NLS-1$ + return new BigInteger(attr.length() > 0 ? attr : "0"); //$NON-NLS-1$ } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/disassembly/DisassemblyContextService.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/disassembly/DisassemblyContextService.java index ba73c21d051..2ffa1bde74a 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/disassembly/DisassemblyContextService.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/disassembly/DisassemblyContextService.java @@ -23,47 +23,47 @@ import org.eclipse.core.runtime.ListenerList; public class DisassemblyContextService implements IDisassemblyContextService { - private ListenerList<IDisassemblyContextListener> fListeners; - private Set<Object> fContexts; + private ListenerList<IDisassemblyContextListener> fListeners; + private Set<Object> fContexts; - public DisassemblyContextService() { - fContexts = new CopyOnWriteArraySet<Object>(); - fListeners = new ListenerList<>(); - } + public DisassemblyContextService() { + fContexts = new CopyOnWriteArraySet<Object>(); + fListeners = new ListenerList<>(); + } - @Override - public void addDisassemblyContextListener( IDisassemblyContextListener listener ) { - fListeners.add( listener ); - } + @Override + public void addDisassemblyContextListener(IDisassemblyContextListener listener) { + fListeners.add(listener); + } - @Override - public void removeDisassemblyContextListener( IDisassemblyContextListener listener ) { - fListeners.remove( listener ); - } + @Override + public void removeDisassemblyContextListener(IDisassemblyContextListener listener) { + fListeners.remove(listener); + } - @Override - public void register( Object context ) { - fContexts.add( context ); - for( IDisassemblyContextListener listener : fListeners) { - listener.contextAdded( context ); - } - } + @Override + public void register(Object context) { + fContexts.add(context); + for (IDisassemblyContextListener listener : fListeners) { + listener.contextAdded(context); + } + } - @Override - public void unregister( Object context ) { - fContexts.remove( context ); - for( IDisassemblyContextListener listener : fListeners) { - listener.contextRemoved( context ); - } - } + @Override + public void unregister(Object context) { + fContexts.remove(context); + for (IDisassemblyContextListener listener : fListeners) { + listener.contextRemoved(context); + } + } - public void dispose() { - for( Object context : fContexts ) { - for( IDisassemblyContextListener listener : fListeners) { - listener.contextRemoved( context ); - } - } - fListeners.clear(); - fContexts.clear(); - } + public void dispose() { + for (Object context : fContexts) { + for (IDisassemblyContextListener listener : fListeners) { + listener.contextRemoved(context); + } + } + fListeners.clear(); + fContexts.clear(); + } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/executables/StandardExecutableImporter.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/executables/StandardExecutableImporter.java index 4fbbf1ec8a3..4e7452b38a8 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/executables/StandardExecutableImporter.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/executables/StandardExecutableImporter.java @@ -58,7 +58,7 @@ public class StandardExecutableImporter implements IExecutableImporter { /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.debug.core.executables.IExecutableImporter#importExecutables(java.lang.String[], * org.eclipse.core.runtime.IProgressMonitor) */ @@ -95,7 +95,7 @@ public class StandardExecutableImporter implements IExecutableImporter { IProject newProjectHandle = workspace.getRoot().getProject(defaultProjectName); int projectSuffix = 2; - while (newProjectHandle.exists()){ + while (newProjectHandle.exists()) { newProjectHandle = workspace.getRoot().getProject(defaultProjectName + projectSuffix); projectSuffix++; } @@ -115,11 +115,12 @@ public class StandardExecutableImporter implements IExecutableImporter { if (fileStore.fetchInfo().isDirectory()) fileStore.delete(EFS.NONE, new NullProgressMonitor()); } - exeProject = CCorePlugin.getDefault().createCProject(description, newProjectHandle, null, DEBUG_PROJECT_ID); + exeProject = CCorePlugin.getDefault().createCProject(description, newProjectHandle, null, + DEBUG_PROJECT_ID); } catch (OperationCanceledException e) { - DebugPlugin.log( e ); + DebugPlugin.log(e); } catch (CoreException e) { - DebugPlugin.log( e ); + DebugPlugin.log(e); } } checkProject = true; @@ -138,7 +139,7 @@ public class StandardExecutableImporter implements IExecutableImporter { } public boolean AllowImport(IPath path) { - return (!ExecutablesManager.getExecutablesManager().executableExists(path)); + return (!ExecutablesManager.getExecutablesManager().executableExists(path)); } private IContainer createFromRoot(IProject exeProject, IPath path) throws CoreException { @@ -148,7 +149,8 @@ public class StandardExecutableImporter implements IExecutableImporter { for (int i = 0; i < segmentCount; i++) { currentFolder = currentFolder.getFolder(new Path(path.segment(i))); if (!currentFolder.exists()) { - ((IFolder) currentFolder).create(IResource.VIRTUAL | IResource.DERIVED, true, new NullProgressMonitor()); + ((IFolder) currentFolder).create(IResource.VIRTUAL | IResource.DERIVED, true, + new NullProgressMonitor()); } } @@ -224,7 +226,8 @@ public class StandardExecutableImporter implements IExecutableImporter { private boolean validateBinaryParsers(IProject exeProject, File file) { IExtension[] binaryParserExtensions; - IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, CCorePlugin.BINARY_PARSER_SIMPLE_ID); + 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<IExtension>(); @@ -243,18 +246,18 @@ public class StandardExecutableImporter implements IExecutableImporter { ICProjectDescription pd = CCorePlugin.getDefault().getProjectDescription(exeProject); try { boolean existsAlready = false; - ICConfigExtensionReference[] parsers = pd.getDefaultSettingConfiguration().get(CCorePlugin.BINARY_PARSER_UNIQ_ID); + ICConfigExtensionReference[] parsers = pd.getDefaultSettingConfiguration() + .get(CCorePlugin.BINARY_PARSER_UNIQ_ID); for (ICConfigExtensionReference configExtensionReference : parsers) { - if (configExtensionReference.getID().equals(parserID)) - { + if (configExtensionReference.getID().equals(parserID)) { existsAlready = true; break; } } - if (!existsAlready) - { + if (!existsAlready) { pd.getDefaultSettingConfiguration().create(CCorePlugin.BINARY_PARSER_UNIQ_ID, parserID); - CCorePlugin.getDefault().setProjectDescription(exeProject, pd, true, new NullProgressMonitor()); + CCorePlugin.getDefault().setProjectDescription(exeProject, pd, true, + new NullProgressMonitor()); } } catch (CoreException e) { } @@ -270,7 +273,8 @@ public class StandardExecutableImporter implements IExecutableImporter { 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); + return bin != null && (bin.getType() == IBinaryParser.IBinaryFile.EXECUTABLE + || bin.getType() == IBinaryParser.IBinaryFile.SHARED); } catch (IOException e) { return false; } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/executables/StandardSourceFileRemapping.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/executables/StandardSourceFileRemapping.java index 8558cf03146..892c1e02020 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/executables/StandardSourceFileRemapping.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/executables/StandardSourceFileRemapping.java @@ -26,7 +26,7 @@ public class StandardSourceFileRemapping implements ISourceFileRemapping { public StandardSourceFileRemapping(IBinary binary) { srcFinder = binary.getAdapter(ISourceFinder.class); } - + @Override public String remapSourceFile(IPath executable, String filePath) { if (srcFinder != null) { @@ -37,12 +37,12 @@ public class StandardSourceFileRemapping implements ISourceFileRemapping { } return filePath; } - + /* (non-Javadoc) * @see java.lang.Object#finalize() */ @Override - public void finalize(){ + public void finalize() { srcFinder.dispose(); } }
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/executables/StandardSourceFileRemappingFactory.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/executables/StandardSourceFileRemappingFactory.java index 0d08970ff1a..44b08ea95fe 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/executables/StandardSourceFileRemappingFactory.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/executables/StandardSourceFileRemappingFactory.java @@ -17,7 +17,7 @@ import org.eclipse.cdt.core.model.IBinary; import org.eclipse.cdt.debug.core.executables.ISourceFileRemapping; import org.eclipse.cdt.debug.core.executables.ISourceFileRemappingFactory; -public class StandardSourceFileRemappingFactory implements ISourceFileRemappingFactory{ +public class StandardSourceFileRemappingFactory implements ISourceFileRemappingFactory { /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.executables.ISourceFileRemappingFactory#createRemapper(org.eclipse.cdt.core.model.IBinary) diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/executables/StandardSourceFilesProvider.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/executables/StandardSourceFilesProvider.java index 92e26bdf5e8..86467ffc52e 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/executables/StandardSourceFilesProvider.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/executables/StandardSourceFilesProvider.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Ken Ryall (Nokia) - initial API and implementation *******************************************************************************/ diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/launch/CoreBuildLocalRunLaunchDelegate.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/launch/CoreBuildLocalRunLaunchDelegate.java index ba237df37f9..d754a6c6a68 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/launch/CoreBuildLocalRunLaunchDelegate.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/launch/CoreBuildLocalRunLaunchDelegate.java @@ -43,7 +43,8 @@ public class CoreBuildLocalRunLaunchDelegate extends CoreBuildLaunchConfigDelega Process process = builder.start(); DebugPlugin.newProcess(launch, process, exeFile.getPath().lastSegment()); } catch (IOException e) { - throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID, InternalDebugCoreMessages.CoreBuildLocalRunLaunchDelegate_ErrorLaunching, e)); + throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID, + InternalDebugCoreMessages.CoreBuildLocalRunLaunchDelegate_ErrorLaunching, e)); } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CoreModelMessages.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CoreModelMessages.java index c25dce38dd9..b117c1a9beb 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CoreModelMessages.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CoreModelMessages.java @@ -20,16 +20,15 @@ public class CoreModelMessages { private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.core.model.CoreModelMessages"; //$NON-NLS-1$ - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); private CoreModelMessages() { } - 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.core/src/org/eclipse/cdt/debug/internal/core/model/IRegisterGroupDescriptor.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/IRegisterGroupDescriptor.java index 660bd940727..3b8fdf006b1 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/IRegisterGroupDescriptor.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/IRegisterGroupDescriptor.java @@ -35,13 +35,13 @@ public interface IRegisterGroupDescriptor { * @throws CoreException */ public IRegisterDescriptor[] getChildren() throws CoreException; - + /** * The id of the container this register group belongs to. - * If null, the register group applies to the entire launch, - * otherwise it applies only to a given core, or process, within the launch. + * If null, the register group applies to the entire launch, + * otherwise it applies only to a given core, or process, within the launch. */ default String getContainerId() { - return null; + return null; }; } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceContainerType.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceContainerType.java index 5d7f5337318..48b49b30dfb 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceContainerType.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceContainerType.java @@ -11,7 +11,7 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.core.sourcelookup; +package org.eclipse.cdt.debug.internal.core.sourcelookup; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.Path; @@ -21,7 +21,7 @@ import org.eclipse.debug.core.sourcelookup.containers.DirectorySourceContainer; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; - + /** * See <code>CDirectorySourceContainer</code>. */ @@ -49,7 +49,7 @@ public class CDirectorySourceContainerType extends AbstractSourceContainerTypeDe abort(InternalSourceLookupMessages.CDirectorySourceContainerType_2, null); return null; } - + /* (non-Javadoc) * @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainerType#getMemento(org.eclipse.debug.internal.core.sourcelookup.ISourceContainer) */ diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceLocation.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceLocation.java index 0764cd5c585..8a7327a6087 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceLocation.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceLocation.java @@ -47,10 +47,10 @@ import org.xml.sax.InputSource; import org.xml.sax.SAXException; /** - * + * * Locates source elements in a directory in the local * file system. Returns instances of <code>FileStorage</code>. - * + * * @since Sep 23, 2002 */ public class CDirectorySourceLocation implements IDirectorySourceLocation { @@ -64,7 +64,7 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation { */ private IPath fDirectory; /** - * The associated path of this source location. + * The associated path of this source location. */ private IPath fAssociation; private boolean fSearchForDuplicateFiles; @@ -124,7 +124,7 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation { /** * Sets the directory in which source elements will be searched for. - * + * * @param directory a directory */ private void setDirectory(IPath directory) { @@ -133,7 +133,7 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation { /** * Returns the root directory of this source location. - * + * * @return directory */ @Override @@ -161,7 +161,7 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation { return null; File[] folders = getFolders(); if (folders != null) { - LinkedList<Object> list = new LinkedList<Object>(); + LinkedList<Object> list = new LinkedList<Object>(); for (int i = 0; i < folders.length; ++i) { Object result = findFileByAbsolutePath(folders[i], name); if (result instanceof List) { @@ -178,7 +178,7 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation { } } } - if (list.size() > 0) + if (list.size() > 0) return (list.size() == 1) ? list.getFirst() : list; } return null; @@ -192,8 +192,8 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation { IPath path = new Path(folder.getAbsolutePath()); IPath association = getAssociation(); if (!isPrefix(path, filePath) || path.segmentCount() + 1 != filePath.segmentCount()) { - if (association != null && - isPrefix(association, filePath) && association.segmentCount() + 1 == filePath.segmentCount()) { + if (association != null && isPrefix(association, filePath) + && association.segmentCount() + 1 == filePath.segmentCount()) { filePath = path.append(filePath.removeFirstSegments(association.segmentCount())); } else { return null; @@ -209,7 +209,7 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation { return wsFiles[j]; list.add(wsFiles[j]); } - if (list.size() > 0) + if (list.size() > 0) return (list.size() == 1) ? list.getFirst() : list; file = filePath.toFile(); @@ -223,7 +223,7 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation { private Object findFileByRelativePath(String fileName) { File[] folders = getFolders(); if (folders != null) { - LinkedList<Object> list = new LinkedList<Object>(); + LinkedList<Object> list = new LinkedList<Object>(); for (int i = 0; i < folders.length; ++i) { Object result = findFileByRelativePath(folders[i], fileName); if (result instanceof List) { @@ -248,7 +248,7 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation { private Object findFileByRelativePath(File folder, String fileName) { IPath path = new Path(folder.getAbsolutePath()); - path = path.append(fileName); + path = path.append(fileName); File file = path.toFile(); if (file.exists() && file.isFile()) { path = new Path(file.getAbsolutePath()); @@ -260,13 +260,13 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation { return wsFiles[j]; list.add(wsFiles[j]); } - if (list.size() > 0) + if (list.size() > 0) return (list.size() == 1) ? list.getFirst() : list; return createExternalFileStorage(path); } return null; } - + private IStorage createExternalFileStorage(IPath path) { return new FileStorage(path); } @@ -276,20 +276,20 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation { */ @Override public String getMemento() throws CoreException { - Document document = null; - Throwable ex = null; - try { - document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); - Element node = document.createElement(ELEMENT_NAME); - document.appendChild(node); - node.setAttribute(ATTR_DIRECTORY, getDirectory().toOSString()); - if (getAssociation() != null) - node.setAttribute(ATTR_ASSOCIATION, getAssociation().toOSString()); - node.setAttribute(ATTR_SEARCH_SUBFOLDERS, String.valueOf(searchSubfolders())); + Document document = null; + Throwable ex = null; + try { + document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); + Element node = document.createElement(ELEMENT_NAME); + document.appendChild(node); + node.setAttribute(ATTR_DIRECTORY, getDirectory().toOSString()); + if (getAssociation() != null) + node.setAttribute(ATTR_ASSOCIATION, getAssociation().toOSString()); + node.setAttribute(ATTR_SEARCH_SUBFOLDERS, String.valueOf(searchSubfolders())); return CDebugUtils.serializeDocument(document); - } catch (ParserConfigurationException e) { - ex = e; - } catch (IOException e) { + } catch (ParserConfigurationException e) { + ex = e; + } catch (IOException e) { ex = e; } catch (TransformerException e) { ex = e; @@ -350,11 +350,8 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation { * Throws an internal error exception */ private void abort(String message, Throwable e) throws CoreException { - IStatus s = new Status(IStatus.ERROR, - CDebugCorePlugin.getUniqueIdentifier(), - CDebugCorePlugin.INTERNAL_ERROR, - message, - e); + IStatus s = new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), CDebugCorePlugin.INTERNAL_ERROR, + message, e); throw new CoreException(s); } @@ -368,8 +365,8 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation { @Override public boolean equals(Object obj) { if (obj instanceof IDirectorySourceLocation) { - IPath dir = ((IDirectorySourceLocation)obj).getDirectory(); - IPath association = ((IDirectorySourceLocation)obj).getAssociation(); + IPath dir = ((IDirectorySourceLocation) obj).getDirectory(); + IPath association = ((IDirectorySourceLocation) obj).getAssociation(); if (dir == null) return false; boolean result = dir.equals(getDirectory()); @@ -444,13 +441,12 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation { private List<File> getFileFolders(File file) { ArrayList<File> list = new ArrayList<File>(); - File[] folders = file.listFiles( - new FileFilter() { - @Override - public boolean accept(File pathname) { - return pathname.isDirectory(); - } - }); + File[] folders = file.listFiles(new FileFilter() { + @Override + public boolean accept(File pathname) { + return pathname.isDirectory(); + } + }); list.addAll(Arrays.asList(folders)); for (int i = 0; i < folders.length; ++i) list.addAll(getFileFolders(folders[i])); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CProjectSourceContainerType.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CProjectSourceContainerType.java index 14a62055c83..f2bb66fe33f 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CProjectSourceContainerType.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CProjectSourceContainerType.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 * Sergey Prigogin (Google) @@ -53,7 +53,7 @@ public class CProjectSourceContainerType extends AbstractSourceContainerTypeDele public ISourceContainer createSourceContainer(String memento) throws CoreException { Node node = parseDocument(memento); if (node.getNodeType() == Node.ELEMENT_NODE) { - Element element = (Element)node; + Element element = (Element) node; if ("project".equals(element.getNodeName())) { //$NON-NLS-1$ String string = element.getAttribute("name"); //$NON-NLS-1$ IProject project = null; @@ -63,10 +63,10 @@ public class CProjectSourceContainerType extends AbstractSourceContainerTypeDele String nest = element.getAttribute("referencedProjects"); //$NON-NLS-1$ boolean ref = Boolean.parseBoolean(nest); return new CProjectSourceContainer(project, ref); - } - abort(InternalSourceLookupMessages.CProjectSourceContainerType_1, null); + } + abort(InternalSourceLookupMessages.CProjectSourceContainerType_1, null); } - abort(InternalSourceLookupMessages.CProjectSourceContainerType_2, null); + abort(InternalSourceLookupMessages.CProjectSourceContainerType_2, null); return null; } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CProjectSourceLocation.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CProjectSourceLocation.java index da3057f7472..81d5b8d4d32 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CProjectSourceLocation.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CProjectSourceLocation.java @@ -49,7 +49,7 @@ import org.xml.sax.SAXException; /** * Locates source elements in a C/C++ project. Returns instances of <code>IFile</code>. - * + * * @since Sep 23, 2002 */ public class CProjectSourceLocation implements IProjectSourceLocation { @@ -88,7 +88,7 @@ public class CProjectSourceLocation implements IProjectSourceLocation { Object result = null; if (!isEmpty(name) && getProject() != null && !notFoundCacheLookup(name)) { result = cacheLookup(name); - if (result == null) { + if (result == null) { result = doFindSourceElement(name); if (result != null) { cacheSourceElement(name, result); @@ -115,7 +115,7 @@ public class CProjectSourceLocation implements IProjectSourceLocation { /** * Sets the project in which source elements will be searched for. - * + * * @param project the project */ private void setProject(IProject project) { @@ -124,7 +124,7 @@ public class CProjectSourceLocation implements IProjectSourceLocation { /** * Returns the project associated with this source location. - * + * * @return project */ @Override @@ -181,11 +181,11 @@ public class CProjectSourceLocation implements IProjectSourceLocation { private Object cacheLookup(String name) { return fCache.get(name); } - + private boolean notFoundCacheLookup(String name) { return fNotFoundCache.contains(name); } - + private void cacheSourceElement(String name, Object element) { fCache.put(name, element); } @@ -205,24 +205,23 @@ public class CProjectSourceLocation implements IProjectSourceLocation { */ @Override public String getMemento() throws CoreException { - Document document = null; - Throwable ex = null; - try { - document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); - Element node = document.createElement(ELEMENT_NAME); - document.appendChild(node); - node.setAttribute(ATTR_PROJECT, getProject().getName()); - node.setAttribute(ATTR_GENERIC, String.valueOf(isGeneric())); + Document document = null; + Throwable ex = null; + try { + document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); + Element node = document.createElement(ELEMENT_NAME); + document.appendChild(node); + node.setAttribute(ATTR_PROJECT, getProject().getName()); + node.setAttribute(ATTR_GENERIC, String.valueOf(isGeneric())); return CDebugUtils.serializeDocument(document); - } catch (ParserConfigurationException e) { - ex = e; - } catch (IOException e) { + } catch (ParserConfigurationException e) { + ex = e; + } catch (IOException e) { ex = e; } catch (TransformerException e) { ex = e; } - abort(NLS.bind(InternalSourceLookupMessages.CProjectSourceLocation_0, - getProject().getName()), ex); + abort(NLS.bind(InternalSourceLookupMessages.CProjectSourceLocation_0, getProject().getName()), ex); // execution will not reach here return null; } @@ -266,8 +265,8 @@ public class CProjectSourceLocation implements IProjectSourceLocation { * Throws an internal error exception */ private void abort(String message, Throwable e) throws CoreException { - IStatus s = new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), - CDebugCorePlugin.INTERNAL_ERROR, message, e); + IStatus s = new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), CDebugCorePlugin.INTERNAL_ERROR, + message, e); throw new CoreException(s); } @@ -302,21 +301,19 @@ public class CProjectSourceLocation implements IProjectSourceLocation { if (getProject() != null && getProject().exists()) { list.add(getProject()); try { - getProject().accept( - new IResourceProxyVisitor() { - @Override - public boolean visit(IResourceProxy proxy) throws CoreException { - switch (proxy.getType()) { - case IResource.FILE: - return false; - case IResource.FOLDER: - list.addLast(proxy.requestResource()); - return true; - } - return true; - } - }, - IResource.NONE); + getProject().accept(new IResourceProxyVisitor() { + @Override + public boolean visit(IResourceProxy proxy) throws CoreException { + switch (proxy.getType()) { + case IResource.FILE: + return false; + case IResource.FOLDER: + list.addLast(proxy.requestResource()); + return true; + } + return true; + } + }, IResource.NONE); } catch (CoreException e) { } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLocator.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLocator.java index b3d242a086e..0f5b7a5f4b4 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLocator.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLocator.java @@ -102,7 +102,7 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato /* * (non-Javadoc) - * + * * @see org.eclipse.debug.core.model.ISourceLocator#getSourceElement(IStackFrame) */ @Override @@ -112,17 +112,17 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.debug.core.ICSourceLocator#getLineNumber(IStackFrameInfo) */ @Override public int getLineNumber(IStackFrame frame) { - return (frame instanceof ICStackFrame) ? ((ICStackFrame)frame).getFrameLineNumber() : 0; + return (frame instanceof ICStackFrame) ? ((ICStackFrame) frame).getFrameLineNumber() : 0; } protected Object getInput(IStackFrame f) { if (f instanceof ICStackFrame) { - ICStackFrame frame = (ICStackFrame)f; + ICStackFrame frame = (ICStackFrame) f; LinkedList<Object> list = new LinkedList<Object>(); Object result = null; String fileName = frame.getFile(); @@ -151,7 +151,7 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.debug.core.ICSourceLocator#contains(IResource) */ @Override @@ -159,7 +159,8 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato ICSourceLocation[] locations = getSourceLocations(); for (int i = 0; i < locations.length; ++i) { if (resource instanceof IProject) { - if (locations[i] instanceof CProjectSourceLocation && ((CProjectSourceLocation)locations[i]).getProject().equals(resource)) { + if (locations[i] instanceof CProjectSourceLocation + && ((CProjectSourceLocation) locations[i]).getProject().equals(resource)) { return true; } } @@ -179,7 +180,7 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#getSourceLocations() */ @Override @@ -199,7 +200,7 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato /** * Returns a default collection of source locations for the given project. Default source locations consist of the given project and all of its referenced * projects. - * + * * @param project * a project * @return a collection of source locations for all required projects @@ -233,7 +234,7 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato private static boolean containsProject(List<IProjectSourceLocation> list, IProject project) { Iterator<IProjectSourceLocation> it = list.iterator(); while (it.hasNext()) { - CProjectSourceLocation location = (CProjectSourceLocation)it.next(); + CProjectSourceLocation location = (CProjectSourceLocation) it.next(); if (project.equals(location.getProject())) return true; } @@ -242,7 +243,7 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#findSourceElement(String) */ @Override @@ -265,7 +266,7 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato /* * (non-Javadoc) - * + * * @see org.eclipse.debug.core.model.IPersistableSourceLocator#getMemento() */ @Override @@ -295,7 +296,7 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato /* * (non-Javadoc) - * + * * @see org.eclipse.debug.core.model.IPersistableSourceLocator#initializeDefaults(org.eclipse.debug.core.ILaunchConfiguration) */ @Override @@ -305,7 +306,7 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato /* * (non-Javadoc) - * + * * @see org.eclipse.debug.core.model.IPersistableSourceLocator#initializeFromMemento(java.lang.String) */ @Override @@ -318,7 +319,7 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato InputSource source = new InputSource(reader); root = parser.parse(source).getDocumentElement(); if (!root.getNodeName().equalsIgnoreCase(SOURCE_LOCATOR_NAME)) { - abort(InternalSourceLookupMessages.CSourceLocator_1 , null); + abort(InternalSourceLookupMessages.CSourceLocator_1, null); } List<ICSourceLocation> sourceLocations = new ArrayList<ICSourceLocation>(); // Add locations based on referenced projects @@ -350,7 +351,7 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato Node node = list.item(i); short type = node.getNodeType(); if (type == Node.ELEMENT_NODE) { - Element entry = (Element)node; + Element entry = (Element) node; if (entry.getNodeName().equalsIgnoreCase(DISABLED_GENERIC_PROJECT_NAME)) { String projectName = entry.getAttribute(ATTR_PROJECT_NAME); if (isEmpty(projectName)) { @@ -363,22 +364,23 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato Iterator<ICSourceLocation> it = sourceLocations.iterator(); while (it.hasNext()) { ICSourceLocation location = it.next(); - if (location instanceof IProjectSourceLocation && disabledProjects.contains(((IProjectSourceLocation)location).getProject().getName())) + if (location instanceof IProjectSourceLocation + && disabledProjects.contains(((IProjectSourceLocation) location).getProject().getName())) it.remove(); } } private void addAdditionalLocations(Element root, List<ICSourceLocation> sourceLocations) throws CoreException { Bundle bundle = CDebugCorePlugin.getDefault().getBundle(); - MultiStatus status = new MultiStatus(CDebugCorePlugin.getUniqueIdentifier(), - CDebugCorePlugin.INTERNAL_ERROR, InternalSourceLookupMessages.CSourceLocator_3, null); + MultiStatus status = new MultiStatus(CDebugCorePlugin.getUniqueIdentifier(), CDebugCorePlugin.INTERNAL_ERROR, + InternalSourceLookupMessages.CSourceLocator_3, null); NodeList list = root.getChildNodes(); int length = list.getLength(); for (int i = 0; i < length; ++i) { Node node = list.item(i); short type = node.getNodeType(); if (type == Node.ELEMENT_NODE) { - Element entry = (Element)node; + Element entry = (Element) node; if (entry.getNodeName().equalsIgnoreCase(ADDITIONAL_SOURCE_LOCATION_NAME)) { String className = entry.getAttribute(ATTR_CLASS); String data = entry.getAttribute(ATTR_MEMENTO); @@ -390,12 +392,13 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato try { clazz = bundle.loadClass(className); } catch (ClassNotFoundException e) { - CDebugCorePlugin.log(MessageFormat.format("Unable to restore source location - class not found {0}", new Object[]{ className })); //$NON-NLS-1$ + CDebugCorePlugin.log(MessageFormat.format( + "Unable to restore source location - class not found {0}", new Object[] { className })); //$NON-NLS-1$ continue; } ICSourceLocation location = null; try { - location = (ICSourceLocation)clazz.newInstance(); + location = (ICSourceLocation) clazz.newInstance(); } catch (IllegalAccessException e) { CDebugCorePlugin.log("Unable to restore source location."); //$NON-NLS-1$ continue; @@ -424,7 +427,7 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato Node node = list.item(i); short type = node.getNodeType(); if (type == Node.ELEMENT_NODE) { - Element entry = (Element)node; + Element entry = (Element) node; if (entry.getNodeName().equalsIgnoreCase(SOURCE_LOCATION_NAME)) { String className = entry.getAttribute(ATTR_CLASS); String data = entry.getAttribute(ATTR_MEMENTO); @@ -436,12 +439,13 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato try { clazz = bundle.loadClass(className); } catch (ClassNotFoundException e) { - CDebugCorePlugin.log(MessageFormat.format("Unable to restore source location - class not found {0}", new Object[]{ className })); //$NON-NLS-1$ + CDebugCorePlugin.log(MessageFormat.format( + "Unable to restore source location - class not found {0}", new Object[] { className })); //$NON-NLS-1$ continue; } ICSourceLocation location = null; try { - location = (ICSourceLocation)clazz.newInstance(); + location = (ICSourceLocation) clazz.newInstance(); } catch (IllegalAccessException e) { CDebugCorePlugin.log("Unable to restore source location."); //$NON-NLS-1$ continue; @@ -452,7 +456,8 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato location.initializeFrom(data); if (!sourceLocations.contains(location)) { if (location instanceof CProjectSourceLocation) - ((CProjectSourceLocation)location).setGenerated(isReferencedProject(((CProjectSourceLocation)location).getProject())); + ((CProjectSourceLocation) location).setGenerated( + isReferencedProject(((CProjectSourceLocation) location).getProject())); sourceLocations.add(location); } } @@ -464,7 +469,8 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato * Throws an internal error exception */ private void abort(String message, Throwable e) throws CoreException { - IStatus s = new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), CDebugCorePlugin.INTERNAL_ERROR, message, e); + IStatus s = new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), CDebugCorePlugin.INTERNAL_ERROR, + message, e); throw new CoreException(s); } @@ -496,7 +502,8 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato names.add(proj.getName()); } for (int i = 0; i < locations.length; ++i) { - if (locations[i] instanceof IProjectSourceLocation && ((IProjectSourceLocation) locations[i]).isGeneric()) + if (locations[i] instanceof IProjectSourceLocation + && ((IProjectSourceLocation) locations[i]).isGeneric()) names.remove(((IProjectSourceLocation) locations[i]).getProject().getName()); } for (String name : names) { @@ -509,7 +516,7 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato private void saveAdditionalSourceLocations(ICSourceLocation[] locations, Document doc, Element node) { for (int i = 0; i < locations.length; i++) { - if (locations[i] instanceof IProjectSourceLocation && ((IProjectSourceLocation)locations[i]).isGeneric()) + if (locations[i] instanceof IProjectSourceLocation && ((IProjectSourceLocation) locations[i]).isGeneric()) continue; Element child = doc.createElement(ADDITIONAL_SOURCE_LOCATION_NAME); child.setAttribute(ATTR_CLASS, locations[i].getClass().getName()); @@ -578,7 +585,8 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato ICSourceLocation[] locations = getSourceLocations(); ArrayList<ICSourceLocation> newLocations = new ArrayList<ICSourceLocation>(locations.length); for (int i = 0; i < locations.length; ++i) { - if (!(locations[i] instanceof IProjectSourceLocation) || !((IProjectSourceLocation)locations[i]).isGeneric()) + if (!(locations[i] instanceof IProjectSourceLocation) + || !((IProjectSourceLocation) locations[i]).isGeneric()) newLocations.add(locations[i]); } setSourceLocations(newLocations.toArray(new ICSourceLocation[newLocations.size()])); @@ -589,10 +597,11 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato ICSourceLocation[] locations = getSourceLocations(); ArrayList<ICSourceLocation> newLocations = new ArrayList<ICSourceLocation>(locations.length); for (int i = 0; i < locations.length; ++i) { - if (!(locations[i] instanceof IProjectSourceLocation) || !((IProjectSourceLocation)locations[i]).isGeneric()) { + if (!(locations[i] instanceof IProjectSourceLocation) + || !((IProjectSourceLocation) locations[i]).isGeneric()) { newLocations.add(locations[i]); } else { - IProject project = ((IProjectSourceLocation)locations[i]).getProject(); + IProject project = ((IProjectSourceLocation) locations[i]).getProject(); if (project.exists() && project.isOpen()) { if (newRefs.contains(project) || project.equals(getProject())) { newLocations.add(locations[i]); @@ -611,7 +620,7 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#searchForDuplicateFiles() */ @Override diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLookupDirector.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLookupDirector.java index 1fbc8a145e5..dfe42e48254 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLookupDirector.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLookupDirector.java @@ -11,10 +11,10 @@ * Contributors: * QNX Software Systems - Initial API and implementation * Nokia - Added support for AbsoluteSourceContainer(159833) - * Texas Instruments - added extension point for source container type (279473) + * Texas Instruments - added extension point for source container type (279473) * Sergey Prigogin (Google) *******************************************************************************/ -package org.eclipse.cdt.debug.internal.core.sourcelookup; +package org.eclipse.cdt.debug.internal.core.sourcelookup; import java.util.HashSet; import java.util.Set; @@ -33,14 +33,14 @@ import org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant; /** * C/C++ source lookup director. - * + * * Most instantiations of this class are transient, created through * {@link ILaunchManager#newSourceLocator(String)}. A singleton is also created * to represent the global source locators. - * + * * An instance is either associated with a particular launch configuration or it * has no association (global). - * + * * This class is created by the {@link ILaunchManager#newSourceLocator(String)} * (e.g. DebugPlugin.getDefault().getLaunchManager().newSourceLocator(type)) and * must have a no-arguments constructor. @@ -92,10 +92,10 @@ public class CSourceLookupDirector extends AbstractSourceLookupDirector { synchronized (fSupportedTypesLock) { if (fSupportedTypes == null) { fSupportedTypes = new HashSet<String>(); - String name = CDebugCorePlugin.PLUGIN_ID + ".supportedSourceContainerTypes"; //$NON-NLS-1$; + String name = CDebugCorePlugin.PLUGIN_ID + ".supportedSourceContainerTypes"; //$NON-NLS-1$; IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(name); - if (extensionPoint != null) { - for (IExtension extension : extensionPoint.getExtensions()) { + if (extensionPoint != null) { + for (IExtension extension : extensionPoint.getExtensions()) { for (IConfigurationElement configurationElements : extension.getConfigurationElements()) { String id = configurationElements.getAttribute("id"); //$NON-NLS-1$; if (id != null) diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLookupParticipant.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLookupParticipant.java index 2e4ae33918e..0b31d12fbee 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLookupParticipant.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLookupParticipant.java @@ -10,12 +10,12 @@ * * Contributors: * QNX Software Systems - Initial API and implementation - * Ken Ryall (Nokia) - Added support for AbsoluteSourceContainer(159833) + * Ken Ryall (Nokia) - Added support for AbsoluteSourceContainer(159833) * Ken Ryall (Nokia) - Added support for CSourceNotFoundElement (167305) * Ken Ryall (Nokia) - Option to open disassembly view when no source (81353) * James Blackburn (Broadcom Corp.) - Linked Resources / Nested Projects (247948) *******************************************************************************/ -package org.eclipse.cdt.debug.internal.core.sourcelookup; +package org.eclipse.cdt.debug.internal.core.sourcelookup; import java.io.File; import java.util.Collections; @@ -31,7 +31,7 @@ import org.eclipse.debug.core.model.IBreakpoint; import org.eclipse.debug.core.model.IDebugElement; import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant; import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; - + /** * A source lookup participant that searches for C/C++ source code. */ @@ -43,11 +43,11 @@ public class CSourceLookupParticipant extends AbstractSourceLookupParticipant { private static final NoSourceElement gfNoSource = new NoSourceElement(); private ListenerList fListeners; - + private Map<Object, Object[]> fCachedResults = Collections.synchronizedMap(new HashMap<Object, Object[]>()); - /** - * Constructor for CSourceLookupParticipant. + /** + * Constructor for CSourceLookupParticipant. */ public CSourceLookupParticipant() { super(); @@ -60,7 +60,7 @@ public class CSourceLookupParticipant extends AbstractSourceLookupParticipant { @Override public String getSourceName(Object object) throws CoreException { if (object instanceof String) { - return (String)object; + return (String) object; } return null; } @@ -74,12 +74,12 @@ public class CSourceLookupParticipant extends AbstractSourceLookupParticipant { Object[] results = fCachedResults.get(object); if (results != null) return results; - - // Workaround for cases when the stack frame doesn't contain the source file name + + // Workaround for cases when the stack frame doesn't contain the source file name String name = null; IBreakpoint breakpoint = null; if (object instanceof String) { - name = (String)object; + name = (String) object; } // Actually query the source containers for the requested resource @@ -91,7 +91,8 @@ public class CSourceLookupParticipant extends AbstractSourceLookupParticipant { if (new File(name).exists()) { foundElements = new AbsolutePathSourceContainer().findSourceElements(name); } else { - foundElements = new Object[] { new CSourceNotFoundElement((IDebugElement) object, ((IDebugElement) object).getLaunch().getLaunchConfiguration(), name) }; + foundElements = new Object[] { new CSourceNotFoundElement((IDebugElement) object, + ((IDebugElement) object).getLaunch().getLaunchConfiguration(), name) }; } } @@ -109,7 +110,7 @@ public class CSourceLookupParticipant extends AbstractSourceLookupParticipant { } } } - fCachedResults.put(object, foundElements); + fCachedResults.put(object, foundElements); return foundElements; } @@ -137,10 +138,10 @@ public class CSourceLookupParticipant extends AbstractSourceLookupParticipant { public void sourceContainersChanged(ISourceLookupDirector director) { // clear the cache fCachedResults.clear(); - + Object[] listeners = fListeners.getListeners(); for (int i = 0; i < listeners.length; ++i) - ((ISourceLookupChangeListener)listeners[i]).sourceContainersChanged(director); + ((ISourceLookupChangeListener) listeners[i]).sourceContainersChanged(director); super.sourceContainersChanged(director); } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceManager.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceManager.java index 23132230275..f057f1490bc 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceManager.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceManager.java @@ -43,7 +43,7 @@ public class CSourceManager implements ICSourceLocator, IPersistableSourceLocato /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#getLineNumber(IStackFrameInfo) */ @Override @@ -52,7 +52,7 @@ public class CSourceManager implements ICSourceLocator, IPersistableSourceLocato return getCSourceLocator().getLineNumber(frame); } if (frame instanceof ICStackFrame) { - return ((ICStackFrame)frame).getFrameLineNumber(); + return ((ICStackFrame) frame).getFrameLineNumber(); } return 0; } @@ -114,7 +114,7 @@ public class CSourceManager implements ICSourceLocator, IPersistableSourceLocato protected ICSourceLocator getCSourceLocator() { if (getSourceLocator() instanceof ICSourceLocator) - return (ICSourceLocator)getSourceLocator(); + return (ICSourceLocator) getSourceLocator(); return null; } @@ -175,7 +175,7 @@ public class CSourceManager implements ICSourceLocator, IPersistableSourceLocato private IPersistableSourceLocator getPersistableSourceLocator() { if (fSourceLocator instanceof IPersistableSourceLocator) - return (IPersistableSourceLocator)fSourceLocator; + return (IPersistableSourceLocator) fSourceLocator; return null; } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceNotFoundElement.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceNotFoundElement.java index 0425f4a3937..dc141229b1a 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceNotFoundElement.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceNotFoundElement.java @@ -21,7 +21,7 @@ import org.eclipse.debug.core.ILaunchConfiguration; * Wrapper for debug elements that have missing source, for example a stack * frame whose source file can not be located. Used to enable the * CSourceNotFoundEditor that will let you find the missing file. - * + * */ public class CSourceNotFoundElement { @@ -36,7 +36,7 @@ public class CSourceNotFoundElement { public CSourceNotFoundElement(IAdaptable element, ILaunchConfiguration launch, String file) { this.element = element; this.launch = launch; - + // client assumes empty string rather than null this.file = file != null ? file : ""; //$NON-NLS-1$ } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourcePathComputerDelegate.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourcePathComputerDelegate.java index 89bbe05c776..7b35e900082 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourcePathComputerDelegate.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourcePathComputerDelegate.java @@ -10,10 +10,10 @@ * * Contributors: * QNX Software Systems - Initial API and implementation - * Nokia - Added support for AbsoluteSourceContainer(159833) + * Nokia - Added support for AbsoluteSourceContainer(159833) * Sergey Prigogin (Google) *******************************************************************************/ -package org.eclipse.cdt.debug.internal.core.sourcelookup; +package org.eclipse.cdt.debug.internal.core.sourcelookup; import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.core.runtime.CoreException; @@ -22,14 +22,14 @@ import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.sourcelookup.ISourceContainer; import org.eclipse.debug.core.sourcelookup.ISourceContainerType; import org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate; - + /** * Computes the default source lookup path for a launch configuration. */ public class CSourcePathComputerDelegate implements ISourcePathComputerDelegate { - /** - * Constructor for CSourcePathComputerDelegate. + /** + * Constructor for CSourcePathComputerDelegate. */ public CSourcePathComputerDelegate() { super(); @@ -39,10 +39,11 @@ public class CSourcePathComputerDelegate implements ISourcePathComputerDelegate * @see org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate#computeSourceContainers(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.runtime.IProgressMonitor) */ @Override - public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException { + public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor) + throws CoreException { ISourceContainer[] common = CDebugCorePlugin.getDefault().getCommonSourceLookupDirector().getSourceContainers(); ISourceContainer[] containers = new ISourceContainer[common.length]; - + for (int i = 0; i < common.length; i++) { ISourceContainer container = common[i]; ISourceContainerType type = container.getType(); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CommonSourceLookupDirector.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CommonSourceLookupDirector.java index c41e9fa48b5..7e46bdc6fa3 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CommonSourceLookupDirector.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CommonSourceLookupDirector.java @@ -12,13 +12,13 @@ * QNX Software Systems - Initial API and implementation * Sergey Prigogin (Google) *******************************************************************************/ -package org.eclipse.cdt.debug.internal.core.sourcelookup; +package org.eclipse.cdt.debug.internal.core.sourcelookup; import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants; import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.sourcelookup.ISourceContainer; - + /** * Director of the common source containers. */ @@ -27,8 +27,10 @@ public class CommonSourceLookupDirector extends CSourceLookupDirector { public void setSourceContainers(ISourceContainer[] containers) { try { super.setSourceContainers(containers); - CDebugCorePlugin.getDefault().getPluginPreferences().setValue(ICDebugInternalConstants.PREF_DEFAULT_SOURCE_CONTAINERS, getMemento()); - CDebugCorePlugin.getDefault().getPluginPreferences().setValue(ICDebugInternalConstants.PREF_COMMON_SOURCE_CONTAINERS, ""); //$NON-NLS-1$ + CDebugCorePlugin.getDefault().getPluginPreferences() + .setValue(ICDebugInternalConstants.PREF_DEFAULT_SOURCE_CONTAINERS, getMemento()); + CDebugCorePlugin.getDefault().getPluginPreferences() + .setValue(ICDebugInternalConstants.PREF_COMMON_SOURCE_CONTAINERS, ""); //$NON-NLS-1$ CDebugCorePlugin.getDefault().savePluginPreferences(); } catch (CoreException e) { CDebugCorePlugin.log(e.getStatus()); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CompilationDirectorySourceContainer.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CompilationDirectorySourceContainer.java index 772e0c5699c..5a74b3dacc6 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CompilationDirectorySourceContainer.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CompilationDirectorySourceContainer.java @@ -35,11 +35,11 @@ import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage; * The assumption is that all files under a compilation directory are compiled relative to * that directory, unless they belong to another compilation directory container that is higher on * the source container list. - * + * * Source elements returned from <code>findSourceElements(...)</code> are instances of * <code>IFile</code> or <code>LocalFileStorage</code>. * <p> - * Clients may instantiate this class. + * Clients may instantiate this class. * </p> * @noextend This class is not intended to be subclassed by clients. */ @@ -48,19 +48,18 @@ public class CompilationDirectorySourceContainer extends CompositeSourceContaine * Unique identifier for the compilation directory source container type * (value <code>org.eclipse.debug.core.containerType.compilationDirectory</code>). */ - public static final String TYPE_ID = - CDebugCorePlugin.getUniqueIdentifier() + ".containerType.compilationDirectory"; //$NON-NLS-1$ - + public static final String TYPE_ID = CDebugCorePlugin.getUniqueIdentifier() + ".containerType.compilationDirectory"; //$NON-NLS-1$ + // Root directory. private File fDirectory; // Whether to each subdirectory of the compilation directory is also the compilation directory // for the files it contains. private boolean fSubfolders; - + /** * Constructs an external folder container for the * directory identified by the given path. - * + * * @param dirPath path to a directory in the local file system * @param subfolders whether folders within the root directory * should be searched for source elements @@ -68,11 +67,11 @@ public class CompilationDirectorySourceContainer extends CompositeSourceContaine public CompilationDirectorySourceContainer(IPath dirPath, boolean subfolders) { this(dirPath.toFile(), subfolders); } - + /** * Constructs an external folder container for the * directory identified by the given file. - * + * * @param dir a directory in the local file system * @param subfolders whether folders within the root directory * should be searched for source elements @@ -80,24 +79,24 @@ public class CompilationDirectorySourceContainer extends CompositeSourceContaine public CompilationDirectorySourceContainer(File dir, boolean subfolders) { fDirectory = dir; fSubfolders = subfolders; - } - + } + @Override public String getName() { return fDirectory.getAbsolutePath(); - } - + } + /** * Returns the root directory in the local file system associated * with this source container. - * + * * @return the root directory in the local file system associated * with this source container */ public File getDirectory() { return fDirectory; } - + @Override public ISourceContainerType getType() { return getSourceContainerType(TYPE_ID); @@ -117,8 +116,8 @@ public class CompilationDirectorySourceContainer extends CompositeSourceContaine if (file.exists() && file.isFile()) { Collections.addAll(sources, SourceUtils.findSourceElements(file, getDirector())); } - - // Check sub-folders + + // Check sub-folders if (fSubfolders && (isFindDuplicates() || sources.isEmpty())) { for (ISourceContainer container : getSourceContainers()) { Object[] elements = container.findSourceElements(name); @@ -134,8 +133,8 @@ public class CompilationDirectorySourceContainer extends CompositeSourceContaine break; } } - } - + } + if (sources.isEmpty()) return EMPTY; return sources.toArray(); @@ -159,7 +158,7 @@ public class CompilationDirectorySourceContainer extends CompositeSourceContaine public int hashCode() { return getDirectory().hashCode(); } - + @Override protected ISourceContainer[] createSourceContainers() throws CoreException { if (fSubfolders) { @@ -175,7 +174,7 @@ public class CompilationDirectorySourceContainer extends CompositeSourceContaine ISourceContainer[] containers = dirs.toArray(new ISourceContainer[dirs.size()]); for (ISourceContainer container : containers) { container.init(getDirector()); - } + } return containers; } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CompilationDirectorySourceContainerType.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CompilationDirectorySourceContainerType.java index 2b06f685ddd..420130e7d56 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CompilationDirectorySourceContainerType.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CompilationDirectorySourceContainerType.java @@ -11,7 +11,7 @@ * Contributors: * Sergey Prigogin (Google) - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.core.sourcelookup; +package org.eclipse.cdt.debug.internal.core.sourcelookup; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.Path; @@ -20,7 +20,7 @@ import org.eclipse.debug.core.sourcelookup.containers.AbstractSourceContainerTyp import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; - + /** * See {@link CompilationDirectorySourceContainer}. */ diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/ICSourceNotFoundDescription.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/ICSourceNotFoundDescription.java index bd9c79e4bd8..d280def239e 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/ICSourceNotFoundDescription.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/ICSourceNotFoundDescription.java @@ -14,7 +14,6 @@ package org.eclipse.cdt.debug.internal.core.sourcelookup; - /** * This interface is used to provide a description of a debug element, * usually a stack frame, when no source can be located for it. @@ -26,7 +25,7 @@ public interface ICSourceNotFoundDescription { * Returns a description of the debug element suitable for use by the * CSourceNotFoundEditor. This description is then used by the editor to * inform the user when describing what it can't locate source for. - * + * * @return the description of the debug element, or null if not available */ String getDescription(); @@ -34,7 +33,7 @@ public interface ICSourceNotFoundDescription { /** * Return true if the debug element only is an address, false if not. This * is used by the editor to know wich type of message he should use. - * + * * @return a boolean that is true if the debug element only is an address */ default boolean isAddressOnly() { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/MapEntrySourceContainer.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/MapEntrySourceContainer.java index d312115fcbd..3a73fbf0983 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/MapEntrySourceContainer.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/MapEntrySourceContainer.java @@ -11,7 +11,7 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.core.sourcelookup; +package org.eclipse.cdt.debug.internal.core.sourcelookup; import java.io.File; import java.io.IOException; @@ -34,7 +34,7 @@ import org.eclipse.debug.core.sourcelookup.containers.AbstractSourceContainer; import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage; import com.ibm.icu.text.MessageFormat; - + /** * The source container that maps a backend path to the local filesystem path. */ @@ -74,7 +74,7 @@ public class MapEntrySourceContainer extends AbstractSourceContainer { * * @param path * @return converted string - * + * * @deprecated createPath existed as a solution to try and store non-current * platform paths in an IPath, however that was limited. * createPath only exists for legacy case (see @@ -95,12 +95,12 @@ public class MapEntrySourceContainer extends AbstractSourceContainer { String device = null; String missingfile = path.replace("\\", "/"); //$NON-NLS-1$ //$NON-NLS-2$ int idx = missingfile.indexOf(":"); //$NON-NLS-1$ - if ( idx > 0 ) { + if (idx > 0) { device = missingfile.substring(0, idx + 1); missingfile = missingfile.substring(idx + 1); } return new Path(device, missingfile); - } + } int idx = 0; // Cygwin or UNC path @@ -115,8 +115,8 @@ public class MapEntrySourceContainer extends AbstractSourceContainer { path = ""; //$NON-NLS-1$ } return new Path(network, path).makeUNC(true); - } - + } + // fallthrough return new Path(path); } @@ -162,7 +162,7 @@ public class MapEntrySourceContainer extends AbstractSourceContainer { break; } } - if (list.size() > 0) + if (list.size() > 0) return list.toArray(); File file = path.toFile(); @@ -172,20 +172,22 @@ public class MapEntrySourceContainer extends AbstractSourceContainer { if (director != null && file.exists() && file.isFile()) { ILaunchConfiguration launchConfiguration = director.getLaunchConfiguration(); if (launchConfiguration != null) { - String projectName = launchConfiguration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$ + String projectName = launchConfiguration + .getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$ if (projectName.length() > 0) { ICProject project = CoreModel.getDefault().getCModel().getCProject(projectName); if (project != null) { String id; try { - final IPath location= Path.fromOSString(file.getCanonicalPath()); + final IPath location = Path.fromOSString(file.getCanonicalPath()); id = CoreModel.getRegistedContentTypeId(project.getProject(), location.lastSegment()); - return new ExternalTranslationUnit[] { new ExternalTranslationUnit(project, location, id) }; + return new ExternalTranslationUnit[] { + new ExternalTranslationUnit(project, location, id) }; } catch (IOException e) { CDebugCorePlugin.log(e); } } - } + } } } @@ -205,7 +207,7 @@ public class MapEntrySourceContainer extends AbstractSourceContainer { public ISourceContainerType getType() { return getSourceContainerType(TYPE_ID); } - + public IPath getLocalPath() { return fLocalPath; } @@ -226,7 +228,7 @@ public class MapEntrySourceContainer extends AbstractSourceContainer { public boolean equals(Object o) { if (!(o instanceof MapEntrySourceContainer)) return false; - MapEntrySourceContainer entry = (MapEntrySourceContainer)o; + MapEntrySourceContainer entry = (MapEntrySourceContainer) o; return (entry.getBackendPathStr().equals(getBackendPathStr()) && entry.getLocalPath().equals(getLocalPath())); } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/MapEntrySourceContainerType.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/MapEntrySourceContainerType.java index 0730c29dc0e..4d8c28d499f 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/MapEntrySourceContainerType.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/MapEntrySourceContainerType.java @@ -11,7 +11,7 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.core.sourcelookup; +package org.eclipse.cdt.debug.internal.core.sourcelookup; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; @@ -21,7 +21,7 @@ import org.eclipse.debug.core.sourcelookup.containers.AbstractSourceContainerTyp import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; - + /** * The map entry container type. */ @@ -37,7 +37,7 @@ public class MapEntrySourceContainerType extends AbstractSourceContainerTypeDele public ISourceContainer createSourceContainer(String memento) throws CoreException { Node node = parseDocument(memento); if (node.getNodeType() == Node.ELEMENT_NODE) { - Element element = (Element)node; + Element element = (Element) node; if (ELEMENT_NAME.equals(element.getNodeName())) { String backend = element.getAttribute(BACKEND_PATH); if (backend == null || backend.isEmpty()) { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/MappingSourceContainerType.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/MappingSourceContainerType.java index 01f8ec970db..ecb102accb6 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/MappingSourceContainerType.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/MappingSourceContainerType.java @@ -11,7 +11,7 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.core.sourcelookup; +package org.eclipse.cdt.debug.internal.core.sourcelookup; import java.util.ArrayList; import java.util.List; @@ -25,7 +25,7 @@ import org.eclipse.debug.core.sourcelookup.containers.AbstractSourceContainerTyp import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; - + /** * The mapping container type. */ @@ -46,7 +46,7 @@ public class MappingSourceContainerType extends AbstractSourceContainerTypeDeleg Element element = (Element) node; if (ELEMENT_MAPPING.equals(element.getNodeName())) { String name = element.getAttribute(ATTR_NAME); - if (name == null) + if (name == null) name = ""; //$NON-NLS-1$ String backendEnabled = element.getAttribute(ATTR_BACKEND_ENABLED); // When upgrading source locator (See Bug 472765), @@ -56,14 +56,16 @@ public class MappingSourceContainerType extends AbstractSourceContainerTypeDeleg Node childNode = element.getFirstChild(); while (childNode != null) { if (childNode.getNodeType() == Node.ELEMENT_NODE) { - Element child = (Element)childNode; + Element child = (Element) childNode; if (ELEMENT_MAP_ENTRY.equals(child.getNodeName())) { String childMemento = child.getAttribute(ATTR_MEMENTO); if (childMemento == null || childMemento.length() == 0) { abort(InternalSourceLookupMessages.MappingSourceContainerType_0, null); } - ISourceContainerType type = DebugPlugin.getDefault().getLaunchManager().getSourceContainerType(MapEntrySourceContainer.TYPE_ID); - MapEntrySourceContainer entry = (MapEntrySourceContainer) type.createSourceContainer(childMemento); + ISourceContainerType type = DebugPlugin.getDefault().getLaunchManager() + .getSourceContainerType(MapEntrySourceContainer.TYPE_ID); + MapEntrySourceContainer entry = (MapEntrySourceContainer) type + .createSourceContainer(childMemento); entries.add(entry); } } @@ -79,7 +81,7 @@ public class MappingSourceContainerType extends AbstractSourceContainerTypeDeleg abort(InternalSourceLookupMessages.MappingSourceContainerType_1, null); } abort(InternalSourceLookupMessages.MappingSourceContainerType_2, null); - return null; + return null; } /* (non-Javadoc) @@ -90,9 +92,9 @@ public class MappingSourceContainerType extends AbstractSourceContainerTypeDeleg Document document = newDocument(); Element element = document.createElement(ELEMENT_MAPPING); element.setAttribute(ATTR_NAME, container.getName()); - boolean backendEnabled = ((MappingSourceContainer)container).isMappingWithBackendEnabled(); + boolean backendEnabled = ((MappingSourceContainer) container).isMappingWithBackendEnabled(); element.setAttribute(ATTR_BACKEND_ENABLED, String.valueOf(backendEnabled)); - ISourceContainer[] entries = ((MappingSourceContainer)container).getSourceContainers(); + ISourceContainer[] entries = ((MappingSourceContainer) container).getSourceContainers(); for (int i = 0; i < entries.length; ++i) { Element child = document.createElement(ELEMENT_MAP_ENTRY); child.setAttribute(ATTR_MEMENTO, entries[i].getType().getMemento(entries[i])); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/ProgramRelativePathSourceContainerType.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/ProgramRelativePathSourceContainerType.java index 564a549d58a..8f4caf95cee 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/ProgramRelativePathSourceContainerType.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/ProgramRelativePathSourceContainerType.java @@ -32,7 +32,7 @@ public class ProgramRelativePathSourceContainerType extends AbstractSourceContai @Override public String getMemento(ISourceContainer container) throws CoreException { - if (container instanceof ProgramRelativePathSourceContainer) { + if (container instanceof ProgramRelativePathSourceContainer) { return ELEMENT_NAME; } else { return ""; //$NON-NLS-1$ diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/SourceFoldersRelativePathSourceContainer.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/SourceFoldersRelativePathSourceContainer.java index 8150c12a241..1e83b69506c 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/SourceFoldersRelativePathSourceContainer.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/SourceFoldersRelativePathSourceContainer.java @@ -39,11 +39,11 @@ import org.eclipse.osgi.util.NLS; * is intended to be used when debugging information produced by the C/C++ compiler contains paths * to the source and header files relative to the directory where the compiler is run from. * The assumption is that all files under a source folder are compiled relative to that folder. - * + * * Source elements returned from <code>findSourceElements(...)</code> are instances of * <code>LocalFileStorage</code>. * <p> - * Clients may instantiate this class. + * Clients may instantiate this class. * </p> * @noextend This class is not intended to be subclassed by clients. */ @@ -53,16 +53,16 @@ public class SourceFoldersRelativePathSourceContainer extends CompositeSourceCon * Unique identifier for the container type * (value <code>org.eclipse.cdt.debug.core.containerType.sourceFoldersRelativePath</code>). */ - public static final String TYPE_ID = - CDebugCorePlugin.getUniqueIdentifier() + ".containerType.sourceFoldersRelativePath"; //$NON-NLS-1$ + public static final String TYPE_ID = CDebugCorePlugin.getUniqueIdentifier() + + ".containerType.sourceFoldersRelativePath"; //$NON-NLS-1$ - private final IProject fOwnProject; // Project assigned to this container at construction time. + private final IProject fOwnProject; // Project assigned to this container at construction time. private IProject fProject; private boolean fSearchReferencedProjects; /** * Constructs a source folder relative path source container. - * + * * @param project the project to search for source in. A {@code null} project indicates * the the project from the launch configuration should be used. * @param referenced whether referenced projects should be considered @@ -101,9 +101,8 @@ public class SourceFoldersRelativePathSourceContainer extends CompositeSourceCon @Override public String getName() { - return fProject == null ? - InternalSourceLookupMessages.SourceFoldersRelativePathSourceContainer_0 : - NLS.bind(InternalSourceLookupMessages.SourceFoldersRelativePathSourceContainer_1, fProject.getName()); + return fProject == null ? InternalSourceLookupMessages.SourceFoldersRelativePathSourceContainer_0 + : NLS.bind(InternalSourceLookupMessages.SourceFoldersRelativePathSourceContainer_1, fProject.getName()); } @Override @@ -116,10 +115,10 @@ public class SourceFoldersRelativePathSourceContainer extends CompositeSourceCon if (obj != null && obj instanceof SourceFoldersRelativePathSourceContainer) { SourceFoldersRelativePathSourceContainer loc = (SourceFoldersRelativePathSourceContainer) obj; return fProject == null ? loc.fProject == null : fProject.equals(loc.fProject); - } + } return false; - } - + } + @Override public int hashCode() { return TYPE_ID.hashCode() * 31 + (fProject == null ? 0 : fProject.hashCode()); @@ -156,14 +155,14 @@ public class SourceFoldersRelativePathSourceContainer extends CompositeSourceCon } for (IProject ref : projects) { if (ref.exists() && ref.isOpen()) { - SourceFoldersRelativePathSourceContainer container = - new SourceFoldersRelativePathSourceContainer(ref, false); + SourceFoldersRelativePathSourceContainer container = new SourceFoldersRelativePathSourceContainer( + ref, false); container.init(getDirector()); containers.add(container); } } return containers.toArray(new ISourceContainer[containers.size()]); - } + } return createCompilationDirectoryContainers(fProject); } return new ISourceContainer[0]; diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/SourceFoldersRelativePathSourceContainerType.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/SourceFoldersRelativePathSourceContainerType.java index a1d672f4f5f..850b6c71f5c 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/SourceFoldersRelativePathSourceContainerType.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/SourceFoldersRelativePathSourceContainerType.java @@ -11,7 +11,7 @@ * Contributors: * Sergey Prigogin (Google) - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.debug.internal.core.sourcelookup; +package org.eclipse.cdt.debug.internal.core.sourcelookup; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; @@ -21,7 +21,7 @@ import org.eclipse.debug.core.sourcelookup.containers.AbstractSourceContainerTyp import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; - + /** * See <code>SourceFoldersRelativePathSourceContainer</code>. */ @@ -51,7 +51,7 @@ public class SourceFoldersRelativePathSourceContainerType extends AbstractSource public ISourceContainer createSourceContainer(String memento) throws CoreException { Node node = parseDocument(memento); if (node.getNodeType() == Node.ELEMENT_NODE) { - Element element = (Element)node; + Element element = (Element) node; if ("project".equals(element.getNodeName())) { //$NON-NLS-1$ String string = element.getAttribute("name"); //$NON-NLS-1$ IProject project = null; @@ -61,10 +61,10 @@ public class SourceFoldersRelativePathSourceContainerType extends AbstractSource String nest = element.getAttribute("referencedProjects"); //$NON-NLS-1$ boolean ref = Boolean.parseBoolean(nest); return new SourceFoldersRelativePathSourceContainer(project, ref); - } - abort(InternalSourceLookupMessages.SourceFoldersRelativePathSourceContainerType_1, null); + } + abort(InternalSourceLookupMessages.SourceFoldersRelativePathSourceContainerType_1, null); } - abort(InternalSourceLookupMessages.SourceFoldersRelativePathSourceContainerType_2, null); + abort(InternalSourceLookupMessages.SourceFoldersRelativePathSourceContainerType_2, null); return null; } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/SourceUtils.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/SourceUtils.java index f4c4fec9076..48580bf6b30 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/SourceUtils.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/SourceUtils.java @@ -91,7 +91,7 @@ public class SourceUtils { } private static void saveSourceLocations(Document doc, Element node, ICSourceLocation[] locations) { - for(int i = 0; i < locations.length; i++) { + for (int i = 0; i < locations.length; i++) { Element child = doc.createElement(NAME_SOURCE_LOCATION); child.setAttribute(ATTR_CLASS, locations[i].getClass().getName()); try { @@ -132,11 +132,11 @@ public class SourceUtils { List<ICSourceLocation> sourceLocations = new LinkedList<ICSourceLocation>(); NodeList list = root.getChildNodes(); int length = list.getLength(); - for(int i = 0; i < length; ++i) { + for (int i = 0; i < length; ++i) { Node node = list.item(i); short type = node.getNodeType(); if (type == Node.ELEMENT_NODE) { - Element entry = (Element)node; + Element entry = (Element) node; if (entry.getNodeName().equalsIgnoreCase(NAME_SOURCE_LOCATION)) { String className = entry.getAttribute(ATTR_CLASS); String data = entry.getAttribute(ATTR_MEMENTO); @@ -148,13 +148,14 @@ public class SourceUtils { try { clazz = CDebugCorePlugin.getDefault().getBundle().loadClass(className); } catch (ClassNotFoundException e) { - CDebugCorePlugin.log(MessageFormat.format("Unable to restore source location - class not found {0}", //$NON-NLS-1$ - (Object[]) new String[] { className })); + CDebugCorePlugin + .log(MessageFormat.format("Unable to restore source location - class not found {0}", //$NON-NLS-1$ + (Object[]) new String[] { className })); continue; } ICSourceLocation location = null; try { - location = (ICSourceLocation)clazz.newInstance(); + location = (ICSourceLocation) clazz.newInstance(); } catch (IllegalAccessException e) { CDebugCorePlugin.log("Unable to restore source location: " + e.getMessage()); //$NON-NLS-1$ continue; @@ -188,8 +189,10 @@ public class SourceUtils { IDirectorySourceLocation d = (IDirectorySourceLocation) location; IPath a = d.getAssociation(); if (a != null) { - MappingSourceContainer mapping = new MappingSourceContainer(InternalSourceLookupMessages.SourceUtils_0 + (++mappingCount)); - mapping.addMapEntries(new MapEntrySourceContainer[] { new MapEntrySourceContainer(a.toOSString(), d.getDirectory()) }); + MappingSourceContainer mapping = new MappingSourceContainer( + InternalSourceLookupMessages.SourceUtils_0 + (++mappingCount)); + mapping.addMapEntries(new MapEntrySourceContainer[] { + new MapEntrySourceContainer(a.toOSString(), d.getDirectory()) }); containers.add(mapping); } @@ -308,7 +311,7 @@ public class SourceUtils { * @param project * @return */ - private static Object[] updateUnavailableResources(IFile[] wfiles, IProject project){ + private static Object[] updateUnavailableResources(IFile[] wfiles, IProject project) { // with no projects context we will not be able to create ITranslationUnits if (project == null) { return wfiles; @@ -316,7 +319,7 @@ public class SourceUtils { ICProject cProject = CoreModel.getDefault().create(project); Object[] result = new Object[wfiles.length]; - for (int i=0; i< wfiles.length; ++i) { + for (int i = 0; i < wfiles.length; ++i) { IFile wkspFile = wfiles[i]; if (wkspFile.isAccessible()) { result[i] = wkspFile; diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/srcfinder/CSourceFinder.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/srcfinder/CSourceFinder.java index ceacc249f05..988a16c53e0 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/srcfinder/CSourceFinder.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/srcfinder/CSourceFinder.java @@ -74,10 +74,11 @@ public class CSourceFinder implements ISourceFinder, ILaunchConfigurationListene * the locators we create and discard when the launch config changes or is * disposed. Collection is subject to be changed by listener invocations. * Map key is the launch configuration name. - * + * * @see CSourceFinder#getLocator(ILaunchConfiguration) */ - private Map<String, ISourceLocator> fConfigLocators = Collections.synchronizedMap(new HashMap<String, ISourceLocator>()); + private Map<String, ISourceLocator> fConfigLocators = Collections + .synchronizedMap(new HashMap<String, ISourceLocator>()); /** * We use this when we don't have an ILaunch or ILaunchConfiguration @@ -89,23 +90,23 @@ public class CSourceFinder implements ISourceFinder, ILaunchConfigurationListene /** * Constructor. - * + * * @param binary * the executable whose source files we will be asked to find * locally */ public CSourceFinder(IBinary binary) { - assert(binary != null); + assert (binary != null); fBinary = binary; - - fRelativePathContainer = new ProgramRelativePathSourceContainer(binary); - + + fRelativePathContainer = new ProgramRelativePathSourceContainer(binary); + ILaunchManager lmgr = DebugPlugin.getDefault().getLaunchManager(); lmgr.addLaunchConfigurationListener(this); lmgr.addLaunchListener(this); - + } - + /* (non-Javadoc) * @see org.eclipse.cdt.core.ISourceFinder#toLocalPath(java.lang.String) */ @@ -113,11 +114,11 @@ public class CSourceFinder implements ISourceFinder, ILaunchConfigurationListene synchronized public String toLocalPath(String compilationPath) { try { Object foundElement = null; - + // Find a suitable launch/config locator if we haven't found one yet if (fLaunchLocator == null) { ILaunchManager lmgr = DebugPlugin.getDefault().getLaunchManager(); - + // See if there are any active debug sessions (running, or // terminated but still in the Debug view) that are targeting // our executable. If there are then use the first one to @@ -129,42 +130,41 @@ public class CSourceFinder implements ISourceFinder, ILaunchConfigurationListene ISourceLocator launchLocator = launch.getSourceLocator(); // in practice, a launch locator is always an ISourceLookupDirector if (launchLocator instanceof ISourceLookupDirector) { - fLaunchLocator = (ISourceLookupDirector)launchLocator; + fLaunchLocator = (ISourceLookupDirector) launchLocator; break; } } } - + // If there were no matching launches or none of them // provided a locator, search the launch configurations if (fLaunchLocator == null) { for (ILaunchConfiguration config : lmgr.getLaunchConfigurations()) { if (isMatch(config)) { String configName = config.getName(); - + // Search our cache of locators that we // instantiate for configurations. Create one if // not found ISourceLocator configLocator = fConfigLocators.get(configName); if (configLocator == null) { - configLocator = getLocator(config); // heavy operation - fConfigLocators.put(configName, configLocator); // cache to avoid next time + configLocator = getLocator(config); // heavy operation + fConfigLocators.put(configName, configLocator); // cache to avoid next time } // In practice, a config's locator is always an ISourceLookupDirector if (configLocator instanceof ISourceLookupDirector) { - fLaunchLocator = (ISourceLookupDirector)configLocator; + fLaunchLocator = (ISourceLookupDirector) configLocator; break; } } } } } - + // Search for the file using the launch/config locator if (fLaunchLocator != null) { foundElement = fLaunchLocator.getSourceElement(compilationPath); - } - else { + } else { // If there isn't a launch/config locator, we need to explicitly // try to resolve relative paths...relative to the binary // location. @@ -186,26 +186,25 @@ public class CSourceFinder implements ISourceFinder, ILaunchConfigurationListene } return foundElementToPath(foundElement); - } - catch (CoreException exc) { - CDebugCorePlugin.log(exc); + } catch (CoreException exc) { + CDebugCorePlugin.log(exc); } return null; } - + /* (non-Javadoc) * @see org.eclipse.cdt.core.ISourceFinder#toLocalPath(org.eclipse.core.runtime.IAdaptable, java.lang.String) */ @Override public String toLocalPath(IAdaptable _launch, String compilationPath) { Object foundElement = null; - + ILaunch launch = _launch.getAdapter(ILaunch.class); if (launch != null) { ISourceLocator locator = launch.getSourceLocator(); // in practice, a launch locator is always an ISourceLookupDirector if (locator instanceof ISourceLookupDirector) { - foundElement = ((ISourceLookupDirector)locator).getSourceElement(compilationPath); + foundElement = ((ISourceLookupDirector) locator).getSourceElement(compilationPath); } } @@ -214,14 +213,14 @@ public class CSourceFinder implements ISourceFinder, ILaunchConfigurationListene CSourceLookupDirector locator = CDebugCorePlugin.getDefault().getCommonSourceLookupDirector(); foundElement = locator.getSourceElement(compilationPath); } - + return foundElementToPath(foundElement); } /** * Utility method to convert the element found by the source locators to a * canonical file path - * + * * @param foundElement * the element found by the source locator, or null if not found * @return the canonical file path of the element @@ -230,23 +229,21 @@ public class CSourceFinder implements ISourceFinder, ILaunchConfigurationListene if (foundElement != null) { try { if (foundElement instanceof IFile) { - IPath path = ((IFile)foundElement).getLocation(); + IPath path = ((IFile) foundElement).getLocation(); if (path != null) { File file = path.toFile(); if (file != null) { - return file.getCanonicalPath(); + return file.getCanonicalPath(); } } - - } - else if (foundElement instanceof LocalFileStorage) { - File file = ((LocalFileStorage)foundElement).getFile(); + + } else if (foundElement instanceof LocalFileStorage) { + File file = ((LocalFileStorage) foundElement).getFile(); if (file != null) { return file.getCanonicalPath(); } - } - else if (foundElement instanceof ExternalTranslationUnit) { - URI uri = ((ExternalTranslationUnit)foundElement).getLocationURI(); + } else if (foundElement instanceof ExternalTranslationUnit) { + URI uri = ((ExternalTranslationUnit) foundElement).getLocationURI(); if (uri != null) { IPath path = URIUtil.toPath(uri); if (path != null) { @@ -261,10 +258,10 @@ public class CSourceFinder implements ISourceFinder, ILaunchConfigurationListene CDebugCorePlugin.log(e); } } - + return null; } - + /** * Utility method to determine if the given launch configuration targets the Binary we are associated with * @param config @@ -279,7 +276,8 @@ public class CSourceFinder implements ISourceFinder, ILaunchConfigurationListene String programNameConfig = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, ""); //$NON-NLS-1$ IProject project = resource.getProject(); if (project != null && project.getName().equals(projectNameConfig)) { - programNameConfig = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(programNameConfig); + programNameConfig = VariablesPlugin.getDefault().getStringVariableManager() + .performStringSubstitution(programNameConfig); Path path = new Path(programNameConfig); if (!path.isEmpty()) { IFile file = project.getFile(path); @@ -294,7 +292,7 @@ public class CSourceFinder implements ISourceFinder, ILaunchConfigurationListene CDebugCorePlugin.log(e); } } - + return false; } @@ -303,25 +301,25 @@ public class CSourceFinder implements ISourceFinder, ILaunchConfigurationListene * configuration. A launch configuration doesn't have a source locator * instance tied to it. Transient instances are created as needed. from * attributes in the launch config. This is a heavy operation. - * + * * @param config * the launch configuration to create the locator for * @return the source locator * @throws CoreException */ static private ISourceLocator getLocator(ILaunchConfiguration config) throws CoreException { - String type = config.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, (String)null); + String type = config.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, (String) null); if (type == null) { type = config.getType().getSourceLocatorId(); } if (type != null) { IPersistableSourceLocator locator = DebugPlugin.getDefault().getLaunchManager().newSourceLocator(type); - String memento = config.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, (String)null); + String memento = config.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, (String) null); if (memento == null) { locator.initializeDefaults(config); } else { - if(locator instanceof IPersistableSourceLocator2) - ((IPersistableSourceLocator2)locator).initializeFromMemento(memento, config); + if (locator instanceof IPersistableSourceLocator2) + ((IPersistableSourceLocator2) locator).initializeFromMemento(memento, config); else locator.initializeFromMemento(memento); } @@ -335,7 +333,7 @@ public class CSourceFinder implements ISourceFinder, ILaunchConfigurationListene */ @Override public void launchConfigurationAdded(ILaunchConfiguration config) { - // Don't care. + // Don't care. } /* (non-Javadoc) @@ -347,7 +345,7 @@ public class CSourceFinder implements ISourceFinder, ILaunchConfigurationListene if (config.isWorkingCopy()) { return; } - + // the source locator attribute may have changed fConfigLocators.remove(config.getName()); if ((fLaunchLocator != null) && (fLaunchLocator.getLaunchConfiguration().getName() == config.getName())) { @@ -364,7 +362,7 @@ public class CSourceFinder implements ISourceFinder, ILaunchConfigurationListene if (config.isWorkingCopy()) { return; } - + fConfigLocators.remove(config.getName()); if ((fLaunchLocator != null) && (fLaunchLocator.getLaunchConfiguration().getName() == config.getName())) { fLaunchLocator = null; @@ -396,7 +394,7 @@ public class CSourceFinder implements ISourceFinder, ILaunchConfigurationListene for (ILaunch launch : launches) { ILaunchConfiguration config = launch.getLaunchConfiguration(); if (config != null && isMatch(config)) { - synchronized(this) { + synchronized (this) { fLaunchLocator = null; } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/srcfinder/CSourceFinderFactory.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/srcfinder/CSourceFinderFactory.java index 74cdad9ae21..b550951c8df 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/srcfinder/CSourceFinderFactory.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/srcfinder/CSourceFinderFactory.java @@ -27,7 +27,7 @@ public class CSourceFinderFactory implements IAdapterFactory { public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) { if (adaptableObject instanceof IBinary) { if (adapterType.equals(ISourceFinder.class)) { - return (T) new CSourceFinder((IBinary)adaptableObject); + return (T) new CSourceFinder((IBinary) adaptableObject); } } return null; 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 + '!'; } } diff --git a/debug/org.eclipse.cdt.gdb.ui/src/org/eclipse/cdt/gdb/ui/internal/Activator.java b/debug/org.eclipse.cdt.gdb.ui/src/org/eclipse/cdt/gdb/ui/internal/Activator.java index 828f4a722bf..bd9b9354502 100644 --- a/debug/org.eclipse.cdt.gdb.ui/src/org/eclipse/cdt/gdb/ui/internal/Activator.java +++ b/debug/org.eclipse.cdt.gdb.ui/src/org/eclipse/cdt/gdb/ui/internal/Activator.java @@ -7,8 +7,8 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: + * + * Contributors: * Freescale Semiconductor - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.gdb.ui.internal; @@ -26,7 +26,7 @@ public class Activator extends AbstractUIPlugin { /** The singleton instance */ private static Activator plugin; - + /** * The constructor */ @@ -37,7 +37,7 @@ public class Activator extends AbstractUIPlugin { * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) */ @Override - public void start(BundleContext context) throws Exception { + public void start(BundleContext context) throws Exception { super.start(context); plugin = this; } @@ -46,7 +46,7 @@ public class Activator extends AbstractUIPlugin { * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) */ @Override - public void stop(BundleContext context) throws Exception { + public void stop(BundleContext context) throws Exception { plugin = null; super.stop(context); } diff --git a/debug/org.eclipse.cdt.gdb/src/org/eclipse/cdt/gdb/eventbkpts/IEventBreakpointConstants.java b/debug/org.eclipse.cdt.gdb/src/org/eclipse/cdt/gdb/eventbkpts/IEventBreakpointConstants.java index 89c02777d73..3a698cf3dc9 100644 --- a/debug/org.eclipse.cdt.gdb/src/org/eclipse/cdt/gdb/eventbkpts/IEventBreakpointConstants.java +++ b/debug/org.eclipse.cdt.gdb/src/org/eclipse/cdt/gdb/eventbkpts/IEventBreakpointConstants.java @@ -7,8 +7,8 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: + * + * Contributors: * Freescale Semiconductor - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.gdb.eventbkpts; @@ -17,7 +17,7 @@ public interface IEventBreakpointConstants { /** * An event breakpoint of this type suspends the target program when it * catches a C++ exception. This type of event has no parameters. - * + * * @since 7.0 */ public static final String EVENT_TYPE_CATCH = "org.eclipse.cdt.debug.gdb.catch"; //$NON-NLS-1$ @@ -25,7 +25,7 @@ public interface IEventBreakpointConstants { /** * An event breakpoint of this type suspends the target program when it * throws a C++ exception. This type of event has no parameters. - * + * * @since 7.0 */ public static final String EVENT_TYPE_THROW = "org.eclipse.cdt.debug.gdb.throw"; //$NON-NLS-1$ @@ -33,7 +33,7 @@ public interface IEventBreakpointConstants { /** * An event breakpoint of this type suspends the target program when it * calls fork() (POSIX). This type of event has no parameters. - * + * * @since 7.0 */ public static final String EVENT_TYPE_FORK = "org.eclipse.cdt.debug.gdb.catch_fork"; //$NON-NLS-1$ @@ -41,7 +41,7 @@ public interface IEventBreakpointConstants { /** * An event breakpoint of this type suspends the target program when it * calls vfork() (POSIX). This type of event has no parameters. - * + * * @since 7.0 */ public static final String EVENT_TYPE_VFORK = "org.eclipse.cdt.debug.gdb.catch_vfork"; //$NON-NLS-1$ @@ -49,7 +49,7 @@ public interface IEventBreakpointConstants { /** * An event breakpoint of this type suspends the target program when it * calls exec() (POSIX). This type of event has no parameters. - * + * * @since 7.0 */ public static final String EVENT_TYPE_EXEC = "org.eclipse.cdt.debug.gdb.catch_exec"; //$NON-NLS-1$ @@ -58,7 +58,7 @@ public interface IEventBreakpointConstants { * An event breakpoint of this type suspends the target program when it * makes a system call (POSIX). This type of event takes a single parameter: * the name or number of the system call. - * + * * @since 7.0 */ public static final String EVENT_TYPE_SYSCALL = "org.eclipse.cdt.debug.gdb.catch_syscall"; //$NON-NLS-1$ diff --git a/debug/org.eclipse.cdt.gdb/src/org/eclipse/cdt/gdb/internal/Activator.java b/debug/org.eclipse.cdt.gdb/src/org/eclipse/cdt/gdb/internal/Activator.java index 347745fe5c0..0899c30354b 100644 --- a/debug/org.eclipse.cdt.gdb/src/org/eclipse/cdt/gdb/internal/Activator.java +++ b/debug/org.eclipse.cdt.gdb/src/org/eclipse/cdt/gdb/internal/Activator.java @@ -7,8 +7,8 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: + * + * Contributors: * Freescale Semiconductor - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.gdb.internal; @@ -26,7 +26,7 @@ public class Activator extends Plugin { /** The singleton instance */ private static Activator plugin; - + /** * The constructor */ @@ -37,7 +37,7 @@ public class Activator extends Plugin { * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) */ @Override - public void start(BundleContext context) throws Exception { + public void start(BundleContext context) throws Exception { super.start(context); plugin = this; } @@ -46,7 +46,7 @@ public class Activator extends Plugin { * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) */ @Override - public void stop(BundleContext context) throws Exception { + public void stop(BundleContext context) throws Exception { plugin = null; super.stop(context); } diff --git a/debug/org.eclipse.cdt.gdb/src/org/eclipse/cdt/gdb/internal/eventbkpts/GdbCatchpoints.java b/debug/org.eclipse.cdt.gdb/src/org/eclipse/cdt/gdb/internal/eventbkpts/GdbCatchpoints.java index f0a4cb34a23..dd14732de58 100644 --- a/debug/org.eclipse.cdt.gdb/src/org/eclipse/cdt/gdb/internal/eventbkpts/GdbCatchpoints.java +++ b/debug/org.eclipse.cdt.gdb/src/org/eclipse/cdt/gdb/internal/eventbkpts/GdbCatchpoints.java @@ -37,7 +37,7 @@ public class GdbCatchpoints { * Get the gdb catchpoint event keyword associated with the given * {@link IEventBreakpointConstants} event type ID. Answer will be, e.g., * "catch", "throw", "fork", etc. - * + * * @param event * an EVENT_TYPE_XXXX constant from IEventBreakpointConstants * @return the gdb keyword for [event]; null if [event] is unrecognized @@ -51,7 +51,7 @@ public class GdbCatchpoints { /** * An inversion of the lookup done by * {@link #eventToGdbCatchpointKeyword(String)} - * + * * @param keyword * a gdb catchpoint keyword, e.g., "catch", "throw", "fork" * @return the EVENT_TYPE_XXXX constant from IEventBreakpointConstants @@ -64,7 +64,7 @@ public class GdbCatchpoints { return eventId; } } - + // Don't assert. Caller may be using us to determine if a token is a // catchpoint keyword. He may have parsed the keyword out from gdb/mi // output. |