diff options
author | Alexander Kurtakov | 2017-02-26 02:30:39 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2017-02-26 02:30:39 +0000 |
commit | 9df881a84283f44a3de8755c9ee62dc2c3c07359 (patch) | |
tree | 3f4a145abc7d8ce3fb3cfad5512a1571ae61823c | |
parent | cd35a16176b3c272d20f8383f12ada0a913abeba (diff) | |
download | org.eclipse.dltk.core-9df881a84283f44a3de8755c9ee62dc2c3c07359.tar.gz org.eclipse.dltk.core-9df881a84283f44a3de8755c9ee62dc2c3c07359.tar.xz org.eclipse.dltk.core-9df881a84283f44a3de8755c9ee62dc2c3c07359.zip |
Add missing @Override annotations in o.e.dltk.debugui.
Some are converted to lambdas to reduce code.
Change-Id: If4deb7f391dac37377b77073cda4abdef5c633fa
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
121 files changed, 2529 insertions, 2827 deletions
diff --git a/core/plugins/org.eclipse.dltk.debug.ui/.settings/org.eclipse.jdt.ui.prefs b/core/plugins/org.eclipse.dltk.debug.ui/.settings/org.eclipse.jdt.ui.prefs index 60f7682b9..87f112b2a 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/.settings/org.eclipse.jdt.ui.prefs +++ b/core/plugins/org.eclipse.dltk.debug.ui/.settings/org.eclipse.jdt.ui.prefs @@ -1,4 +1,3 @@ -#Tue Apr 29 16:17:52 CEST 2008 eclipse.preferences.version=1 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true formatter_profile=org.eclipse.jdt.ui.default.eclipse_profile @@ -7,22 +6,29 @@ sp_cleanup.add_default_serial_version_id=true sp_cleanup.add_generated_serial_version_id=false sp_cleanup.add_missing_annotations=true sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false sp_cleanup.add_missing_nls_tags=false sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true sp_cleanup.add_serial_version_id=false sp_cleanup.always_use_blocks=true sp_cleanup.always_use_parentheses_in_expressions=false sp_cleanup.always_use_this_for_non_static_field_access=false sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_functional_interfaces=true sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=false sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.insert_inferred_type_arguments=false sp_cleanup.make_local_variable_final=false sp_cleanup.make_parameters_final=false sp_cleanup.make_private_fields_final=true -sp_cleanup.make_variable_declarations_final=true +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=false sp_cleanup.never_use_blocks=false sp_cleanup.never_use_parentheses_in_expressions=true -sp_cleanup.on_save_use_additional_actions=false +sp_cleanup.on_save_use_additional_actions=true sp_cleanup.organize_imports=true sp_cleanup.qualify_static_field_accesses_with_declaring_class=false sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true @@ -30,12 +36,13 @@ sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class= sp_cleanup.qualify_static_member_accesses_with_declaring_class=false sp_cleanup.qualify_static_method_accesses_with_declaring_class=false sp_cleanup.remove_private_constructors=true -sp_cleanup.remove_trailing_whitespaces=false +sp_cleanup.remove_redundant_type_arguments=true +sp_cleanup.remove_trailing_whitespaces=true sp_cleanup.remove_trailing_whitespaces_all=true sp_cleanup.remove_trailing_whitespaces_ignore_empty=false sp_cleanup.remove_unnecessary_casts=true sp_cleanup.remove_unnecessary_nls_tags=false -sp_cleanup.remove_unused_imports=false +sp_cleanup.remove_unused_imports=true sp_cleanup.remove_unused_local_variables=false sp_cleanup.remove_unused_private_fields=true sp_cleanup.remove_unused_private_members=false @@ -43,8 +50,10 @@ sp_cleanup.remove_unused_private_methods=true sp_cleanup.remove_unused_private_types=true sp_cleanup.sort_members=false sp_cleanup.sort_members_all=false +sp_cleanup.use_anonymous_class_creation=false sp_cleanup.use_blocks=false sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_lambda=true sp_cleanup.use_parentheses_in_expressions=false sp_cleanup.use_this_for_non_static_field_access=false sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/AbstractDebugUILanguageToolkit.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/AbstractDebugUILanguageToolkit.java index dfbe801f9..7853cc53a 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/AbstractDebugUILanguageToolkit.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/AbstractDebugUILanguageToolkit.java @@ -1,12 +1,9 @@ package org.eclipse.dltk.debug.ui; -public abstract class AbstractDebugUILanguageToolkit implements - IDLTKDebugUILanguageToolkit { +public abstract class AbstractDebugUILanguageToolkit + implements IDLTKDebugUILanguageToolkit { - /* - * @see org.eclipse.dltk.debug.ui.IDLTKDebugUILanguageToolkit# - * getVariablesViewPreferencePages() - */ + @Override public String[] getVariablesViewPreferencePages() { return new String[] { "" }; //$NON-NLS-1$ } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/DLTKDebugUIPlugin.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/DLTKDebugUIPlugin.java index ebee1eb18..41f3cbb30 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/DLTKDebugUIPlugin.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/DLTKDebugUIPlugin.java @@ -1,11 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * Copyright (c) 2005, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.debug.ui; @@ -28,9 +27,7 @@ import org.eclipse.debug.core.model.ISourceLocator; import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.debug.ui.ILaunchConfigurationTab; import org.eclipse.dltk.debug.core.DLTKDebugPlugin; -import org.eclipse.dltk.debug.core.model.IScriptStackFrame; import org.eclipse.dltk.debug.core.model.IScriptVariable; -import org.eclipse.dltk.debug.core.model.ISourceOffsetLookup; import org.eclipse.dltk.internal.debug.core.model.HotCodeReplaceManager; import org.eclipse.dltk.internal.debug.ui.ScriptDebugOptionsManager; import org.eclipse.dltk.internal.debug.ui.ScriptHotCodeReplaceListener; @@ -78,7 +75,7 @@ public class DLTKDebugUIPlugin extends AbstractUIPlugin { // Map of InterpreterInstallTypeIDs to IConfigurationElements protected Map<String, IConfigurationElement> fInterpreterInstallTypePageMap; - protected Map<RGB, Color> fColorTable = new HashMap<RGB, Color>(10); + protected Map<RGB, Color> fColorTable = new HashMap<>(10); /** * Whether this plugin is in the process of shutting down. @@ -87,7 +84,7 @@ public class DLTKDebugUIPlugin extends AbstractUIPlugin { private ScriptHotCodeReplaceListener fHCRListener; - private HashMap<String, ScriptDebugModelPresentation> fPresentations = new HashMap<String, ScriptDebugModelPresentation>(); + private HashMap<String, ScriptDebugModelPresentation> fPresentations = new HashMap<>(); // private Object fUtilPresentation; @@ -122,20 +119,20 @@ public class DLTKDebugUIPlugin extends AbstractUIPlugin { // Special listener that prints command line on the console // TODO: add user preferences - ConsolePlugin.getDefault().getConsoleManager().addConsoleListener( - new IConsoleListener() { + ConsolePlugin.getDefault().getConsoleManager() + .addConsoleListener(new IConsoleListener() { + @Override public void consolesAdded( org.eclipse.ui.console.IConsole[] consoles) { for (int i = 0; i < consoles.length; ++i) { if (consoles[i] instanceof org.eclipse.debug.ui.console.IConsole) { org.eclipse.debug.ui.console.IConsole console = (org.eclipse.debug.ui.console.IConsole) consoles[i]; org.eclipse.ui.console.IOConsoleOutputStream stream = console - .getStream(IDebugUIConstants.ID_STANDARD_OUTPUT_STREAM); + .getStream( + IDebugUIConstants.ID_STANDARD_OUTPUT_STREAM); if (stream != null) { - String cmdLine = console - .getProcess() - .getLaunch() - .getAttribute( + String cmdLine = console.getProcess() + .getLaunch().getAttribute( DLTKLaunchingPlugin.LAUNCH_COMMAND_LINE); if (cmdLine != null) { @@ -151,59 +148,58 @@ public class DLTKDebugUIPlugin extends AbstractUIPlugin { } } + @Override public void consolesRemoved( org.eclipse.ui.console.IConsole[] consoles) { } }); fHCRListener = new ScriptHotCodeReplaceListener(); - HotCodeReplaceManager.getDefault().addHotCodeReplaceListener( - fHCRListener); - DLTKDebugPlugin.setSourceOffsetRetriever(new ISourceOffsetLookup() { - - public int calculateOffset(IScriptStackFrame frame, int lineNumber, - int column, boolean isEndOffset) { - final ILaunch launch = frame.getLaunch(); - final ISourceLocator sourceLocator = launch.getSourceLocator(); - final Object object = sourceLocator.getSourceElement(frame); - if (object instanceof IFile) { - final IDocumentProvider provider = DLTKUIPlugin - .getDocumentProvider(); - final IDocument document = provider - .getDocument(new FileEditorInput((IFile) object)); - if (document != null) { - try { - if (column >= 0) { - return document.getLineOffset(lineNumber - 1) - + column; - } else { - if (!isEndOffset) { - return document - .getLineOffset(lineNumber - 1); + HotCodeReplaceManager.getDefault() + .addHotCodeReplaceListener(fHCRListener); + DLTKDebugPlugin.setSourceOffsetRetriever( + (frame, lineNumber, column, isEndOffset) -> { + final ILaunch launch = frame.getLaunch(); + final ISourceLocator sourceLocator = launch + .getSourceLocator(); + final Object object = sourceLocator.getSourceElement(frame); + if (object instanceof IFile) { + final IDocumentProvider provider = DLTKUIPlugin + .getDocumentProvider(); + final IDocument document = provider.getDocument( + new FileEditorInput((IFile) object)); + if (document != null) { + try { + if (column >= 0) { + return document.getLineOffset( + lineNumber - 1) + column; } else { - final IRegion region = document - .getLineInformation(lineNumber - 1); - return region.getOffset() - + region.getLength(); + if (!isEndOffset) { + return document + .getLineOffset(lineNumber - 1); + } else { + final IRegion region = document + .getLineInformation( + lineNumber - 1); + return region.getOffset() + + region.getLength(); + } } + } catch (BadLocationException e) { + // ignore } - } catch (BadLocationException e) { - // ignore } } - } - return -1; - } - - }); + return -1; + }); } @Override public void stop(BundleContext context) throws Exception { try { DLTKDebugPlugin.setSourceOffsetRetriever(null); - HotCodeReplaceManager.getDefault().removeHotCodeReplaceListener( - fHCRListener); + HotCodeReplaceManager.getDefault() + .removeHotCodeReplaceListener(fHCRListener); setShuttingDown(true); @@ -212,10 +208,10 @@ public class DLTKDebugUIPlugin extends AbstractUIPlugin { ILaunchManager launchManager = DebugPlugin.getDefault() .getLaunchManager(); - launchManager.removeLaunchListener(DebugConsoleManager - .getInstance()); - launchManager.removeLaunchListener(ScriptDebugLogManager - .getInstance()); + launchManager + .removeLaunchListener(DebugConsoleManager.getInstance()); + launchManager + .removeLaunchListener(ScriptDebugLogManager.getInstance()); Iterator<Color> e = fColorTable.values().iterator(); while (e.hasNext()) @@ -228,7 +224,7 @@ public class DLTKDebugUIPlugin extends AbstractUIPlugin { /** * Returns whether this plug-in is in the process of being shutdown. - * + * * @return whether this plug-in is in the process of being shutdown */ public boolean isShuttingDown() { @@ -241,7 +237,7 @@ public class DLTKDebugUIPlugin extends AbstractUIPlugin { /** * Returns the shared instance - * + * * @return the shared instance */ public static DLTKDebugUIPlugin getDefault() { @@ -251,7 +247,7 @@ public class DLTKDebugUIPlugin extends AbstractUIPlugin { // UI /** * Returns the active workbench window - * + * * @return the active workbench window */ public static IWorkbenchWindow getActiveWorkbenchWindow() { @@ -260,7 +256,7 @@ public class DLTKDebugUIPlugin extends AbstractUIPlugin { /** * Returns the active workbench shell or <code>null</code> if none - * + * * @return the active workbench shell or <code>null</code> if none */ public static Shell getActiveWorkbenchShell() { @@ -289,7 +285,7 @@ public class DLTKDebugUIPlugin extends AbstractUIPlugin { /** * Displays the given preference page. - * + * * @param id * pref page id * @param page @@ -300,22 +296,19 @@ public class DLTKDebugUIPlugin extends AbstractUIPlugin { PreferenceManager manager = new PreferenceManager(); manager.addToRoot(targetNode); - final PreferenceDialog dialog = new PreferenceDialog(DLTKDebugUIPlugin - .getActiveWorkbenchShell(), manager); + final PreferenceDialog dialog = new PreferenceDialog( + DLTKDebugUIPlugin.getActiveWorkbenchShell(), manager); final boolean[] result = new boolean[] { false }; - BusyIndicator.showWhile(DLTKDebugUIPlugin.getStandardDisplay(), - new Runnable() { - public void run() { - dialog.create(); - dialog.setMessage(targetNode.getLabelText()); - result[0] = (dialog.open() == Window.OK); - } - }); + BusyIndicator.showWhile(DLTKDebugUIPlugin.getStandardDisplay(), () -> { + dialog.create(); + dialog.setMessage(targetNode.getLabelText()); + result[0] = (dialog.open() == Window.OK); + }); } /** * Logs the specified status with this plug-in's log. - * + * * @param status * status to log */ @@ -325,7 +318,7 @@ public class DLTKDebugUIPlugin extends AbstractUIPlugin { /** * Logs an internal error with the specified message. - * + * * @param message * the error message to log */ @@ -336,7 +329,7 @@ public class DLTKDebugUIPlugin extends AbstractUIPlugin { /** * Logs an internal error with the specified throwable - * + * * @param e * the exception to be logged */ @@ -365,7 +358,7 @@ public class DLTKDebugUIPlugin extends AbstractUIPlugin { if (shell != null) { IStatus status = new Status(IStatus.ERROR, getUniqueIdentifier(), IDLTKDebugUIConstants.INTERNAL_ERROR, - "Error logged from DLTK Debug UI: ", t); //$NON-NLS-1$ + "Error logged from DLTK Debug UI: ", t); //$NON-NLS-1$ ErrorDialog.openError(shell, "DebugUIMessages.JDIDebugUIPlugin_Error_1", //$NON-NLS-1$ message, status); @@ -389,9 +382,7 @@ public class DLTKDebugUIPlugin extends AbstractUIPlugin { tab = (ILaunchConfigurationTab) configElement .createExecutableExtension("class"); //$NON-NLS-1$ } catch (CoreException ce) { - log(new Status( - IStatus.ERROR, - getUniqueIdentifier(), + log(new Status(IStatus.ERROR, getUniqueIdentifier(), IDLTKDebugUIConstants.INTERNAL_ERROR, "DebugUIMessages.JDIDebugUIPlugin_An_error_occurred_retrieving_a_InterpreterInstallType_page_1", //$NON-NLS-1$ ce)); @@ -401,13 +392,11 @@ public class DLTKDebugUIPlugin extends AbstractUIPlugin { } protected void initializeInterpreterInstallTypePageMap() { - fInterpreterInstallTypePageMap = new HashMap<String, IConfigurationElement>( + fInterpreterInstallTypePageMap = new HashMap<>( 10); - IExtensionPoint extensionPoint = Platform - .getExtensionRegistry() - .getExtensionPoint( - getUniqueIdentifier(), + IExtensionPoint extensionPoint = Platform.getExtensionRegistry() + .getExtensionPoint(getUniqueIdentifier(), IDLTKDebugUIConstants.EXTENSION_POINT_INTERPRETER_INSTALL_TYPE_PAGE); IConfigurationElement[] infos = extensionPoint .getConfigurationElements(); diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/DLTKDebugUIPluginPreferenceInitializer.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/DLTKDebugUIPluginPreferenceInitializer.java index 09a8ae663..676acd53a 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/DLTKDebugUIPluginPreferenceInitializer.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/DLTKDebugUIPluginPreferenceInitializer.java @@ -10,20 +10,17 @@ import org.eclipse.jface.preference.IPreferenceStore; * Base class for initialized preferences for a dltk debugging ui plug-in * implementation. This class will initialize all values against the preference * store returned by {@link IDLTKUILanguageToolkit#getPreferenceStore()}. - * + * * <p> * Any plug-in using a preference page based upon an * {@link AbstractScriptPreferencePage} must provide an implementation of this * class to properly initialize preference values. * </p> */ -public abstract class DLTKDebugUIPluginPreferenceInitializer extends - AbstractPreferenceInitializer { +public abstract class DLTKDebugUIPluginPreferenceInitializer + extends AbstractPreferenceInitializer { - /* - * @seeorg.eclipse.core.runtime.preferences.AbstractPreferenceInitializer# - * initializeDefaultPreferences() - */ + @Override public void initializeDefaultPreferences() { /* * preferences must be saved to the following preference store, else @@ -31,8 +28,8 @@ public abstract class DLTKDebugUIPluginPreferenceInitializer extends * anything that uses the preferences it controls, will not work * properly. */ - IPreferenceStore store = DLTKDebugUILanguageManager.getLanguageToolkit( - getNatureId()).getPreferenceStore(); + IPreferenceStore store = DLTKDebugUILanguageManager + .getLanguageToolkit(getNatureId()).getPreferenceStore(); Assert.isNotNull(store); store.setDefault( @@ -57,7 +54,7 @@ public abstract class DLTKDebugUIPluginPreferenceInitializer extends * Initialize any plug-in specific preferences that should be saved to the * preference store returned from a call to * {@link IDLTKUILanguageToolkit#getPreferenceStore()} - * + * * <p> * Sub-classes may also use this method to initialized preferences against * another preference store of their choosing. diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/DebugConsoleManager.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/DebugConsoleManager.java index 1e373c00b..5a01c5906 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/DebugConsoleManager.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/DebugConsoleManager.java @@ -1,11 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * Copyright (c) 2005, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.debug.ui; @@ -191,6 +190,7 @@ public class DebugConsoleManager implements ILaunchesListener2 { /** * @since 2.0 */ + @Override public void launchesAdded(ILaunch[] launches) { launchesChanged(launches); } @@ -198,6 +198,7 @@ public class DebugConsoleManager implements ILaunchesListener2 { /** * @since 2.0 */ + @Override public void launchesChanged(ILaunch[] launches) { for (ILaunch launch : launches) { if (acceptLaunch(launch)) { @@ -225,6 +226,7 @@ public class DebugConsoleManager implements ILaunchesListener2 { /** * @since 2.0 */ + @Override public void launchesRemoved(ILaunch[] launches) { for (ILaunch launch : launches) { final ScriptDebugConsole console = launchToConsoleMap.get(launch); @@ -238,17 +240,14 @@ public class DebugConsoleManager implements ILaunchesListener2 { /** * @since 2.0 */ + @Override public void launchesTerminated(ILaunch[] launches) { for (ILaunch launch : launches) { final ScriptDebugConsole console = launchToConsoleMap.get(launch); if (console != null) { final String newName = computeName(launch); if (!newName.equals(console.getName())) { - final Runnable r = new Runnable() { - public void run() { - console.setName(newName); - } - }; + final Runnable r = () -> console.setName(newName); DLTKDebugUIPlugin.getStandardDisplay().asyncExec(r); } } @@ -269,14 +268,14 @@ public class DebugConsoleManager implements ILaunchesListener2 { /** * Returns a new console document color provider extension for the given * process type, or <code>null</code> if none. - * + * * @param type * corresponds to <code>IProcess.ATTR_PROCESS_TYPE</code> * @return IConsoleColorProvider */ private IConsoleColorProvider getColorProvider(String type) { if (fColorProviders == null) { - fColorProviders = new HashMap<String, IConfigurationElement>(); + fColorProviders = new HashMap<>(); IExtensionPoint extensionPoint = Platform.getExtensionRegistry() .getExtensionPoint(IDebugUIConstants.PLUGIN_ID, IDebugUIConstants.EXTENSION_POINT_CONSOLE_COLOR_PROVIDERS); diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/DebugImageDescriptor.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/DebugImageDescriptor.java index 253a31df1..04c7dc130 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/DebugImageDescriptor.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/DebugImageDescriptor.java @@ -1,11 +1,10 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.debug.ui; @@ -57,21 +56,19 @@ public class DebugImageDescriptor extends CompositeImageDescriptor { /** * Create a new JDIImageDescriptor. - * + * * @param baseImage * an image descriptor used as the base image * @param flags * flags indicating which adornments are to be rendered - * + * */ public DebugImageDescriptor(ImageDescriptor baseImage, int flags) { setBaseImage(baseImage); setFlags(flags); } - /** - * @see CompositeImageDescriptor#getSize() - */ + @Override protected Point getSize() { if (fSize == null) { ImageData data = getBaseImage().getImageData(); @@ -80,29 +77,23 @@ public class DebugImageDescriptor extends CompositeImageDescriptor { return fSize; } - /** - * @see Object#equals(java.lang.Object) - */ + @Override public boolean equals(Object object) { if (!(object instanceof DebugImageDescriptor)) { return false; } DebugImageDescriptor other = (DebugImageDescriptor) object; - return (getBaseImage().equals(other.getBaseImage()) && getFlags() == other - .getFlags()); + return (getBaseImage().equals(other.getBaseImage()) + && getFlags() == other.getFlags()); } - /** - * @see Object#hashCode() - */ + @Override public int hashCode() { return getBaseImage().hashCode() | getFlags(); } - /** - * @see CompositeImageDescriptor#drawCompositeImage(int, int) - */ + @Override protected void drawCompositeImage(int width, int height) { ImageData bg = getBaseImage().getImageData(); if (bg == null) { @@ -173,7 +164,8 @@ public class DebugImageDescriptor extends CompositeImageDescriptor { } else if ((flags & IN_CONTENTION_FOR_MONITOR) != 0) { x = getSize().x; y = 0; - data = getImageData(ScriptDebugImages.IMG_OVR_IN_CONTENTION_FOR_MONITOR); + data = getImageData( + ScriptDebugImages.IMG_OVR_IN_CONTENTION_FOR_MONITOR); x -= data.width; drawImage(data, x, y); } else { @@ -191,9 +183,11 @@ public class DebugImageDescriptor extends CompositeImageDescriptor { x = 0; y = getSize().y; if ((flags & ENABLED) != 0) { - data = getImageData(ScriptDebugImages.IMG_OVR_BREAKPOINT_INSTALLED); + data = getImageData( + ScriptDebugImages.IMG_OVR_BREAKPOINT_INSTALLED); } else { - data = getImageData(ScriptDebugImages.IMG_OVR_BREAKPOINT_INSTALLED_DISABLED); + data = getImageData( + ScriptDebugImages.IMG_OVR_BREAKPOINT_INSTALLED_DISABLED); } y -= data.height; @@ -201,9 +195,11 @@ public class DebugImageDescriptor extends CompositeImageDescriptor { } if ((flags & CAUGHT) != 0) { if ((flags & ENABLED) != 0) { - data = getImageData(ScriptDebugImages.IMG_OVR_CAUGHT_BREAKPOINT); + data = getImageData( + ScriptDebugImages.IMG_OVR_CAUGHT_BREAKPOINT); } else { - data = getImageData(ScriptDebugImages.IMG_OVR_CAUGHT_BREAKPOINT_DISABLED); + data = getImageData( + ScriptDebugImages.IMG_OVR_CAUGHT_BREAKPOINT_DISABLED); } x = 0; y = 0; @@ -211,9 +207,11 @@ public class DebugImageDescriptor extends CompositeImageDescriptor { } if ((flags & UNCAUGHT) != 0) { if ((flags & ENABLED) != 0) { - data = getImageData(ScriptDebugImages.IMG_OVR_UNCAUGHT_BREAKPOINT); + data = getImageData( + ScriptDebugImages.IMG_OVR_UNCAUGHT_BREAKPOINT); } else { - data = getImageData(ScriptDebugImages.IMG_OVR_UNCAUGHT_BREAKPOINT_DISABLED); + data = getImageData( + ScriptDebugImages.IMG_OVR_UNCAUGHT_BREAKPOINT_DISABLED); } x = data.width; y = data.height; @@ -221,9 +219,11 @@ public class DebugImageDescriptor extends CompositeImageDescriptor { } if ((flags & SCOPED) != 0) { if ((flags & ENABLED) != 0) { - data = getImageData(ScriptDebugImages.IMG_OVR_SCOPED_BREAKPOINT); + data = getImageData( + ScriptDebugImages.IMG_OVR_SCOPED_BREAKPOINT); } else { - data = getImageData(ScriptDebugImages.IMG_OVR_SCOPED_BREAKPOINT_DISABLED); + data = getImageData( + ScriptDebugImages.IMG_OVR_SCOPED_BREAKPOINT_DISABLED); } x = 0; y = getSize().y; @@ -232,9 +232,11 @@ public class DebugImageDescriptor extends CompositeImageDescriptor { } if ((flags & CONDITIONAL) != 0) { if ((flags & ENABLED) != 0) { - data = getImageData(ScriptDebugImages.IMG_OVR_CONDITIONAL_BREAKPOINT); + data = getImageData( + ScriptDebugImages.IMG_OVR_CONDITIONAL_BREAKPOINT); } else { - data = getImageData(ScriptDebugImages.IMG_OVR_CONDITIONAL_BREAKPOINT_DISABLED); + data = getImageData( + ScriptDebugImages.IMG_OVR_CONDITIONAL_BREAKPOINT_DISABLED); } x = 0; y = 0; @@ -244,9 +246,11 @@ public class DebugImageDescriptor extends CompositeImageDescriptor { x = getSize().x; y = 0; if ((flags & ENABLED) != 0) { - data = getImageData(ScriptDebugImages.IMG_OVR_METHOD_BREAKPOINT_ENTRY); + data = getImageData( + ScriptDebugImages.IMG_OVR_METHOD_BREAKPOINT_ENTRY); } else { - data = getImageData(ScriptDebugImages.IMG_OVR_METHOD_BREAKPOINT_ENTRY_DISABLED); + data = getImageData( + ScriptDebugImages.IMG_OVR_METHOD_BREAKPOINT_ENTRY_DISABLED); } x -= data.width; drawImage(data, x, y); @@ -255,9 +259,11 @@ public class DebugImageDescriptor extends CompositeImageDescriptor { x = getSize().x; y = getSize().y; if ((flags & ENABLED) != 0) { - data = getImageData(ScriptDebugImages.IMG_OVR_METHOD_BREAKPOINT_EXIT); + data = getImageData( + ScriptDebugImages.IMG_OVR_METHOD_BREAKPOINT_EXIT); } else { - data = getImageData(ScriptDebugImages.IMG_OVR_METHOD_BREAKPOINT_EXIT_DISABLED); + data = getImageData( + ScriptDebugImages.IMG_OVR_METHOD_BREAKPOINT_EXIT_DISABLED); } x -= data.width; y -= data.height; diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebugConsole.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebugConsole.java index 10ad70cd9..1dda77179 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebugConsole.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebugConsole.java @@ -92,7 +92,7 @@ public class ScriptDebugConsole extends IOConsole { */ public synchronized void connect(IScriptProcess process) { if (connectedProcesses == null) { - connectedProcesses = new HashSet<IScriptProcess>(); + connectedProcesses = new HashSet<>(); } if (connectedProcesses.add(process)) { final IStreamsProxy proxy = process.getScriptStreamsProxy(); @@ -117,13 +117,14 @@ public class ScriptDebugConsole extends IOConsole { } } - private List<StreamListener> fStreamListeners = new ArrayList<StreamListener>(); + private List<StreamListener> fStreamListeners = new ArrayList<>(); /** * @param streamMonitor * @param idStandardErrorStream */ - private void connect(IStreamMonitor streamMonitor, String streamIdentifier) { + private void connect(IStreamMonitor streamMonitor, + String streamIdentifier) { synchronized (streamMonitor) { IOConsoleOutputStream stream = newOutputStream(); stream.setColor(fColorProvider.getColor(streamIdentifier)); @@ -170,6 +171,7 @@ public class ScriptDebugConsole extends IOConsole { streamAppended(null, monitor); } + @Override public void streamAppended(String text, IStreamMonitor monitor) { String encoding = getEncoding(); if (fFlushed) { diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebugConsoleGenericHyperlink.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebugConsoleGenericHyperlink.java index 277b030b5..6722e64ce 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebugConsoleGenericHyperlink.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebugConsoleGenericHyperlink.java @@ -25,9 +25,11 @@ public abstract class ScriptDebugConsoleGenericHyperlink implements IHyperlink { this.fConsole = console; } + @Override public void linkEntered() { } + @Override public void linkExited() { } @@ -37,7 +39,7 @@ public abstract class ScriptDebugConsoleGenericHyperlink implements IHyperlink { /** * Returns this link's text - * + * * @exception CoreException * if unable to retrieve the text */ @@ -62,6 +64,7 @@ public abstract class ScriptDebugConsoleGenericHyperlink implements IHyperlink { protected abstract int getLineNumber(String linkText) throws CoreException; + @Override public void linkActivated() { try { String fileName; @@ -109,8 +112,8 @@ public abstract class ScriptDebugConsoleGenericHyperlink implements IHyperlink { public String getEditorId(IEditorInput input, Object inputObject) { try { - IEditorDescriptor descriptor = IDE.getEditorDescriptor(input - .getName()); + IEditorDescriptor descriptor = IDE + .getEditorDescriptor(input.getName()); return descriptor.getId(); } catch (PartInitException e) { return null; diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebugConsoleTraceTracker.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebugConsoleTraceTracker.java index eee0a627d..25009126c 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebugConsoleTraceTracker.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebugConsoleTraceTracker.java @@ -18,14 +18,16 @@ public class ScriptDebugConsoleTraceTracker extends ScriptDebugConsoleTracker { this.patternString = patternString; } + @Override public void matchFound(PatternMatchEvent event) { try { int offset = event.getOffset(); int length = event.getLength(); ScriptDebuggerConsoleToFileHyperlink link = new ScriptDebuggerConsoleToFileHyperlink( console, getPatternInstance()); - console.addHyperlink(link, link.computeOffset(offset, length, - console), link.computeLength(offset, length, console)); + console.addHyperlink(link, + link.computeOffset(offset, length, console), + link.computeLength(offset, length, console)); } catch (BadLocationException e) { } @@ -38,8 +40,9 @@ public class ScriptDebugConsoleTraceTracker extends ScriptDebugConsoleTracker { return pattern; } + @Override public String getPattern() { - return patternString; //$NON-NLS-1$ + return patternString; // $NON-NLS-1$ } } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebugConsoleTracker.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebugConsoleTracker.java index d52ce9504..bb585ad0d 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebugConsoleTracker.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebugConsoleTracker.java @@ -3,17 +3,20 @@ package org.eclipse.dltk.debug.ui; import org.eclipse.ui.console.IPatternMatchListener; import org.eclipse.ui.console.TextConsole; -public abstract class ScriptDebugConsoleTracker implements IPatternMatchListener { +public abstract class ScriptDebugConsoleTracker + implements IPatternMatchListener { protected TextConsole console; public ScriptDebugConsoleTracker() { super(); } + @Override public void connect(TextConsole console) { this.console = console; } + @Override public void disconnect() { console = null; } @@ -22,11 +25,13 @@ public abstract class ScriptDebugConsoleTracker implements IPatternMatchListener return console; } + @Override public int getCompilerFlags() { // TODO Auto-generated method stub return 0; } + @Override public String getLineQualifier() { return null; } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebugImageDescriptor.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebugImageDescriptor.java index c4eff823e..87c015eee 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebugImageDescriptor.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebugImageDescriptor.java @@ -6,164 +6,162 @@ import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.graphics.Point; /** - * A JDIImageDescriptor consists of a main icon and several adornments. The adornments - * are computed according to flags set on creation of the descriptor. + * A JDIImageDescriptor consists of a main icon and several adornments. The + * adornments are computed according to flags set on creation of the descriptor. */ public class ScriptDebugImageDescriptor extends CompositeImageDescriptor { - + /** Flag to render the is out of synch adornment */ - public final static int IS_OUT_OF_SYNCH= 0x0001; + public final static int IS_OUT_OF_SYNCH = 0x0001; /** Flag to render the may be out of synch adornment */ - public final static int MAY_BE_OUT_OF_SYNCH= 0x0002; + public final static int MAY_BE_OUT_OF_SYNCH = 0x0002; /** Flag to render the installed breakpoint adornment */ - public final static int INSTALLED= 0x0004; + public final static int INSTALLED = 0x0004; /** Flag to render the entry method breakpoint adornment */ - public final static int ENTRY= 0x0008; + public final static int ENTRY = 0x0008; /** Flag to render the exit method breakpoint adornment */ - public final static int EXIT= 0x0010; + public final static int EXIT = 0x0010; /** Flag to render the enabled breakpoint adornment */ - public final static int ENABLED= 0x0020; + public final static int ENABLED = 0x0020; /** Flag to render the conditional breakpoint adornment */ - public final static int CONDITIONAL= 0x0040; + public final static int CONDITIONAL = 0x0040; /** Flag to render the caught breakpoint adornment */ - public final static int CAUGHT= 0x0080; + public final static int CAUGHT = 0x0080; /** Flag to render the uncaught breakpoint adornment */ - public final static int UNCAUGHT= 0x0100; + public final static int UNCAUGHT = 0x0100; /** Flag to render the scoped breakpoint adornment */ - public final static int SCOPED= 0x0200; - + public final static int SCOPED = 0x0200; + /** Flag to render the owning a monitor thread adornment */ - public final static int OWNS_MONITOR= 0x0400; + public final static int OWNS_MONITOR = 0x0400; /** Flag to render the owned monitor adornment */ - public final static int OWNED_MONITOR= 0x0800; + public final static int OWNED_MONITOR = 0x0800; /** Flag to render the in contention monitor adornment */ - public final static int CONTENTED_MONITOR= 0x1000; + public final static int CONTENTED_MONITOR = 0x1000; /** Flag to render the in contention for monitor thread adornment */ - public final static int IN_CONTENTION_FOR_MONITOR= 0x2000; + public final static int IN_CONTENTION_FOR_MONITOR = 0x2000; /** Flag to render the in deadlock adornment */ - public final static int IN_DEADLOCK= 0x8000; - + public final static int IN_DEADLOCK = 0x8000; + /** Flag to render the synchronized stack frame adornment */ - public final static int SYNCHRONIZED= 0x4000; + public final static int SYNCHRONIZED = 0x4000; private ImageDescriptor fBaseImage; private int fFlags; private Point fSize; - + /** * Create a new JDIImageDescriptor. - * - * @param baseImage an image descriptor used as the base image - * @param flags flags indicating which adornments are to be rendered - * + * + * @param baseImage + * an image descriptor used as the base image + * @param flags + * flags indicating which adornments are to be rendered + * */ public ScriptDebugImageDescriptor(ImageDescriptor baseImage, int flags) { setBaseImage(baseImage); setFlags(flags); } - - /** - * @see CompositeImageDescriptor#getSize() - */ + + @Override protected Point getSize() { if (fSize == null) { - ImageData data= getBaseImage().getImageData(); + ImageData data = getBaseImage().getImageData(); setSize(new Point(data.width, data.height)); } return fSize; } - - /** - * @see Object#equals(java.lang.Object) - */ + + @Override public boolean equals(Object object) { - if (!(object instanceof ScriptDebugImageDescriptor)){ + if (!(object instanceof ScriptDebugImageDescriptor)) { return false; } - - ScriptDebugImageDescriptor other= (ScriptDebugImageDescriptor)object; - return (getBaseImage().equals(other.getBaseImage()) && getFlags() == other.getFlags()); + + ScriptDebugImageDescriptor other = (ScriptDebugImageDescriptor) object; + return (getBaseImage().equals(other.getBaseImage()) + && getFlags() == other.getFlags()); } - - /** - * @see Object#hashCode() - */ + + @Override public int hashCode() { return getBaseImage().hashCode() | getFlags(); } - - /** - * @see CompositeImageDescriptor#drawCompositeImage(int, int) - */ + + @Override protected void drawCompositeImage(int width, int height) { - ImageData bg= getBaseImage().getImageData(); + ImageData bg = getBaseImage().getImageData(); if (bg == null) { - bg= DEFAULT_IMAGE_DATA; + bg = DEFAULT_IMAGE_DATA; } drawImage(bg, 0, 0); drawOverlays(); } private ImageData getImageData(String imageDescriptorKey) { - return ScriptDebugImages.getImageDescriptor(imageDescriptorKey).getImageData(); + return ScriptDebugImages.getImageDescriptor(imageDescriptorKey) + .getImageData(); } + /** * Add any overlays to the image as specified in the flags. */ protected void drawOverlays() { - int flags= getFlags(); - int x= 0; - int y= 0; - ImageData data= null; + int flags = getFlags(); + int x = 0; + int y = 0; + ImageData data = null; if ((flags & IS_OUT_OF_SYNCH) != 0) { - x= getSize().x; - y= 0; - data= getImageData(ScriptDebugImages.IMG_OVR_OUT_OF_SYNCH); + x = getSize().x; + y = 0; + data = getImageData(ScriptDebugImages.IMG_OVR_OUT_OF_SYNCH); x -= data.width; drawImage(data, x, y); } else if ((flags & MAY_BE_OUT_OF_SYNCH) != 0) { - x= getSize().x; - y= 0; - data= getImageData(ScriptDebugImages.IMG_OVR_MAY_BE_OUT_OF_SYNCH); + x = getSize().x; + y = 0; + data = getImageData(ScriptDebugImages.IMG_OVR_MAY_BE_OUT_OF_SYNCH); x -= data.width; drawImage(data, x, y); } else if ((flags & SYNCHRONIZED) != 0) { - x= getSize().x; - y= 0; - data= getImageData(ScriptDebugImages.IMG_OVR_SYNCHRONIZED); + x = getSize().x; + y = 0; + data = getImageData(ScriptDebugImages.IMG_OVR_SYNCHRONIZED); x -= data.width; drawImage(data, x, y); } else { if ((flags & IN_DEADLOCK) != 0) { - x= 0; - y= 0; - data= getImageData(ScriptDebugImages.IMG_OVR_IN_DEADLOCK); + x = 0; + y = 0; + data = getImageData(ScriptDebugImages.IMG_OVR_IN_DEADLOCK); drawImage(data, x, y); } if ((flags & OWNED_MONITOR) != 0) { - x= getSize().x; - y= getSize().y; - data= getImageData(ScriptDebugImages.IMG_OVR_OWNED); + x = getSize().x; + y = getSize().y; + data = getImageData(ScriptDebugImages.IMG_OVR_OWNED); x -= data.width; y -= data.height; drawImage(data, x, y); } else if ((flags & CONTENTED_MONITOR) != 0) { - x= getSize().x; - y= getSize().y; - data= getImageData(ScriptDebugImages.IMG_OVR_IN_CONTENTION); + x = getSize().x; + y = getSize().y; + data = getImageData(ScriptDebugImages.IMG_OVR_IN_CONTENTION); x -= data.width; y -= data.height; drawImage(data, x, y); } else if ((flags & OWNS_MONITOR) != 0) { - x= getSize().x; - y= 0; - data= getImageData(ScriptDebugImages.IMG_OVR_OWNS_MONITOR); + x = getSize().x; + y = 0; + data = getImageData(ScriptDebugImages.IMG_OVR_OWNS_MONITOR); x -= data.width; drawImage(data, x, y); } else if ((flags & IN_CONTENTION_FOR_MONITOR) != 0) { - x= getSize().x; - y= 0; - data= getImageData(ScriptDebugImages.IMG_OVR_IN_CONTENTION_FOR_MONITOR); + x = getSize().x; + y = 0; + data = getImageData( + ScriptDebugImages.IMG_OVR_IN_CONTENTION_FOR_MONITOR); x -= data.width; drawImage(data, x, y); } else { @@ -171,89 +169,104 @@ public class ScriptDebugImageDescriptor extends CompositeImageDescriptor { } } } - + protected void drawBreakpointOverlays() { - int flags= getFlags(); - int x= 0; - int y= 0; - ImageData data= null; + int flags = getFlags(); + int x = 0; + int y = 0; + ImageData data = null; if ((flags & INSTALLED) != 0) { - x= 0; - y= getSize().y; - if ((flags & ENABLED) !=0) { - data= getImageData(ScriptDebugImages.IMG_OVR_BREAKPOINT_INSTALLED); + x = 0; + y = getSize().y; + if ((flags & ENABLED) != 0) { + data = getImageData( + ScriptDebugImages.IMG_OVR_BREAKPOINT_INSTALLED); } else { - data= getImageData(ScriptDebugImages.IMG_OVR_BREAKPOINT_INSTALLED_DISABLED); + data = getImageData( + ScriptDebugImages.IMG_OVR_BREAKPOINT_INSTALLED_DISABLED); } - + y -= data.height; drawImage(data, x, y); } if ((flags & CAUGHT) != 0) { - if ((flags & ENABLED) !=0) { - data= getImageData(ScriptDebugImages.IMG_OVR_CAUGHT_BREAKPOINT); + if ((flags & ENABLED) != 0) { + data = getImageData( + ScriptDebugImages.IMG_OVR_CAUGHT_BREAKPOINT); } else { - data= getImageData(ScriptDebugImages.IMG_OVR_CAUGHT_BREAKPOINT_DISABLED); + data = getImageData( + ScriptDebugImages.IMG_OVR_CAUGHT_BREAKPOINT_DISABLED); } - x= 0; - y= 0; + x = 0; + y = 0; drawImage(data, x, y); } if ((flags & UNCAUGHT) != 0) { - if ((flags & ENABLED) !=0) { - data= getImageData(ScriptDebugImages.IMG_OVR_UNCAUGHT_BREAKPOINT); + if ((flags & ENABLED) != 0) { + data = getImageData( + ScriptDebugImages.IMG_OVR_UNCAUGHT_BREAKPOINT); } else { - data= getImageData(ScriptDebugImages.IMG_OVR_UNCAUGHT_BREAKPOINT_DISABLED); + data = getImageData( + ScriptDebugImages.IMG_OVR_UNCAUGHT_BREAKPOINT_DISABLED); } - x= data.width; - y= data.height; + x = data.width; + y = data.height; drawImage(data, x, y); } if ((flags & SCOPED) != 0) { - if ((flags & ENABLED) !=0) { - data= getImageData(ScriptDebugImages.IMG_OVR_SCOPED_BREAKPOINT); + if ((flags & ENABLED) != 0) { + data = getImageData( + ScriptDebugImages.IMG_OVR_SCOPED_BREAKPOINT); } else { - data= getImageData(ScriptDebugImages.IMG_OVR_SCOPED_BREAKPOINT_DISABLED); + data = getImageData( + ScriptDebugImages.IMG_OVR_SCOPED_BREAKPOINT_DISABLED); } - x= 0; - y= getSize().y; - y-= data.height; + x = 0; + y = getSize().y; + y -= data.height; drawImage(data, x, y); } if ((flags & CONDITIONAL) != 0) { - if ((flags & ENABLED) !=0) { - data= getImageData(ScriptDebugImages.IMG_OVR_CONDITIONAL_BREAKPOINT); + if ((flags & ENABLED) != 0) { + data = getImageData( + ScriptDebugImages.IMG_OVR_CONDITIONAL_BREAKPOINT); } else { - data= getImageData(ScriptDebugImages.IMG_OVR_CONDITIONAL_BREAKPOINT_DISABLED); + data = getImageData( + ScriptDebugImages.IMG_OVR_CONDITIONAL_BREAKPOINT_DISABLED); } - x= 0; - y= 0; + x = 0; + y = 0; drawImage(data, x, y); } if ((flags & ENTRY) != 0) { - x= getSize().x; - y= 0; - if ((flags & ENABLED) !=0) { - data= getImageData(ScriptDebugImages.IMG_OVR_METHOD_BREAKPOINT_ENTRY); + x = getSize().x; + y = 0; + if ((flags & ENABLED) != 0) { + data = getImageData( + ScriptDebugImages.IMG_OVR_METHOD_BREAKPOINT_ENTRY); } else { - data= getImageData(ScriptDebugImages.IMG_OVR_METHOD_BREAKPOINT_ENTRY_DISABLED); + data = getImageData( + ScriptDebugImages.IMG_OVR_METHOD_BREAKPOINT_ENTRY_DISABLED); } x -= data.width; drawImage(data, x, y); } - if ((flags & EXIT) != 0){ - x= getSize().x; - y= getSize().y; + if ((flags & EXIT) != 0) { + x = getSize().x; + y = getSize().y; if ((flags & ENABLED) != 0) { - data= getImageData(ScriptDebugImages.IMG_OVR_METHOD_BREAKPOINT_EXIT); + data = getImageData( + ScriptDebugImages.IMG_OVR_METHOD_BREAKPOINT_EXIT); } else { - data= getImageData(ScriptDebugImages.IMG_OVR_METHOD_BREAKPOINT_EXIT_DISABLED); + data = getImageData( + ScriptDebugImages.IMG_OVR_METHOD_BREAKPOINT_EXIT_DISABLED); } x -= data.width; y -= data.height; drawImage(data, x, y); } } + protected ImageDescriptor getBaseImage() { return fBaseImage; } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebugModelPresentation.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebugModelPresentation.java index 3166c68e6..2150bd6db 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebugModelPresentation.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebugModelPresentation.java @@ -1,11 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * Copyright (c) 2005, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.debug.ui; @@ -317,7 +316,7 @@ public abstract class ScriptDebugModelPresentation extends LabelProvider private static String retrieveStackFrameLine(IScriptStackFrame frame, final IDocument document) - throws BadLocationException, DebugException { + throws BadLocationException, DebugException { if (frame.getBeginLine() > 0 && frame.getEndLine() > 0) { final IRegion region = document .getLineInformation(frame.getBeginLine() - 1); @@ -426,12 +425,10 @@ public abstract class ScriptDebugModelPresentation extends LabelProvider private String getVariableDetail(IScriptValue value) { final String[] detail = new String[1]; final Object lock = new Object(); - computeDetail(value, new IValueDetailListener() { - public void detailComputed(IValue computedValue, String result) { - synchronized (lock) { - detail[0] = result; - lock.notifyAll(); - } + computeDetail(value, (computedValue, result) -> { + synchronized (lock) { + detail[0] = result; + lock.notifyAll(); } }); synchronized (lock) { @@ -508,7 +505,7 @@ public abstract class ScriptDebugModelPresentation extends LabelProvider /* * TODO: Uncomment this comment when add support for caught and * uncaught exceptions - * + * * String state; boolean c= b.isCaught(); boolean u= * b.isUncaught(); if (c && u) { state= "caught and uncaught"; } * else if (c) { state= "caught"; } else if (u) { state= @@ -564,6 +561,7 @@ public abstract class ScriptDebugModelPresentation extends LabelProvider return type.getName(); } + @Override public final String getText(Object element) { if (element instanceof IScriptDebugTarget) { return getDebugTargetText((IScriptDebugTarget) element); @@ -587,6 +585,7 @@ public abstract class ScriptDebugModelPresentation extends LabelProvider } // Details + @Override public void computeDetail(IValue value, IValueDetailListener listener) { if (value instanceof IScriptValue) { IScriptDebugTarget target = (IScriptDebugTarget) value @@ -606,6 +605,7 @@ public abstract class ScriptDebugModelPresentation extends LabelProvider } } + @Override public void setAttribute(String id, Object value) { if (value == null) { return; @@ -650,6 +650,7 @@ public abstract class ScriptDebugModelPresentation extends LabelProvider return null; } + @Override public Image getImage(Object element) { if (element instanceof IScriptBreakpoint) { return getBreakpointImage((IScriptBreakpoint) element); @@ -665,6 +666,7 @@ public abstract class ScriptDebugModelPresentation extends LabelProvider } // Editor + @Override public IEditorInput getEditorInput(Object element) { if (element instanceof IFileHandle) { return new ExternalFileEditorInput((IFileHandle) element); @@ -715,5 +717,6 @@ public abstract class ScriptDebugModelPresentation extends LabelProvider return null; } + @Override public abstract String getEditorId(IEditorInput input, Object element); } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebuggerConsoleToFileHyperlink.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebuggerConsoleToFileHyperlink.java index 125a46317..e2407b2db 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebuggerConsoleToFileHyperlink.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebuggerConsoleToFileHyperlink.java @@ -1,11 +1,10 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.debug.ui; @@ -23,8 +22,8 @@ import org.eclipse.ui.console.TextConsole; /** * A hyperlink from a stack trace line of the form "(file "*.*")" */ -public class ScriptDebuggerConsoleToFileHyperlink extends - ScriptDebugConsoleGenericHyperlink { +public class ScriptDebuggerConsoleToFileHyperlink + extends ScriptDebugConsoleGenericHyperlink { private final Pattern pattern; public ScriptDebuggerConsoleToFileHyperlink(TextConsole console, @@ -33,6 +32,7 @@ public class ScriptDebuggerConsoleToFileHyperlink extends this.pattern = pattern; } + @Override protected String getFileName(String linkText) throws CoreException { Matcher m = pattern.matcher(linkText); @@ -45,6 +45,7 @@ public class ScriptDebuggerConsoleToFileHyperlink extends throw new CoreException(status); } + @Override protected int getLineNumber(String linkText) throws CoreException { Matcher m = pattern.matcher(linkText); diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptStreamProxy.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptStreamProxy.java index 9aa21c3df..e1e8feb58 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptStreamProxy.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptStreamProxy.java @@ -1,11 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * Copyright (c) 2005, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.debug.ui; @@ -46,16 +45,14 @@ public class ScriptStreamProxy implements IScriptStreamProxy { stdErr.setActivateOnWrite(debugUIStore .getBoolean(IDebugPreferenceConstants.CONSOLE_OPEN_ON_ERR)); - getDisplay().asyncExec(new Runnable() { - public void run() { - final DLTKDebugUIPlugin colors = DLTKDebugUIPlugin.getDefault(); - stdOut.setColor(colors.getColor(PreferenceConverter.getColor( - debugUIStore, - IDebugPreferenceConstants.CONSOLE_SYS_OUT_COLOR))); - stdErr.setColor(colors.getColor(PreferenceConverter.getColor( - debugUIStore, - IDebugPreferenceConstants.CONSOLE_SYS_ERR_COLOR))); - } + getDisplay().asyncExec(() -> { + final DLTKDebugUIPlugin colors = DLTKDebugUIPlugin.getDefault(); + stdOut.setColor( + colors.getColor(PreferenceConverter.getColor(debugUIStore, + IDebugPreferenceConstants.CONSOLE_SYS_OUT_COLOR))); + stdErr.setColor( + colors.getColor(PreferenceConverter.getColor(debugUIStore, + IDebugPreferenceConstants.CONSOLE_SYS_ERR_COLOR))); }); } @@ -72,18 +69,22 @@ public class ScriptStreamProxy implements IScriptStreamProxy { return Display.getDefault(); } + @Override public OutputStream getStderr() { return stdErr; } + @Override public OutputStream getStdout() { return stdOut; } + @Override public InputStream getStdin() { return input; } + @Override public synchronized void close() { if (!closed) { try { @@ -102,21 +103,24 @@ public class ScriptStreamProxy implements IScriptStreamProxy { private boolean needsEncoding = false; private String encoding = null; + @Override public String getEncoding() { return encoding; } + @Override public void setEncoding(String encoding) { this.encoding = encoding; - needsEncoding = encoding != null - && !encoding.equals(WorkbenchEncoding - .getWorkbenchDefaultEncoding()); + needsEncoding = encoding != null && !encoding + .equals(WorkbenchEncoding.getWorkbenchDefaultEncoding()); } + @Override public void writeStdout(String value) { write(stdOut, value); } + @Override public void writeStderr(String value) { write(stdErr, value); } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptWatchExpressionFilter.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptWatchExpressionFilter.java index 9e2613632..a1c8cd9e9 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptWatchExpressionFilter.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptWatchExpressionFilter.java @@ -5,13 +5,15 @@ import org.eclipse.debug.core.model.IVariable; import org.eclipse.debug.ui.actions.IWatchExpressionFactoryAdapterExtension; import org.eclipse.dltk.debug.core.model.IScriptValue; -public class ScriptWatchExpressionFilter implements - IWatchExpressionFactoryAdapterExtension { +public class ScriptWatchExpressionFilter + implements IWatchExpressionFactoryAdapterExtension { + @Override public boolean canCreateWatchExpression(IVariable variable) { return true; } + @Override public String createWatchExpression(IVariable variable) throws CoreException { IScriptValue v = (IScriptValue) variable.getValue(); diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/AddExceptionAction.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/AddExceptionAction.java index 6e98d1ee8..537f9e4ee 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/AddExceptionAction.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/AddExceptionAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.dltk.debug.ui.actions; - import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; @@ -43,30 +42,30 @@ import org.eclipse.ui.PlatformUI; /** * The workbench menu action for adding an exception breakpoint */ -public abstract class AddExceptionAction implements IViewActionDelegate, IWorkbenchWindowActionDelegate { - +public abstract class AddExceptionAction + implements IViewActionDelegate, IWorkbenchWindowActionDelegate { + public static final String CAUGHT_CHECKED = "caughtChecked"; //$NON-NLS-1$ public static final String UNCAUGHT_CHECKED = "uncaughtChecked"; //$NON-NLS-1$ - public static final String DIALOG_SETTINGS = "AddExceptionDialog"; //$NON-NLS-1$ + public static final String DIALOG_SETTINGS = "AddExceptionDialog"; //$NON-NLS-1$ private IDLTKUILanguageToolkit fToolkit; - /* (non-Javadoc) - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ + @Override public void run(IAction action) { - String natureId = ScriptDebugManager.getInstance().getNatureByDebugModel(getDebugModelId()); + String natureId = ScriptDebugManager.getInstance() + .getNatureByDebugModel(getDebugModelId()); fToolkit = DLTKUILanguageManager.getLanguageToolkit(natureId); IDialogSettings settings = getDialogSettings(); - AddExceptionTypeDialogExtension ext = new AddExceptionTypeDialogExtension(null, - settings.getBoolean(CAUGHT_CHECKED), settings - .getBoolean(UNCAUGHT_CHECKED)); - + AddExceptionTypeDialogExtension ext = new AddExceptionTypeDialogExtension( + null, settings.getBoolean(CAUGHT_CHECKED), + settings.getBoolean(UNCAUGHT_CHECKED)); + TypeSelectionDialog2 dialog = new TypeSelectionDialog2( - DLTKUIPlugin.getActiveWorkbenchShell(), false, - PlatformUI.getWorkbench().getProgressService(), + DLTKUIPlugin.getActiveWorkbenchShell(), false, + PlatformUI.getWorkbench().getProgressService(), SearchEngine.createWorkspaceScope(fToolkit.getCoreToolkit()), IDLTKSearchConstants.TYPE, ext, fToolkit); - + dialog.setMessage(Messages.AddExceptionAction_search); dialog.setTitle(Messages.AddExceptionAction_addExceptionBreakpoint); if (dialog.open() == IDialogConstants.OK_ID) { @@ -74,57 +73,66 @@ public abstract class AddExceptionAction implements IViewActionDelegate, IWorkbe if (types != null && types.length > 0) { boolean caught = ext.shouldHandleCaughtExceptions(); boolean uncaught = ext.shouldHandleUncaughtExceptions(); - Object[] results = dialog.getResult(); - if(results != null && results.length > 0) { + Object[] results = dialog.getResult(); + if (results != null && results.length > 0) { try { - createBreakpoint(caught, uncaught, (IType)results[0]); + createBreakpoint(caught, uncaught, (IType) results[0]); settings.put(CAUGHT_CHECKED, caught); settings.put(UNCAUGHT_CHECKED, uncaught); - } - catch (CoreException e) { - DLTKDebugUIPlugin.errorDialog(Messages.AddExceptionAction_unableToCreateBreakpoint, e.getStatus()); + } catch (CoreException e) { + DLTKDebugUIPlugin.errorDialog( + Messages.AddExceptionAction_unableToCreateBreakpoint, + e.getStatus()); } } } } } - + /** - * Returns the existing dialog settings for the persisted state of the caught and uncaught check boxes. - * If no section exists then a new one is created - * + * Returns the existing dialog settings for the persisted state of the + * caught and uncaught check boxes. If no section exists then a new one is + * created + * * @return the dialog settings section for the type dialog extension - * + * * @since 3.4 */ private IDialogSettings getDialogSettings() { - IDialogSettings allSetttings = DLTKDebugUIPlugin.getDefault().getDialogSettings(); - IDialogSettings section = allSetttings.getSection(DIALOG_SETTINGS); - if (section == null) { - section = allSetttings.addNewSection(DIALOG_SETTINGS); - section.put(CAUGHT_CHECKED, true); - section.put(UNCAUGHT_CHECKED, true); - } - return section; - } - + IDialogSettings allSetttings = DLTKDebugUIPlugin.getDefault() + .getDialogSettings(); + IDialogSettings section = allSetttings.getSection(DIALOG_SETTINGS); + if (section == null) { + section = allSetttings.addNewSection(DIALOG_SETTINGS); + section.put(CAUGHT_CHECKED, true); + section.put(UNCAUGHT_CHECKED, true); + } + return section; + } + /** * creates a single breakpoint of the specified type - * @param caught if the exception is caught - * @param uncaught if the exception is uncaught - * @param type the type of the exception + * + * @param caught + * if the exception is caught + * @param uncaught + * if the exception is uncaught + * @param type + * the type of the exception * @since 3.2 */ - private void createBreakpoint(final boolean caught, final boolean uncaught, final IType type) throws CoreException { - IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints( - getDebugModelId()); + private void createBreakpoint(final boolean caught, final boolean uncaught, + final IType type) throws CoreException { + IBreakpoint[] breakpoints = DebugPlugin.getDefault() + .getBreakpointManager().getBreakpoints(getDebugModelId()); boolean exists = false; for (int j = 0; j < breakpoints.length; j++) { IScriptBreakpoint breakpoint = (IScriptBreakpoint) breakpoints[j]; if (breakpoint instanceof IScriptExceptionBreakpoint) { IScriptExceptionBreakpoint exceptBreak = (IScriptExceptionBreakpoint) breakpoint; - if (exceptBreak.getTypeName().equals(type.getFullyQualifiedName())) { + if (exceptBreak.getTypeName() + .equals(type.getFullyQualifiedName())) { exists = true; break; } @@ -132,9 +140,11 @@ public abstract class AddExceptionAction implements IViewActionDelegate, IWorkbe } if (!exists) { new Job(Messages.AddExceptionAction_scriptToggleExceptionBreakpoint) { + @Override protected IStatus run(IProgressMonitor monitor) { try { - BreakpointUtils.addExceptionBreakpoint(getDebugModelId(), caught, uncaught, type); + BreakpointUtils.addExceptionBreakpoint( + getDebugModelId(), caught, uncaught, type); return Status.OK_STATUS; } catch (CoreException e) { return e.getStatus(); @@ -144,28 +154,22 @@ public abstract class AddExceptionAction implements IViewActionDelegate, IWorkbe }.schedule(); } } - - /* (non-Javadoc) - * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart) - */ - public void init(IViewPart view) {} - /* (non-Javadoc) - * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) {} - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() - */ + @Override + public void init(IViewPart view) { + } + + @Override + public void selectionChanged(IAction action, ISelection selection) { + } + + @Override public void dispose() { } - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) - */ + @Override public void init(IWorkbenchWindow window) { } - + protected abstract String getDebugModelId(); } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/AddExceptionTypeDialogExtension.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/AddExceptionTypeDialogExtension.java index 4540e81dc..7116ed98a 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/AddExceptionTypeDialogExtension.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/AddExceptionTypeDialogExtension.java @@ -22,105 +22,124 @@ import org.eclipse.ui.dialogs.ISelectionStatusValidator; /** * Provides a type dialog extension for the JDT type selection dialog - * + * * @since 3.4 */ public class AddExceptionTypeDialogExtension extends TypeSelectionExtension { - + /** - * widgets - */ - private Button fCaughtButton; - private Button fUncaughtButton; - private boolean fCaught = false; - private boolean fUncaught = false; + * widgets + */ + private Button fCaughtButton; + private Button fUncaughtButton; + private boolean fCaught = false; + private boolean fUncaught = false; protected Object fExceptionBaseClassName; - - /** + + /** * Constructor + * * @param caught * @param uncaught */ - public AddExceptionTypeDialogExtension(String fExceptionBaseClassName, boolean caught, boolean uncaught) { - fCaught = caught; - fUncaught = uncaught; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.ui.dialogs.TypeSelectionExtension#createContentArea(org.eclipse.swt.widgets.Composite) - */ + public AddExceptionTypeDialogExtension(String fExceptionBaseClassName, + boolean caught, boolean uncaught) { + fCaught = caught; + fUncaught = uncaught; + } + + @Override public Control createContentArea(Composite parent) { - Composite comp = SWTFactory.createComposite(parent, parent.getFont(), 1, 1, GridData.FILL_HORIZONTAL); - fCaughtButton = SWTFactory.createCheckButton(comp, Messages.AddExceptionTypeDialogExtension_suspendOnCaught, null, fCaught, 1); + Composite comp = SWTFactory.createComposite(parent, parent.getFont(), 1, + 1, GridData.FILL_HORIZONTAL); + fCaughtButton = SWTFactory.createCheckButton(comp, + Messages.AddExceptionTypeDialogExtension_suspendOnCaught, null, + fCaught, 1); fCaughtButton.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) {} + @Override + public void widgetDefaultSelected(SelectionEvent e) { + } + + @Override public void widgetSelected(SelectionEvent e) { fCaught = fCaughtButton.getSelection(); } }); - fUncaughtButton = SWTFactory.createCheckButton(comp, Messages.AddExceptionTypeDialogExtension_SuspendOnUncaught, null, fUncaught, 1); + fUncaughtButton = SWTFactory.createCheckButton(comp, + Messages.AddExceptionTypeDialogExtension_SuspendOnUncaught, + null, fUncaught, 1); fUncaughtButton.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) {} + @Override + public void widgetDefaultSelected(SelectionEvent e) { + } + + @Override public void widgetSelected(SelectionEvent e) { fUncaught = fUncaughtButton.getSelection(); } }); return comp; } - - /* (non-Javadoc) - * @see org.eclipse.jdt.ui.dialogs.TypeSelectionExtension#getSelectionValidator() - */ + + @Override public ISelectionStatusValidator getSelectionValidator() { - return new ISelectionStatusValidator() { - public IStatus validate(Object[] selection) { - if(selection.length == 1) { - // if any class can be thrown return OK - if (fExceptionBaseClassName == null) { - return Status.OK_STATUS; - } + return selection -> { + if (selection.length == 1) { + // if any class can be thrown return OK + if (fExceptionBaseClassName == null) { + return Status.OK_STATUS; + } - // else check that selected class was enherited from exception base class - try { - LinkedList queue = new LinkedList(); - IType type = (IType) selection[0]; - ITypeHierarchy hierarchy = type.newSupertypeHierarchy(new NullProgressMonitor()); - IType curr = type; - while (curr != null) { - if (fExceptionBaseClassName.equals(curr.getFullyQualifiedName("."))) { //$NON-NLS-1$ - return Status.OK_STATUS; - } - IType[] superclasses = hierarchy.getSuperclass(curr); - if (superclasses != null) - queue.addAll(Arrays.asList(superclasses)); - - if (queue.size() > 0) - curr = (IType) queue.removeFirst(); - else - curr = null; - } - } - catch (ModelException e) { - DLTKDebugUIPlugin.log(e); - return Status.CANCEL_STATUS; - } + // else check that selected class was enherited from exception + // base class + try { + LinkedList queue = new LinkedList(); + IType type = (IType) selection[0]; + ITypeHierarchy hierarchy = type + .newSupertypeHierarchy(new NullProgressMonitor()); + IType curr = type; + while (curr != null) { + if (fExceptionBaseClassName + .equals(curr.getFullyQualifiedName("."))) { //$NON-NLS-1$ + return Status.OK_STATUS; + } + IType[] superclasses = hierarchy.getSuperclass(curr); + if (superclasses != null) + queue.addAll(Arrays.asList(superclasses)); + + if (queue.size() > 0) + curr = (IType) queue.removeFirst(); + else + curr = null; + } + } catch (ModelException e) { + DLTKDebugUIPlugin.log(e); + return Status.CANCEL_STATUS; } - return new Status(IStatus.ERROR, DLTKDebugUIPlugin.getUniqueIdentifier(), Messages.AddExceptionTypeDialogExtension_selectedItemIsNotAnException); } - + return new Status(IStatus.ERROR, + DLTKDebugUIPlugin.getUniqueIdentifier(), + Messages.AddExceptionTypeDialogExtension_selectedItemIsNotAnException); }; } - + /** - * Returns if the breakpoint should be set to suspend when the associated exception is thrown, but caught - * @return if the breakpoint should be set to suspend when the associated exception is thrown, but caught + * Returns if the breakpoint should be set to suspend when the associated + * exception is thrown, but caught + * + * @return if the breakpoint should be set to suspend when the associated + * exception is thrown, but caught */ public boolean shouldHandleCaughtExceptions() { return fCaught; } - - /**Returns if the breakpoint should be set to suspend when the associated exception is thrown, but not caught - * @return if the breakpoint should be set to suspend when the associated exception is thrown, but not caught + + /** + * Returns if the breakpoint should be set to suspend when the associated + * exception is thrown, but not caught + * + * @return if the breakpoint should be set to suspend when the associated + * exception is thrown, but not caught */ public boolean shouldHandleUncaughtExceptions() { return fUncaught; diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/BreakpointToggleAction.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/BreakpointToggleAction.java index ef5965035..b68021697 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/BreakpointToggleAction.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/BreakpointToggleAction.java @@ -1,16 +1,15 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.dltk.debug.ui.actions; - import java.util.Iterator; import org.eclipse.core.resources.IMarker; @@ -26,7 +25,6 @@ import org.eclipse.dltk.ui.util.ExceptionHandler; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IActionDelegate; import org.eclipse.ui.IObjectActionDelegate; import org.eclipse.ui.IPartListener; import org.eclipse.ui.IWorkbenchPart; @@ -34,33 +32,30 @@ import org.eclipse.ui.IWorkbenchPart; /** * Provides a general toggle action for breakpoints to reuse */ -public abstract class BreakpointToggleAction implements IObjectActionDelegate, IBreakpointsListener, IPartListener { - +public abstract class BreakpointToggleAction + implements IObjectActionDelegate, IBreakpointsListener, IPartListener { + private IStructuredSelection fSelection; private IAction fAction; private IWorkbenchPart fPart; - /** - * @see IActionDelegate#run(IAction) - */ + @Override public void run(IAction action) { - IStructuredSelection selection= getStructuredSelection(); - Iterator itr= selection.iterator(); + IStructuredSelection selection = getStructuredSelection(); + Iterator itr = selection.iterator(); while (itr.hasNext()) { try { - IScriptBreakpoint breakpoint= (IScriptBreakpoint) itr.next(); + IScriptBreakpoint breakpoint = (IScriptBreakpoint) itr.next(); doAction(breakpoint); } catch (CoreException e) { - String title= ActionMessages.BreakpointAction_Breakpoint_configuration_1; - String message= ActionMessages.BreakpointAction_Exceptions_occurred_attempting_to_modify_breakpoint__2; + String title = ActionMessages.BreakpointAction_Breakpoint_configuration_1; + String message = ActionMessages.BreakpointAction_Exceptions_occurred_attempting_to_modify_breakpoint__2; ExceptionHandler.handle(e, title, message); - } + } } } - /** - * @see IActionDelegate#selectionChanged(IAction, ISelection) - */ + @Override public void selectionChanged(IAction action, ISelection selection) { setAction(action); if (selection.isEmpty()) { @@ -68,14 +63,16 @@ public abstract class BreakpointToggleAction implements IObjectActionDelegate, I return; } if (selection instanceof IStructuredSelection) { - setStructuredSelection((IStructuredSelection)selection); + setStructuredSelection((IStructuredSelection) selection); boolean enabled = isEnabledFor(getStructuredSelection()); action.setEnabled(enabled); if (enabled && isToggleAction()) { - IBreakpoint breakpoint = (IBreakpoint)getStructuredSelection().getFirstElement(); + IBreakpoint breakpoint = (IBreakpoint) getStructuredSelection() + .getFirstElement(); if (breakpoint instanceof IScriptBreakpoint) { try { - action.setChecked(getToggleState((IScriptBreakpoint) breakpoint)); + action.setChecked( + getToggleState((IScriptBreakpoint) breakpoint)); } catch (CoreException e) { DLTKDebugPlugin.log(e); } @@ -85,44 +82,53 @@ public abstract class BreakpointToggleAction implements IObjectActionDelegate, I } /** - * Returns if the action is a checkable action. i.e. if we should bother updating checked state - * @return if the action is a checkable action + * Returns if the action is a checkable action. i.e. if we should bother + * updating checked state * + * @return if the action is a checkable action + * * @since 3.3 */ protected boolean isToggleAction() { return true; } - + /** * Toggle the state of this action */ - public abstract void doAction(IScriptBreakpoint breakpoint) throws CoreException; - + public abstract void doAction(IScriptBreakpoint breakpoint) + throws CoreException; + /** * Returns whether this action is currently toggled on */ - protected abstract boolean getToggleState(IScriptBreakpoint breakpoint) throws CoreException; - + protected abstract boolean getToggleState(IScriptBreakpoint breakpoint) + throws CoreException; + /** * Get the current selection */ protected IStructuredSelection getStructuredSelection() { return fSelection; } - + /** * Allows the current structured selection to be set - * @param selection the new selection + * + * @param selection + * the new selection */ protected void setStructuredSelection(IStructuredSelection selection) { - fSelection= selection; + fSelection = selection; } - + /** - * Returns if the underlying action should be enabled for the given selection + * Returns if the underlying action should be enabled for the given + * selection + * * @param selection - * @return if the underlying action should be enabled for the given selection + * @return if the underlying action should be enabled for the given + * selection */ public abstract boolean isEnabledFor(IStructuredSelection selection); @@ -130,9 +136,9 @@ public abstract class BreakpointToggleAction implements IObjectActionDelegate, I * Get the breakpoint manager for the debug plugin */ protected IBreakpointManager getBreakpointManager() { - return DebugPlugin.getDefault().getBreakpointManager(); + return DebugPlugin.getDefault().getBreakpointManager(); } - + /** * Get the breakpoint associated with the given marker */ @@ -142,6 +148,7 @@ public abstract class BreakpointToggleAction implements IObjectActionDelegate, I /** * Returns the underlying <code>IAction</code> for this delegate + * * @return the underlying <code>IAction</code> for this delegate */ protected IAction getAction() { @@ -150,26 +157,26 @@ public abstract class BreakpointToggleAction implements IObjectActionDelegate, I /** * Allows the underlying <code>IAction</code> for this delegate to be set - * @param action the new action to set for this delegate + * + * @param action + * the new action to set for this delegate */ protected void setAction(IAction action) { fAction = action; } - - /** - * @see IBreakpointsListener#breakpointsAdded(IBreakpoint[]) - */ + + @Override public void breakpointsAdded(IBreakpoint[] breakpoints) { } - /** - * @see IBreakpointsListener#breakpointsChanged(IBreakpoint[], IMarkerDelta[]) - */ - public void breakpointsChanged(IBreakpoint[] breakpoints, IMarkerDelta[] deltas) { + @Override + public void breakpointsChanged(IBreakpoint[] breakpoints, + IMarkerDelta[] deltas) { if (getAction() != null) { - IStructuredSelection selection= getStructuredSelection(); + IStructuredSelection selection = getStructuredSelection(); if (selection != null) { - IBreakpoint selectedBreakpoint= (IBreakpoint)selection.getFirstElement(); + IBreakpoint selectedBreakpoint = (IBreakpoint) selection + .getFirstElement(); for (int i = 0; i < breakpoints.length; i++) { IBreakpoint breakpoint = breakpoints[i]; if (selectedBreakpoint.equals(breakpoint)) { @@ -177,18 +184,18 @@ public abstract class BreakpointToggleAction implements IObjectActionDelegate, I return; } } - } + } } } - /** - * @see IBreakpointsListener#breakpointsRemoved(IBreakpoint[], IMarkerDelta[]) - */ - public void breakpointsRemoved(IBreakpoint[] breakpoints, IMarkerDelta[] deltas) { + @Override + public void breakpointsRemoved(IBreakpoint[] breakpoints, + IMarkerDelta[] deltas) { } - + /** * Returns the <code>IWorkbenchPart</code> this delegate is associated with + * * @return the <code>IWorkbenchPart</code> this delegate is associated with */ protected IWorkbenchPart getPart() { @@ -197,27 +204,23 @@ public abstract class BreakpointToggleAction implements IObjectActionDelegate, I /** * Allows the <code>IWorkbenchPart</code> to be set for this delegate - * @param part the new part to set + * + * @param part + * the new part to set */ protected void setPart(IWorkbenchPart part) { fPart = part; } - - /** - * @see IPartListener#partActivated(IWorkbenchPart) - */ + + @Override public void partActivated(IWorkbenchPart part) { } - /** - * @see IPartListener#partBroughtToTop(IWorkbenchPart) - */ + @Override public void partBroughtToTop(IWorkbenchPart part) { } - /** - * @see IPartListener#partClosed(IWorkbenchPart) - */ + @Override public void partClosed(IWorkbenchPart part) { if (part == getPart()) { getBreakpointManager().removeBreakpointListener(this); @@ -225,30 +228,23 @@ public abstract class BreakpointToggleAction implements IObjectActionDelegate, I } } - /** - * @see IPartListener#partDeactivated(IWorkbenchPart) - */ + @Override public void partDeactivated(IWorkbenchPart part) { } - /** - * @see IPartListener#partOpened(IWorkbenchPart) - */ + @Override public void partOpened(IWorkbenchPart part) { } - - /** - * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) - */ + + @Override public void setActivePart(IAction action, IWorkbenchPart targetPart) { - IWorkbenchPart oldPart= getPart(); + IWorkbenchPart oldPart = getPart(); if (oldPart != null) { - getPart().getSite().getPage().removePartListener(this); - } - + getPart().getSite().getPage().removePartListener(this); + } + getBreakpointManager().addBreakpointListener(this); setPart(targetPart); - targetPart.getSite().getPage().addPartListener(this); + targetPart.getSite().getPage().addPartListener(this); } } - diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ControlAccessibleListener.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ControlAccessibleListener.java index 946475f28..67c6cedfb 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ControlAccessibleListener.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ControlAccessibleListener.java @@ -1,11 +1,10 @@ /******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. + * Copyright (c) 2003, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.debug.ui.actions; @@ -15,22 +14,24 @@ import org.eclipse.swt.widgets.Control; public class ControlAccessibleListener extends AccessibleAdapter { private String controlName; - + public ControlAccessibleListener(String name) { controlName = name; } + @Override public void getName(AccessibleEvent e) { e.result = controlName; } public static void addListener(Control comp, String name) { - //strip mnemonic + // strip mnemonic String[] strs = name.split("&"); //$NON-NLS-1$ StringBuffer stripped = new StringBuffer(); for (int i = 0; i < strs.length; i++) { stripped.append(strs[i]); } - comp.getAccessible().addAccessibleListener(new ControlAccessibleListener(stripped.toString())); + comp.getAccessible().addAccessibleListener( + new ControlAccessibleListener(stripped.toString())); } } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/EntryToggleAction.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/EntryToggleAction.java index 0cf005e2d..71f5de629 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/EntryToggleAction.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/EntryToggleAction.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -19,17 +19,19 @@ import org.eclipse.jface.viewers.IStructuredSelection; public class EntryToggleAction extends BreakpointToggleAction { + @Override protected boolean getToggleState(IScriptBreakpoint breakpoint) throws CoreException { return ((IScriptMethodEntryBreakpoint) breakpoint).breakOnEntry(); } + @Override public void doAction(IScriptBreakpoint breakpoint) throws CoreException { - ((IScriptMethodEntryBreakpoint) breakpoint) - .setBreakOnEntry(!((IScriptMethodEntryBreakpoint) breakpoint) - .breakOnEntry()); + ((IScriptMethodEntryBreakpoint) breakpoint).setBreakOnEntry( + !((IScriptMethodEntryBreakpoint) breakpoint).breakOnEntry()); } + @Override public boolean isEnabledFor(IStructuredSelection selection) { Iterator iter = selection.iterator(); while (iter.hasNext()) { diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ExitToggleAction.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ExitToggleAction.java index b32524f7a..e111d0c7a 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ExitToggleAction.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ExitToggleAction.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -19,17 +19,19 @@ import org.eclipse.jface.viewers.IStructuredSelection; public class ExitToggleAction extends BreakpointToggleAction { + @Override protected boolean getToggleState(IScriptBreakpoint breakpoint) throws CoreException { return ((IScriptMethodEntryBreakpoint) breakpoint).breakOnExit(); } + @Override public void doAction(IScriptBreakpoint breakpoint) throws CoreException { - ((IScriptMethodEntryBreakpoint) breakpoint) - .setBreakOnExit(!((IScriptMethodEntryBreakpoint) breakpoint) - .breakOnExit()); + ((IScriptMethodEntryBreakpoint) breakpoint).setBreakOnExit( + !((IScriptMethodEntryBreakpoint) breakpoint).breakOnExit()); } + @Override public boolean isEnabledFor(IStructuredSelection selection) { Iterator iter = selection.iterator(); while (iter.hasNext()) { diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/RulerToggleWatchPointActionDelegate.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/RulerToggleWatchPointActionDelegate.java index 2c396e8dd..d0767a0bb 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/RulerToggleWatchPointActionDelegate.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/RulerToggleWatchPointActionDelegate.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials + * Copyright (c) 2005, 2017 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -29,7 +29,7 @@ import org.eclipse.ui.texteditor.ITextEditor; * Following is example plug-in XML used to contribute this action to an editor. * Note that the label attribute of this action is not displayed in the editor. * Instead, the label of the created action is displayed. - * + * * <pre> * <extension point="org.eclipse.ui.editorActions"> * <editorContribution @@ -44,13 +44,13 @@ import org.eclipse.ui.texteditor.ITextEditor; * </editorContribution> * </extension> * </pre> - * + * * </p> * <p> * This action can also be contributed to a vertical ruler context menu via the * <code>popupMenus</code> extension point, by referencing the ruler's context * menu identifier in the <code>targetID</code> attribute. - * + * * <pre> * <extension point="org.eclipse.ui.popupMenus"> * <viewerContribution @@ -64,18 +64,19 @@ import org.eclipse.ui.texteditor.ITextEditor; * </action> * </viewerContribution> * </pre> - * + * * </p> * <p> * Clients may refer to this class as an action delegate in plug-in XML. This * class is not intended to be subclassed. * </p> - * + * * @since 3.1 */ -public class RulerToggleWatchPointActionDelegate extends - AbstractRulerActionDelegate implements IActionDelegate2 { +public class RulerToggleWatchPointActionDelegate + extends AbstractRulerActionDelegate implements IActionDelegate2 { + @Override public void menuAboutToShow(IMenuManager manager) { super.menuAboutToShow(manager); @@ -84,13 +85,16 @@ public class RulerToggleWatchPointActionDelegate extends private IEditorPart fEditor = null; private ToggleWatchPointAction fDelegate = null; + @Override protected IAction createAction(ITextEditor editor, IVerticalRulerInfo rulerInfo) { fDelegate = new ToggleWatchPointAction(editor, null, rulerInfo); return fDelegate; } - public void setActiveEditor(IAction callerAction, IEditorPart targetEditor) { + @Override + public void setActiveEditor(IAction callerAction, + IEditorPart targetEditor) { if (fEditor != null) { if (fDelegate != null) { fDelegate.dispose(); @@ -101,9 +105,11 @@ public class RulerToggleWatchPointActionDelegate extends super.setActiveEditor(callerAction, targetEditor); } + @Override public void init(IAction action) { } + @Override public void dispose() { if (fDelegate != null) { fDelegate.dispose(); @@ -112,6 +118,7 @@ public class RulerToggleWatchPointActionDelegate extends fEditor = null; } + @Override public void runWithEvent(IAction action, Event event) { run(action); } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ScriptBreakpointPropertiesAction.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ScriptBreakpointPropertiesAction.java index 128bbe539..21ca2b5cb 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ScriptBreakpointPropertiesAction.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ScriptBreakpointPropertiesAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -19,7 +19,6 @@ import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.window.IShellProvider; -import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IObjectActionDelegate; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.dialogs.PropertyDialogAction; @@ -33,38 +32,40 @@ public class ScriptBreakpointPropertiesAction implements IObjectActionDelegate { private IWorkbenchPart part; private IScriptBreakpoint breakpoint; + @Override public void run(IAction action) { IShellProvider provider; if (part != null) { provider = part.getSite(); } else { - provider = new IShellProvider() { - public Shell getShell() { - return DLTKDebugUIPlugin.getActiveWorkbenchShell(); - } - }; + provider = () -> DLTKDebugUIPlugin.getActiveWorkbenchShell(); } - - PropertyDialogAction propertyAction = new PropertyDialogAction( - provider, new ISelectionProvider() { + + PropertyDialogAction propertyAction = new PropertyDialogAction(provider, + new ISelectionProvider() { + @Override public void addSelectionChangedListener( ISelectionChangedListener listener) { } + @Override public ISelection getSelection() { return new StructuredSelection(breakpoint); } + @Override public void removeSelectionChangedListener( ISelectionChangedListener listener) { } + @Override public void setSelection(ISelection selection) { } }); propertyAction.run(); } + @Override public void selectionChanged(IAction action, ISelection selection) { if (selection instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection) selection; @@ -82,6 +83,7 @@ public class ScriptBreakpointPropertiesAction implements IObjectActionDelegate { this.breakpoint = breakpoint; } + @Override public void setActivePart(IAction action, IWorkbenchPart targetPart) { part = targetPart; } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ScriptBreakpointPropertiesRulerAction.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ScriptBreakpointPropertiesRulerAction.java index 600345be1..6599528cb 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ScriptBreakpointPropertiesRulerAction.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ScriptBreakpointPropertiesRulerAction.java @@ -1,11 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * Copyright (c) 2005, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.debug.ui.actions; @@ -21,8 +20,8 @@ import org.eclipse.ui.dialogs.PropertyDialogAction; import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.ui.texteditor.IUpdate; -public class ScriptBreakpointPropertiesRulerAction extends - RulerBreakpointAction implements IUpdate { +public class ScriptBreakpointPropertiesRulerAction extends RulerBreakpointAction + implements IUpdate { private IBreakpoint fBreakpoint; @@ -32,29 +31,35 @@ public class ScriptBreakpointPropertiesRulerAction extends setText(ActionMessages.ScriptBreakpointPropertiesRulerAction_BreakpointProperties); } + @Override public void run() { if (getBreakpoint() != null) { - PropertyDialogAction action = new PropertyDialogAction(getEditor() - .getEditorSite(), new ISelectionProvider() { - public void addSelectionChangedListener( - ISelectionChangedListener listener) { - } + PropertyDialogAction action = new PropertyDialogAction( + getEditor().getEditorSite(), new ISelectionProvider() { + @Override + public void addSelectionChangedListener( + ISelectionChangedListener listener) { + } - public ISelection getSelection() { - return new StructuredSelection(getBreakpoint()); - } + @Override + public ISelection getSelection() { + return new StructuredSelection(getBreakpoint()); + } - public void removeSelectionChangedListener( - ISelectionChangedListener listener) { - } + @Override + public void removeSelectionChangedListener( + ISelectionChangedListener listener) { + } - public void setSelection(ISelection selection) { - } - }); + @Override + public void setSelection(ISelection selection) { + } + }); action.run(); } } + @Override public void update() { fBreakpoint = null; IBreakpoint breakpoint = getBreakpoint(); diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ScriptBreakpointPropertiesRulerActionDelegate.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ScriptBreakpointPropertiesRulerActionDelegate.java index 9255e6ee0..395cc590b 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ScriptBreakpointPropertiesRulerActionDelegate.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ScriptBreakpointPropertiesRulerActionDelegate.java @@ -1,11 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * Copyright (c) 2005, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.debug.ui.actions; @@ -14,9 +13,11 @@ import org.eclipse.jface.text.source.IVerticalRulerInfo; import org.eclipse.ui.texteditor.AbstractRulerActionDelegate; import org.eclipse.ui.texteditor.ITextEditor; -public class ScriptBreakpointPropertiesRulerActionDelegate extends AbstractRulerActionDelegate { +public class ScriptBreakpointPropertiesRulerActionDelegate + extends AbstractRulerActionDelegate { + @Override protected IAction createAction(ITextEditor editor, IVerticalRulerInfo rulerInfo) { - return new ScriptBreakpointPropertiesRulerAction(editor, rulerInfo); + return new ScriptBreakpointPropertiesRulerAction(editor, rulerInfo); } } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ToggleGlobalVariablesHandler.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ToggleGlobalVariablesHandler.java index aec5e9cb3..090cc0c2e 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ToggleGlobalVariablesHandler.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ToggleGlobalVariablesHandler.java @@ -1,4 +1,5 @@ package org.eclipse.dltk.debug.ui.actions; + import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; @@ -10,23 +11,20 @@ import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.ISources; - public class ToggleGlobalVariablesHandler extends AbstractHandler { + @Override public Object execute(ExecutionEvent arg0) throws ExecutionException { - IEvaluationContext context = (IEvaluationContext) arg0.getApplicationContext(); + IEvaluationContext context = (IEvaluationContext) arg0 + .getApplicationContext(); - Object editor = context.getVariable(ISources.ACTIVE_EDITOR_NAME); - if (editor instanceof ScriptEditor) - { - IEditorInput input = ((IEditorPart) editor).getEditorInput(); + if (editor instanceof ScriptEditor) { + IEditorInput input = ((IEditorPart) editor).getEditorInput(); IScriptProject project = EditorUtility.getScriptProject(input); - - - + } - + // TODO Auto-generated method stub return null; } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ToggleShowClassVariablesActionDelegate.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ToggleShowClassVariablesActionDelegate.java index ac6f6d1af..bd0e65035 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ToggleShowClassVariablesActionDelegate.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ToggleShowClassVariablesActionDelegate.java @@ -8,24 +8,28 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.IViewActionDelegate; import org.eclipse.ui.IViewPart; -public class ToggleShowClassVariablesActionDelegate implements - IViewActionDelegate { +public class ToggleShowClassVariablesActionDelegate + implements IViewActionDelegate { protected Preferences getPrefs() { return DLTKDebugPlugin.getDefault().getPluginPreferences(); } + @Override public void init(IViewPart view) { } + @Override public void run(IAction action) { boolean value = getPrefs().getBoolean( DLTKDebugPreferenceConstants.PREF_DBGP_SHOW_SCOPE_CLASS); getPrefs().setValue( - DLTKDebugPreferenceConstants.PREF_DBGP_SHOW_SCOPE_CLASS, !value); + DLTKDebugPreferenceConstants.PREF_DBGP_SHOW_SCOPE_CLASS, + !value); } + @Override public void selectionChanged(IAction action, ISelection selection) { } } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ToggleShowGlobalVariablesActionDelegate.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ToggleShowGlobalVariablesActionDelegate.java index 2214cfef6..7ddb4461b 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ToggleShowGlobalVariablesActionDelegate.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ToggleShowGlobalVariablesActionDelegate.java @@ -8,23 +8,27 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.IViewActionDelegate; import org.eclipse.ui.IViewPart; -public class ToggleShowGlobalVariablesActionDelegate implements - IViewActionDelegate { +public class ToggleShowGlobalVariablesActionDelegate + implements IViewActionDelegate { protected Preferences getPrefs() { return DLTKDebugPlugin.getDefault().getPluginPreferences(); } + @Override public void init(IViewPart view) { } + @Override public void run(IAction action) { boolean value = getPrefs().getBoolean( DLTKDebugPreferenceConstants.PREF_DBGP_SHOW_SCOPE_GLOBAL); getPrefs().setValue( - DLTKDebugPreferenceConstants.PREF_DBGP_SHOW_SCOPE_GLOBAL, !value); + DLTKDebugPreferenceConstants.PREF_DBGP_SHOW_SCOPE_GLOBAL, + !value); } + @Override public void selectionChanged(IAction action, ISelection selection) { - } + } } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ToggleWatchPointAction.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ToggleWatchPointAction.java index 9981e53ce..bed1afa88 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ToggleWatchPointAction.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ToggleWatchPointAction.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2016 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials + * Copyright (c) 2005, 2017 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -36,7 +36,7 @@ import org.eclipse.ui.texteditor.IUpdate; * Clients may instantiate this class. This class is not intended to be * subclassed. * </p> - * + * * @since 3.1 * @see org.eclipse.debug.ui.actions.RulerToggleBreakpointActionDelegate */ @@ -49,7 +49,7 @@ public class ToggleWatchPointAction extends Action implements IUpdate { /** * 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 @@ -67,11 +67,7 @@ public class ToggleWatchPointAction extends Action implements IUpdate { fRulerInfo = rulerInfo; } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.action.IAction#run() - */ + @Override public void run() { IDocument document = getDocument(); if (document == null) { @@ -122,7 +118,7 @@ public class ToggleWatchPointAction extends Action implements IUpdate { /** * Report an error to the user. - * + * * @param e * underlying exception */ @@ -144,7 +140,7 @@ public class ToggleWatchPointAction extends Action implements IUpdate { /** * Returns the document on which this action operates. - * + * * @return the document or <code>null</code> if none */ private IDocument getDocument() { @@ -166,11 +162,7 @@ public class ToggleWatchPointAction extends Action implements IUpdate { return null; } - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.texteditor.IUpdate#update() - */ + @Override public void update() { IDocument document = getDocument(); if (document != null) { diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ViewFilterAction.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ViewFilterAction.java index 8f92b1a7c..ec43e7362 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ViewFilterAction.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ViewFilterAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2016 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -32,6 +32,7 @@ public abstract class ViewFilterAction extends ViewerFilter class Updater implements IPropertyChangeListener { + @Override public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(getPreferenceKey()) || event.getProperty().equals(getCompositeKey())) { @@ -44,6 +45,7 @@ public abstract class ViewFilterAction extends ViewerFilter super(); } + @Override public void init(IViewPart view) { fView = view; fAction.setChecked(getPreferenceValue()); @@ -51,18 +53,22 @@ public abstract class ViewFilterAction extends ViewerFilter getPreferenceStore().addPropertyChangeListener(fListener); } + @Override public void init(IAction action) { fAction = action; } + @Override public void dispose() { getPreferenceStore().removePropertyChangeListener(fListener); } + @Override public void runWithEvent(IAction action, Event event) { run(action); } + @Override public void run(IAction action) { StructuredViewer viewer = getStructuredViewer(); ViewerFilter[] filters = viewer.getFilters(); @@ -91,6 +97,7 @@ public abstract class ViewFilterAction extends ViewerFilter store.setValue(key, checked); } + @Override public void selectionChanged(IAction action, ISelection selection) { } @@ -100,7 +107,7 @@ public abstract class ViewFilterAction extends ViewerFilter /** * Returns the value of this filters preference (on/off) for the given view. - * + * * @param part * @return boolean */ @@ -118,7 +125,7 @@ public abstract class ViewFilterAction extends ViewerFilter /** * Returns the key for this action's preference - * + * * @return String */ protected abstract String getPreferenceKey(); @@ -126,7 +133,7 @@ public abstract class ViewFilterAction extends ViewerFilter /** * Returns the key used by this action to store its preference * value/setting. Based on a base key (suffix) and part id (prefix). - * + * * @return preference store key */ protected String getCompositeKey() { @@ -152,7 +159,7 @@ public abstract class ViewFilterAction extends ViewerFilter /** * Returns whether this action is selected/checked. - * + * * @return whether this action is selected/checked */ protected boolean getValue() { diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/BreakpointUtils.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/BreakpointUtils.java index 37f78d193..bebe9496c 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/BreakpointUtils.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/BreakpointUtils.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2016 IBM Corporation and others. + * Copyright (c) 2005, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -154,6 +154,7 @@ public class BreakpointUtils { this.resource = resource; } + @Override public boolean evaluate(IBreakpoint breakpoint) { return resource.equals(breakpoint.getMarker().getResource()); } @@ -171,6 +172,7 @@ public class BreakpointUtils { this.path = path.toPortableString(); } + @Override public boolean evaluate(IBreakpoint breakpoint) throws CoreException { final IResource bpResource = breakpoint.getMarker().getResource(); if (bpResource.equals(getWorkspaceRoot())) { @@ -248,9 +250,9 @@ public class BreakpointUtils { } /** - * + * * ...assume we already know debugModelId - * + * * @since 2.0 * @param editor * @param lineNumber diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptBreakpointLineValidatorFactory.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptBreakpointLineValidatorFactory.java index a1ef7d12f..56be637f4 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptBreakpointLineValidatorFactory.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptBreakpointLineValidatorFactory.java @@ -1,21 +1,15 @@ package org.eclipse.dltk.debug.ui.breakpoints; - public class ScriptBreakpointLineValidatorFactory { - public static final IScriptBreakpointLineValidator NON_EMPTY_VALIDATOR = new IScriptBreakpointLineValidator() { - public boolean isValid(String line, int number) { - return line.trim().length() > 0; - } - }; + public static final IScriptBreakpointLineValidator NON_EMPTY_VALIDATOR = ( + line, number) -> line.trim().length() > 0; public static IScriptBreakpointLineValidator createNonEmptyNoCommentValidator( final String commentPrefix) { - return new IScriptBreakpointLineValidator() { - public boolean isValid(String line, int number) { - final String trimmedLine = line.trim(); - return trimmedLine.length() > 0 - && trimmedLine.indexOf(commentPrefix) != 0; - } + return (line, number) -> { + final String trimmedLine = line.trim(); + return trimmedLine.length() > 0 + && trimmedLine.indexOf(commentPrefix) != 0; }; } } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptBreakpointPropertyPage.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptBreakpointPropertyPage.java index 764d85975..ac1e47922 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptBreakpointPropertyPage.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptBreakpointPropertyPage.java @@ -1,20 +1,17 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * Copyright (c) 2005, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.debug.ui.breakpoints; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.dltk.core.DLTKCore; import org.eclipse.dltk.core.IDLTKLanguageToolkit; @@ -90,8 +87,9 @@ public class ScriptBreakpointPropertyPage extends PropertyPage { protected int getHitCondition() { if (!hasOnlyGreaterOrEqualsHitCount()) { - return getEnabledHitChecking() ? hitConditionCombo - .getSelectionIndex() : -1; + return getEnabledHitChecking() + ? hitConditionCombo.getSelectionIndex() + : -1; } return IScriptBreakpoint.HIT_CONDITION_GREATER_OR_EQUAL; } @@ -101,8 +99,9 @@ public class ScriptBreakpointPropertyPage extends PropertyPage { } protected int getHitValue() { - return getEnabledHitChecking() ? Integer.parseInt(hitValueText - .getText()) : -1; + return getEnabledHitChecking() + ? Integer.parseInt(hitValueText.getText()) + : -1; } // Expression @@ -130,8 +129,8 @@ public class ScriptBreakpointPropertyPage extends PropertyPage { parent.getFont(), 2, 1, GridData.FILL_HORIZONTAL); // Script language - SWTFactory.createLabel(labelComposite, - BreakpointMessages.LanguageLabel, 1); + SWTFactory.createLabel(labelComposite, BreakpointMessages.LanguageLabel, + 1); SWTFactory.createLabel(labelComposite, BreakpointUtils .getLanguageToolkit(breakpoint).getLanguageName(), 1); @@ -175,7 +174,7 @@ public class ScriptBreakpointPropertyPage extends PropertyPage { /** * Returns the label text for the location field - * + * * @return */ protected String getBreakpointLocationLabel() { @@ -184,7 +183,7 @@ public class ScriptBreakpointPropertyPage extends PropertyPage { /** * Returns the value for the location field - * + * * @return * @throws CoreException */ @@ -202,9 +201,8 @@ public class ScriptBreakpointPropertyPage extends PropertyPage { Composite buttonsComposite = SWTFactory.createComposite(parent, parent.getFont(), 1, 1, GridData.FILL_HORIZONTAL); - enabledBreakpointButton = SWTFactory.createCheckButton( - buttonsComposite, BreakpointMessages.EnabledLabel, null, false, - 1); + enabledBreakpointButton = SWTFactory.createCheckButton(buttonsComposite, + BreakpointMessages.EnabledLabel, null, false, 1); createTypeSpecificButtons(buttonsComposite); } @@ -218,11 +216,11 @@ public class ScriptBreakpointPropertyPage extends PropertyPage { parent.getFont(), 4, 1, GridData.FILL_HORIZONTAL); // Hit count checking - hitCountCheckingButton = SWTFactory.createCheckButton( - hitCountComposite, BreakpointMessages.BreakWhenHitCountLabel, - null, false, 1); + hitCountCheckingButton = SWTFactory.createCheckButton(hitCountComposite, + BreakpointMessages.BreakWhenHitCountLabel, null, false, 1); hitCountCheckingButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { updateControlsState(UPDATE_OTHER); } @@ -232,8 +230,7 @@ public class ScriptBreakpointPropertyPage extends PropertyPage { hitConditionCombo = new Combo(hitCountComposite, SWT.READ_ONLY); // Hit condition - hitConditionCombo.add( - BreakpointMessages.HitConditionGreaterOrEqual, + hitConditionCombo.add(BreakpointMessages.HitConditionGreaterOrEqual, IScriptBreakpoint.HIT_CONDITION_GREATER_OR_EQUAL); hitConditionCombo.add(BreakpointMessages.HitConditionEqual, @@ -246,6 +243,7 @@ public class ScriptBreakpointPropertyPage extends PropertyPage { .select(IScriptBreakpoint.HIT_CONDITION_GREATER_OR_EQUAL); hitConditionCombo.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { updateControlsState(UPDATE_OTHER); } @@ -256,10 +254,11 @@ public class ScriptBreakpointPropertyPage extends PropertyPage { // Hit value hitValueText = new Text(hitCountComposite, SWT.BORDER); - hitValueText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, - false)); + hitValueText + .setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); hitValueText.addKeyListener(new KeyAdapter() { + @Override public void keyReleased(KeyEvent e) { updateControlsState(UPDATE_OTHER); } @@ -277,6 +276,7 @@ public class ScriptBreakpointPropertyPage extends PropertyPage { enableExpressionButton = new Button(group, SWT.CHECK); enableExpressionButton.setText(BreakpointMessages.UseConditionLabel); enableExpressionButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { updateControlsState(UPDATE_EXPRESSION_ENABLE); } @@ -300,8 +300,8 @@ public class ScriptBreakpointPropertyPage extends PropertyPage { expressionViewer.configure(config); expressionViewer.setDocument(document); - expressionViewer.getControl().setLayoutData( - new GridData(SWT.FILL, SWT.FILL, true, true)); + expressionViewer.getControl() + .setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); } @@ -309,6 +309,7 @@ public class ScriptBreakpointPropertyPage extends PropertyPage { return (IScriptBreakpoint) getElement(); } + @Override protected Control createContents(Composite parent) { noDefaultAndApplyButton(); Composite composite = SWTFactory.createComposite(parent, @@ -488,14 +489,13 @@ public class ScriptBreakpointPropertyPage extends PropertyPage { setErrorMessage(errorMessage); } + @Override public boolean performOk() { try { - ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) throws CoreException { - saveValues(); - DebugPlugin.getDefault().getBreakpointManager() - .fireBreakpointChanged(getBreakpoint()); - } + ResourcesPlugin.getWorkspace().run(monitor -> { + saveValues(); + DebugPlugin.getDefault().getBreakpointManager() + .fireBreakpointChanged(getBreakpoint()); }, null, 0, null); } catch (CoreException e) { DebugPlugin.log(e); diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptExceptionBreakpointPropertyPage.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptExceptionBreakpointPropertyPage.java index bb27f1560..478d0d545 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptExceptionBreakpointPropertyPage.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptExceptionBreakpointPropertyPage.java @@ -5,9 +5,10 @@ import org.eclipse.dltk.debug.core.model.IScriptExceptionBreakpoint; import org.eclipse.dltk.ui.util.SWTFactory; import org.eclipse.swt.widgets.Composite; -public class ScriptExceptionBreakpointPropertyPage extends - ScriptBreakpointPropertyPage { +public class ScriptExceptionBreakpointPropertyPage + extends ScriptBreakpointPropertyPage { + @Override protected void createLocationLabels(Composite parent) throws CoreException { super.createLocationLabels(parent); final IScriptExceptionBreakpoint breakpoint = (IScriptExceptionBreakpoint) getBreakpoint(); @@ -21,6 +22,7 @@ public class ScriptExceptionBreakpointPropertyPage extends // private Button fSuspendOnUncaught; // private Button fSuspendOnSubclasses; + @Override protected void createTypeSpecificButtons(Composite parent) { // fSuspendOnCaught = SWTFactory.createCheckButton(parent, // "Caught Exception", null, false, 1); @@ -32,6 +34,7 @@ public class ScriptExceptionBreakpointPropertyPage extends // "Suspend on Subclasses of this Exception", null, false, 1); } + @Override protected void loadValues() throws CoreException { super.loadValues(); // @@ -40,9 +43,10 @@ public class ScriptExceptionBreakpointPropertyPage extends // // fSuspendOnCaught.setSelection(breakpoint.isCaught()); // fSuspendOnUncaught.setSelection(breakpoint.isUncaught()); - //fSuspendOnSubclasses.setSelection(breakpoint.isSuspendOnSubclasses()); + // fSuspendOnSubclasses.setSelection(breakpoint.isSuspendOnSubclasses()); } + @Override protected void saveValues() throws CoreException { super.saveValues(); // diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptLineBreakpointPropertyPage.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptLineBreakpointPropertyPage.java index e205bdb7a..17548ed6a 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptLineBreakpointPropertyPage.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptLineBreakpointPropertyPage.java @@ -11,9 +11,10 @@ import org.eclipse.dltk.debug.core.model.IScriptLineBreakpoint; import org.eclipse.dltk.ui.util.SWTFactory; import org.eclipse.swt.widgets.Composite; -public class ScriptLineBreakpointPropertyPage extends - ScriptBreakpointPropertyPage { +public class ScriptLineBreakpointPropertyPage + extends ScriptBreakpointPropertyPage { + @Override protected void createLocationLabels(Composite parent) throws CoreException { super.createLocationLabels(parent); IScriptLineBreakpoint breakpoint = (IScriptLineBreakpoint) getBreakpoint(); @@ -25,6 +26,7 @@ public class ScriptLineBreakpointPropertyPage extends SWTFactory.createLabel(parent, Integer.toString(lineNumber), 1); } + @Override protected String getBreakpointLocationLabel() { final IScriptBreakpoint breakpoint = getBreakpoint(); if (breakpoint instanceof IScriptLineBreakpoint) { @@ -37,6 +39,7 @@ public class ScriptLineBreakpointPropertyPage extends return super.getBreakpointLocationLabel(); } + @Override protected String getBreakpointResourceName() throws CoreException { final IScriptBreakpoint breakpoint = getBreakpoint(); if (breakpoint instanceof IScriptLineBreakpoint) { diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptMethodBreakpointPropertyPage.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptMethodBreakpointPropertyPage.java index b007ed73b..de69f5ad6 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptMethodBreakpointPropertyPage.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptMethodBreakpointPropertyPage.java @@ -6,8 +6,8 @@ import org.eclipse.dltk.ui.util.SWTFactory; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; -public class ScriptMethodBreakpointPropertyPage extends - ScriptBreakpointPropertyPage { +public class ScriptMethodBreakpointPropertyPage + extends ScriptBreakpointPropertyPage { private Button breakOnEntryButton; private Button breakOnExitButton; @@ -16,6 +16,7 @@ public class ScriptMethodBreakpointPropertyPage extends } + @Override protected void createTypeSpecificButtons(Composite parent) { setTitle(BreakpointMessages.MethodBreakpointTitle); @@ -26,6 +27,7 @@ public class ScriptMethodBreakpointPropertyPage extends BreakpointMessages.SuspendOnMethodExitLabel, null, false, 1); } + @Override protected void loadValues() throws CoreException { super.loadValues(); @@ -35,6 +37,7 @@ public class ScriptMethodBreakpointPropertyPage extends breakOnExitButton.setSelection(breakpoint.breakOnExit()); } + @Override protected void saveValues() throws CoreException { super.saveValues(); diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptSpawnpointPropertyPage.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptSpawnpointPropertyPage.java index b2fe16ff7..d4fc49b22 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptSpawnpointPropertyPage.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptSpawnpointPropertyPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 xored software, Inc. + * Copyright (c) 2008, 2017 xored software, Inc. and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -13,14 +13,17 @@ package org.eclipse.dltk.debug.ui.breakpoints; public class ScriptSpawnpointPropertyPage extends ScriptBreakpointPropertyPage { + @Override protected boolean hasHitCountAttribute() { return false; } + @Override protected boolean hasHitCountEditor() { return false; } + @Override protected boolean hasExpressionEditor() { return false; } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptToggleBreakpointAdapter.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptToggleBreakpointAdapter.java index 25856731d..b46223dff 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptToggleBreakpointAdapter.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptToggleBreakpointAdapter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2016 IBM Corporation and others. + * Copyright (c) 2005, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -94,23 +94,20 @@ public abstract class ScriptToggleBreakpointAdapter } protected void report(final String message, final IWorkbenchPart part) { - DLTKDebugUIPlugin.getStandardDisplay().asyncExec(new Runnable() { - public void run() { - 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 && DLTKDebugUIPlugin - .getActiveWorkbenchShell() != null) { - DLTKDebugUIPlugin.getActiveWorkbenchShell().getDisplay() - .beep(); + DLTKDebugUIPlugin.getStandardDisplay().asyncExec(() -> { + 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 + && DLTKDebugUIPlugin.getActiveWorkbenchShell() != null) { + DLTKDebugUIPlugin.getActiveWorkbenchShell().getDisplay().beep(); + } }); } @@ -155,6 +152,7 @@ public abstract class ScriptToggleBreakpointAdapter } + @Override public boolean canToggleLineBreakpoints(IWorkbenchPart part, ISelection selection) { if (isRemote(part, selection)) { @@ -167,7 +165,7 @@ public abstract class ScriptToggleBreakpointAdapter /** * Returns a selection of the member in the given text selection, or the * original selection if none. - * + * * @param part * @param selection * @return a structured selection of the member in the given text selection, @@ -223,10 +221,12 @@ public abstract class ScriptToggleBreakpointAdapter return selection; } + @Override public void toggleLineBreakpoints(final IWorkbenchPart part, final ISelection selection) throws CoreException { Job job = new Job("Script Toggle Line Breakpoint") { //$NON-NLS-1$ + @Override protected IStatus run(IProgressMonitor monitor) { final ITextEditor editor = getTextEditor(part); if (editor != null && selection instanceof ITextSelection) { @@ -293,7 +293,7 @@ public abstract class ScriptToggleBreakpointAdapter /** * gets the <code>IJavaElement</code> from the editor input - * + * * @param input * the current editor input * @return the corresponding <code>IJavaElement</code> @@ -310,7 +310,7 @@ public abstract class ScriptToggleBreakpointAdapter /** * Returns if the text selection is a field selection or not - * + * * @param selection * the text selection * @param part @@ -341,7 +341,7 @@ public abstract class ScriptToggleBreakpointAdapter /** * Determines if the selection is a field or not - * + * * @param selection * the current selection * @return true if the selection is a field false otherwise @@ -365,7 +365,7 @@ public abstract class ScriptToggleBreakpointAdapter * in the given selection. When an <code>IField</code> can be resolved for * an <code>IJavaFieldVariable</code>, it is returned in favour of the * variable. - * + * * @param selection * @return list of <code>IField</code> and <code>IJavaFieldVariable</code>, * possibly empty @@ -376,7 +376,7 @@ public abstract class ScriptToggleBreakpointAdapter if (selection.isEmpty()) { return Collections.EMPTY_LIST; } - List<Object> fields = new ArrayList<Object>(selection.size()); + List<Object> fields = new ArrayList<>(selection.size()); Iterator<?> iterator = selection.iterator(); while (iterator.hasNext()) { Object thing = iterator.next(); diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptWatchpointPropertyPage.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptWatchpointPropertyPage.java index 324b95142..f04fbe755 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptWatchpointPropertyPage.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/breakpoints/ScriptWatchpointPropertyPage.java @@ -17,6 +17,7 @@ public class ScriptWatchpointPropertyPage extends ScriptBreakpointPropertyPage { } + @Override protected void createTypeSpecificLabels(Composite parent) throws CoreException { setTitle(BreakpointMessages.WatchpointTitle); @@ -28,6 +29,7 @@ public class ScriptWatchpointPropertyPage extends ScriptBreakpointPropertyPage { SWTFactory.createLabel(parent, watchPoint.getFieldName(), 1); } + @Override protected boolean hasExpressionEditor() { IScriptBreakpointPropertyPageExtension extension = getBreakpointPropertyPageExtension(); if (extension != null) { @@ -36,6 +38,7 @@ public class ScriptWatchpointPropertyPage extends ScriptBreakpointPropertyPage { return false; } + @Override protected void createTypeSpecificButtons(Composite parent) { suspendOnAccessButton = SWTFactory.createCheckButton(parent, BreakpointMessages.SuspendOnAccessLabel, null, false, 1); @@ -43,6 +46,7 @@ public class ScriptWatchpointPropertyPage extends ScriptBreakpointPropertyPage { BreakpointMessages.SuspendOnModificationLabel, null, false, 1); } + @Override protected void loadValues() throws CoreException { super.loadValues(); @@ -51,8 +55,8 @@ public class ScriptWatchpointPropertyPage extends ScriptBreakpointPropertyPage { .getDebugToolkitByDebugModel(watchpoint.getModelIdentifier()); if (debugToolkit.isAccessWatchpointSupported()) { suspendOnAccessButton.setSelection(watchpoint.isAccess()); - suspendOnModificationButton.setSelection(watchpoint - .isModification()); + suspendOnModificationButton + .setSelection(watchpoint.isModification()); } else { suspendOnAccessButton.setEnabled(false); suspendOnModificationButton.setEnabled(false); @@ -60,6 +64,7 @@ public class ScriptWatchpointPropertyPage extends ScriptBreakpointPropertyPage { } } + @Override protected void saveValues() throws CoreException { super.saveValues(); @@ -68,8 +73,8 @@ public class ScriptWatchpointPropertyPage extends ScriptBreakpointPropertyPage { .getDebugToolkitByDebugModel(watchpoint.getModelIdentifier()); if (debugToolkit.isAccessWatchpointSupported()) { watchpoint.setAccess(suspendOnAccessButton.getSelection()); - watchpoint.setModification(suspendOnModificationButton - .getSelection()); + watchpoint.setModification( + suspendOnModificationButton.getSelection()); } } } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/DebugConsole.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/DebugConsole.java index a9281da72..33440f15f 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/DebugConsole.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/DebugConsole.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 xored software, Inc. + * Copyright (c) 2008, 2017 xored software, Inc. and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -30,6 +30,7 @@ public class DebugConsole extends ScriptConsole implements IEvaluateConsole { setContentAssistProcessor(new DebugConsoleContentAssistProcessor()); } + @Override protected ScriptConsolePage createPage(IConsoleView view, SourceViewerConfiguration cfg) { return new DebugConsolePage(this, view, cfg); diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/DebugConsoleContentAssistProcessor.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/DebugConsoleContentAssistProcessor.java index c88fa7473..aa0856ad5 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/DebugConsoleContentAssistProcessor.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/DebugConsoleContentAssistProcessor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 + * Copyright (c) 2008, 2017 Johan Compagner and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -13,9 +13,9 @@ package org.eclipse.dltk.debug.ui.display; import java.util.Iterator; import java.util.Map; +import java.util.Map.Entry; import java.util.SortedMap; import java.util.TreeMap; -import java.util.Map.Entry; import org.eclipse.dltk.console.ui.IScriptConsoleViewer; import org.eclipse.dltk.dbgp.IDbgpProperty; @@ -36,27 +36,33 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; class DebugConsoleContentAssistProcessor implements IContentAssistProcessor { + @Override public String getErrorMessage() { return null; } + @Override public IContextInformationValidator getContextInformationValidator() { return null; } + @Override public char[] getContextInformationAutoActivationCharacters() { return null; } + @Override public char[] getCompletionProposalAutoActivationCharacters() { return null; } + @Override public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) { return null; } + @Override public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) { if (!(viewer instanceof IScriptConsoleViewer)) { @@ -108,8 +114,8 @@ class DebugConsoleContentAssistProcessor implements IContentAssistProcessor { if (index != -1) { name = name.substring(index + 1); } - map.put(name, getTree(property - .getAvailableChildren())); + map.put(name, + getTree(property.getAvailableChildren())); SortedMap segmentMap = (SortedMap) map .get(segments[lastSegment]); if (segmentMap == null) { @@ -139,7 +145,8 @@ class DebugConsoleContentAssistProcessor implements IContentAssistProcessor { Iterator iterator = map.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Entry) iterator.next(); - if (((String) entry.getKey()).startsWith(lastSegmentString)) { + if (((String) entry.getKey()) + .startsWith(lastSegmentString)) { hit.put(entry.getKey(), entry.getKey()); } } @@ -150,9 +157,9 @@ class DebugConsoleContentAssistProcessor implements IContentAssistProcessor { int i = 0; while (iterator.hasNext()) { String proposal = (String) iterator.next(); - proposals[i++] = new CompletionProposal(proposal - .substring(beginOffset), offset, 0, proposal.length(), - null, proposal, null, null); + proposals[i++] = new CompletionProposal( + proposal.substring(beginOffset), offset, 0, + proposal.length(), null, proposal, null, null); } return proposals; } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/DebugConsolePage.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/DebugConsolePage.java index 468dd970f..283254f48 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/DebugConsolePage.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/DebugConsolePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2016 xored software, Inc. + * Copyright (c) 2008, 2017 xored software, Inc. and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -46,8 +46,6 @@ import org.eclipse.swt.dnd.TextTransfer; import org.eclipse.swt.dnd.Transfer; import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.FocusListener; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; @@ -76,6 +74,7 @@ public class DebugConsolePage extends ScriptConsolePage { super(console, view, cfg); } + @Override protected IAction createTerminateConsoleAction() { return null; } @@ -89,6 +88,7 @@ public class DebugConsolePage extends ScriptConsolePage { private IHandlerActivation cutHandler; private IHandlerActivation selectAllHandler; + @Override protected void createActions() { super.createActions(); final IActionBars actionBars = getSite().getActionBars(); @@ -131,11 +131,13 @@ public class DebugConsolePage extends ScriptConsolePage { /* * @see TextConsolePage#createControl(Composite) */ + @Override public void createControl(Composite parent) { sash = new SashForm(parent, SWT.VERTICAL | SWT.SMOOTH); inputField = new StyledText(sash, SWT.V_SCROLL | SWT.H_SCROLL); inputField.addFocusListener(new FocusListener() { + @Override public void focusLost(FocusEvent e) { if (pasteHandler != null) { IHandlerService service = getSite() @@ -151,15 +153,18 @@ public class DebugConsolePage extends ScriptConsolePage { } } + @Override public void focusGained(FocusEvent e) { IHandlerService service = getSite() .getService(IHandlerService.class); Expression expression = new Expression() { + @Override public final EvaluationResult evaluate( final IEvaluationContext context) { return EvaluationResult.TRUE; } + @Override public final void collectExpressionInfo( final ExpressionInfo info) { info.addVariableNameAccess(ISources.ACTIVE_EDITOR_NAME); @@ -190,18 +195,21 @@ public class DebugConsolePage extends ScriptConsolePage { | DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK); target.setTransfer(new Transfer[] { TextTransfer.getInstance() }); target.addDropListener(new StyledTextDropTargetEffect(inputField) { + @Override public void dragEnter(DropTargetEvent e) { super.dragEnter(e); if (e.detail == DND.DROP_DEFAULT) e.detail = DND.DROP_COPY; } + @Override public void dragOperationChanged(DropTargetEvent e) { super.dragOperationChanged(e); if (e.detail == DND.DROP_DEFAULT) e.detail = DND.DROP_COPY; } + @Override public void drop(DropTargetEvent e) { super.drop(e); Point selection = inputField.getSelectionRange(); @@ -212,13 +220,7 @@ public class DebugConsolePage extends ScriptConsolePage { inputField.setEditable(true); super.createControl(sash); inputField.setFont(getViewer().getControl().getFont()); - inputField.addModifyListener(new ModifyListener() { - - public void modifyText(ModifyEvent e) { - updateActions(); - } - - }); + inputField.addModifyListener(e -> updateActions()); sash.setMaximizedControl(getViewer().getControl()); setEnabled(isDebuggerAvailable()); if (debugEventListener == null) { @@ -252,9 +254,7 @@ public class DebugConsolePage extends ScriptConsolePage { return false; } - /** - * @see org.eclipse.dltk.console.ui.internal.ScriptConsolePage#dispose() - */ + @Override public void dispose() { if (debugEventListener != null) { DebugPlugin.getDefault() @@ -310,27 +310,22 @@ public class DebugConsolePage extends ScriptConsolePage { private final Job enableUpdateJob = new Job("Enable update") { //$NON-NLS-1$ + @Override protected IStatus run(IProgressMonitor monitor) { - DLTKDebugUIPlugin.getStandardDisplay().asyncExec(new Runnable() { - public void run() { - setEnabled(isDebuggerAvailable()); - } - }); + DLTKDebugUIPlugin.getStandardDisplay() + .asyncExec(() -> setEnabled(isDebuggerAvailable())); return Status.OK_STATUS; } }; private final class DebugEventListener implements IDebugEventSetListener { + @Override public void handleDebugEvents(DebugEvent[] events) { enableUpdateJob.schedule(500); if (resetOnLaunch && isTargetCreate(events)) { - DLTKDebugUIPlugin.getStandardDisplay() - .asyncExec(new Runnable() { - public void run() { - ((DebugConsole) getConsole()).clearConsole(); - } - }); + DLTKDebugUIPlugin.getStandardDisplay().asyncExec( + () -> ((DebugConsole) getConsole()).clearConsole()); } } } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/DebugScriptInterpreter.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/DebugScriptInterpreter.java index 4894ee3df..78924db51 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/DebugScriptInterpreter.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/DebugScriptInterpreter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 xored software, Inc. + * Copyright (c) 2008, 2017 xored software, Inc. and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -40,14 +40,17 @@ public class DebugScriptInterpreter implements IScriptInterpreter { this.part = part; } + @Override public void addInitialListenerOperation(Runnable runnable) { // NOP } + @Override public InputStream getInitialOutputStream() { return new ByteArrayInputStream(new byte[0]); } + @Override public boolean isValid() { return true; } @@ -55,24 +58,29 @@ public class DebugScriptInterpreter implements IScriptInterpreter { /* * @see org.eclipse.dltk.console.IScriptConsoleShell#close() */ + @Override public void close() throws IOException { // NOP } + @Override public List getCompletions(String commandLine, int position) throws IOException { return null; } + @Override public String getDescription(String commandLine, int position) throws IOException { return null; } + @Override public String[] getNames(String type) throws IOException { return null; } + @Override public IScriptExecResult exec(String command) throws IOException { if (command == null || command.length() == 0) { return null; @@ -103,10 +111,8 @@ public class DebugScriptInterpreter implements IScriptInterpreter { boolean datatypes = thread.getDbgpSession() .getDebugOptions() .get(DebugOption.ENGINE_SUPPORT_DATATYPES); - if (!datatypes - && output.length() > 2 - && output.charAt(0) == '"' - && output.charAt( + if (!datatypes && output.length() > 2 + && output.charAt(0) == '"' && output.charAt( output.length() - 1) == '"') { output = output.substring(1, output.length() - 1); @@ -124,8 +130,8 @@ public class DebugScriptInterpreter implements IScriptInterpreter { buffer.append(Util.LINE_SEPARATOR); } if (errors.length == 0) { - buffer - .append(Messages.DebugScriptInterpreter_unknownEvaluationError); + buffer.append( + Messages.DebugScriptInterpreter_unknownEvaluationError); buffer.append(Util.LINE_SEPARATOR); } return new ScriptExecResult(buffer.toString(), true); @@ -136,10 +142,12 @@ public class DebugScriptInterpreter implements IScriptInterpreter { + Util.LINE_SEPARATOR, true); } + @Override public int getState() { return WAIT_NEW_COMMAND; } + @Override public void consoleConnected(IScriptConsoleIO protocol) { // NOP } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/OpenInputFieldAction.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/OpenInputFieldAction.java index ce89ff97a..b26a88a73 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/OpenInputFieldAction.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/OpenInputFieldAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 xored software, Inc. + * Copyright (c) 2008, 2017 xored software, Inc. and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -20,11 +20,12 @@ public class OpenInputFieldAction extends Action { public OpenInputFieldAction(DebugConsolePage page) { super(Messages.OpenInputFieldAction_openCodeField, AS_CHECK_BOX); - setImageDescriptor(ScriptDebugImages - .getImageDescriptor(ScriptDebugImages.IMG_OBJS_SHOW_SNIPPET_FIELD)); + setImageDescriptor(ScriptDebugImages.getImageDescriptor( + ScriptDebugImages.IMG_OBJS_SHOW_SNIPPET_FIELD)); this.page = page; } + @Override public void run() { if (isChecked()) { page.openInputField(); diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/ResetOnLaunchAction.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/ResetOnLaunchAction.java index 62560a1f0..3a6481526 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/ResetOnLaunchAction.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/ResetOnLaunchAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 xored software, Inc. + * Copyright (c) 2009, 2017 xored software, Inc. and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -22,6 +22,7 @@ public class ResetOnLaunchAction extends Action { this.page = page; } + @Override public void run() { page.setResetOnLaunch(isChecked()); } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/RunInputFieldAction.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/RunInputFieldAction.java index 3e8585136..2f425c008 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/RunInputFieldAction.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/RunInputFieldAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 xored software, Inc. + * Copyright (c) 2008, 2017 xored software, Inc. and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -22,14 +22,16 @@ public class RunInputFieldAction extends Action implements IUpdate { public RunInputFieldAction(DebugConsolePage page) { super(Messages.RunInputFieldAction_runCode); this.page = page; - setImageDescriptor(ScriptDebugImages - .getImageDescriptor(ScriptDebugImages.IMG_OBJS_SNIPPET_EVALUATING)); + setImageDescriptor(ScriptDebugImages.getImageDescriptor( + ScriptDebugImages.IMG_OBJS_SNIPPET_EVALUATING)); } + @Override public void update() { setEnabled(page.canExecuteInputField()); } + @Override public void run() { page.executeInputField(); } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/internal/ConsoleDropDownAction.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/internal/ConsoleDropDownAction.java index 108aef40f..ea9c39b4c 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/internal/ConsoleDropDownAction.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/internal/ConsoleDropDownAction.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -34,17 +34,13 @@ import org.eclipse.ui.texteditor.IUpdate; /** * Drop down action in the console to select the console to display. */ -public class ConsoleDropDownAction extends Action implements IMenuCreator, - IEvaluateConsoleListener, IUpdate { +public class ConsoleDropDownAction extends Action + implements IMenuCreator, IEvaluateConsoleListener, IUpdate { private ScriptDisplayView fView; private Menu fMenu; - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.texteditor.IUpdate#update() - */ + @Override public void update() { setEnabled(fView.getConsoles().length > 1); } @@ -62,11 +58,7 @@ public class ConsoleDropDownAction extends Action implements IMenuCreator, update(); } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.action.IMenuCreator#dispose() - */ + @Override public void dispose() { if (fMenu != null) { fMenu.dispose(); @@ -77,24 +69,12 @@ public class ConsoleDropDownAction extends Action implements IMenuCreator, // .removeConsoleListener(this); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets - * .Menu) - */ + @Override public Menu getMenu(Menu parent) { return null; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets - * .Control) - */ + @Override public Menu getMenu(Control parent) { if (fMenu != null) { fMenu.dispose(); @@ -126,11 +106,7 @@ public class ConsoleDropDownAction extends Action implements IMenuCreator, item.fill(parent, -1); } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.action.IAction#run() - */ + @Override public void run() { boolean pinned = fView.isPinned(); if (pinned) { @@ -146,15 +122,10 @@ public class ConsoleDropDownAction extends Action implements IMenuCreator, } } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ui.console.IConsoleListener#consolesAdded(org.eclipse.ui. - * console.IConsole[]) - */ + @Override public void consoleAdded(IEvaluateConsole console) { UIJob job = new UIJob("") { //$NON-NLS-1$ + @Override public IStatus runInUIThread(IProgressMonitor monitor) { update(); return Status.OK_STATUS; @@ -167,16 +138,17 @@ public class ConsoleDropDownAction extends Action implements IMenuCreator, /* * (non-Javadoc) - * + * * Dispose the menu when a launch is removed, such that the actions in this * menu do not hang on to associated resources. - * + * * @see * org.eclipse.ui.console.IConsoleListener#consolesRemoved(org.eclipse.ui * .console.IConsole[]) */ public void consolesRemoved(IConsole[] consoles) { UIJob job = new UIJob("") { //$NON-NLS-1$ + @Override public IStatus runInUIThread(IProgressMonitor monitor) { if (fMenu != null) { fMenu.dispose(); diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/internal/OpenConsoleAction.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/internal/OpenConsoleAction.java index 25af9cc0a..7d951f158 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/internal/OpenConsoleAction.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/internal/OpenConsoleAction.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -42,8 +42,8 @@ public class OpenConsoleAction extends Action implements IMenuCreator { fFactoryExtensions = factories; setText(ConsoleMessages.OpenConsoleAction_0); setToolTipText(ConsoleMessages.OpenConsoleAction_1); - setImageDescriptor(ConsolePluginImages - .getImageDescriptor(IInternalConsoleConstants.IMG_ELCL_NEW_CON)); + setImageDescriptor(ConsolePluginImages.getImageDescriptor( + IInternalConsoleConstants.IMG_ELCL_NEW_CON)); setMenuCreator(this); // PlatformUI // .getWorkbench() @@ -52,11 +52,7 @@ public class OpenConsoleAction extends Action implements IMenuCreator { // IConsoleHelpContextIds.CONSOLE_OPEN_CONSOLE_ACTION); } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.action.IMenuCreator#dispose() - */ + @Override public void dispose() { fFactoryExtensions = null; } @@ -65,9 +61,10 @@ public class OpenConsoleAction extends Action implements IMenuCreator { * @see * org.eclipse.jface.action.Action#runWithEvent(org.eclipse.swt.widgets. * Event) - * + * * @since 3.5 */ + @Override public void runWithEvent(Event event) { if (event.widget instanceof ToolItem) { ToolItem toolItem = (ToolItem) event.widget; @@ -81,13 +78,7 @@ public class OpenConsoleAction extends Action implements IMenuCreator { } } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets - * .Control) - */ + @Override public Menu getMenu(Control parent) { if (fMenu != null) { fMenu.dispose(); @@ -101,8 +92,9 @@ public class OpenConsoleAction extends Action implements IMenuCreator { && extension.isEnabled()) { String label = extension.getLabel(); ImageDescriptor image = extension.getImageDescriptor(); - addActionToMenu(fMenu, new ConsoleFactoryAction(label, image, - extension), accel); + addActionToMenu(fMenu, + new ConsoleFactoryAction(label, image, extension), + accel); accel++; } } @@ -124,13 +116,7 @@ public class OpenConsoleAction extends Action implements IMenuCreator { item.fill(parent, -1); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets - * .Menu) - */ + @Override public Menu getMenu(Menu parent) { return null; } @@ -148,11 +134,7 @@ public class OpenConsoleAction extends Action implements IMenuCreator { fConfig = extension; } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.action.IAction#run() - */ + @Override public void run() { final IEvaluateConsole console = fConfig.create(); if (console != null) { @@ -160,13 +142,7 @@ public class OpenConsoleAction extends Action implements IMenuCreator { } } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jface.action.IAction#runWithEvent(org.eclipse.swt.widgets - * .Event) - */ + @Override public void runWithEvent(Event event) { run(); } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/handlers/AbstractScriptDebugHandler.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/handlers/AbstractScriptDebugHandler.java index 15d0b0f74..cbccec4b5 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/handlers/AbstractScriptDebugHandler.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/handlers/AbstractScriptDebugHandler.java @@ -21,6 +21,7 @@ public abstract class AbstractScriptDebugHandler extends AbstractHandler private String natureId; + @Override public final Object execute(ExecutionEvent event) throws ExecutionException { Object result = handleEvent(event); @@ -32,12 +33,14 @@ public abstract class AbstractScriptDebugHandler extends AbstractHandler return result; } + @Override public final void setInitializationData(IConfigurationElement config, String propertyName, Object data) { natureId = DLTKExecuteExtensionHelper.getNatureId(config, propertyName, data); } + @Override public void updateElement(UIElement element, Map parameters) { // default does nothing } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/handlers/AbstractToggleClassVariableHandler.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/handlers/AbstractToggleClassVariableHandler.java index d9245aede..372ee8405 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/handlers/AbstractToggleClassVariableHandler.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/handlers/AbstractToggleClassVariableHandler.java @@ -7,19 +7,15 @@ import org.eclipse.dltk.debug.core.model.IScriptDebugTarget; * Abstract handler implementation that can be used to toggle the display of * 'class' debugging variables. */ -public abstract class AbstractToggleClassVariableHandler extends - AbstractToggleVariableHandler { +public abstract class AbstractToggleClassVariableHandler + extends AbstractToggleVariableHandler { - /* - * @see org.eclipse.dltk.debug.ui.handlers.AbstractToggleVariableHandler#getVariableDisplayPreferenceKey() - */ + @Override protected String getVariableDisplayPreferenceKey() { return DLTKDebugPreferenceConstants.PREF_DBGP_SHOW_SCOPE_CLASS; } - /* - * @see org.eclipse.dltk.debug.ui.handlers.AbstractToggleVariableHandler#toggleVariableDisplay(org.eclipse.dltk.debug.core.model.IScriptDebugTarget) - */ + @Override protected final void toggleVariableDisplay(IScriptDebugTarget target, boolean enabled) { target.toggleClassVariables(enabled); diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/handlers/AbstractToggleGlobalVariableHandler.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/handlers/AbstractToggleGlobalVariableHandler.java index a5db46e6e..f27be2e94 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/handlers/AbstractToggleGlobalVariableHandler.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/handlers/AbstractToggleGlobalVariableHandler.java @@ -7,21 +7,18 @@ import org.eclipse.dltk.debug.core.model.IScriptDebugTarget; * Abstract handler implementation that can be used to toggle the display of * 'global' debugging variables. */ -public abstract class AbstractToggleGlobalVariableHandler extends - AbstractToggleVariableHandler { +public abstract class AbstractToggleGlobalVariableHandler + extends AbstractToggleVariableHandler { - /* - * @see org.eclipse.dltk.debug.ui.handlers.AbstractToggleVariableHandler#getVariableDisplayPreferenceKey() - */ + @Override protected String getVariableDisplayPreferenceKey() { - return DLTKDebugPreferenceConstants.PREF_DBGP_SHOW_SCOPE_GLOBAL; + return DLTKDebugPreferenceConstants.PREF_DBGP_SHOW_SCOPE_GLOBAL; } - /* - * @see org.eclipse.dltk.debug.ui.handlers.AbstractToggleVariableHandler#toggleVariableDisplay(org.eclipse.dltk.debug.core.model.IScriptDebugTarget, boolean) - */ - protected final void toggleVariableDisplay(IScriptDebugTarget target, boolean enabled) { - target.toggleGlobalVariables(enabled); + @Override + protected final void toggleVariableDisplay(IScriptDebugTarget target, + boolean enabled) { + target.toggleGlobalVariables(enabled); } } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/handlers/AbstractToggleLocalVariableHandler.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/handlers/AbstractToggleLocalVariableHandler.java index a6d1fc4eb..552587ab1 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/handlers/AbstractToggleLocalVariableHandler.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/handlers/AbstractToggleLocalVariableHandler.java @@ -7,20 +7,15 @@ import org.eclipse.dltk.debug.core.model.IScriptDebugTarget; * Abstract handler implementation that can be used to toggle the display of * 'local' debugging variables. */ -public abstract class AbstractToggleLocalVariableHandler extends - AbstractToggleVariableHandler { +public abstract class AbstractToggleLocalVariableHandler + extends AbstractToggleVariableHandler { - /* - * @see org.eclipse.dltk.debug.ui.handlers.AbstractToggleVariableHandler#getVariableDisplayPreferenceKey() - */ + @Override protected String getVariableDisplayPreferenceKey() { return DLTKDebugPreferenceConstants.PREF_DBGP_SHOW_SCOPE_LOCAL; } - /* - * @see org.eclipse.dltk.debug.ui.handlers.AbstractToggleVariableHandler#toggleVariableDisplay(org.eclipse.dltk.debug.core.model.IScriptDebugTarget, - * boolean) - */ + @Override protected final void toggleVariableDisplay(IScriptDebugTarget target, boolean enabled) { target.toggleLocalVariables(enabled); diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/handlers/AbstractToggleVariableHandler.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/handlers/AbstractToggleVariableHandler.java index 4e312074e..3b5c70398 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/handlers/AbstractToggleVariableHandler.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/handlers/AbstractToggleVariableHandler.java @@ -22,10 +22,7 @@ import org.eclipse.ui.menus.UIElement; abstract class AbstractToggleVariableHandler extends AbstractHandler implements IElementUpdater { - /* - * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core. - * commands.ExecutionEvent) - */ + @Override public final Object execute(ExecutionEvent event) throws ExecutionException { toggleVariableDisplay(); @@ -40,11 +37,7 @@ abstract class AbstractToggleVariableHandler extends AbstractHandler return null; } - /* - * @see - * org.eclipse.ui.commands.IElementUpdater#updateElement(org.eclipse.ui. - * menus.UIElement, java.util.Map) - */ + @Override public void updateElement(UIElement element, Map parameters) { element.setChecked(isVariableDisplayEnabled()); } @@ -68,7 +61,7 @@ abstract class AbstractToggleVariableHandler extends AbstractHandler /** * Toggle the variable display value the subclass is responsible for * handling. - * + * * @param target * script debug target * @param enabled diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/handlers/LaunchStatusHandler.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/handlers/LaunchStatusHandler.java index c3c9c3f6c..a32a2eff5 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/handlers/LaunchStatusHandler.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/handlers/LaunchStatusHandler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 xored software, Inc. + * Copyright (c) 2009, 2017 xored software, Inc. and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -23,14 +23,15 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; -public class LaunchStatusHandler implements ILaunchStatusHandler, - ILaunchStatusHandlerExtension { +public class LaunchStatusHandler + implements ILaunchStatusHandler, ILaunchStatusHandlerExtension { private IDebugTarget debugTarget; private final Object lock = new Object(); private boolean disposed = false; private LaunchStatusDialog dialog = null; + @Override public void initialize(IDebugTarget target, IProgressMonitor monitor) { if (Display.getCurrent() != null) { throw new IllegalStateException(getClass().getSimpleName() @@ -51,19 +52,18 @@ public class LaunchStatusHandler implements ILaunchStatusHandler, } } + @Override public void updateElapsedTime(final long elapsedTime) { if (isDisposed()) { return; } - asyncExec(new Runnable() { - public void run() { - if (!isDialogCreated()) { - createDialog(); - } - final LaunchStatusDialog d = dialog; - if (d != null) - d.updateElapsedTime(elapsedTime); + asyncExec(() -> { + if (!isDialogCreated()) { + createDialog(); } + final LaunchStatusDialog d = dialog; + if (d != null) + d.updateElapsedTime(elapsedTime); }); } @@ -84,8 +84,8 @@ public class LaunchStatusHandler implements ILaunchStatusHandler, && PlatformUI.getWorkbench().getWorkbenchWindowCount() > 0) { window = PlatformUI.getWorkbench().getWorkbenchWindows()[0]; } - dialog = new LaunchStatusDialog(window != null ? window.getShell() - : null, this); + dialog = new LaunchStatusDialog( + window != null ? window.getShell() : null, this); final ILaunch launch = debugTarget.getLaunch(); if (launch != null) { final ILaunchConfiguration configuration = launch @@ -95,8 +95,9 @@ public class LaunchStatusHandler implements ILaunchStatusHandler, } } final IProcess process = debugTarget.getProcess(); - String cmdLine = process != null ? process - .getAttribute(IProcess.ATTR_CMDLINE) : null; + String cmdLine = process != null + ? process.getAttribute(IProcess.ATTR_CMDLINE) + : null; dialog.setCommandLine(cmdLine); dialog.open(); } @@ -108,6 +109,7 @@ public class LaunchStatusHandler implements ILaunchStatusHandler, } } + @Override public void dispose() { if (isDisposed()) { return; @@ -116,11 +118,7 @@ public class LaunchStatusHandler implements ILaunchStatusHandler, disposed = true; } if (isDialogCreated()) { - asyncExec(new Runnable() { - public void run() { - disposeDialog(); - } - }); + asyncExec(() -> disposeDialog()); } } @@ -129,6 +127,7 @@ public class LaunchStatusHandler implements ILaunchStatusHandler, /** * @since 2.0 */ + @Override public boolean isCanceled() { synchronized (lock) { return canceled; diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/handlers/VariablesViewOptionsHandler.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/handlers/VariablesViewOptionsHandler.java index f5d4a72d0..544420b3b 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/handlers/VariablesViewOptionsHandler.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/handlers/VariablesViewOptionsHandler.java @@ -6,19 +6,19 @@ import org.eclipse.dltk.ui.util.SWTFactory; /** * Handler for the 'preferences' menu option in the 'Variables' view. - * + * * <p> * Use the following from with your <code>plugin.xml</code> to add: * </p> - * + * * <pre> * <extension point="org.eclipse.ui.commands"> * <command * id="command_id" * description="..." - * name="..." /> + * name="..." /> * </extension> - * + * * <extension point="org.eclipse.ui.menus"> * <menuContribution locationURI="menu:org.eclipse.debug.ui.VariableView"> * <menu @@ -27,21 +27,22 @@ import org.eclipse.dltk.ui.util.SWTFactory; * </menuContribution> * <menuContribution locationURI="menu:menu_id"> * <command - * commandId="command_id" /> - * </menuContribution> + * commandId="command_id" /> + * </menuContribution> * </extension> - * + * * <extension point="org.eclipse.ui.handlers"> * <handler * commandId="command_id" * class="org.eclipse.dltk.debug.ui.handlers.VariablesViewOptionsHandler:nature_id" /> * </extension> * </pre> - * + * * @see IDLTKDebugUILanguageToolkit#getVariablesViewPreferencePages() */ public class VariablesViewOptionsHandler extends AbstractScriptDebugHandler { + @Override protected Object handleEvent(ExecutionEvent event) { String[] prefPages = getToolkit().getVariablesViewPreferencePages(); @@ -50,6 +51,7 @@ public class VariablesViewOptionsHandler extends AbstractScriptDebugHandler { return null; } + @Override protected boolean requiresRefresh() { return false; } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/interpreters/InterpretersUpdater.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/interpreters/InterpretersUpdater.java index 27af9fbc5..f2fb27c79 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/interpreters/InterpretersUpdater.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/interpreters/InterpretersUpdater.java @@ -1,11 +1,10 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.debug.ui.interpreters; @@ -17,7 +16,6 @@ import java.util.Set; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.TransformerException; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.dltk.core.environment.EnvironmentManager; import org.eclipse.dltk.core.environment.IEnvironment; import org.eclipse.dltk.debug.ui.DLTKDebugUIPlugin; @@ -57,10 +55,9 @@ public class InterpretersUpdater { .getDefaultInterpreterInstall(entry); if (def != null) { - fOriginalInterpreters - .setDefaultInterpreterInstallCompositeID(entry, - ScriptRuntime - .getCompositeIdFromInterpreter(def)); + fOriginalInterpreters.setDefaultInterpreterInstallCompositeID( + entry, + ScriptRuntime.getCompositeIdFromInterpreter(def)); } } @@ -79,7 +76,7 @@ public class InterpretersUpdater { /** * Updates Interpreter settings and returns whether the update was * successful. - * + * * @param interpreters * new installed InterpreterEnvironments * @param defaultInterpreters @@ -93,7 +90,7 @@ public class InterpretersUpdater { InterpreterDefinitionsContainer container = new InterpreterDefinitionsContainer(); // Default interpreter id for natureId - final Set<String> envIds = new HashSet<String>(); + final Set<String> envIds = new HashSet<>(); if (defaultInterpreters != null) { for (int i = 0; i < defaultInterpreters.length; i++) { final String defaultId = ScriptRuntime @@ -136,8 +133,8 @@ public class InterpretersUpdater { // Save interpreters from other languages to the container for (final IInterpreterInstall install : fOriginalInterpreters .getInterpreterList()) { - if (!langNatureId.equals(install.getInterpreterInstallType() - .getNatureId())) { + if (!langNatureId.equals( + install.getInterpreterInstallType().getNatureId())) { container.addInterpreter(install); } } @@ -153,30 +150,27 @@ public class InterpretersUpdater { private void saveInterpreterDefinitions( final InterpreterDefinitionsContainer container) { - IRunnableWithProgress runnable = new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) - throws InvocationTargetException, InterruptedException { - try { - monitor.beginTask( - InterpretersMessages.InterpretersUpdater_0, 100); - final String xml = container.getAsXML(); - monitor.worked(40); - ScriptRuntime.getPreferences().put( - ScriptRuntime.PREF_INTERPRETER_XML, xml); - monitor.worked(30); - ScriptRuntime.savePreferences(); - monitor.worked(30); - } catch (IOException ioe) { - DLTKDebugUIPlugin.log(ioe); - } catch (ParserConfigurationException e) { - DLTKDebugUIPlugin.log(e); - } catch (TransformerException e) { - DLTKDebugUIPlugin.log(e); - } finally { - monitor.done(); - } - + IRunnableWithProgress runnable = monitor -> { + try { + monitor.beginTask(InterpretersMessages.InterpretersUpdater_0, + 100); + final String xml = container.getAsXML(); + monitor.worked(40); + ScriptRuntime.getPreferences() + .put(ScriptRuntime.PREF_INTERPRETER_XML, xml); + monitor.worked(30); + ScriptRuntime.savePreferences(); + monitor.worked(30); + } catch (IOException ioe) { + DLTKDebugUIPlugin.log(ioe); + } catch (ParserConfigurationException e1) { + DLTKDebugUIPlugin.log(e1); + } catch (TransformerException e2) { + DLTKDebugUIPlugin.log(e2); + } finally { + monitor.done(); } + }; try { DLTKDebugUIPlugin.getDefault().getWorkbench().getProgressService() diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/CommonScriptLaunchTab.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/CommonScriptLaunchTab.java index 0e23371a8..8b6c23000 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/CommonScriptLaunchTab.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/CommonScriptLaunchTab.java @@ -1,19 +1,18 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * Copyright (c) 2005, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.debug.ui.launchConfigurations; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; -public abstract class CommonScriptLaunchTab extends - AbstractLaunchConfigurationTab { +public abstract class CommonScriptLaunchTab + extends AbstractLaunchConfigurationTab { /** * Config being modified @@ -22,7 +21,7 @@ public abstract class CommonScriptLaunchTab extends /** * Returns the launch configuration this tab was initialized from. - * + * * @return launch configuration this tab was initialized from */ protected ILaunchConfiguration getCurrentLaunchConfiguration() { @@ -31,7 +30,7 @@ public abstract class CommonScriptLaunchTab extends /** * Sets the launch configuration this tab was initialized from - * + * * @param config * launch configuration this tab was initialized from */ @@ -43,6 +42,7 @@ public abstract class CommonScriptLaunchTab extends * Subclasses may override this method and should call * super.initializeFrom(...). */ + @Override public void initializeFrom(ILaunchConfiguration config) { setCurrentLaunchConfiguration(config); } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/InterpreterTab.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/InterpreterTab.java index 0ca9ddf23..0c1767f23 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/InterpreterTab.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/InterpreterTab.java @@ -1,11 +1,10 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.debug.ui.launchConfigurations; @@ -33,7 +32,6 @@ import org.eclipse.dltk.launching.ScriptRuntime; import org.eclipse.dltk.ui.DLTKPluginImages; import org.eclipse.dltk.ui.viewsupport.ImageDescriptorRegistry; import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Font; @@ -84,11 +82,7 @@ public class InterpreterTab extends CommonScriptLaunchTab { } // Selection changed listener (checked InterpreterEnvironment) - private IPropertyChangeListener fCheckListener = new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - handleSelectedInterpreterChanged(); - } - }; + private IPropertyChangeListener fCheckListener = event -> handleSelectedInterpreterChanged(); // Constants protected static final String EMPTY_STRING = ""; //$NON-NLS-1$ @@ -102,9 +96,7 @@ public class InterpreterTab extends CommonScriptLaunchTab { } } - /** - * @see ILaunchConfigurationTab#createControl(Composite) - */ + @Override public void createControl(Composite parent) { Font font = parent.getFont(); @@ -122,15 +114,16 @@ public class InterpreterTab extends CommonScriptLaunchTab { topComp.setLayoutData(gd); topComp.setFont(font); - fInterpreterBlock = createInterpreterBlock(createInterpreterBlockHost()); + fInterpreterBlock = createInterpreterBlock( + createInterpreterBlockHost()); if (mainListener == null) { mainListener = new MainListener(); getMainTab().addListener(mainListener); } - fInterpreterBlock - .setDefaultInterpreterDescriptor(getDefaultInterpreterDescriptor()); - fInterpreterBlock - .setSpecificInterpreterDescriptor(getSpecificInterpreterDescriptor()); + fInterpreterBlock.setDefaultInterpreterDescriptor( + getDefaultInterpreterDescriptor()); + fInterpreterBlock.setSpecificInterpreterDescriptor( + getSpecificInterpreterDescriptor()); fInterpreterBlock.createControl(topComp); Control control = fInterpreterBlock.getControl(); fInterpreterBlock.addPropertyChangeListener(fCheckListener); @@ -153,10 +146,12 @@ public class InterpreterTab extends CommonScriptLaunchTab { private IMainLaunchConfigurationTabListener mainListener = null; private class MainListener implements IMainLaunchConfigurationTabListener { + @Override public void projectChanged(IProject project) { refreshInterpreters(); } + @Override public void interactiveChanged(boolean state) { } } @@ -174,10 +169,12 @@ public class InterpreterTab extends CommonScriptLaunchTab { private IInterpreterComboBlockContext createInterpreterBlockHost() { return new IInterpreterComboBlockContext() { + @Override public int getMode() { return M_LAUNCH_CONFIGURATION; } + @Override public IEnvironment getEnvironment() { final IScriptProject project = getScriptProject(); if (project != null) { @@ -187,6 +184,7 @@ public class InterpreterTab extends CommonScriptLaunchTab { } } + @Override public String getNatureId() { return fMainTab.getNatureID(); } @@ -217,9 +215,7 @@ public class InterpreterTab extends CommonScriptLaunchTab { return fDynamicTab; } - /** - * @see ILaunchConfigurationTab#setDefaults(ILaunchConfigurationWorkingCopy) - */ + @Override public void setDefaults(ILaunchConfigurationWorkingCopy config) { setLaunchConfigurationWorkingCopy(config); ILaunchConfigurationTab dynamicTab = getDynamicTab(); @@ -228,17 +224,14 @@ public class InterpreterTab extends CommonScriptLaunchTab { } } - /** - * @see ILaunchConfigurationTab#initializeFrom(ILaunchConfiguration) - */ @Override public void initializeFrom(ILaunchConfiguration configuration) { fIsInitializing = true; getControl().setRedraw(false); setLaunchConfiguration(configuration); updateInterpreterFromConfig(configuration); - fInterpreterBlock - .setDefaultInterpreterDescriptor(getDefaultInterpreterDescriptor()); + fInterpreterBlock.setDefaultInterpreterDescriptor( + getDefaultInterpreterDescriptor()); fInterpreterBlock.refreshInterpreters(); ILaunchConfigurationTab dynamicTab = getDynamicTab(); if (dynamicTab != null) { @@ -252,9 +245,7 @@ public class InterpreterTab extends CommonScriptLaunchTab { return fMainTab.getNatureID(); } - /** - * @see ILaunchConfigurationTab#performApply(ILaunchConfigurationWorkingCopy) - */ + @Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { configuration.setAttribute( ScriptLaunchConfigurationConstants.ATTR_SCRIPT_NATURE, @@ -277,18 +268,14 @@ public class InterpreterTab extends CommonScriptLaunchTab { // Handle any attributes in the Interpreter-specific area ILaunchConfigurationTab dynamicTab = getDynamicTab(); if (dynamicTab == null) { - configuration - .setAttribute( - ScriptLaunchConfigurationConstants.ATTR_INTERPRETER_INSTALL_TYPE_SPECIFIC_ATTRS_MAP, - (Map<String, String>) null); + configuration.setAttribute( + ScriptLaunchConfigurationConstants.ATTR_INTERPRETER_INSTALL_TYPE_SPECIFIC_ATTRS_MAP, + (Map<String, String>) null); } else { dynamicTab.performApply(configuration); } } - /** - * @see ILaunchConfigurationTab#isValid(ILaunchConfiguration) - */ @Override public boolean isValid(ILaunchConfiguration config) { @@ -308,16 +295,11 @@ public class InterpreterTab extends CommonScriptLaunchTab { return true; } - /** - * @see ILaunchConfigurationTab#getName() - */ + @Override public String getName() { return ScriptLaunchMessages.InterpreterTab__Interp_1; } - /** - * @see ILaunchConfigurationTab#getImage() - */ @Override public Image getImage() { return registry.get(DLTKPluginImages.DESC_OBJS_NATIVE_LIB_PATH_ATTRIB); @@ -375,10 +357,9 @@ public class InterpreterTab extends CommonScriptLaunchTab { wc = getLaunchConfiguration().getWorkingCopy(); } } catch (CoreException e) { - DLTKDebugUIPlugin - .errorDialog( - ScriptLaunchMessages.InterpreterTab_Unable_to_initialize_defaults_for_selected_InterpreterEnvironment_1, - e); + DLTKDebugUIPlugin.errorDialog( + ScriptLaunchMessages.InterpreterTab_Unable_to_initialize_defaults_for_selected_InterpreterEnvironment_1, + e); return; } } @@ -413,9 +394,9 @@ public class InterpreterTab extends CommonScriptLaunchTab { if (Interpreter != null) { String InterpreterInstallTypeID = Interpreter .getInterpreterInstallType().getId(); - return DLTKDebugUIPlugin - .getDefault() - .getInterpreterInstallTypePage(InterpreterInstallTypeID); + return DLTKDebugUIPlugin.getDefault() + .getInterpreterInstallTypePage( + InterpreterInstallTypeID); } } return null; @@ -456,7 +437,7 @@ public class InterpreterTab extends CommonScriptLaunchTab { /** * Overridden here so that any error message in the dynamic UI gets * returned. - * + * * @see ILaunchConfigurationTab#getErrorMessage() */ @Override @@ -485,7 +466,7 @@ public class InterpreterTab extends CommonScriptLaunchTab { /** * Sets whether this tab will display the Interpreter specific arguments * area if a InterpreterEnvironment supports Interpreter specific arguments. - * + * * @param visible * whether this tab will display the Interpreter specific * arguments area if a InterpreterEnvironment supports @@ -507,14 +488,16 @@ public class InterpreterTab extends CommonScriptLaunchTab { final IScriptProject project = getScriptProject(); String name = ScriptLaunchMessages.InterpreterTab_7; if (!isValid(project)) { - final IInterpreterInstall interpreter = getWorkspaceInterpreter(project); + final IInterpreterInstall interpreter = getWorkspaceInterpreter( + project); if (interpreter != null) { name = interpreter.getName(); } - return NLS - .bind(ScriptLaunchMessages.InterpreterTab_8, name); + return NLS.bind(ScriptLaunchMessages.InterpreterTab_8, + name); } - IInterpreterInstall interpreter = getProjectInterpreter(project); + IInterpreterInstall interpreter = getProjectInterpreter( + project); if (interpreter != null) { name = interpreter.getName(); } @@ -561,7 +544,7 @@ public class InterpreterTab extends CommonScriptLaunchTab { /** * Returns the Script project associated with the current config being * edited, or <code>null</code> if none. - * + * * @return scriptproject or <code>null</code> */ protected IScriptProject getScriptProject() { diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/MainLaunchConfigurationTab.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/MainLaunchConfigurationTab.java index c92d8bc79..d2f918274 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/MainLaunchConfigurationTab.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/MainLaunchConfigurationTab.java @@ -1,11 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * Copyright (c) 2005, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.debug.ui.launchConfigurations; @@ -69,10 +68,12 @@ public abstract class MainLaunchConfigurationTab extends super(mode); } + @Override public void addListener(IMainLaunchConfigurationTabListener listener) { this.listeners.add(listener); } + @Override public void removeListener(IMainLaunchConfigurationTabListener listener) { this.listeners.remove(listener); } @@ -129,22 +130,19 @@ public abstract class MainLaunchConfigurationTab extends private void initializeDebugConsole(ILaunchConfiguration config) { if (debugConsole != null) { - debugConsole - .setSelection(LaunchConfigurationUtils - .getBoolean( - config, - ScriptLaunchConfigurationConstants.ATTR_DEBUG_CONSOLE, - true)); + debugConsole.setSelection(LaunchConfigurationUtils.getBoolean( + config, + ScriptLaunchConfigurationConstants.ATTR_DEBUG_CONSOLE, + true)); } } - protected void initializeInteractiveConsoleFrom(ILaunchConfiguration config) { + protected void initializeInteractiveConsoleFrom( + ILaunchConfiguration config) { if (useInteractiveConsoleGroup) { - boolean console = LaunchConfigurationUtils - .getBoolean( - config, - ScriptLaunchConfigurationConstants.ATTR_USE_INTERACTIVE_CONSOLE, - false); + boolean console = LaunchConfigurationUtils.getBoolean(config, + ScriptLaunchConfigurationConstants.ATTR_USE_INTERACTIVE_CONSOLE, + false); this.interactiveConsoleCheck.setSelection(console); } } @@ -155,7 +153,7 @@ public abstract class MainLaunchConfigurationTab extends /** * Creates the widgets for specifying a main type. - * + * * @param parent * the parent composite */ @@ -207,10 +205,10 @@ public abstract class MainLaunchConfigurationTab extends ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog( getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider()); - dialog - .setTitle(DLTKLaunchConfigurationsMessages.mainTab_searchButton_title); - dialog - .setMessage(DLTKLaunchConfigurationsMessages.mainTab_searchButton_message); + dialog.setTitle( + DLTKLaunchConfigurationsMessages.mainTab_searchButton_title); + dialog.setMessage( + DLTKLaunchConfigurationsMessages.mainTab_searchButton_message); IScriptProject proj = getProject(); if (proj == null) return; @@ -226,7 +224,7 @@ public abstract class MainLaunchConfigurationTab extends /** * Loads the main type from the launch configuration's preference store - * + * * @param config * the config to load the main type from */ @@ -244,10 +242,8 @@ public abstract class MainLaunchConfigurationTab extends protected void createDebugOptions(Composite group) { super.createDebugOptions(group); if (canSelectDebugConsoleType()) { - debugConsole = SWTFactory - .createCheckButton( - group, - DLTKLaunchConfigurationsMessages.mainTab_debugConsoleRedirect); + debugConsole = SWTFactory.createCheckButton(group, + DLTKLaunchConfigurationsMessages.mainTab_debugConsoleRedirect); debugConsole.addSelectionListener(getWidgetListener()); } } @@ -261,6 +257,7 @@ public abstract class MainLaunchConfigurationTab extends /* * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName() */ + @Override public String getName() { return DLTKLaunchConfigurationsMessages.mainTab_title; } @@ -278,7 +275,8 @@ public abstract class MainLaunchConfigurationTab extends } private void setDefaultsDebugConsole( - ILaunchConfigurationWorkingCopy configuration, IModelElement element) { + ILaunchConfigurationWorkingCopy configuration, + IModelElement element) { if (debugConsole != null) { debugConsole.setSelection(true); } @@ -309,10 +307,9 @@ public abstract class MainLaunchConfigurationTab extends protected void performApplyConnectionTimeout( ILaunchConfigurationWorkingCopy config) { - config - .setAttribute( - ScriptLaunchConfigurationConstants.ATTR_DLTK_DBGP_WAITING_TIMEOUT, - (String) null); + config.setAttribute( + ScriptLaunchConfigurationConstants.ATTR_DLTK_DBGP_WAITING_TIMEOUT, + (String) null); } @Override @@ -346,26 +343,23 @@ public abstract class MainLaunchConfigurationTab extends if (useInteractiveConsoleGroup) { final boolean useInteractiveConsole = this.interactiveConsoleCheck .getSelection(); - config - .setAttribute( - ScriptLaunchConfigurationConstants.ATTR_USE_INTERACTIVE_CONSOLE, - useInteractiveConsole); + config.setAttribute( + ScriptLaunchConfigurationConstants.ATTR_USE_INTERACTIVE_CONSOLE, + useInteractiveConsole); String old = null; try { - old = config - .getAttribute( - ScriptLaunchConfigurationConstants.ATTR_DLTK_CONSOLE_ID, - (String) null); + old = config.getAttribute( + ScriptLaunchConfigurationConstants.ATTR_DLTK_CONSOLE_ID, + (String) null); } catch (CoreException e) { if (DLTKCore.DEBUG) { e.printStackTrace(); } } if (old == null) { - config - .setAttribute( - ScriptLaunchConfigurationConstants.ATTR_DLTK_CONSOLE_ID, - "dltk_" + System.currentTimeMillis()); //$NON-NLS-1$ + config.setAttribute( + ScriptLaunchConfigurationConstants.ATTR_DLTK_CONSOLE_ID, + "dltk_" + System.currentTimeMillis()); //$NON-NLS-1$ } } } @@ -380,7 +374,7 @@ public abstract class MainLaunchConfigurationTab extends /** * Validates the selected launch script. - * + * * @return true if the selected script is valid, false otherwise */ protected boolean validateScript() { @@ -393,21 +387,24 @@ public abstract class MainLaunchConfigurationTab extends if (!result.isOK()) { IFileHandle file = PlatformFileUtils - .findAbsoluteOrEclipseRelativeFile(environment, Path - .fromPortableString(script.getPath())); + .findAbsoluteOrEclipseRelativeFile(environment, + Path.fromPortableString(script.getPath())); if (file.exists() && file.isDirectory()) { if (useInteractiveConsoleGroup) { if (!interactiveConsoleCheck.getSelection()) { - setErrorMessage(DLTKLaunchConfigurationsMessages.MainLaunchConfigurationTab_0); + setErrorMessage( + DLTKLaunchConfigurationsMessages.MainLaunchConfigurationTab_0); return false; } return true; } else { - setErrorMessage(DLTKLaunchConfigurationsMessages.error_scriptNotFound); + setErrorMessage( + DLTKLaunchConfigurationsMessages.error_scriptNotFound); return false; } } - setErrorMessage(DLTKLaunchConfigurationsMessages.error_scriptNotFound); + setErrorMessage( + DLTKLaunchConfigurationsMessages.error_scriptNotFound); return false; } } @@ -416,7 +413,7 @@ public abstract class MainLaunchConfigurationTab extends /** * typo in method name - * + * * @return */ @Deprecated @@ -426,7 +423,7 @@ public abstract class MainLaunchConfigurationTab extends /** * Gets the currently selected {@link ISourceModule}. - * + * * @return the selected source module or <code>null</code> */ protected ISourceModule getSourceModule() { @@ -452,15 +449,16 @@ public abstract class MainLaunchConfigurationTab extends } URI location = proj.getProject().getLocationURI(); if (location == null) { - setErrorMessage(DLTKLaunchConfigurationsMessages.error_notAValidProject); + setErrorMessage( + DLTKLaunchConfigurationsMessages.error_notAValidProject); return null; } URI script = null; try { - script = new URI(location.getScheme(), location.getHost(), location - .getPath() - + '/' + getScriptName(), location.getFragment()); + script = new URI(location.getScheme(), location.getHost(), + location.getPath() + '/' + getScriptName(), + location.getFragment()); } catch (URISyntaxException e) { if (DLTKCore.DEBUG) { e.printStackTrace(); @@ -500,23 +498,22 @@ public abstract class MainLaunchConfigurationTab extends protected void createCustomSections(Composite parent) { if (useInteractiveConsoleGroup) { Group group = new Group(parent, SWT.NONE); - group - .setText(DLTKLaunchConfigurationsMessages.MainLaunchConfigurationTab_1); + group.setText( + DLTKLaunchConfigurationsMessages.MainLaunchConfigurationTab_1); GridData gd = new GridData(GridData.FILL_HORIZONTAL); group.setLayoutData(gd); GridLayout layout = new GridLayout(); layout.numColumns = 2; group.setLayout(layout); - interactiveConsoleCheck = createCheckButton( - group, + interactiveConsoleCheck = createCheckButton(group, DLTKLaunchConfigurationsMessages.MainLaunchConfigurationTab_2); interactiveConsoleCheck.addSelectionListener(getWidgetListener()); interactiveConsoleCheck .addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - notifyInteractiveChangedListeners(interactiveConsoleCheck - .getSelection()); + notifyInteractiveChangedListeners( + interactiveConsoleCheck.getSelection()); } }); } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/RemoteLaunchConfigurationTab.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/RemoteLaunchConfigurationTab.java index c617ff0b9..528cd9916 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/RemoteLaunchConfigurationTab.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/RemoteLaunchConfigurationTab.java @@ -19,8 +19,8 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Text; -public abstract class RemoteLaunchConfigurationTab extends - ScriptLaunchConfigurationTab { +public abstract class RemoteLaunchConfigurationTab + extends ScriptLaunchConfigurationTab { private static int DEFAULT_PORT = 10000; private static String DEFAULT_IDEKEY = "idekey"; //$NON-NLS-1$ @@ -35,30 +35,21 @@ public abstract class RemoteLaunchConfigurationTab extends super(mode); } - /* - * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName() - */ + @Override public String getName() { return DLTKLaunchConfigurationsMessages.remoteTab_title; } - /* - * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#getImage() - */ @Override public Image getImage() { return DebugUITools.getImage(IDebugUIConstants.IMG_LCL_DISCONNECT); } - /* - * @see - * org.eclipse.dltk.debug.ui.launchConfigurations.ScriptLaunchConfigurationTab - * #doInitializeForm(org.eclipse.debug.core.ILaunchConfiguration) - */ + @Override protected void doInitializeForm(ILaunchConfiguration config) { port.setText(LaunchConfigurationUtils.getString(config, - ScriptLaunchConfigurationConstants.ATTR_DLTK_DBGP_PORT, Integer - .toString(getDefaultPort()))); + ScriptLaunchConfigurationConstants.ATTR_DLTK_DBGP_PORT, + Integer.toString(getDefaultPort()))); ideKey.setText(LaunchConfigurationUtils.getString(config, ScriptLaunchConfigurationConstants.ATTR_DLTK_DBGP_SESSION_ID, @@ -68,18 +59,13 @@ public abstract class RemoteLaunchConfigurationTab extends .toString(LaunchConfigurationUtils.getConnectionTimeout(config, getDefaultRemoteTimeout()) / 1000)); - remoteWorkingDir - .setText(LaunchConfigurationUtils - .getString( - config, - ScriptLaunchConfigurationConstants.ATTR_DLTK_DBGP_REMOTE_WORKING_DIR, - getDefaultRemoteWorkingDir())); - stripSourceFolders - .setSelection(LaunchConfigurationUtils - .getBoolean( - config, - ScriptLaunchConfigurationConstants.ATTR_DLTK_DBGP_STRIP_SOURCE_FOLDERS, - getDefaultStripSourceFolders())); + remoteWorkingDir.setText(LaunchConfigurationUtils.getString(config, + ScriptLaunchConfigurationConstants.ATTR_DLTK_DBGP_REMOTE_WORKING_DIR, + getDefaultRemoteWorkingDir())); + stripSourceFolders.setSelection(LaunchConfigurationUtils.getBoolean( + config, + ScriptLaunchConfigurationConstants.ATTR_DLTK_DBGP_STRIP_SOURCE_FOLDERS, + getDefaultStripSourceFolders())); } /** @@ -107,15 +93,11 @@ public abstract class RemoteLaunchConfigurationTab extends return false; } - /* - * @see - * org.eclipse.dltk.debug.ui.launchConfigurations.ScriptLaunchConfigurationTab - * #doPerformApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) - */ + @Override protected void doPerformApply(ILaunchConfigurationWorkingCopy config) { config.setAttribute( - ScriptLaunchConfigurationConstants.ATTR_DLTK_DBGP_PORT, port - .getText().trim()); + ScriptLaunchConfigurationConstants.ATTR_DLTK_DBGP_PORT, + port.getText().trim()); config.setAttribute( ScriptLaunchConfigurationConstants.ATTR_DLTK_DBGP_SESSION_ID, ideKey.getText().trim()); @@ -125,25 +107,23 @@ public abstract class RemoteLaunchConfigurationTab extends } catch (NumberFormatException e) { timeout = getDefaultRemoteTimeout() / 1000; } - config - .setAttribute( - ScriptLaunchConfigurationConstants.ATTR_DLTK_DBGP_WAITING_TIMEOUT, - timeout * 1000); - - config - .setAttribute( - ScriptLaunchConfigurationConstants.ATTR_DLTK_DBGP_REMOTE_WORKING_DIR, - remoteWorkingDir.getText().trim()); - config - .setAttribute( - ScriptLaunchConfigurationConstants.ATTR_DLTK_DBGP_STRIP_SOURCE_FOLDERS, - stripSourceFolders.getSelection()); + config.setAttribute( + ScriptLaunchConfigurationConstants.ATTR_DLTK_DBGP_WAITING_TIMEOUT, + timeout * 1000); + + config.setAttribute( + ScriptLaunchConfigurationConstants.ATTR_DLTK_DBGP_REMOTE_WORKING_DIR, + remoteWorkingDir.getText().trim()); + config.setAttribute( + ScriptLaunchConfigurationConstants.ATTR_DLTK_DBGP_STRIP_SOURCE_FOLDERS, + stripSourceFolders.getSelection()); } private int getDefaultRemoteTimeout() { return DLTKDebugPlugin.getConnectionTimeout() * 3; } + @Override protected boolean validate() { return super.validate() && validatePort() && validateIdeKey() && validateRemoteWorkingDir(); @@ -164,7 +144,8 @@ public abstract class RemoteLaunchConfigurationTab extends protected boolean validateIdeKey() { String key = ideKey.getText().trim(); if (key.length() == 0) { - setErrorMessage(DLTKLaunchConfigurationsMessages.remoteError_ideKeyEmpty); + setErrorMessage( + DLTKLaunchConfigurationsMessages.remoteError_ideKeyEmpty); return false; } @@ -176,17 +157,11 @@ public abstract class RemoteLaunchConfigurationTab extends return true; } - /* - * @see - * org.eclipse.dltk.debug.ui.launchConfigurations.ScriptLaunchConfigurationTab - * #doCreateControl(org.eclipse.swt.widgets.Composite) - */ + @Override protected void doCreateControl(Composite composite) { - Group group = SWTFactory - .createGroup( - composite, - DLTKLaunchConfigurationsMessages.remoteTab_connectionProperties, - 2, 1, GridData.FILL_HORIZONTAL); + Group group = SWTFactory.createGroup(composite, + DLTKLaunchConfigurationsMessages.remoteTab_connectionProperties, + 2, 1, GridData.FILL_HORIZONTAL); SWTFactory.createLabel(group, DLTKLaunchConfigurationsMessages.remoteTab_connectionPort, 1); diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/ScriptArgumentsTab.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/ScriptArgumentsTab.java index af0c2e131..d6f488c4f 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/ScriptArgumentsTab.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/ScriptArgumentsTab.java @@ -1,11 +1,10 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.debug.ui.launchConfigurations; @@ -23,8 +22,6 @@ import org.eclipse.dltk.internal.launching.DLTKLaunchingPlugin; import org.eclipse.dltk.launching.ScriptLaunchConfigurationConstants; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Font; @@ -44,7 +41,7 @@ import org.eclipse.swt.widgets.Text; * This class may be instantiated. This class may be subclassed by overloading * createInterpreterArgsBlock and createWorkingDirBlock. * </p> - * + * */ public class ScriptArgumentsTab extends CommonScriptLaunchTab { @@ -73,6 +70,7 @@ public class ScriptArgumentsTab extends CommonScriptLaunchTab { return new WorkingDirectoryBlock(); } + @Override public void createControl(Composite parent) { Font font = parent.getFont(); Composite comp = new Composite(parent, SWT.NONE); @@ -94,27 +92,25 @@ public class ScriptArgumentsTab extends CommonScriptLaunchTab { String controlName = (ScriptLaunchMessages.ArgumentsTab__Program_arguments__5); group.setText(controlName); - fPrgmArgumentsText = new Text(group, SWT.MULTI | SWT.WRAP | SWT.BORDER - | SWT.V_SCROLL); + fPrgmArgumentsText = new Text(group, + SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL); gd = new GridData(GridData.FILL_BOTH); gd.heightHint = 40; gd.widthHint = 100; fPrgmArgumentsText.setLayoutData(gd); fPrgmArgumentsText.setFont(font); - fPrgmArgumentsText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent evt) { - updateLaunchConfigurationDialog(); - } - }); - ControlAccessibleListener.addListener(fPrgmArgumentsText, group - .getText()); + fPrgmArgumentsText + .addModifyListener(evt -> updateLaunchConfigurationDialog()); + ControlAccessibleListener.addListener(fPrgmArgumentsText, + group.getText()); String buttonLabel = ScriptLaunchMessages.ArgumentsTab_5; Button pgrmArgVariableButton = createPushButton(group, buttonLabel, null); - pgrmArgVariableButton.setLayoutData(new GridData( - GridData.HORIZONTAL_ALIGN_END)); + pgrmArgVariableButton + .setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); pgrmArgVariableButton.addSelectionListener(new SelectionListener() { + @Override public void widgetSelected(SelectionEvent e) { StringVariableSelectionDialog dialog = new StringVariableSelectionDialog( getShell()); @@ -125,6 +121,7 @@ public class ScriptArgumentsTab extends CommonScriptLaunchTab { } } + @Override public void widgetDefaultSelected(SelectionEvent e) { } @@ -149,12 +146,14 @@ public class ScriptArgumentsTab extends CommonScriptLaunchTab { /** * @see org.eclipse.debug.ui.ILaunchConfigurationTab#dispose() */ + @Override public void dispose() { } /** * @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(ILaunchConfiguration) */ + @Override public boolean isValid(ILaunchConfiguration config) { return fWorkingDirectoryBlock.isValid(config); } @@ -162,6 +161,7 @@ public class ScriptArgumentsTab extends CommonScriptLaunchTab { /** * Defaults are empty. */ + @Override public void setDefaults(ILaunchConfigurationWorkingCopy config) { config.setAttribute( ScriptLaunchConfigurationConstants.ATTR_SCRIPT_ARGUMENTS, @@ -174,6 +174,7 @@ public class ScriptArgumentsTab extends CommonScriptLaunchTab { fWorkingDirectoryBlock.setDefaults(config); } + @Override public void initializeFrom(ILaunchConfiguration configuration) { try { fPrgmArgumentsText.setText(configuration.getAttribute( @@ -183,14 +184,14 @@ public class ScriptArgumentsTab extends CommonScriptLaunchTab { fInterpreterArgumentsBlock.initializeFrom(configuration); fWorkingDirectoryBlock.initializeFrom(configuration); } catch (CoreException e) { - setErrorMessage(NLS - .bind( - ScriptLaunchMessages.ArgumentsTab_Exception_occurred_reading_configuration___15, - e.getStatus().getMessage())); + setErrorMessage(NLS.bind( + ScriptLaunchMessages.ArgumentsTab_Exception_occurred_reading_configuration___15, + e.getStatus().getMessage())); DLTKLaunchingPlugin.log(e); } } + @Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { configuration.setAttribute( ScriptLaunchConfigurationConstants.ATTR_SCRIPT_ARGUMENTS, @@ -202,7 +203,7 @@ public class ScriptArgumentsTab extends CommonScriptLaunchTab { /** * Returns the string in the text widget, or <code>null</code> if empty. - * + * * @return text or <code>null</code> */ protected String getAttributeValueFrom(Text text) { @@ -213,17 +214,21 @@ public class ScriptArgumentsTab extends CommonScriptLaunchTab { return null; } + @Override public String getName() { return ScriptLaunchMessages.ArgumentsTab__Arguments_16; } - public void setLaunchConfigurationDialog(ILaunchConfigurationDialog dialog) { + @Override + public void setLaunchConfigurationDialog( + ILaunchConfigurationDialog dialog) { super.setLaunchConfigurationDialog(dialog); fWorkingDirectoryBlock.setLaunchConfigurationDialog(dialog); if (fInterpreterArgumentsBlock != null) fInterpreterArgumentsBlock.setLaunchConfigurationDialog(dialog); } + @Override public String getErrorMessage() { String m = super.getErrorMessage(); if (m == null) { @@ -232,6 +237,7 @@ public class ScriptArgumentsTab extends CommonScriptLaunchTab { return m; } + @Override public String getMessage() { String m = super.getMessage(); if (m == null) { @@ -240,14 +246,17 @@ public class ScriptArgumentsTab extends CommonScriptLaunchTab { return m; } + @Override public Image getImage() { return ScriptDebugImages.get(ScriptDebugImages.IMG_VIEW_ARGUMENTS_TAB); } + @Override public void activated(ILaunchConfigurationWorkingCopy workingCopy) { fWorkingDirectoryBlock.initializeFrom(workingCopy); } + @Override public void deactivated(ILaunchConfigurationWorkingCopy workingCopy) { // do nothing when deactivated } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/ScriptCommonTab.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/ScriptCommonTab.java index b508c0f1a..2a751ff46 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/ScriptCommonTab.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/ScriptCommonTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -52,9 +52,7 @@ import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.CheckStateChangedEvent; import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.ICheckStateListener; import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.ITableLabelProvider; @@ -65,7 +63,6 @@ import org.eclipse.swt.accessibility.AccessibleAdapter; import org.eclipse.swt.accessibility.AccessibleEvent; import org.eclipse.swt.events.KeyAdapter; import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -95,7 +92,7 @@ import org.eclipse.ui.views.navigator.ResourceComparator; * <p> * Clients may instantiate this class. * </p> - * + * * @noextend This class is not intended to be subclassed by clients. */ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { @@ -113,7 +110,7 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { * This attribute exists solely for the purpose of making sure that invalid * shared locations can be revertible. This attribute is not saveable and * will never appear in a saved launch configuration. - * + * * @since 3.3 */ private static final String BAD_CONTAINER = "bad_container_name"; //$NON-NLS-1$ @@ -137,10 +134,12 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { public ScriptCommonTab(MainLaunchConfigurationTab mainTab) { mainTab.addListener(new IMainLaunchConfigurationTabListener() { + @Override public void interactiveChanged(boolean state) { fConsoleOutput.setSelection(!state); } + @Override public void projectChanged(IProject project) { } }); @@ -158,28 +157,21 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { * Modify listener that simply updates the owning launch configuration * dialog. */ - private ModifyListener fBasicModifyListener = new ModifyListener() { - public void modifyText(ModifyEvent evt) { - scheduleUpdateJob(); - } - }; + private ModifyListener fBasicModifyListener = evt -> scheduleUpdateJob(); /* * (non-Javadoc) - * + * * @see * org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse * .swt.widgets.Composite) */ + @Override public void createControl(Composite parent) { Composite comp = new Composite(parent, SWT.NONE); setControl(comp); - PlatformUI - .getWorkbench() - .getHelpSystem() - .setHelp( - getControl(), - IDebugHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_COMMON_TAB); + PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), + IDebugHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_COMMON_TAB); comp.setLayout(new GridLayout(2, true)); comp.setFont(parent.getFont()); @@ -207,35 +199,30 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { /** * Creates the favorites control - * + * * @param parent * the parent composite to add this one to * @since 3.2 */ private void createFavoritesComponent(Composite parent) { - Group favComp = SWTFactory - .createGroup( - parent, - LaunchConfigurationsMessages.CommonTab_Display_in_favorites_menu__10, - 1, 1, GridData.FILL_BOTH); - fFavoritesTable = CheckboxTableViewer.newCheckList(favComp, SWT.CHECK - | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); + Group favComp = SWTFactory.createGroup(parent, + LaunchConfigurationsMessages.CommonTab_Display_in_favorites_menu__10, + 1, 1, GridData.FILL_BOTH); + fFavoritesTable = CheckboxTableViewer.newCheckList(favComp, + SWT.CHECK | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); Control table = fFavoritesTable.getControl(); GridData gd = new GridData(GridData.FILL_BOTH); table.setLayoutData(gd); table.setFont(parent.getFont()); fFavoritesTable.setContentProvider(new FavoritesContentProvider()); fFavoritesTable.setLabelProvider(new FavoritesLabelProvider()); - fFavoritesTable.addCheckStateListener(new ICheckStateListener() { - public void checkStateChanged(CheckStateChangedEvent event) { - updateLaunchConfigurationDialog(); - } - }); + fFavoritesTable.addCheckStateListener( + event -> updateLaunchConfigurationDialog()); } /** * Creates the shared config component - * + * * @param parent * the parent composite to add this component to * @since 3.2 @@ -254,13 +241,15 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { fSharedRadioButton = createRadioButton(comp, LaunchConfigurationsMessages.CommonTab_S_hared_4); fSharedRadioButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent evt) { handleSharedRadioButtonSelected(); } }); fSharedLocationText = SWTFactory.createSingleText(comp, 1); - fSharedLocationText.getAccessible().addAccessibleListener( - new AccessibleAdapter() { + fSharedLocationText.getAccessible() + .addAccessibleListener(new AccessibleAdapter() { + @Override public void getName(AccessibleEvent e) { e.result = LaunchConfigurationsMessages.CommonTab_S_hared_4; } @@ -269,6 +258,7 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { fSharedLocationButton = createPushButton(comp, LaunchConfigurationsMessages.CommonTab__Browse_6, null); fSharedLocationButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent evt) { handleSharedLocationButtonSelected(); } @@ -280,7 +270,7 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { /** * Creates the component set for the capture output composite - * + * * @param parent * the parent to add this component to */ @@ -299,6 +289,7 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { gd.horizontalSpan = 5; fConsoleOutput.setLayoutData(gd); fConsoleOutput.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { updateLaunchConfigurationDialog(); } @@ -306,17 +297,19 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { fFileOutput = createCheckButton(comp, LaunchConfigurationsMessages.CommonTab_6); - fFileOutput.setLayoutData(new GridData(SWT.BEGINNING, SWT.NORMAL, - false, false)); + fFileOutput.setLayoutData( + new GridData(SWT.BEGINNING, SWT.NORMAL, false, false)); fFileOutput.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { enableOuputCaptureWidgets(fFileOutput.getSelection()); updateLaunchConfigurationDialog(); } }); fFileText = SWTFactory.createSingleText(comp, 4); - fFileText.getAccessible().addAccessibleListener( - new AccessibleAdapter() { + fFileText.getAccessible() + .addAccessibleListener(new AccessibleAdapter() { + @Override public void getName(AccessibleEvent e) { e.result = LaunchConfigurationsMessages.CommonTab_6; } @@ -331,6 +324,7 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { fWorkspaceBrowse = createPushButton(bcomp, LaunchConfigurationsMessages.CommonTab_12, null); fWorkspaceBrowse.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog( getShell(), new WorkbenchLabelProvider(), @@ -338,8 +332,8 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { dialog.setTitle(LaunchConfigurationsMessages.CommonTab_13); dialog.setMessage(LaunchConfigurationsMessages.CommonTab_14); dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); - dialog.setComparator(new ResourceComparator( - ResourceComparator.NAME)); + dialog.setComparator( + new ResourceComparator(ResourceComparator.NAME)); dialog.setDialogBoundsSettings( getDialogBoundsSettings(WORKSPACE_SELECTION_DIALOG), Dialog.DIALOG_PERSISTSIZE); @@ -347,11 +341,10 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { IResource resource = (IResource) dialog.getFirstResult(); if (resource != null) { String arg = resource.getFullPath().toString(); - String fileLoc = VariablesPlugin - .getDefault() + String fileLoc = VariablesPlugin.getDefault() .getStringVariableManager() - .generateVariableExpression( - "workspace_loc", arg); //$NON-NLS-1$ + .generateVariableExpression("workspace_loc", //$NON-NLS-1$ + arg); fFileText.setText(fileLoc); } } @@ -360,6 +353,7 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { fFileBrowse = createPushButton(bcomp, LaunchConfigurationsMessages.CommonTab_7, null); fFileBrowse.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { String filePath = fFileText.getText(); FileDialog dialog = new FileDialog(getShell(), SWT.SAVE); @@ -372,6 +366,7 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { fVariables = createPushButton(bcomp, LaunchConfigurationsMessages.CommonTab_9, null); fVariables.addSelectionListener(new SelectionListener() { + @Override public void widgetSelected(SelectionEvent e) { StringVariableSelectionDialog dialog = new StringVariableSelectionDialog( getShell()); @@ -382,6 +377,7 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { } } + @Override public void widgetDefaultSelected(SelectionEvent e) { } }); @@ -391,6 +387,7 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { gd.horizontalSpan = 4; fAppend.setLayoutData(gd); fAppend.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { updateLaunchConfigurationDialog(); } @@ -400,7 +397,7 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { /** * Enables or disables the output capture widgets based on the the specified * enablement - * + * * @param enable * if the output capture widgets should be enabled or not * @since 3.2 @@ -415,10 +412,10 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { /** * Returns the default encoding for the specified config - * + * * @param config * @return the default encoding - * + * * @since 3.4 */ private String getDefaultEncoding(ILaunchConfiguration config) { @@ -440,7 +437,7 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { /** * Creates the encoding component - * + * * @param parent * the parent to add this composite to */ @@ -457,8 +454,8 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { fAltEncodingButton = createRadioButton(group, LaunchConfigurationsMessages.CommonTab_3); - fAltEncodingButton.setLayoutData(new GridData( - GridData.HORIZONTAL_ALIGN_BEGINNING)); + fAltEncodingButton.setLayoutData( + new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); fEncodingCombo = new Combo(group, SWT.NONE); fEncodingCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); @@ -469,20 +466,22 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { if (encodingArray.length > 0) { fEncodingCombo.select(0); } - fEncodingCombo.getAccessible().addAccessibleListener( - new AccessibleAdapter() { + fEncodingCombo.getAccessible() + .addAccessibleListener(new AccessibleAdapter() { + @Override public void getName(AccessibleEvent e) { e.result = LaunchConfigurationsMessages.CommonTab_3; } }); SelectionListener listener = new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { if (e.getSource() instanceof Button) { Button button = (Button) e.getSource(); if (button.getSelection()) { updateLaunchConfigurationDialog(); - fEncodingCombo.setEnabled(fAltEncodingButton - .getSelection() == true); + fEncodingCombo.setEnabled( + fAltEncodingButton.getSelection() == true); } } else { updateLaunchConfigurationDialog(); @@ -495,11 +494,12 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { fEncodingCombo.addKeyListener(new KeyAdapter() { /* * (non-Javadoc) - * + * * @see * org.eclipse.swt.events.KeyListener#keyReleased(org.eclipse.swt * .events.KeyEvent) */ + @Override public void keyReleased(KeyEvent e) { scheduleUpdateJob(); } @@ -508,7 +508,7 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { /** * Returns whether or not the given encoding is valid. - * + * * @param enc * the encoding to validate * @return <code>true</code> if the encoding is valid, <code>false</code> @@ -526,7 +526,7 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { /** * Creates the controls needed to edit the launch in background attribute of * an external tool - * + * * @param parent * the composite to create the controls in */ @@ -538,6 +538,7 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { fLaunchInBackgroundButton.setLayoutData(data); fLaunchInBackgroundButton.setFont(parent.getFont()); fLaunchInBackgroundButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { updateLaunchConfigurationDialog(); } @@ -555,7 +556,7 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { /** * Sets the widgets for specifying that a launch configuration is to be * shared to the enable value - * + * * @param enable * the enabled value for */ @@ -586,7 +587,7 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { /** * if the shared radio button is selected, indicating that the launch * configuration is to be shared - * + * * @return true if the radio button is selected, false otherwise */ private boolean isShared() { @@ -600,9 +601,7 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { String currentContainerString = fSharedLocationText.getText(); IContainer currentContainer = getContainer(currentContainerString); ContainerSelectionDialog dialog = new ContainerSelectionDialog( - getShell(), - currentContainer, - false, + getShell(), currentContainer, false, LaunchConfigurationsMessages.CommonTab_Select_a_location_for_the_launch_configuration_13); dialog.showClosedProjects(false); dialog.setDialogBoundsSettings( @@ -620,7 +619,7 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { /** * gets the container form the specified path - * + * * @param path * the path to get the container from * @return the container for the specified path or null if one cannot be @@ -633,11 +632,12 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { /* * (non-Javadoc) - * + * * @see * org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse * .debug.core.ILaunchConfiguration) */ + @Override public void initializeFrom(ILaunchConfiguration configuration) { boolean isShared = !configuration.isLocal(); fSharedRadioButton.setSelection(isShared); @@ -664,7 +664,7 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { /** * Updates the console output form the local configuration - * + * * @param configuration * the local configuration */ @@ -678,12 +678,11 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, true); outputFile = configuration.getAttribute( IDebugUIConstants.ATTR_CAPTURE_IN_FILE, (String) null); - append = configuration.getAttribute( - IDebugUIConstants.ATTR_APPEND_TO_FILE, false); - isInteractive = configuration - .getAttribute( - ScriptLaunchConfigurationConstants.ATTR_USE_INTERACTIVE_CONSOLE, - false); + append = configuration + .getAttribute(IDebugUIConstants.ATTR_APPEND_TO_FILE, false); + isInteractive = configuration.getAttribute( + ScriptLaunchConfigurationConstants.ATTR_USE_INTERACTIVE_CONSOLE, + false); } catch (CoreException e) { if (DLTKCore.DEBUG) { e.printStackTrace(); @@ -706,18 +705,19 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { /** * Updates the launch on background check button - * + * * @param configuration * the local launch configuration */ - protected void updateLaunchInBackground(ILaunchConfiguration configuration) { + protected void updateLaunchInBackground( + ILaunchConfiguration configuration) { fLaunchInBackgroundButton .setSelection(isLaunchInBackground(configuration)); } /** * Updates the encoding - * + * * @param configuration * the local configuration */ @@ -747,7 +747,7 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { /** * Returns whether the given configuration should be launched in the * background. - * + * * @param configuration * the configuration * @return whether the configuration is configured to launch in the @@ -767,7 +767,7 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { /** * Updates the favorites selections from the local configuration - * + * * @param config * the local configuration */ @@ -808,7 +808,7 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { /** * Updates the configuration form the local shared config working copy - * + * * @param config * the local shared config working copy */ @@ -838,7 +838,7 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { /** * Update the favorite settings. - * + * * NOTE: set to <code>null</code> instead of <code>false</code> for * backwards compatibility when comparing if content is equal, since 'false' * is default and will be missing for older configurations. @@ -847,10 +847,10 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { ILaunchConfigurationWorkingCopy config) { try { Object[] checked = fFavoritesTable.getCheckedElements(); - boolean debug = config.getAttribute( - IDebugUIConstants.ATTR_DEBUG_FAVORITE, false); - boolean run = config.getAttribute( - IDebugUIConstants.ATTR_RUN_FAVORITE, false); + boolean debug = config + .getAttribute(IDebugUIConstants.ATTR_DEBUG_FAVORITE, false); + boolean run = config + .getAttribute(IDebugUIConstants.ATTR_RUN_FAVORITE, false); if (debug || run) { // old attributes List groups = new ArrayList(); @@ -906,11 +906,12 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { /* * (non-Javadoc) - * + * * @see * org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug * .core.ILaunchConfiguration) */ + @Override public boolean isValid(ILaunchConfiguration config) { setMessage(null); setErrorMessage(null); @@ -921,14 +922,15 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { /** * validates the encoding selection - * + * * @return true if the validate encoding is allowable, false otherwise */ private boolean validateEncoding() { if (fAltEncodingButton.getSelection()) { if (fEncodingCombo.getSelectionIndex() == -1) { if (!isValidEncoding(fEncodingCombo.getText().trim())) { - setErrorMessage(DLTKLaunchConfigurationsMessages.commonTab_EncodingNotSupported); + setErrorMessage( + DLTKLaunchConfigurationsMessages.commonTab_EncodingNotSupported); return false; } } @@ -938,7 +940,7 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { /** * Validates if the redirect file is valid - * + * * @return true if the filename is not zero, false otherwise */ private boolean validateRedirectFile() { @@ -954,20 +956,21 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { /** * validates the local shared config file location - * + * * @return true if the local shared file exists, false otherwise */ private boolean validateLocalShared() { if (isShared()) { String path = fSharedLocationText.getText().trim(); IContainer container = getContainer(path); - if (container == null - || container.equals(ResourcesPlugin.getWorkspace() - .getRoot())) { - setErrorMessage(LaunchConfigurationsMessages.CommonTab_Invalid_shared_configuration_location_14); + if (container == null || container + .equals(ResourcesPlugin.getWorkspace().getRoot())) { + setErrorMessage( + LaunchConfigurationsMessages.CommonTab_Invalid_shared_configuration_location_14); return false; } else if (!container.getProject().isOpen()) { - setErrorMessage(LaunchConfigurationsMessages.CommonTab_Cannot_save_launch_configuration_in_a_closed_project__1); + setErrorMessage( + LaunchConfigurationsMessages.CommonTab_Cannot_save_launch_configuration_in_a_closed_project__1); return false; } } @@ -976,11 +979,12 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { /* * (non-Javadoc) - * + * * @see * org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse. * debug.core.ILaunchConfigurationWorkingCopy) */ + @Override public void setDefaults(ILaunchConfigurationWorkingCopy config) { config.setContainer(null); setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, config, true, @@ -989,18 +993,18 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { /* * (non-Javadoc) - * + * * @see * org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse * .debug.core.ILaunchConfigurationWorkingCopy) */ + @Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { boolean isInteractive = false; try { - isInteractive = configuration - .getAttribute( - ScriptLaunchConfigurationConstants.ATTR_USE_INTERACTIVE_CONSOLE, - false); + isInteractive = configuration.getAttribute( + ScriptLaunchConfigurationConstants.ATTR_USE_INTERACTIVE_CONSOLE, + false); } catch (CoreException e) { if (DLTKCore.DEBUG) { e.printStackTrace(); @@ -1009,8 +1013,8 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { updateConfigFromLocalShared(configuration); updateConfigFromFavorites(configuration); - setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, - configuration, fLaunchInBackgroundButton.getSelection(), true); + setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, configuration, + fLaunchInBackgroundButton.getSelection(), true); String encoding = null; if (fAltEncodingButton.getSelection()) { encoding = fEncodingCombo.getText().trim(); @@ -1052,36 +1056,40 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { /* * (non-Javadoc) - * + * * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName() */ + @Override public String getName() { return LaunchConfigurationsMessages.CommonTab__Common_15; } /** * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#getId() - * + * * @since 3.3 */ + @Override public String getId() { return "org.eclipse.debug.ui.commonTab"; //$NON-NLS-1$ } /* * (non-Javadoc) - * + * * @see org.eclipse.debug.ui.ILaunchConfigurationTab#canSave() */ + @Override public boolean canSave() { return validateLocalShared(); } /* * (non-Javadoc) - * + * * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage() */ + @Override public Image getImage() { return DebugUITools .getImage(IInternalDebugUIConstants.IMG_OBJS_COMMON_TAB); @@ -1089,22 +1097,24 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { /* * (non-Javadoc) - * + * * @see * org.eclipse.debug.ui.ILaunchConfigurationTab#activated(org.eclipse.debug * .core.ILaunchConfigurationWorkingCopy) */ + @Override public void activated(ILaunchConfigurationWorkingCopy workingCopy) { updateConsoleOutput(workingCopy); } /* * (non-Javadoc) - * + * * @see * org.eclipse.debug.ui.ILaunchConfigurationTab#deactivated(org.eclipse. * debug.core.ILaunchConfigurationWorkingCopy) */ + @Override public void deactivated(ILaunchConfigurationWorkingCopy workingCopy) { } @@ -1113,6 +1123,7 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { */ class FavoritesContentProvider implements IStructuredContentProvider { + @Override public Object[] getElements(Object inputElement) { ILaunchGroup[] groups = DebugUITools.getLaunchGroups(); List possibleGroups = new ArrayList(); @@ -1128,22 +1139,26 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { return possibleGroups.toArray(); } + @Override public void dispose() { } - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + @Override + public void inputChanged(Viewer viewer, Object oldInput, + Object newInput) { } } /** * Provides the labels for the favorites table - * + * */ class FavoritesLabelProvider implements ITableLabelProvider { private Map fImages = new HashMap(); + @Override public Image getColumnImage(Object element, int columnIndex) { Image image = (Image) fImages.get(element); if (image == null) { @@ -1157,14 +1172,17 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { return image; } + @Override public String getColumnText(Object element, int columnIndex) { String label = ((LaunchGroupExtension) element).getLabel(); return DebugUIPlugin.removeAccelerators(label); } + @Override public void addListener(ILabelProviderListener listener) { } + @Override public void dispose() { Iterator images = fImages.values().iterator(); while (images.hasNext()) { @@ -1173,10 +1191,12 @@ public class ScriptCommonTab extends AbstractLaunchConfigurationTab { } } + @Override public boolean isLabelProperty(Object element, String property) { return false; } + @Override public void removeListener(ILabelProviderListener listener) { } } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/ScriptLaunchConfigurationTab.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/ScriptLaunchConfigurationTab.java index 85a4f5acb..35958ae27 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/ScriptLaunchConfigurationTab.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/ScriptLaunchConfigurationTab.java @@ -53,10 +53,8 @@ import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.dialogs.ElementListSelectionDialog; -/** - */ -public abstract class ScriptLaunchConfigurationTab extends - AbstractLaunchConfigurationTab { +public abstract class ScriptLaunchConfigurationTab + extends AbstractLaunchConfigurationTab { protected static final String EMPTY_STRING = ""; //$NON-NLS-1$ private final String fMode; @@ -73,9 +71,7 @@ public abstract class ScriptLaunchConfigurationTab extends this.fMode = mode; } - /* - * @see ILaunchConfigurationTab#createControl(Composite) - */ + @Override public void createControl(Composite parent) { Composite comp = new Composite(parent, SWT.NONE); setControl(comp); @@ -106,7 +102,7 @@ public abstract class ScriptLaunchConfigurationTab extends /** * Creates the widgets for specifying a main type. - * + * * @param parent * the parent composite */ @@ -117,7 +113,8 @@ public abstract class ScriptLaunchConfigurationTab extends group.setText(text); GridData gd = new GridData(GridData.FILL_HORIZONTAL); if (parent.getLayout() instanceof GridLayout) { - gd.horizontalSpan = ((GridLayout) parent.getLayout()).numColumns; + gd.horizontalSpan = ((GridLayout) parent + .getLayout()).numColumns; } group.setLayoutData(gd); GridLayout layout = new GridLayout(); @@ -135,9 +132,7 @@ public abstract class ScriptLaunchConfigurationTab extends private boolean initializing = false; - /* - * @see ILaunchConfigurationTab#initializeFrom(ILaunchConfiguration) - */ + @Override public final void initializeFrom(ILaunchConfiguration config) { initializing = true; try { @@ -173,7 +168,7 @@ public abstract class ScriptLaunchConfigurationTab extends /** * Validates the page. This method should be overridden when more checks are * needed. - * + * * @return <code>true</code> if input is correct and <code>false</code> * otherwise */ @@ -185,10 +180,7 @@ public abstract class ScriptLaunchConfigurationTab extends return getErrorMessage() != null; } - /* - * @see - * ILaunchConfigurationTab#performApply(ILaunchConfigurationWorkingCopy) - */ + @Override public final void performApply(ILaunchConfigurationWorkingCopy config) { String project = fProjText.getText().trim(); config.setAttribute( @@ -196,10 +188,9 @@ public abstract class ScriptLaunchConfigurationTab extends if (ILaunchManager.DEBUG_MODE.equals(fMode)) { if (breakOnFirstLine != null) - config - .setAttribute( - ScriptLaunchConfigurationConstants.ENABLE_BREAK_ON_FIRST_LINE, - breakOnFirstLine.getSelection()); + config.setAttribute( + ScriptLaunchConfigurationConstants.ENABLE_BREAK_ON_FIRST_LINE, + breakOnFirstLine.getSelection()); if (enableLogging != null) config.setAttribute( ScriptLaunchConfigurationConstants.ENABLE_DBGP_LOGGING, @@ -233,7 +224,7 @@ public abstract class ScriptLaunchConfigurationTab extends /** * Returns a resource mapping for the given launch configuration, or * <code>null</code> if none. - * + * * @param config * working copy * @throws CoreException @@ -256,9 +247,7 @@ public abstract class ScriptLaunchConfigurationTab extends return null; } - /* - * @see ILaunchConfigurationTab#setDefaults(ILaunchConfigurationWorkingCopy) - */ + @Override public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { IModelElement element = getContextModelElement(); setDefaults(configuration, element); @@ -305,7 +294,8 @@ public abstract class ScriptLaunchConfigurationTab extends * Returns the current preference value for the 'Dbgp logging enabled' * setting */ - protected boolean dbpgLoggingPrefEnabled(PreferencesLookupDelegate delegate) { + protected boolean dbpgLoggingPrefEnabled( + PreferencesLookupDelegate delegate) { return false; } @@ -320,25 +310,25 @@ public abstract class ScriptLaunchConfigurationTab extends /** * Creates the sub-class specific control. - * + * * <p> * Sub-classes can widgets directly to the <code>composite</code> object * that is passed to them. * </p> - * + * * @param composite * control composite - * + * * @see #createControl(Composite) */ protected abstract void doCreateControl(Composite composite); /** * Performs the sub-class specific configuration tab initialization. - * + * * @param config * launch configuration - * + * * @see #initializeFrom(ILaunchConfiguration) */ protected abstract void doInitializeForm(ILaunchConfiguration config); @@ -350,10 +340,10 @@ public abstract class ScriptLaunchConfigurationTab extends /** * Validate the specified toolkit is valid for the launch configuration - * + * * @param toolkit * language toolkit - * + * * @return <code>true</code> if the toolkit is valid for the launch * configuration, <code>false</code> otherwise */ @@ -368,12 +358,12 @@ public abstract class ScriptLaunchConfigurationTab extends /** * Add the 'break on first line' option to a group composite. - * + * * <p> * Sub-classes are responsible for adding this option to a group composite * of their choosing. * </p> - * + * * @param group * group composite */ @@ -386,12 +376,12 @@ public abstract class ScriptLaunchConfigurationTab extends /** * Add the 'Dbgp logging enabled' option to a group composite. - * + * * <p> * Sub-classes are responsible for adding this option to a group composite * of their choosing. * </p> - * + * * @param group * group composite */ @@ -404,7 +394,7 @@ public abstract class ScriptLaunchConfigurationTab extends /** * chooses a project for the type of launch config that it is - * + * * @return */ protected IScriptProject chooseProject() { @@ -412,15 +402,15 @@ public abstract class ScriptLaunchConfigurationTab extends .createLabelProvider(getNatureID()); final ElementListSelectionDialog dialog = new ElementListSelectionDialog( getShell(), labelProvider); - dialog - .setTitle(DLTKLaunchConfigurationsMessages.mainTab_chooseProject_title); - dialog - .setMessage(DLTKLaunchConfigurationsMessages.mainTab_chooseProject_message); + dialog.setTitle( + DLTKLaunchConfigurationsMessages.mainTab_chooseProject_title); + dialog.setMessage( + DLTKLaunchConfigurationsMessages.mainTab_chooseProject_message); try { final IScriptProject[] projects = ScriptModelHelper - .getOpenedScriptProjects(DLTKCore - .create(getWorkspaceRoot()), getNatureID()); + .getOpenedScriptProjects( + DLTKCore.create(getWorkspaceRoot()), getNatureID()); dialog.setElements(projects); } catch (ModelException e) { DLTKLaunchingPlugin.log(e); @@ -466,12 +456,12 @@ public abstract class ScriptLaunchConfigurationTab extends /** * Creates a project editor - * + * * <p> * Creates a group containing an input text field and 'Browse' button to * select a project from the workspace. * </p> - * + * * @param parent * the parent composite */ @@ -479,8 +469,8 @@ public abstract class ScriptLaunchConfigurationTab extends final Composite editParent; if (needGroupForField(FIELD_PROJECT)) { Group group = new Group(parent, SWT.NONE); - group - .setText(DLTKLaunchConfigurationsMessages.mainTab_projectGroup); + group.setText( + DLTKLaunchConfigurationsMessages.mainTab_projectGroup); GridData gd = new GridData(GridData.FILL_HORIZONTAL); group.setLayoutData(gd); @@ -543,7 +533,7 @@ public abstract class ScriptLaunchConfigurationTab extends /** * Attempts to guess the current project and script being launched. - * + * * @return model element - the script or the project. */ protected IModelElement getContextModelElement() { @@ -639,20 +629,15 @@ public abstract class ScriptLaunchConfigurationTab extends } if (!validateProject(project)) { - String msg = Messages - .format( - DLTKLaunchConfigurationsMessages.mainTab_errorDlg_notALangProject, - new String[] { getLanguageName() }); - String reason = Messages - .format( - DLTKLaunchConfigurationsMessages.mainTab_errorDlg_reasonNotALangProject, - new String[] { getLanguageName() }); - ErrorDialog - .openError( - getShell(), - DLTKLaunchConfigurationsMessages.mainTab_errorDlg_invalidProject, - msg, DLTKUIStatus.createError(IStatus.ERROR, - reason, null)); + String msg = Messages.format( + DLTKLaunchConfigurationsMessages.mainTab_errorDlg_notALangProject, + new String[] { getLanguageName() }); + String reason = Messages.format( + DLTKLaunchConfigurationsMessages.mainTab_errorDlg_reasonNotALangProject, + new String[] { getLanguageName() }); + ErrorDialog.openError(getShell(), + DLTKLaunchConfigurationsMessages.mainTab_errorDlg_invalidProject, + msg, DLTKUIStatus.createError(IStatus.ERROR, reason, null)); return; } @@ -662,16 +647,17 @@ public abstract class ScriptLaunchConfigurationTab extends /** * Sets the name of the project associated with the launch configuration - * + * * @param name * project name */ protected final void setProjectName(String name) { - setProjectName(name, new PreferencesLookupDelegate(getScriptModel() - .getScriptProject(name))); + setProjectName(name, new PreferencesLookupDelegate( + getScriptModel().getScriptProject(name))); } - private void setProjectName(String name, PreferencesLookupDelegate delegate) { + private void setProjectName(String name, + PreferencesLookupDelegate delegate) { fProjText.setText(name); if (delegate != null && ILaunchManager.DEBUG_MODE.equals(fMode)) { if (breakOnFirstLine != null) @@ -684,7 +670,7 @@ public abstract class ScriptLaunchConfigurationTab extends /** * updates the project text field form the configuration - * + * * @param config * the configuration we are editing */ @@ -695,8 +681,8 @@ public abstract class ScriptLaunchConfigurationTab extends if (ILaunchManager.DEBUG_MODE.equals(fMode) && Path.EMPTY.isValidSegment(projectName)) { - final IProject project = getWorkspaceRoot().getProject( - projectName); + final IProject project = getWorkspaceRoot() + .getProject(projectName); if (project.isAccessible()) { final PreferencesLookupDelegate delegate = new PreferencesLookupDelegate( project); @@ -719,13 +705,15 @@ public abstract class ScriptLaunchConfigurationTab extends protected boolean validateProject() { String projectName = getProjectName(); if (projectName.length() == 0) { - setErrorMessage(DLTKLaunchConfigurationsMessages.error_selectProject); + setErrorMessage( + DLTKLaunchConfigurationsMessages.error_selectProject); return false; } IScriptProject proj = getScriptModel().getScriptProject(projectName); if (proj == null || !validateProject(proj)) { - setErrorMessage(DLTKLaunchConfigurationsMessages.error_notAValidProject); + setErrorMessage( + DLTKLaunchConfigurationsMessages.error_notAValidProject); return false; } @@ -735,7 +723,7 @@ public abstract class ScriptLaunchConfigurationTab extends /** * Tests if the project field is valid. Returns <code>true</code> if valid * project is selected or <code>false</code> otherwise. - * + * * @return */ protected boolean isValidProject() { @@ -750,7 +738,7 @@ public abstract class ScriptLaunchConfigurationTab extends /** * Tests if the specified project is valid for this launch configuration * type. - * + * * @param project * @return */ @@ -775,6 +763,7 @@ public abstract class ScriptLaunchConfigurationTab extends * tab. */ class WidgetListener implements ModifyListener, SelectionListener { + @Override public void modifyText(ModifyEvent e) { if (initializing) { return; @@ -799,10 +788,12 @@ public abstract class ScriptLaunchConfigurationTab extends updateLaunchConfigurationDialog(); } + @Override public void widgetDefaultSelected(SelectionEvent e) { /* do nothing */ } + @Override public void widgetSelected(SelectionEvent e) { updateLaunchConfigurationDialog(); } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/AbstractDebuggingEngineOptionsBlock.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/AbstractDebuggingEngineOptionsBlock.java index 610df7e15..9a3a7008d 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/AbstractDebuggingEngineOptionsBlock.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/AbstractDebuggingEngineOptionsBlock.java @@ -8,39 +8,31 @@ import org.eclipse.dltk.ui.preferences.PreferenceKey; import org.eclipse.dltk.ui.util.IStatusChangeListener; import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; -public abstract class AbstractDebuggingEngineOptionsBlock extends - ContributedExtensionOptionsBlock { +public abstract class AbstractDebuggingEngineOptionsBlock + extends ContributedExtensionOptionsBlock { public AbstractDebuggingEngineOptionsBlock(IStatusChangeListener context, IProject project, PreferenceKey[] allKeys, IWorkbenchPreferenceContainer container) { super(context, project, allKeys, container); } - - /* - * @see org.eclipse.dltk.ui.preferences.DLTKContributedExtensionOptionsBlock#getExtensionManager() - */ + + @Override protected DLTKContributionExtensionManager getExtensionManager() { return DebuggingEngineManager.getInstance(); } - /* - * @see org.eclipse.dltk.ui.preferences.DLTKContributedExtensionOptionsBlock#getSelectorGroupLabel() - */ + @Override protected String getSelectorGroupLabel() { return ScriptDebugPreferencesMessages.DebuggingEngine; } - /* - * @see org.eclipse.dltk.ui.preferences.DLTKContributedExtensionOptionsBlock#getSelectorNameLabel() - */ + @Override protected String getSelectorNameLabel() { return ScriptDebugPreferencesMessages.NameLabel; } - /* - * @see org.eclipse.dltk.ui.preferences.ContributedExtensionOptionsBlock#getPreferenceLinkMessage() - */ + @Override protected String getPreferenceLinkMessage() { return ScriptDebugPreferencesMessages.LinkToDebuggingEnginePreferences; } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/AbstractDebuggingOptionsBlock.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/AbstractDebuggingOptionsBlock.java index 087c10c51..22efcde3f 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/AbstractDebuggingOptionsBlock.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/AbstractDebuggingOptionsBlock.java @@ -15,8 +15,8 @@ import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; /** * Options block for general debugging engine settings. */ -public abstract class AbstractDebuggingOptionsBlock extends - AbstractOptionsBlock { +public abstract class AbstractDebuggingOptionsBlock + extends AbstractOptionsBlock { private static String DLTK_DEBUG_PREF_PAGE_ID = "org.eclipse.dltk.preferences.debug"; //$NON-NLS-1$ @@ -26,12 +26,10 @@ public abstract class AbstractDebuggingOptionsBlock extends super(context, project, allKeys, container); } - /* - * @see AbstractOptionsBlock#createOptionsBlock(Composite) - */ + @Override protected Control createOptionsBlock(Composite parent) { - Composite composite = SWTFactory.createComposite(parent, parent - .getFont(), 1, 1, GridData.FILL_HORIZONTAL); + Composite composite = SWTFactory.createComposite(parent, + parent.getFont(), 1, 1, GridData.FILL_HORIZONTAL); createSettingsGroup(SWTFactory.createGroup(composite, ScriptDebugPreferencesMessages.EngineSettingsLabel, 1, 1, diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/AbstractScriptDebugPreferencePage.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/AbstractScriptDebugPreferencePage.java index 9dc19268c..fc362312d 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/AbstractScriptDebugPreferencePage.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/AbstractScriptDebugPreferencePage.java @@ -13,40 +13,35 @@ import org.eclipse.jface.preference.IPreferenceStore; /** * Abstract base class for script debug preference pages. - * + * * <p> * Preferenece pages that extend from this class will have their preference * values stored in the <code>IPreferenceStore</code> returned from the plugin's * {@link IDLTKDebugUILanguageToolkit} implementation. * </p> - * + * * <p> * These pages will also need to be configured with the specific nature id for * the plugin in the <code>plugin.xml</code> file. ie: * </p> - * + * * <pre> - * <page + * <page * category="..." * class="class:nature_id" * id="..." * name="..." /> * </pre> - * + * * @see DLTKDebugPluginPreferenceInitializer */ -public abstract class AbstractScriptDebugPreferencePage extends - AbstractConfigurationBlockPreferencePage implements - IExecutableExtension { +public abstract class AbstractScriptDebugPreferencePage + extends AbstractConfigurationBlockPreferencePage + implements IExecutableExtension { private IDLTKLanguageToolkit fToolkit; - /* - * @see - * org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org - * .eclipse.core.runtime.IConfigurationElement, java.lang.String, - * java.lang.Object) - */ + @Override public final void setInitializationData(IConfigurationElement config, String propertyName, Object data) { fToolkit = DLTKExecuteExtensionHelper.getLanguageToolkit(config, @@ -55,20 +50,12 @@ public abstract class AbstractScriptDebugPreferencePage extends Assert.isNotNull(fToolkit); } - /* - * @see - * org.eclipse.dltk.ui.preferences.AbstractConfigurationBlockPreferencePage - * #getHelpId() - */ + @Override protected String getHelpId() { return null; } - /* - * @see - * org.eclipse.dltk.ui.preferences.AbstractConfigurationBlockPreferencePage - * #setPreferenceStore() - */ + @Override protected final void setPreferenceStore() { IDLTKDebugUILanguageToolkit uiToolkit = DLTKDebugUILanguageManager .getLanguageToolkit(fToolkit.getNatureId()); diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/DebuggingEngineConfigOptionsBlock.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/DebuggingEngineConfigOptionsBlock.java index b5ec196ea..2eb842e29 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/DebuggingEngineConfigOptionsBlock.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/DebuggingEngineConfigOptionsBlock.java @@ -34,9 +34,7 @@ public abstract class DebuggingEngineConfigOptionsBlock super(context, project, allKeys, container); } - /* - * @see AbstractOptionsBlock#createOptionsBlock(Composite) - */ + @Override protected Control createOptionsBlock(Composite parent) { final Composite composite = SWTFactory.createComposite(parent, parent.getFont(), 1, 1, GridData.FILL); @@ -49,12 +47,12 @@ public abstract class DebuggingEngineConfigOptionsBlock /** * Creates the options block for engine specific preferences/settings. - * + * * <p> * Subclasses may provide an empty implementation if their debugging engine * does not have any preferences/settings * </p> - * + * * @param parent * composite */ @@ -62,13 +60,13 @@ public abstract class DebuggingEngineConfigOptionsBlock /** * Creates the options block that controls debugging engine logging. - * + * * <p> * Subclasses may override this method, providing an empty implementation if * their debugging engine does not support logging. This block will be * placed after the 'engine options' block. * </p> - * + * * @param parent * composite */ @@ -124,10 +122,10 @@ public abstract class DebuggingEngineConfigOptionsBlock /** * Returns the array of {@link IEnvironment}s relevant for this * preference/property page. - * + * * If it is used as preference page - all {@link IEnvironment} are returned, * otherwise only {@link IEnvironment} of the current project is returned. - * + * * @return */ protected IEnvironment[] getRelevantEnvironments() { @@ -140,6 +138,7 @@ public abstract class DebuggingEngineConfigOptionsBlock } } + @Override protected boolean processChanges(IWorkbenchPreferenceContainer container) { saveLoggingOptions(); return super.processChanges(container); @@ -156,11 +155,11 @@ public abstract class DebuggingEngineConfigOptionsBlock /** * Creates an an options block for items that fall into the 'other' category * - ie: adding a link to download an external debugging engine. - * + * * <p> * This block will be placed after the 'logging options' block. * </p> - * + * * @param parent */ protected void createOtherBlock(Composite parent) { @@ -169,12 +168,12 @@ public abstract class DebuggingEngineConfigOptionsBlock /** * Returns the enable logging preference key - * + * * <p> * Note: this preference controls logging for the actual debugging engine, * and not the DBGP protocol output. * </p> - * + * * @deprecated */ @Deprecated @@ -189,7 +188,7 @@ public abstract class DebuggingEngineConfigOptionsBlock /** * Returns the log file path preference key - * + * * @deprecated */ @Deprecated diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/ExternalDebuggingEngineOptionsBlock.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/ExternalDebuggingEngineOptionsBlock.java index 0bf1d293d..d6c81ebbe 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/ExternalDebuggingEngineOptionsBlock.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/ExternalDebuggingEngineOptionsBlock.java @@ -28,8 +28,8 @@ import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; * Options block for external debugging engine that require the user to specify * their location on disk. */ -public abstract class ExternalDebuggingEngineOptionsBlock extends - DebuggingEngineConfigOptionsBlock { +public abstract class ExternalDebuggingEngineOptionsBlock + extends DebuggingEngineConfigOptionsBlock { EnvironmentPathBlock enginePaths; @@ -42,7 +42,7 @@ public abstract class ExternalDebuggingEngineOptionsBlock extends /** * Add a link to an external site where the debugging engine can be * downloaded from - * + * * @param parent * parent composite * @param text @@ -54,6 +54,7 @@ public abstract class ExternalDebuggingEngineOptionsBlock extends final String url) { Link link = new Link(parent, SWT.NONE); link.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { openExternalUrl(url); } @@ -69,16 +70,17 @@ public abstract class ExternalDebuggingEngineOptionsBlock extends /** * Creates the engine path block. - * + * * <p> * Sub-classes are free to override if they wish to make additional * contributions to the parent composite to provide additional options for * their specific engine. * </p> - * + * * @param parent * parent composite */ + @Override protected void createEngineBlock(final Composite parent) { final Group group = SWTFactory.createGroup(parent, ScriptDebugPreferencesMessages.ExternalEngineGroup, 3, 1, diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/Filter.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/Filter.java index 1b7edbe1f..af755e5bf 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/Filter.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/Filter.java @@ -1,16 +1,15 @@ /******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.dltk.debug.ui.preferences; - /** * Model object that represents a single entry in a filter table. */ @@ -51,6 +50,7 @@ public class Filter { fChecked = checked; } + @Override public boolean equals(Object o) { if (o instanceof Filter) { Filter other = (Filter) o; @@ -61,6 +61,7 @@ public class Filter { return false; } + @Override public int hashCode() { return getName().hashCode(); } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/FilterLabelProvider.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/FilterLabelProvider.java index eebee6efd..260ed6e1f 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/FilterLabelProvider.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/FilterLabelProvider.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -15,7 +15,6 @@ import java.util.Map; import org.eclipse.dltk.ui.DLTKPluginImages; import org.eclipse.dltk.ui.ScriptElementImageProvider; -import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.graphics.Image; @@ -23,14 +22,12 @@ import org.eclipse.swt.graphics.Image; /** * Label provider for Filter model objects */ -public class FilterLabelProvider extends LabelProvider implements - ITableLabelProvider { +public class FilterLabelProvider extends LabelProvider + implements ITableLabelProvider { - private Map<Integer, Image> typeImages = new HashMap<Integer, Image>(); + private Map<Integer, Image> typeImages = new HashMap<>(); - /** - * @see ITableLabelProvider#getColumnText(Object, int) - */ + @Override public String getColumnText(Object object, int column) { if (column == 0) { return ((Filter) object).getName(); @@ -38,17 +35,12 @@ public class FilterLabelProvider extends LabelProvider implements return ""; //$NON-NLS-1$ } - /** - * @see ILabelProvider#getText(Object) - */ @Override public String getText(Object element) { return ((Filter) element).getName(); } - /** - * @see ITableLabelProvider#getColumnImage(Object, int) - */ + @Override public Image getColumnImage(Object object, int column) { Filter filter = (Filter) object; String name = filter.getName(); @@ -59,8 +51,9 @@ public class FilterLabelProvider extends LabelProvider implements if (typeImages.containsKey(mod)) { return typeImages.get(mod); } else { - Image img = ScriptElementImageProvider.getTypeImageDescriptor( - filter.getModifiers(), false).createImage(); + Image img = ScriptElementImageProvider + .getTypeImageDescriptor(filter.getModifiers(), false) + .createImage(); typeImages.put(mod, img); return img; } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/FilterViewerComparator.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/FilterViewerComparator.java index 89b05846d..d3e4b230d 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/FilterViewerComparator.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/FilterViewerComparator.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -16,9 +16,10 @@ import org.eclipse.jface.viewers.Viewer; import org.eclipse.ui.model.WorkbenchViewerComparator; public class FilterViewerComparator extends WorkbenchViewerComparator { + @Override public int compare(Viewer viewer, Object e1, Object e2) { - ILabelProvider lprov = - (ILabelProvider) ((ContentViewer) viewer).getLabelProvider(); + ILabelProvider lprov = (ILabelProvider) ((ContentViewer) viewer) + .getLabelProvider(); String name1 = lprov.getText(e1); String name2 = lprov.getText(e2); if (name1 == null) { diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/ScriptDebugConfigurationBlock.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/ScriptDebugConfigurationBlock.java index cd3fb8dd3..99172e01f 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/ScriptDebugConfigurationBlock.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/ScriptDebugConfigurationBlock.java @@ -1,11 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * Copyright (c) 2005, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.debug.ui.preferences; @@ -41,12 +40,13 @@ import org.eclipse.swt.widgets.Text; import org.eclipse.ui.dialogs.PreferenceLinkArea; import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; -public class ScriptDebugConfigurationBlock extends - ImprovedAbstractConfigurationBlock { +public class ScriptDebugConfigurationBlock + extends ImprovedAbstractConfigurationBlock { private PreferencePage preferencePage; private Preferences fUIPreferences; + @Override protected List createOverlayKeys() { ArrayList overlayKeys = new ArrayList(); @@ -104,19 +104,16 @@ public class ScriptDebugConfigurationBlock extends GridData.FILL_HORIZONTAL); // Port - SWTFactory - .createLabel( - group, - ScriptDebugPreferencesMessages.ScriptDebugConfigurationBlock_BindAddress, - 1); + SWTFactory.createLabel(group, + ScriptDebugPreferencesMessages.ScriptDebugConfigurationBlock_BindAddress, + 1); ipCombo = SWTFactory.createCombo(group, SWT.READ_ONLY | SWT.BORDER, 0, new String[] {}); - ipCombo - .add( - ScriptDebugPreferencesMessages.ScriptDebugConfigurationBlock_AutoDetectBindAddress, - AUTODETECT_BIND_ADDRESS_INDEX); + ipCombo.add( + ScriptDebugPreferencesMessages.ScriptDebugConfigurationBlock_AutoDetectBindAddress, + AUTODETECT_BIND_ADDRESS_INDEX); String[] ipAddresses = DLTKDebugPlugin.getLocalAddresses(); for (int i = 0; i < ipAddresses.length; i++) { @@ -127,14 +124,14 @@ public class ScriptDebugConfigurationBlock extends SWTFactory.createLabel(group, ScriptDebugPreferencesMessages.PortLabel, 1); - Composite portCompsite = SWTFactory.createComposite(group, group - .getFont(), 2, 0, GridData.FILL_HORIZONTAL); + Composite portCompsite = SWTFactory.createComposite(group, + group.getFont(), 2, 0, GridData.FILL_HORIZONTAL); GridLayout portCompsiteLayout = (GridLayout) portCompsite.getLayout(); portCompsiteLayout.marginWidth = 0; portCompsiteLayout.marginHeight = 0; - portCombo = SWTFactory.createCombo(portCompsite, SWT.READ_ONLY - | SWT.BORDER, 0, new String[] {}); + portCombo = SWTFactory.createCombo(portCompsite, + SWT.READ_ONLY | SWT.BORDER, 0, new String[] {}); portCombo.add(ScriptDebugPreferencesMessages.AutoSelectLabel, AUTO_SELECT_PORT_INDEX); @@ -145,11 +142,14 @@ public class ScriptDebugConfigurationBlock extends bindControl(portText, FieldValidators.PORT_VALIDATOR); portCombo.addSelectionListener(new SelectionListener() { + @Override public void widgetDefaultSelected(SelectionEvent e) { } + @Override public void widgetSelected(SelectionEvent e) { - boolean isCustom = portCombo.getSelectionIndex() == CUSTOM_PORT_INDEX; + boolean isCustom = portCombo + .getSelectionIndex() == CUSTOM_PORT_INDEX; portText.setEnabled(isCustom); @@ -163,10 +163,12 @@ public class ScriptDebugConfigurationBlock extends final NumberTransformer timeoutTransformer = new NumberTransformer() { + @Override protected int convertPreference(int value) { return value / 1000; } + @Override protected int convertInput(int input) { return input * 1000; } @@ -185,8 +187,8 @@ public class ScriptDebugConfigurationBlock extends // Response timeout SWTFactory.createLabel(group, ScriptDebugPreferencesMessages.ResponseTimeoutLabel, 1); - final Text responseTimeout = SWTFactory.createText(group, SWT.BORDER, - 1, ""); //$NON-NLS-1$ + final Text responseTimeout = SWTFactory.createText(group, SWT.BORDER, 1, + ""); //$NON-NLS-1$ bindControl(responseTimeout, DLTKDebugPreferenceConstants.PREF_DBGP_RESPONSE_TIMEOUT, FieldValidators.POSITIVE_NUMBER_VALIDATOR, timeoutTransformer); @@ -199,15 +201,15 @@ public class ScriptDebugConfigurationBlock extends ScriptDebugPreferencesMessages.HCRLabel, 1, 1, GridData.FILL_HORIZONTAL); - boolean alertHcrFailed = fUIPreferences - .getBoolean(IDLTKDebugUIPreferenceConstants.PREF_ALERT_HCR_FAILED); + boolean alertHcrFailed = fUIPreferences.getBoolean( + IDLTKDebugUIPreferenceConstants.PREF_ALERT_HCR_FAILED); fAlertHCRFailed = SWTFactory.createCheckButton(group, ScriptDebugPreferencesMessages.HCRFailedLabel, null, alertHcrFailed, 1); - boolean alertHcrNotSupported = fUIPreferences - .getBoolean(IDLTKDebugUIPreferenceConstants.PREF_ALERT_HCR_NOT_SUPPORTED); + boolean alertHcrNotSupported = fUIPreferences.getBoolean( + IDLTKDebugUIPreferenceConstants.PREF_ALERT_HCR_NOT_SUPPORTED); fAlertHCRNotSupported = SWTFactory.createCheckButton(group, ScriptDebugPreferencesMessages.HCRNotSupportedLabel, null, @@ -220,8 +222,8 @@ public class ScriptDebugConfigurationBlock extends IDLTKUILanguageToolkit[] toolkits = DLTKUILanguageManager .getLanguageToolkits(); - Composite composite = SWTFactory.createComposite(parent, parent - .getFont(), 1, 1, GridData.FILL_HORIZONTAL); + Composite composite = SWTFactory.createComposite(parent, + parent.getFont(), 1, 1, GridData.FILL_HORIZONTAL); for (int i = 0; i < toolkits.length; ++i) { final IDLTKUILanguageToolkit toolkit = toolkits[i]; @@ -236,15 +238,15 @@ public class ScriptDebugConfigurationBlock extends * meh, is there a better way to allow this string to be * externalized and still support the preference link? */ - String message = NLS - .bind( - ScriptDebugPreferencesMessages.LinkToLanguageDebugOptions, - new Object[] { "{0}", languageName }); //$NON-NLS-1$ + String message = NLS.bind( + ScriptDebugPreferencesMessages.LinkToLanguageDebugOptions, + new Object[] { "{0}", languageName }); //$NON-NLS-1$ PreferenceLinkArea area = new PreferenceLinkArea(composite, SWT.NONE, pageId, message, (IWorkbenchPreferenceContainer) preferencePage - .getContainer(), null); + .getContainer(), + null); area.getControl().setLayoutData( new GridData(SWT.FILL, SWT.FILL, false, false)); @@ -252,9 +254,10 @@ public class ScriptDebugConfigurationBlock extends } } + @Override public Control createControl(Composite parent) { - final Composite composite = SWTFactory.createComposite(parent, parent - .getFont(), 1, 1, GridData.FILL_HORIZONTAL); + final Composite composite = SWTFactory.createComposite(parent, + parent.getFont(), 1, 1, GridData.FILL_HORIZONTAL); createDbgpGroup(composite); createHotCodeReplaceGroup(composite); @@ -263,6 +266,7 @@ public class ScriptDebugConfigurationBlock extends return composite; } + @Override public void initialize() { super.initialize(); @@ -286,12 +290,14 @@ public class ScriptDebugConfigurationBlock extends } } + @Override public void performDefaults() { fAlertHCRFailed.setSelection(true); fAlertHCRNotSupported.setSelection(true); super.performDefaults(); } + @Override public void performOk() { super.performOk(); @@ -317,8 +323,8 @@ public class ScriptDebugConfigurationBlock extends store.setValue(DLTKDebugPreferenceConstants.PREF_DBGP_PORT, DLTKDebugPreferenceConstants.DBGP_AVAILABLE_PORT); } else { - store.setValue(DLTKDebugPreferenceConstants.PREF_DBGP_PORT, Integer - .parseInt(portText.getText())); + store.setValue(DLTKDebugPreferenceConstants.PREF_DBGP_PORT, + Integer.parseInt(portText.getText())); } } }
\ No newline at end of file diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/ScriptDebugPreferencePage.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/ScriptDebugPreferencePage.java index be0de3b8c..6f8959a3c 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/ScriptDebugPreferencePage.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/ScriptDebugPreferencePage.java @@ -1,11 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * Copyright (c) 2005, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.debug.ui.preferences; @@ -15,29 +14,35 @@ import org.eclipse.dltk.ui.preferences.AbstractConfigurationBlockPreferencePage; import org.eclipse.dltk.ui.preferences.IPreferenceConfigurationBlock; import org.eclipse.dltk.ui.preferences.OverlayPreferenceStore; -public class ScriptDebugPreferencePage extends - AbstractConfigurationBlockPreferencePage { - +public class ScriptDebugPreferencePage + extends AbstractConfigurationBlockPreferencePage { + public static final String PAGE_ID = "org.eclipse.dltk.preferences.debug"; //$NON-NLS-1$ + @Override protected IPreferenceConfigurationBlock createConfigurationBlock( OverlayPreferenceStore overlayPreferenceStore) { return new ScriptDebugConfigurationBlock(overlayPreferenceStore, this); } + @Override protected String getHelpId() { return null; } + @Override protected void setDescription() { - setDescription(ScriptDebugPreferencesMessages.GeneralPreferencesDescription); + setDescription( + ScriptDebugPreferencesMessages.GeneralPreferencesDescription); } + @Override protected void setPreferenceStore() { - setPreferenceStore(new PreferencesAdapter(DLTKDebugPlugin.getDefault() - .getPluginPreferences())); + setPreferenceStore(new PreferencesAdapter( + DLTKDebugPlugin.getDefault().getPluginPreferences())); } + @Override public boolean performOk() { super.performOk(); DLTKDebugPlugin.getDefault().savePluginPreferences(); diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/ScriptDetailFormattersPreferencePage.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/ScriptDetailFormattersPreferencePage.java index bf3629f4f..ee860889e 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/ScriptDetailFormattersPreferencePage.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/ScriptDetailFormattersPreferencePage.java @@ -19,49 +19,41 @@ import org.eclipse.swt.widgets.Group; /** * Preference page for script detail formatters. - * + * * <p> * Implementations that wish to expose this preference page need only include * the following snippet in their <code>plugin.xml</code>: * </p> - * + * * <pre> * <extension point="org.eclipse.ui.preferencePages"> * <page * category="..." * class="org.eclipse.dltk.debug.ui.preferences.ScriptDetailFormattersPreferencePage:nature_id" * id="..." - * name="..." /> + * name="..." /> * <extension> * </pre> - * + * * @see DLTKDebugPluginPreferenceInitializer */ -public class ScriptDetailFormattersPreferencePage extends - AbstractScriptDebugPreferencePage { - - /* - * @see - * org.eclipse.dltk.ui.preferences.AbstractConfigurationBlockPreferencePage - * #createConfigurationBlock - * (org.eclipse.dltk.ui.preferences.OverlayPreferenceStore) - */ +public class ScriptDetailFormattersPreferencePage + extends AbstractScriptDebugPreferencePage { + + @Override protected IPreferenceConfigurationBlock createConfigurationBlock( OverlayPreferenceStore store) { return new ScriptDetailFormattersConfigurationBlock(store, this); } - /* - * @see - * org.eclipse.dltk.ui.preferences.AbstractConfigurationBlockPreferencePage - * #setDescription() - */ + @Override protected void setDescription() { - setDescription(ScriptDebugPreferencesMessages.ScriptDetailFormattersPreferencePage_description); + setDescription( + ScriptDebugPreferencesMessages.ScriptDetailFormattersPreferencePage_description); } - class ScriptDetailFormattersConfigurationBlock extends - ImprovedAbstractConfigurationBlock { + class ScriptDetailFormattersConfigurationBlock + extends ImprovedAbstractConfigurationBlock { private Button fDetailPaneButton; private Button fInlineAllButton; @@ -73,6 +65,7 @@ public class ScriptDetailFormattersPreferencePage extends super(store, page); } + @Override public Control createControl(Composite parent) { final Composite composite = SWTFactory.createComposite(parent, parent.getFont(), 2, 0, GridData.FILL_BOTH); @@ -82,6 +75,7 @@ public class ScriptDetailFormattersPreferencePage extends return composite; } + @Override public void performOk() { String value = IDLTKDebugUIPreferenceConstants.DETAIL_PANE; if (fInlineAllButton.getSelection()) { @@ -96,6 +90,7 @@ public class ScriptDetailFormattersPreferencePage extends IDLTKDebugUIPreferenceConstants.PREF_SHOW_DETAILS, value); } + @Override protected List createOverlayKeys() { ArrayList keys = new ArrayList(1); keys.add(new OverlayPreferenceStore.OverlayKey( @@ -105,17 +100,16 @@ public class ScriptDetailFormattersPreferencePage extends return keys; } + @Override protected void initializeFields() { super.initializeFields(); initializeLabels(); } private void createLabelPreferences(Composite parent) { - Group group = SWTFactory - .createGroup( - parent, - ScriptDebugPreferencesMessages.ScriptDetailFormattersPreferencePage_1, - 1, 2, GridData.FILL_HORIZONTAL); + Group group = SWTFactory.createGroup(parent, + ScriptDebugPreferencesMessages.ScriptDetailFormattersPreferencePage_1, + 1, 2, GridData.FILL_HORIZONTAL); // Create the 3 detail option radio buttons // TODO: uncomment when inline formatter support added @@ -124,21 +118,17 @@ public class ScriptDetailFormattersPreferencePage extends // group, // ScriptDebugPreferencesMessages. // ScriptDetailFormattersPreferencePage_2); - fInlineAllButton = SWTFactory - .createRadioButton( - group, - ScriptDebugPreferencesMessages.ScriptDetailFormattersPreferencePage_3); - fDetailPaneButton = SWTFactory - .createRadioButton( - group, - ScriptDebugPreferencesMessages.ScriptDetailFormattersPreferencePage_4); + fInlineAllButton = SWTFactory.createRadioButton(group, + ScriptDebugPreferencesMessages.ScriptDetailFormattersPreferencePage_3); + fDetailPaneButton = SWTFactory.createRadioButton(group, + ScriptDebugPreferencesMessages.ScriptDetailFormattersPreferencePage_4); } private void initializeLabels() { IPreferenceStore store = getPreferenceStore(); - String preference = store - .getString(IDLTKDebugUIPreferenceConstants.PREF_SHOW_DETAILS); + String preference = store.getString( + IDLTKDebugUIPreferenceConstants.PREF_SHOW_DETAILS); // TODO: uncomment when inline formatter support added // fInlineFormattersButton diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/ScriptStepFilterPreferencePage.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/ScriptStepFilterPreferencePage.java index 9b8cd5fe3..7be7c5cbb 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/ScriptStepFilterPreferencePage.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/ScriptStepFilterPreferencePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2016 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -23,7 +23,6 @@ import org.eclipse.dltk.core.DLTKCore; import org.eclipse.dltk.core.DLTKLanguageManager; import org.eclipse.dltk.core.IDLTKLanguageToolkit; import org.eclipse.dltk.core.IModelElement; -import org.eclipse.dltk.core.IModelElementVisitor; import org.eclipse.dltk.core.IProjectFragment; import org.eclipse.dltk.core.IScriptModel; import org.eclipse.dltk.core.IType; @@ -41,14 +40,10 @@ import org.eclipse.dltk.ui.util.SWTFactory; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferencePage; -import org.eclipse.jface.viewers.CheckStateChangedEvent; import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.ICheckStateListener; import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.SWT; import org.eclipse.swt.events.KeyAdapter; @@ -60,9 +55,7 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.TableItem; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; @@ -80,21 +73,24 @@ public class ScriptStepFilterPreferencePage extends PreferencePage /** * Content provider for the table. Content consists of instances of * StepFilter. - * + * */ class StepFilterContentProvider implements IStructuredContentProvider { public StepFilterContentProvider() { initTableState(false); } + @Override public Object[] getElements(Object inputElement) { return getAllFiltersFromTable(); } + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } + @Override public void dispose() { } } @@ -122,13 +118,7 @@ public class ScriptStepFilterPreferencePage extends PreferencePage ScriptDebugPreferencesMessages.ScriptStepFilterPreferencePage_description); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse - * .swt.widgets.Composite) - */ + @Override protected Control createContents(Composite parent) { // PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), // IJavaDebugHelpContextIds.JAVA_STEP_FILTER_PREFERENCE_PAGE); @@ -139,18 +129,13 @@ public class ScriptStepFilterPreferencePage extends PreferencePage return composite; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) - */ + @Override public void init(IWorkbench workbench) { } /** * handles the filter button being clicked - * + * * @param event * the clicked event */ @@ -170,10 +155,12 @@ public class ScriptStepFilterPreferencePage extends PreferencePage ScriptDebugPreferencesMessages.ScriptStepFilterPreferencePage__Use_step_filters, null, DebugPlugin.isUseStepFilters(), 2); fUseStepFiltersButton.addSelectionListener(new SelectionListener() { + @Override public void widgetSelected(SelectionEvent e) { setPageEnablement(fUseStepFiltersButton.getSelection()); } + @Override public void widgetDefaultSelected(SelectionEvent e) { } }); @@ -188,23 +175,19 @@ public class ScriptStepFilterPreferencePage extends PreferencePage fTableViewer.setContentProvider(new StepFilterContentProvider()); fTableViewer.setInput(getAllStoredFilters(false)); fTableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH)); - fTableViewer.addCheckStateListener(new ICheckStateListener() { - public void checkStateChanged(CheckStateChangedEvent event) { - ((Filter) event.getElement()).setChecked(event.getChecked()); + fTableViewer + .addCheckStateListener(event -> ((Filter) event.getElement()) + .setChecked(event.getChecked())); + fTableViewer.addSelectionChangedListener(event -> { + ISelection selection = event.getSelection(); + if (selection.isEmpty()) { + fRemoveFilterButton.setEnabled(false); + } else { + fRemoveFilterButton.setEnabled(true); } }); - fTableViewer - .addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - ISelection selection = event.getSelection(); - if (selection.isEmpty()) { - fRemoveFilterButton.setEnabled(false); - } else { - fRemoveFilterButton.setEnabled(true); - } - } - }); fTableViewer.getControl().addKeyListener(new KeyAdapter() { + @Override public void keyPressed(KeyEvent event) { handleFilterViewerKeyPress(event); } @@ -217,7 +200,7 @@ public class ScriptStepFilterPreferencePage extends PreferencePage /** * initializes the checked state of the filters when the dialog opens - * + * * @since 3.2 */ private void initTableState(boolean defaults) { @@ -231,7 +214,7 @@ public class ScriptStepFilterPreferencePage extends PreferencePage /** * Enables or disables the widgets on the page, with the exception of * <code>fUseStepFiltersButton</code> according to the passed boolean - * + * * @param enabled * the new enablement status of the page's widgets * @since 3.2 @@ -249,7 +232,7 @@ public class ScriptStepFilterPreferencePage extends PreferencePage /** * Creates the button for the step filter options - * + * * @param container * the parent container */ @@ -284,31 +267,19 @@ public class ScriptStepFilterPreferencePage extends PreferencePage ScriptDebugPreferencesMessages.ScriptStepFilterPreferencePage_Add__Type____11, ScriptDebugPreferencesMessages.ScriptStepFilterPreferencePage_Choose_a_Java_type_and_add_it_to_step_filters_12, null); - fAddTypeButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - addType(); - } - }); + fAddTypeButton.addListener(SWT.Selection, e -> addType()); // Add package button fAddAllButton = SWTFactory.createPushButton(buttonContainer, ScriptDebugPreferencesMessages.ScriptStepFilterPreferencePage_Add__All____13, ScriptDebugPreferencesMessages.ScriptStepFilterPreferencePage_Choose_a_package_and_add_it_to_step_filters_14, null); - fAddAllButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - addAll(); - } - }); + fAddAllButton.addListener(SWT.Selection, e -> addAll()); // Remove button fRemoveFilterButton = SWTFactory.createPushButton(buttonContainer, ScriptDebugPreferencesMessages.ScriptStepFilterPreferencePage__Remove_15, ScriptDebugPreferencesMessages.ScriptStepFilterPreferencePage_Remove_all_selected_step_filters_16, null); - fRemoveFilterButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - removeFilters(); - } - }); + fRemoveFilterButton.addListener(SWT.Selection, e -> removeFilters()); fRemoveFilterButton.setEnabled(false); Label separator = new Label(buttonContainer, SWT.NONE); @@ -323,21 +294,15 @@ public class ScriptStepFilterPreferencePage extends PreferencePage ScriptDebugPreferencesMessages.ScriptStepFilterPreferencePage__Select_All_1, ScriptDebugPreferencesMessages.ScriptStepFilterPreferencePage_Selects_all_step_filters_2, null); - fSelectAllButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - fTableViewer.setAllChecked(true); - } - }); + fSelectAllButton.addListener(SWT.Selection, + e -> fTableViewer.setAllChecked(true)); // De-Select All button fDeselectAllButton = SWTFactory.createPushButton(buttonContainer, ScriptDebugPreferencesMessages.ScriptStepFilterPreferencePage_Deselect_All_3, ScriptDebugPreferencesMessages.ScriptStepFilterPreferencePage_Deselects_all_step_filters_4, null); - fDeselectAllButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - fTableViewer.setAllChecked(false); - } - }); + fDeselectAllButton.addListener(SWT.Selection, + e -> fTableViewer.setAllChecked(false)); } @@ -384,40 +349,37 @@ public class ScriptStepFilterPreferencePage extends PreferencePage IScriptModel model = DLTKCore .create(ResourcesPlugin.getWorkspace().getRoot()); try { - model.accept(new IModelElementVisitor() { - public boolean visit(IModelElement element) { - if (element - .getElementType() == IModelElement.SCRIPT_PROJECT) { - IDLTKLanguageToolkit languageToolkit; - languageToolkit = DLTKLanguageManager - .getLanguageToolkit(element); - if (!fToolkit.getNatureId() - .equals(languageToolkit.getNatureId())) { - return false; - } + model.accept(element -> { + if (element.getElementType() == IModelElement.SCRIPT_PROJECT) { + IDLTKLanguageToolkit languageToolkit; + languageToolkit = DLTKLanguageManager + .getLanguageToolkit(element); + if (!fToolkit.getNatureId() + .equals(languageToolkit.getNatureId())) { + return false; } - if (element - .getElementType() == IModelElement.PROJECT_FRAGMENT) { - IProjectFragment fragment = (IProjectFragment) element; - if (fragment.isExternal()) { - return false; - } + } + if (element + .getElementType() == IModelElement.PROJECT_FRAGMENT) { + IProjectFragment fragment = (IProjectFragment) element; + if (fragment.isExternal()) { + return false; } - if (element.getElementType() == IModelElement.TYPE) { - IType type = (IType) element; - Filter filter; - try { - filter = new Filter(type.getTypeQualifiedName("."), //$NON-NLS-1$ - true, type.getFlags()); - addFilter(filter); - } catch (ModelException e) { - if (DLTKCore.DEBUG) { - e.printStackTrace(); - } + } + if (element.getElementType() == IModelElement.TYPE) { + IType type = (IType) element; + Filter filter; + try { + filter = new Filter(type.getTypeQualifiedName("."), //$NON-NLS-1$ + true, type.getFlags()); + addFilter(filter); + } catch (ModelException e) { + if (DLTKCore.DEBUG) { + e.printStackTrace(); } } - return true; } + return true; }); } catch (ModelException e) { if (DLTKCore.DEBUG) { @@ -464,11 +426,7 @@ public class ScriptStepFilterPreferencePage extends PreferencePage return super.performOk(); } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.PreferencePage#performDefaults() - */ + @Override protected void performDefaults() { boolean stepenabled = DebugUITools.isUseStepFilters(); fUseStepFiltersButton.setSelection(stepenabled); @@ -480,7 +438,7 @@ public class ScriptStepFilterPreferencePage extends PreferencePage /** * adds a single filter to the viewer - * + * * @param filter * the new filter to add * @param checked @@ -511,7 +469,7 @@ public class ScriptStepFilterPreferencePage extends PreferencePage /** * returns all of the filters from the table, this includes ones that have * not yet been saved - * + * * @return a possibly empty lits of filters fron the table * @since 3.2 */ @@ -527,7 +485,7 @@ public class ScriptStepFilterPreferencePage extends PreferencePage /** * Returns all of the committed filters - * + * * @return an array of committed filters * @since 3.2 */ @@ -572,6 +530,7 @@ public class ScriptStepFilterPreferencePage extends PreferencePage return filters; } + @Override public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException { fToolkit = DLTKExecuteExtensionHelper.getLanguageToolkit(config, diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/dialogs/CreateStepFilterDialog.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/dialogs/CreateStepFilterDialog.java index 7679f01c9..bccde1c9a 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/dialogs/CreateStepFilterDialog.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/preferences/dialogs/CreateStepFilterDialog.java @@ -1,14 +1,13 @@ /******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. + * Copyright (c) 2004, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ - package org.eclipse.dltk.debug.ui.preferences.dialogs; import org.eclipse.core.runtime.IStatus; @@ -20,8 +19,6 @@ import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.dialogs.StatusDialog; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -66,6 +63,7 @@ public class CreateStepFilterDialog extends StatusDialog { return createStepFilterDialog.filter; } + @Override protected void createButtonsForButtonBar(Composite parent) { okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); @@ -74,6 +72,7 @@ public class CreateStepFilterDialog extends StatusDialog { IDialogConstants.CANCEL_LABEL, false); } + @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); @@ -107,21 +106,17 @@ public class CreateStepFilterDialog extends StatusDialog { text.setLayoutData(gridData); text.setFont(container.getFont()); - text.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - validateChange(); - if (!filterValid) - updateStatus(new StatusInfo( - IStatus.ERROR, - ScriptDebugPreferencesMessages.CreateStepFilterDialog_4)); - else if (isDuplicateFilter(text.getText().trim())) { - updateStatus(new StatusInfo( - IStatus.WARNING, - ScriptDebugPreferencesMessages.CreateStepFilterDialog_5)); - return; - } else - updateStatus(new StatusInfo()); - } + text.addModifyListener(e -> { + validateChange(); + if (!filterValid) + updateStatus(new StatusInfo(IStatus.ERROR, + ScriptDebugPreferencesMessages.CreateStepFilterDialog_4)); + else if (isDuplicateFilter(text.getText().trim())) { + updateStatus(new StatusInfo(IStatus.WARNING, + ScriptDebugPreferencesMessages.CreateStepFilterDialog_5)); + return; + } else + updateStatus(new StatusInfo()); }); return container; @@ -181,18 +176,14 @@ public class CreateStepFilterDialog extends StatusDialog { /** * Returns the name of the section that this dialog stores its settings in - * + * * @return String */ protected String getDialogSettingsSectionName() { return DLTKUIPlugin.PLUGIN_ID + ".CREATE_STEP_FILTER_DIALOG_SECTION"; //$NON-NLS-1$ } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.window.Window#close() - */ + @Override public boolean close() { if (!okClicked) { filterValid = false; @@ -201,11 +192,7 @@ public class CreateStepFilterDialog extends StatusDialog { return super.close(); } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.dialogs.Dialog#getDialogBoundsSettings() - */ + @Override protected IDialogSettings getDialogBoundsSettings() { IDialogSettings settings = DLTKUIPlugin.getDefault() .getDialogSettings(); @@ -217,6 +204,7 @@ public class CreateStepFilterDialog extends StatusDialog { return section; } + @Override protected void okPressed() { okClicked = true; super.okPressed(); diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/DetailFormatter.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/DetailFormatter.java index de8c90491..c6318d538 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/DetailFormatter.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/DetailFormatter.java @@ -4,21 +4,22 @@ package org.eclipse.dltk.internal.debug.ui; * Information about a detail formatter. */ public class DetailFormatter implements Comparable { - + private boolean fEnabled; - + private String fTypeName; - + private String fSnippet; - + public DetailFormatter(String typeName, String snippet, boolean enabled) { - fTypeName= typeName; - fSnippet= snippet; - fEnabled= enabled; + fTypeName = typeName; + fSnippet = snippet; + fEnabled = enabled; } - + /** * Indicate if this pretty should be used or not. + * * @return boolean */ public boolean isEnabled() { @@ -27,6 +28,7 @@ public class DetailFormatter implements Comparable { /** * Returns the code snippet. + * * @return String */ public String getSnippet() { @@ -35,6 +37,7 @@ public class DetailFormatter implements Comparable { /** * Returns the type name. + * * @return String */ public String getTypeName() { @@ -43,33 +46,37 @@ public class DetailFormatter implements Comparable { /** * Sets the enabled flag. - * @param enabled the new value of the flag + * + * @param enabled + * the new value of the flag */ public void setEnabled(boolean enabled) { - fEnabled= enabled; + fEnabled = enabled; } /** * Sets the code snippet. - * @param snippet the snippet to set + * + * @param snippet + * the snippet to set */ public void setSnippet(String snippet) { - fSnippet= snippet; + fSnippet = snippet; } /** * Sets the type name. - * @param typeName the type name to set + * + * @param typeName + * the type name to set */ public void setTypeName(String typeName) { - fTypeName= typeName; + fTypeName = typeName; } - /** - * @see java.lang.Comparable#compareTo(java.lang.Object) - */ + @Override public int compareTo(Object another) { - DetailFormatter detailFormatter= (DetailFormatter)another; + DetailFormatter detailFormatter = (DetailFormatter) another; if (fTypeName == null) { if (detailFormatter.fTypeName == null) { return 0; diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ErrorDialogWithToggle.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ErrorDialogWithToggle.java index af9769576..6f3b3c566 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ErrorDialogWithToggle.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ErrorDialogWithToggle.java @@ -1,5 +1,5 @@ package org.eclipse.dltk.internal.debug.ui; - + import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.IDialogConstants; @@ -12,70 +12,73 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; /** - * An error dialog which allows the user to set - * a boolean preference. - * - * This is typically used to set a preference that - * determines if the dialog should be shown in - * the future + * An error dialog which allows the user to set a boolean preference. + * + * This is typically used to set a preference that determines if the dialog + * should be shown in the future */ public class ErrorDialogWithToggle extends ErrorDialog { /** - * The preference key which is set by the toggle button. - * This key must be a boolean preference in the preference store. + * The preference key which is set by the toggle button. This key must be a + * boolean preference in the preference store. */ - private String fPreferenceKey= null; + private String fPreferenceKey = null; /** * The message displayed to the user, with the toggle button */ - private String fToggleMessage= null; - private Button fToggleButton= null; + private String fToggleMessage = null; + private Button fToggleButton = null; /** * The preference store which will be affected by the toggle button */ - IPreferenceStore fStore= null; + IPreferenceStore fStore = null; - public ErrorDialogWithToggle(Shell parentShell, String dialogTitle, String message, IStatus status, String preferenceKey, String toggleMessage, IPreferenceStore store) { - super(parentShell, dialogTitle, message, status, IStatus.WARNING | IStatus.ERROR | IStatus.INFO); - fStore= store; - fPreferenceKey= preferenceKey; - fToggleMessage= toggleMessage; + public ErrorDialogWithToggle(Shell parentShell, String dialogTitle, + String message, IStatus status, String preferenceKey, + String toggleMessage, IPreferenceStore store) { + super(parentShell, dialogTitle, message, status, + IStatus.WARNING | IStatus.ERROR | IStatus.INFO); + fStore = store; + fPreferenceKey = preferenceKey; + fToggleMessage = toggleMessage; } + @Override protected Control createDialogArea(Composite parent) { - Composite dialogComposite= (Composite) super.createDialogArea(parent); + Composite dialogComposite = (Composite) super.createDialogArea(parent); dialogComposite.setFont(parent.getFont()); setToggleButton(createCheckButton(dialogComposite, fToggleMessage)); getToggleButton().setSelection(!fStore.getBoolean(fPreferenceKey)); applyDialogFont(dialogComposite); return dialogComposite; } - + /** - * Creates a button with the given label and sets the default - * configuration data. + * Creates a button with the given label and sets the default configuration + * data. */ private Button createCheckButton(Composite parent, String label) { - Button button= new Button(parent, SWT.CHECK | SWT.LEFT); - button.setText(label); + Button button = new Button(parent, SWT.CHECK | SWT.LEFT); + button.setText(label); GridData data = new GridData(SWT.NONE); - data.horizontalSpan= 2; - data.horizontalAlignment= GridData.CENTER; + data.horizontalSpan = 2; + data.horizontalAlignment = GridData.CENTER; button.setLayoutData(data); button.setFont(parent.getFont()); - + return button; } + @Override protected void buttonPressed(int id) { - if (id == IDialogConstants.OK_ID) { // was the OK button pressed? + if (id == IDialogConstants.OK_ID) { // was the OK button pressed? storePreference(); } super.buttonPressed(id); } - + private void storePreference() { fStore.setValue(fPreferenceKey, !getToggleButton().getSelection()); } @@ -87,10 +90,8 @@ public class ErrorDialogWithToggle extends ErrorDialog { protected void setToggleButton(Button button) { fToggleButton = button; } - - /** - * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) - */ + + @Override protected void createButtonsForButtonBar(Composite parent) { super.createButtonsForButtonBar(parent); getButton(IDialogConstants.OK_ID).setFocus(); diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/HotCodeReplaceErrorDialog.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/HotCodeReplaceErrorDialog.java index 9e1f2a150..9a12b6f87 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/HotCodeReplaceErrorDialog.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/HotCodeReplaceErrorDialog.java @@ -15,85 +15,92 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Shell; /** - * An error dialog reporting a problem with a debug - * target which gives the user the option to continue - * or terminate/disconnect or restart the target. + * An error dialog reporting a problem with a debug target which gives the user + * the option to continue or terminate/disconnect or restart the target. */ public class HotCodeReplaceErrorDialog extends ErrorDialogWithToggle { protected IDebugTarget target; - // The IDs of the buttons. Set to the sum of the other possible IDs generated by + // The IDs of the buttons. Set to the sum of the other possible IDs + // generated by // this dialog to ensure the IDs' uniqueness. - protected int TERMINATE_ID= IDialogConstants.OK_ID + IDialogConstants.DETAILS_ID + IDialogConstants.CANCEL_ID; - protected int DISCONNECT_ID= TERMINATE_ID + 1; - protected int RESTART_ID= TERMINATE_ID + 2; + protected int TERMINATE_ID = IDialogConstants.OK_ID + + IDialogConstants.DETAILS_ID + IDialogConstants.CANCEL_ID; + protected int DISCONNECT_ID = TERMINATE_ID + 1; + protected int RESTART_ID = TERMINATE_ID + 2; /** - * Creates a new dialog which can terminate, disconnect or restart the given debug target. - * - * @param target the debug target - * @see ErrorDialogWithToggle#ErrorDialogWithToggle(Shell, String, String, IStatus, String, String, IPreferenceStore) + * Creates a new dialog which can terminate, disconnect or restart the given + * debug target. + * + * @param target + * the debug target + * @see ErrorDialogWithToggle#ErrorDialogWithToggle(Shell, String, String, + * IStatus, String, String, IPreferenceStore) */ - public HotCodeReplaceErrorDialog(Shell parentShell, String dialogTitle, String message, IStatus status, String preferenceKey, String toggleMessage, IPreferenceStore store, IDebugTarget target) { - super(parentShell, dialogTitle, message, status, preferenceKey, toggleMessage, store); + public HotCodeReplaceErrorDialog(Shell parentShell, String dialogTitle, + String message, IStatus status, String preferenceKey, + String toggleMessage, IPreferenceStore store, IDebugTarget target) { + super(parentShell, dialogTitle, message, status, preferenceKey, + toggleMessage, store); this.target = target; } - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) - */ + @Override protected void createButtonsForButtonBar(Composite parent) { super.createButtonsForButtonBar(parent); - getButton(IDialogConstants.OK_ID).setText(Messages.HotCodeReplaceErrorDialog_continue); - boolean canTerminate= target.canTerminate(); - boolean canDisconnect= target.canDisconnect(); + getButton(IDialogConstants.OK_ID) + .setText(Messages.HotCodeReplaceErrorDialog_continue); + boolean canTerminate = target.canTerminate(); + boolean canDisconnect = target.canDisconnect(); if (canTerminate) { - createButton(parent, TERMINATE_ID, Messages.HotCodeReplaceErrorDialog_terminate, false); - } + createButton(parent, TERMINATE_ID, + Messages.HotCodeReplaceErrorDialog_terminate, false); + } if (canDisconnect) { - createButton(parent, DISCONNECT_ID, Messages.HotCodeReplaceErrorDialog_disconnect, false); + createButton(parent, DISCONNECT_ID, + Messages.HotCodeReplaceErrorDialog_disconnect, false); } if (canTerminate && !canDisconnect) { - createButton(parent, RESTART_ID, Messages.HotCodeReplaceErrorDialog_restart, false); + createButton(parent, RESTART_ID, + Messages.HotCodeReplaceErrorDialog_restart, false); } } - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int) - */ + @Override protected void buttonPressed(final int id) { if (id == TERMINATE_ID || id == DISCONNECT_ID || id == RESTART_ID) { final DebugException[] ex = new DebugException[1]; final String[] operation = new String[1]; ex[0] = null; - Runnable r = new Runnable() { - public void run() { - try { - if (id == TERMINATE_ID) { - operation[0]= Messages.HotCodeReplaceErrorDialog_terminate2; - target.terminate(); - } else if (id == DISCONNECT_ID){ - operation[0]= Messages.HotCodeReplaceErrorDialog_disconnect2; - target.disconnect(); - } else { - operation[0]= Messages.HotCodeReplaceErrorDialog_restart2; - ILaunch launch = target.getLaunch(); - launch.terminate(); - ILaunchConfiguration config = launch.getLaunchConfiguration(); - if (config != null && config.exists()) { - DebugUITools.launch(config, launch.getLaunchMode()); - } + Runnable r = () -> { + try { + if (id == TERMINATE_ID) { + operation[0] = Messages.HotCodeReplaceErrorDialog_terminate2; + target.terminate(); + } else if (id == DISCONNECT_ID) { + operation[0] = Messages.HotCodeReplaceErrorDialog_disconnect2; + target.disconnect(); + } else { + operation[0] = Messages.HotCodeReplaceErrorDialog_restart2; + ILaunch launch = target.getLaunch(); + launch.terminate(); + ILaunchConfiguration config = launch + .getLaunchConfiguration(); + if (config != null && config.exists()) { + DebugUITools.launch(config, launch.getLaunchMode()); } - } catch (DebugException e) { - ex[0] = e; } + } catch (DebugException e) { + ex[0] = e; } }; BusyIndicator.showWhile(getShell().getDisplay(), r); if (ex[0] != null) { - DLTKDebugUIPlugin.errorDialog(NLS.bind( - Messages.HotCodeReplaceErrorDialog_failed, operation), - ex[0].getStatus()); + DLTKDebugUIPlugin.errorDialog( + NLS.bind(Messages.HotCodeReplaceErrorDialog_failed, + operation), + ex[0].getStatus()); } okPressed(); } else { diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ScriptDebugHover.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ScriptDebugHover.java index da8802c9a..ec0c584b0 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ScriptDebugHover.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ScriptDebugHover.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2016 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -28,13 +28,11 @@ import org.eclipse.dltk.ui.DLTKUIPlugin; import org.eclipse.dltk.ui.text.hover.IScriptEditorTextHover; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.text.DefaultInformationControl; -import org.eclipse.jface.text.IInformationControl; import org.eclipse.jface.text.IInformationControlCreator; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextHoverExtension; import org.eclipse.jface.text.ITextViewer; import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.editors.text.EditorsUI; @@ -44,10 +42,12 @@ public abstract class ScriptDebugHover private IEditorPart editor; + @Override public void setEditor(IEditorPart editor) { this.editor = editor; } + @Override public IRegion getHoverRegion(final ITextViewer textViewer, int offset) { return ScriptWordFinder.findWord(textViewer.getDocument(), offset); } @@ -55,7 +55,7 @@ public abstract class ScriptDebugHover /** * Returns the stack frame in which to search for variables, or * <code>null</code> if none. - * + * * @return the stack frame in which to search for variables, or * <code>null</code> if none */ @@ -67,6 +67,7 @@ public abstract class ScriptDebugHover return null; } + @Override public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { IScriptStackFrame frame = getFrame(); if (frame == null || editor == null) @@ -165,7 +166,7 @@ public abstract class ScriptDebugHover /** * Returns the value of this filters preference (on/off) for the given view. - * + * * @param part * @return boolean */ @@ -183,14 +184,11 @@ public abstract class ScriptDebugHover return value; } + @Override public IInformationControlCreator getHoverControlCreator() { - return new IInformationControlCreator() { - public IInformationControl createInformationControl(Shell parent) { - return new DefaultInformationControl(parent, SWT.NONE, - new HTMLTextPresenter(true), - EditorsUI.getTooltipAffordanceString()); - } - }; + return parent -> new DefaultInformationControl(parent, SWT.NONE, + new HTMLTextPresenter(true), + EditorsUI.getTooltipAffordanceString()); } /** diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ScriptDebugOptionsManager.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ScriptDebugOptionsManager.java index dbcf0f407..b9cb4e3f0 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ScriptDebugOptionsManager.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ScriptDebugOptionsManager.java @@ -1,11 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * Copyright (c) 2005, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.internal.debug.ui; @@ -17,7 +16,6 @@ import org.eclipse.core.resources.IMarkerDelta; import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.debug.core.DebugEvent; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.IBreakpointsListener; @@ -43,9 +41,9 @@ import org.eclipse.dltk.ui.DLTKUIPlugin; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.viewers.ILabelProvider; -public class ScriptDebugOptionsManager implements IDebugEventSetListener, - IPropertyChangeListener, IScriptBreakpointListener, ILaunchListener, - IBreakpointsListener { +public class ScriptDebugOptionsManager + implements IDebugEventSetListener, IPropertyChangeListener, + IScriptBreakpointListener, ILaunchListener, IBreakpointsListener { private static ScriptDebugOptionsManager instance; @@ -58,16 +56,14 @@ public class ScriptDebugOptionsManager implements IDebugEventSetListener, protected void updateBreakpoints(final IBreakpoint[] breakpoints, final IBreakpointUpdater updater) { - IWorkspaceRunnable runnable = new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) throws CoreException { - for (int i = 0; i < breakpoints.length; i++) { - IBreakpoint breakpoint = breakpoints[i]; - if (breakpoint instanceof IScriptBreakpoint) { - try { - updater.update((IScriptBreakpoint) breakpoint); - } catch (CoreException e) { - DLTKDebugUIPlugin.log(e); - } + IWorkspaceRunnable runnable = monitor -> { + for (int i = 0; i < breakpoints.length; i++) { + IBreakpoint breakpoint = breakpoints[i]; + if (breakpoint instanceof IScriptBreakpoint) { + try { + updater.update((IScriptBreakpoint) breakpoint); + } catch (CoreException e) { + DLTKDebugUIPlugin.log(e); } } } @@ -81,61 +77,51 @@ public class ScriptDebugOptionsManager implements IDebugEventSetListener, } private void updateBreakpointMessages(final IBreakpoint[] breakpoints) { - updateBreakpoints(breakpoints, new IBreakpointUpdater() { - public void update(IScriptBreakpoint breakpoint) - throws CoreException { - final String message = fLabelProvider.getText(breakpoint); - breakpoint.setMessage(message); - } + updateBreakpoints(breakpoints, breakpoint -> { + final String message = fLabelProvider.getText(breakpoint); + breakpoint.setMessage(message); }); } protected void updateBreakpointHitCounts(final IBreakpoint[] breakpoints, final IScriptThread thread) { - updateBreakpoints(breakpoints, new IBreakpointUpdater() { - public void update(IScriptBreakpoint breakpoint) - throws CoreException { + updateBreakpoints(breakpoints, breakpoint -> { - IDbgpBreakpoint br = null; + IDbgpBreakpoint br = null; - if (breakpoint instanceof IScriptMethodEntryBreakpoint) { - IScriptMethodEntryBreakpoint entryBreakpoint = (IScriptMethodEntryBreakpoint) breakpoint; + if (breakpoint instanceof IScriptMethodEntryBreakpoint) { + IScriptMethodEntryBreakpoint entryBreakpoint = (IScriptMethodEntryBreakpoint) breakpoint; - final String entryId = entryBreakpoint - .getEntryBreakpointId(); - if (entryId != null) { - br = thread.getDbgpBreakpoint(entryId); - } + final String entryId = entryBreakpoint.getEntryBreakpointId(); + if (entryId != null) { + br = thread.getDbgpBreakpoint(entryId); + } - final String exitId = entryBreakpoint.getExitBreakpointId(); - if (exitId != null) { - br = thread.getDbgpBreakpoint(exitId); - } - } else if (breakpoint instanceof IScriptSpawnpoint) { - // NOP - } else { - String id = breakpoint.getId(thread.getDbgpSession()); - if (id != null && id.length() != 0) { - br = thread.getDbgpBreakpoint(id); - } + final String exitId = entryBreakpoint.getExitBreakpointId(); + if (exitId != null) { + br = thread.getDbgpBreakpoint(exitId); } - if (br != null) { - breakpoint.setHitCount(thread.getDbgpSession(), br - .getHitCount()); + } else if (breakpoint instanceof IScriptSpawnpoint) { + // NOP + } else { + String id = breakpoint.getId(thread.getDbgpSession()); + if (id != null && id.length() != 0) { + br = thread.getDbgpBreakpoint(id); } } + if (br != null) { + breakpoint.setHitCount(thread.getDbgpSession(), + br.getHitCount()); + } }); } protected void updateBreakpoinInfoToDefault(IBreakpoint[] breakpoints) { - updateBreakpoints(breakpoints, new IBreakpointUpdater() { - public void update(IScriptBreakpoint breakpoint) - throws CoreException { - breakpoint.clearSessionInfo(); - } - }); + updateBreakpoints(breakpoints, + breakpoint -> breakpoint.clearSessionInfo()); } + @Override public void handleDebugEvents(DebugEvent[] events) { for (int i = 0; i < events.length; ++i) { DebugEvent event = events[i]; @@ -189,25 +175,30 @@ public class ScriptDebugOptionsManager implements IDebugEventSetListener, } } + @Override public void launchAdded(ILaunch launch) { // TODO Auto-generated method stub } + @Override public void launchChanged(ILaunch launch) { // TODO Auto-generated method stub } + @Override public void launchRemoved(ILaunch launch) { // TODO Auto-generated method stub } + @Override public void breakpointsAdded(IBreakpoint[] breakpoints) { List list = new ArrayList(); for (int i = 0; i < breakpoints.length; i++) { try { IBreakpoint breakpoint = breakpoints[i]; if (breakpoint instanceof IScriptBreakpoint - && ((IScriptBreakpoint) breakpoint).getMessage() == null) { + && ((IScriptBreakpoint) breakpoint) + .getMessage() == null) { list.add(breakpoint); } } catch (CoreException e) { @@ -216,16 +207,18 @@ public class ScriptDebugOptionsManager implements IDebugEventSetListener, } if (!list.isEmpty()) { - updateBreakpointMessages((IBreakpoint[]) list - .toArray(new IBreakpoint[list.size()])); + updateBreakpointMessages( + (IBreakpoint[]) list.toArray(new IBreakpoint[list.size()])); } } + @Override public void breakpointsChanged(IBreakpoint[] breakpoints, IMarkerDelta[] deltas) { updateBreakpointMessages(breakpoints); } + @Override public void breakpointsRemoved(IBreakpoint[] breakpoints, IMarkerDelta[] deltas) { } @@ -263,7 +256,9 @@ public class ScriptDebugOptionsManager implements IDebugEventSetListener, DLTKDebugUIPlugin.getUniqueIdentifier() + ".debuggerActive"); //$NON-NLS-1$ } - public void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event) { + @Override + public void propertyChange( + org.eclipse.jface.util.PropertyChangeEvent event) { // TODO: } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ScriptDetailFormattersManager.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ScriptDetailFormattersManager.java index e5f216fcb..058f13d53 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ScriptDetailFormattersManager.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ScriptDetailFormattersManager.java @@ -15,8 +15,6 @@ import org.eclipse.dltk.core.DLTKCore; import org.eclipse.dltk.core.SimpleDLTKExtensionManager; import org.eclipse.dltk.core.SimpleDLTKExtensionManager.ElementInfo; import org.eclipse.dltk.debug.core.eval.IScriptEvaluationCommand; -import org.eclipse.dltk.debug.core.eval.IScriptEvaluationListener; -import org.eclipse.dltk.debug.core.eval.IScriptEvaluationResult; import org.eclipse.dltk.debug.core.model.IScriptStackFrame; import org.eclipse.dltk.debug.core.model.IScriptThread; import org.eclipse.dltk.debug.core.model.IScriptValue; @@ -42,9 +40,9 @@ public class ScriptDetailFormattersManager implements IPropertyChangeListener { /** * Return the default detail formatters manager. - * + * * @param natureId - * + * * @return default detail formatters manager. */ static public ScriptDetailFormattersManager getDefault(String natureId) { @@ -117,24 +115,22 @@ public class ScriptDetailFormattersManager implements IPropertyChangeListener { listener.detailComputed(value, getValueText(value)); return; } - command.asyncEvaluate(new IScriptEvaluationListener() { - public void evaluationComplete(IScriptEvaluationResult result) { - if (result == null) - return; - - IScriptValue resultValue = result.getValue(); - if (resultValue != null) { - listener.detailComputed(value, getValueText(resultValue)); - } else { - try { - listener.detailComputed(value, - value.getValueString()/* CANNOT_EVALUATE */); - } catch (DebugException e) { - if (DLTKCore.DEBUG) { - e.printStackTrace(); - } - listener.detailComputed(value, CANNOT_EVALUATE); + command.asyncEvaluate(result -> { + if (result == null) + return; + + IScriptValue resultValue = result.getValue(); + if (resultValue != null) { + listener.detailComputed(value, getValueText(resultValue)); + } else { + try { + listener.detailComputed(value, + value.getValueString()/* CANNOT_EVALUATE */); + } catch (DebugException e) { + if (DLTKCore.DEBUG) { + e.printStackTrace(); } + listener.detailComputed(value, CANNOT_EVALUATE); } } }); @@ -164,6 +160,7 @@ public class ScriptDetailFormattersManager implements IPropertyChangeListener { formatters.remove(formatter.getTypeName()); } + @Override public void propertyChange(PropertyChangeEvent event) { String property = event.getProperty(); if (handlesPropertyEvent(property)) { diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ScriptEvaluationContextManager.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ScriptEvaluationContextManager.java index 5392615a8..823e0f280 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ScriptEvaluationContextManager.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ScriptEvaluationContextManager.java @@ -1,12 +1,11 @@ /******************************************************************************* - * Copyright (c) 2000, 2016 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * *******************************************************************************/ - package org.eclipse.dltk.internal.debug.ui; import java.util.ArrayList; @@ -53,46 +52,47 @@ public class ScriptEvaluationContextManager protected ScriptEvaluationContextManager() { DebugUITools.getDebugContextManager().addDebugContextListener(this); - pageToContextMap = new HashMap<IWorkbenchPage, IScriptStackFrame>(); + pageToContextMap = new HashMap<>(); } public static void startup() { - Runnable r = new Runnable() { - public void run() { - if (manager == null) { - manager = new ScriptEvaluationContextManager(); + Runnable r = () -> { + if (manager == null) { + manager = new ScriptEvaluationContextManager(); - IWorkbench workbench = PlatformUI.getWorkbench(); - IWorkbenchWindow[] windows = workbench - .getWorkbenchWindows(); - for (int i = 0; i < windows.length; i++) { - manager.windowOpened(windows[i]); - } - workbench.addWindowListener(manager); - manager.activeWindow = workbench.getActiveWorkbenchWindow(); + IWorkbench workbench = PlatformUI.getWorkbench(); + IWorkbenchWindow[] windows = workbench.getWorkbenchWindows(); + for (int i = 0; i < windows.length; i++) { + manager.windowOpened(windows[i]); } + workbench.addWindowListener(manager); + manager.activeWindow = workbench.getActiveWorkbenchWindow(); } }; DLTKDebugUIPlugin.getStandardDisplay().asyncExec(r); } + @Override public void windowActivated(IWorkbenchWindow window) { activeWindow = window; } + @Override public void windowClosed(IWorkbenchWindow window) { } + @Override public void windowDeactivated(IWorkbenchWindow window) { } + @Override public void windowOpened(IWorkbenchWindow window) { } /** * Sets the evaluation context for the given page, and notes that a valid * execution context exists. - * + * * @param page * @param frame */ @@ -120,7 +120,7 @@ public class ScriptEvaluationContextManager /** * Removes an evaluation context for the given page, and determines if any * valid execution context remain. - * + * * @param page */ private void removeContext(IWorkbenchPage page) { @@ -154,7 +154,7 @@ public class ScriptEvaluationContextManager * <li>stack frame in active page of other window</li> * <li>stack frame in page of other windows</li> * </ol> - * + * * @param part * the part that the evaluation action was invoked from * @return the stack frame that supplies an evaluation context, or @@ -179,7 +179,7 @@ public class ScriptEvaluationContextManager * <li>stack frame in active page of another window</li> * <li>stack frame in a page of another window</li> * </ol> - * + * * @param window * the window that the evaluation action was invoked from, or * <code>null</code> if the current window should be consulted @@ -189,7 +189,7 @@ public class ScriptEvaluationContextManager */ public static IScriptStackFrame getEvaluationContext( IWorkbenchWindow window) { - List<IWorkbenchWindow> alreadyVisited = new ArrayList<IWorkbenchWindow>(); + List<IWorkbenchWindow> alreadyVisited = new ArrayList<>(); if (window == null) { window = manager.activeWindow; } @@ -231,6 +231,7 @@ public class ScriptEvaluationContextManager return frame; } + @Override public void debugContextChanged(DebugContextEvent event) { if ((event.getFlags() & DebugContextEvent.ACTIVATED) > 0) { IWorkbenchPart part = event.getDebugContextProvider().getPart(); diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ScriptHotCodeReplaceListener.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ScriptHotCodeReplaceListener.java index c32ee7fdb..6117d6477 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ScriptHotCodeReplaceListener.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ScriptHotCodeReplaceListener.java @@ -13,25 +13,18 @@ import org.eclipse.swt.widgets.Shell; public class ScriptHotCodeReplaceListener implements IHotCodeReplaceListener { - /** - * @see IScriptHotCodeReplaceListener#hotCodeReplaceSucceeded(IScriptDebugTarget) - */ + @Override public void hotCodeReplaceSucceeded(IScriptDebugTarget target) { } - /** - * @see IScriptHotCodeReplaceListener#hotCodeReplaceFailed(IScriptDebugTarget, - * DebugException) - */ + @Override public void hotCodeReplaceFailed(final IScriptDebugTarget target, final DebugException exception) { if ((exception != null && !DLTKDebugUIPlugin.getDefault() .getPreferenceStore().getBoolean( IDLTKDebugUIPreferenceConstants.PREF_ALERT_HCR_FAILED)) - || ((exception == null) && !DLTKDebugUIPlugin - .getDefault() - .getPreferenceStore() - .getBoolean( + || ((exception == null) && !DLTKDebugUIPlugin.getDefault() + .getPreferenceStore().getBoolean( IDLTKDebugUIPreferenceConstants.PREF_ALERT_HCR_NOT_SUPPORTED))) { return; } @@ -47,39 +40,34 @@ public class ScriptHotCodeReplaceListener implements IHotCodeReplaceListener { final String launchName = target.getLaunch().getLaunchConfiguration() .getName(); if (exception == null) { - status = new Status( - IStatus.WARNING, - DLTKDebugUIPlugin.getUniqueIdentifier(), - IStatus.WARNING, + status = new Status(IStatus.WARNING, + DLTKDebugUIPlugin.getUniqueIdentifier(), IStatus.WARNING, Messages.ScriptHotCodeReplaceListener_theTargetDoesntSupportHotCodeReplace, null); preference = IDLTKDebugUIPreferenceConstants.PREF_ALERT_HCR_NOT_SUPPORTED; alertMessage = Messages.ScriptHotCodeReplaceListener_doNotShowErrorWhenHotCodeReplaceIsNotSupported; } else { - status = new Status(IStatus.WARNING, DLTKDebugUIPlugin - .getUniqueIdentifier(), IStatus.WARNING, exception - .getMessage(), exception.getCause()); + status = new Status(IStatus.WARNING, + DLTKDebugUIPlugin.getUniqueIdentifier(), IStatus.WARNING, + exception.getMessage(), exception.getCause()); preference = IDLTKDebugUIPreferenceConstants.PREF_ALERT_HCR_FAILED; alertMessage = Messages.ScriptHotCodeReplaceListener_doNotShowErrorWhenHotCodeReplaceFails; } final String title = Messages.ScriptHotCodeReplaceListener_hotCodeReplaceFailed; - final String message = NLS - .bind( - Messages.ScriptHotCodeReplaceListener_someCodeChangesCannotBeHotSwappedIntoARunningInterpreter, - launchName); - display.asyncExec(new Runnable() { - public void run() { - if (display.isDisposed()) { - return; - } - Shell shell = DLTKDebugUIPlugin.getActiveWorkbenchShell(); - HotCodeReplaceErrorDialog dialog = new HotCodeReplaceErrorDialog( - shell, title, message, status, preference, - alertMessage, DLTKDebugUIPlugin.getDefault() - .getPreferenceStore(), target); - dialog.setBlockOnOpen(false); - dialog.open(); + final String message = NLS.bind( + Messages.ScriptHotCodeReplaceListener_someCodeChangesCannotBeHotSwappedIntoARunningInterpreter, + launchName); + display.asyncExec(() -> { + if (display.isDisposed()) { + return; } + Shell shell = DLTKDebugUIPlugin.getActiveWorkbenchShell(); + HotCodeReplaceErrorDialog dialog = new HotCodeReplaceErrorDialog( + shell, title, message, status, preference, alertMessage, + DLTKDebugUIPlugin.getDefault().getPreferenceStore(), + target); + dialog.setBlockOnOpen(false); + dialog.open(); }); } } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ScriptRunToLineAdapter.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ScriptRunToLineAdapter.java index 297cf36a9..23247408c 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ScriptRunToLineAdapter.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ScriptRunToLineAdapter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2016 IBM Corporation and others. + * Copyright (c) 2005, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -49,11 +49,13 @@ public class ScriptRunToLineAdapter implements IRunToLineTarget { } + @Override public boolean canRunToLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) { return true; } + @Override public void runToLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) throws CoreException { diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/actions/PopupScriptDisplayAction.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/actions/PopupScriptDisplayAction.java index a73b87b19..31eace821 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/actions/PopupScriptDisplayAction.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/actions/PopupScriptDisplayAction.java @@ -1,13 +1,11 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ - package org.eclipse.dltk.internal.debug.ui.actions; import org.eclipse.debug.ui.DebugPopup; @@ -21,70 +19,60 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkbenchPart; -public class PopupScriptDisplayAction extends ScriptDisplayAction { +public class PopupScriptDisplayAction extends ScriptDisplayAction { private static class DisplayPopup extends DebugPopup { private String message; - - public DisplayPopup(String message, Shell shell, Point anchor) { - // TODO: add real commandId - super(shell, anchor, null); - - this.message = message; - } - protected String getActionText() { - return Messages.PopupScriptDisplayAction_moveToDisplayView; + public DisplayPopup(String message, Shell shell, Point anchor) { + // TODO: add real commandId + super(shell, anchor, null); + + this.message = message; } - /*protected void persist() { - IDataDisplay directDisplay = getDirectDataDisplay(); - Display display = DLTKDebugUIPlugin.getStandardDisplay(); + @Override + protected String getActionText() { + return Messages.PopupScriptDisplayAction_moveToDisplayView; + } - if (!display.isDisposed()) { - IDataDisplay dataDisplay = getDataDisplay(); - if (dataDisplay != null) { - if (directDisplay == null) { - dataDisplay.displayExpression(snippet); - } - dataDisplay.displayExpressionValue(resultString); - } - } - }*/ + @Override + protected Control createDialogArea(Composite parent) { + GridData gd = new GridData(GridData.FILL_BOTH); + StyledText text = new StyledText(parent, SWT.MULTI | SWT.READ_ONLY + | SWT.WRAP | SWT.H_SCROLL | SWT.V_SCROLL); + text.setLayoutData(gd); - protected Control createDialogArea(Composite parent) { - GridData gd = new GridData(GridData.FILL_BOTH); - StyledText text = new StyledText(parent, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP | SWT.H_SCROLL | SWT.V_SCROLL); - text.setLayoutData(gd); + text.setForeground(parent.getDisplay() + .getSystemColor(SWT.COLOR_INFO_FOREGROUND)); + text.setBackground(parent.getDisplay() + .getSystemColor(SWT.COLOR_INFO_BACKGROUND)); - text.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND)); - text.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); + text.setText(message); + return text; + } + } - text.setText(message); - return text; - } - } + public PopupScriptDisplayAction() { + super(); + } - public PopupScriptDisplayAction() { - super(); - } + private void showPopup(StyledText textWidget, String message) { + DebugPopup displayPopup = new DisplayPopup(message, getShell(), + getPopupAnchor(textWidget)); + displayPopup.open(); + } - private void showPopup(StyledText textWidget, String message) { - DebugPopup displayPopup = new DisplayPopup(message, getShell(), getPopupAnchor(textWidget)); - displayPopup.open(); - } + @Override + protected void displayStringResult(String currentSnippet, + final String currentResultString) { + IWorkbenchPart part = getPart(); - protected void displayStringResult(String currentSnippet, final String currentResultString) { - IWorkbenchPart part = getPart(); + final StyledText textWidget = getStyledText(part); + if (textWidget != null) { + Display.getDefault().asyncExec( + () -> showPopup(textWidget, currentResultString)); - final StyledText textWidget = getStyledText(part); - if (textWidget != null) { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - showPopup(textWidget, currentResultString); - } - }); - - evaluationCleanup(); - } - } + evaluationCleanup(); + } + } } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/actions/PopupScriptInspectAction.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/actions/PopupScriptInspectAction.java index 89625600b..6bfa77d2f 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/actions/PopupScriptInspectAction.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/actions/PopupScriptInspectAction.java @@ -1,13 +1,11 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ - package org.eclipse.dltk.internal.debug.ui.actions; import org.eclipse.debug.core.model.IExpression; @@ -27,17 +25,16 @@ public class PopupScriptInspectAction extends ScriptInspectAction { displayPopup.open(); } + @Override protected void displayResult(final IScriptEvaluationResult result) { IWorkbenchPart part = getPart(); final StyledText styledText = getStyledText(part); if (styledText != null) { - final IExpression expression = new EvaluatedScriptExpression(result); - DLTKDebugUIPlugin.getStandardDisplay().asyncExec(new Runnable() { - public void run() { - showPopup(styledText, expression); - } - }); + final IExpression expression = new EvaluatedScriptExpression( + result); + DLTKDebugUIPlugin.getStandardDisplay() + .asyncExec(() -> showPopup(styledText, expression)); } evaluationCleanup(); diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/actions/ScriptDisplayAction.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/actions/ScriptDisplayAction.java index a2f8bb0af..ac4932796 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/actions/ScriptDisplayAction.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/actions/ScriptDisplayAction.java @@ -1,22 +1,18 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ - package org.eclipse.dltk.internal.debug.ui.actions; import java.text.MessageFormat; -import org.eclipse.debug.core.model.IValue; import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.IDebugModelPresentation; import org.eclipse.debug.ui.IDebugUIConstants; -import org.eclipse.debug.ui.IValueDetailListener; import org.eclipse.dltk.debug.core.eval.IScriptEvaluationResult; import org.eclipse.dltk.debug.core.model.IScriptValue; import org.eclipse.dltk.debug.ui.DLTKDebugUIPlugin; @@ -24,27 +20,26 @@ import org.eclipse.swt.widgets.Display; public abstract class ScriptDisplayAction extends ScriptEvaluationAction { public static String trimDisplayResult(String result) { - int max = DebugUITools.getPreferenceStore().getInt( - IDebugUIConstants.PREF_MAX_DETAIL_LENGTH); + int max = DebugUITools.getPreferenceStore() + .getInt(IDebugUIConstants.PREF_MAX_DETAIL_LENGTH); if (max > 0 && result.length() > max) { result = result.substring(0, max) + "..."; //$NON-NLS-1$ } return result; } + @Override protected void displayResult(final IScriptEvaluationResult result) { // Errors if (result.hasErrors()) { final Display display = DLTKDebugUIPlugin.getStandardDisplay(); - display.asyncExec(new Runnable() { - public void run() { - if (display.isDisposed()) { - return; - } - - reportErrors(result); - evaluationCleanup(); + display.asyncExec(() -> { + if (display.isDisposed()) { + return; } + + reportErrors(result); + evaluationCleanup(); }); return; } @@ -54,14 +49,14 @@ public abstract class ScriptDisplayAction extends ScriptEvaluationAction { final String typeName = resultValue.getType().getName(); - IDebugModelPresentation presentation = getDebugModelPresentation(result - .getThread().getModelIdentifier()); - presentation.computeDetail(resultValue, new IValueDetailListener() { - public void detailComputed(IValue value, String result) { - displayStringResult(snippet, MessageFormat.format(Messages.ScriptDisplayAction_displayResult, - new Object[] { typeName, trimDisplayResult(result) })); - } - }); + IDebugModelPresentation presentation = getDebugModelPresentation( + result.getThread().getModelIdentifier()); + presentation.computeDetail(resultValue, + (value, result1) -> displayStringResult(snippet, + MessageFormat.format( + Messages.ScriptDisplayAction_displayResult, + new Object[] { typeName, + trimDisplayResult(result1) }))); presentation.dispose(); // displayStringResult(snippet, getExceptionMessage(x)); diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/actions/ScriptEvaluationAction.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/actions/ScriptEvaluationAction.java index 0a9b3544e..ca2fab3df 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/actions/ScriptEvaluationAction.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/actions/ScriptEvaluationAction.java @@ -1,19 +1,17 @@ /******************************************************************************* - * Copyright (c) 2000, 2016 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * *******************************************************************************/ - package org.eclipse.dltk.internal.debug.ui.actions; import java.lang.reflect.InvocationTargetException; import java.util.Iterator; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.debug.ui.DebugUITools; @@ -242,6 +240,7 @@ public class ScriptEvaluationAction implements IWorkbenchWindowActionDelegate, } // IWorkbenchWindowActionDelegate + @Override public void init(IWorkbenchWindow window) { setWindow(window); @@ -254,6 +253,7 @@ public class ScriptEvaluationAction implements IWorkbenchWindowActionDelegate, update(); } + @Override public void dispose() { // disposeDebugModelPresentation(); @@ -264,6 +264,7 @@ public class ScriptEvaluationAction implements IWorkbenchWindowActionDelegate, } // IObjectActionDelegate + @Override public void setActivePart(IAction action, IWorkbenchPart targetPart) { setAction(action); setPart(targetPart); @@ -271,34 +272,41 @@ public class ScriptEvaluationAction implements IWorkbenchWindowActionDelegate, } // IActionDelegate + @Override public void run(IAction action) { update(); run(); } + @Override public void selectionChanged(IAction action, ISelection selection) { setAction(action); } // IPartListener + @Override public void partActivated(IWorkbenchPart part) { setPart(part); } + @Override public void partBroughtToTop(IWorkbenchPart part) { } + @Override public void partClosed(IWorkbenchPart part) { if (part == getPart()) { setPart(null); } } + @Override public void partDeactivated(IWorkbenchPart part) { } + @Override public void partOpened(IWorkbenchPart part) { } @@ -396,25 +404,22 @@ public class ScriptEvaluationAction implements IWorkbenchWindowActionDelegate, // setNewTargetPart(getTargetPart()); // Preparing runnable - IRunnableWithProgress runnable = new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) - throws InvocationTargetException, InterruptedException { - if (stackFrame.isSuspended()) { - Object selection = getSelectedObject(); - if (!(selection instanceof String)) { - return; - } - String expression = (String) selection; - - IScriptEvaluationEngine engine = stackFrame - .getScriptThread().getEvaluationEngine(); - setEvaluating(true); - engine.asyncEvaluate(expression, stackFrame, - ScriptEvaluationAction.this); - } else { - throw new InvocationTargetException(null, - Messages.ScriptEvaluationAction_threadIsNotSuspended); + IRunnableWithProgress runnable = monitor -> { + if (stackFrame.isSuspended()) { + Object selection = getSelectedObject(); + if (!(selection instanceof String)) { + return; } + String expression = (String) selection; + + IScriptEvaluationEngine engine = stackFrame.getScriptThread() + .getEvaluationEngine(); + setEvaluating(true); + engine.asyncEvaluate(expression, stackFrame, + ScriptEvaluationAction.this); + } else { + throw new InvocationTargetException(null, + Messages.ScriptEvaluationAction_threadIsNotSuspended); } }; @@ -498,6 +503,7 @@ public class ScriptEvaluationAction implements IWorkbenchWindowActionDelegate, } // IScriptEvaluationListener + @Override public void evaluationComplete(IScriptEvaluationResult result) { // if plug-in has shutdown, ignore - see bug# 8693 if (DLTKDebugUIPlugin.getDefault() == null) { @@ -522,11 +528,13 @@ public class ScriptEvaluationAction implements IWorkbenchWindowActionDelegate, } // IEditorActionDelegate + @Override public void setActiveEditor(IAction action, IEditorPart targetEditor) { setEditor((ScriptEditor) targetEditor); } // IViewActionDelegate + @Override public void init(IViewPart view) { setPart(view); } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/actions/ScriptInspectAction.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/actions/ScriptInspectAction.java index e85ceada7..31b26082d 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/actions/ScriptInspectAction.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/actions/ScriptInspectAction.java @@ -1,13 +1,11 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ - package org.eclipse.dltk.internal.debug.ui.actions; import org.eclipse.debug.core.DebugPlugin; @@ -20,19 +18,18 @@ import org.eclipse.swt.widgets.Display; * Places the result of an evaluation in the debug expression view. */ public class ScriptInspectAction extends ScriptEvaluationAction { + @Override protected void displayResult(final IScriptEvaluationResult result) { final Display display = DLTKDebugUIPlugin.getStandardDisplay(); - display.asyncExec(new Runnable() { - public void run() { - if (!display.isDisposed()) { - showExpressionView(); - InspectEvaluatedScriptExpression expression = new InspectEvaluatedScriptExpression( - result); - DebugPlugin.getDefault().getExpressionManager() - .addExpression(expression); - } - evaluationCleanup(); + display.asyncExec(() -> { + if (!display.isDisposed()) { + showExpressionView(); + InspectEvaluatedScriptExpression expression = new InspectEvaluatedScriptExpression( + result); + DebugPlugin.getDefault().getExpressionManager() + .addExpression(expression); } + evaluationCleanup(); }); } } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/actions/ScriptWatchAction.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/actions/ScriptWatchAction.java index 2966283bf..3f6be1204 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/actions/ScriptWatchAction.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/actions/ScriptWatchAction.java @@ -1,13 +1,11 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ - package org.eclipse.dltk.internal.debug.ui.actions; import java.util.Iterator; @@ -27,8 +25,9 @@ public class ScriptWatchAction extends ScriptEvaluationAction { private void createWatchExpression(String snippet) { IWatchExpression expression = DebugPlugin.getDefault() .getExpressionManager().newWatchExpression(snippet); - DebugPlugin.getDefault().getExpressionManager().addExpression(expression); - + DebugPlugin.getDefault().getExpressionManager() + .addExpression(expression); + IAdaptable object = DebugUITools.getDebugContext(); IDebugElement context = null; if (object instanceof IDebugElement) { @@ -36,10 +35,11 @@ public class ScriptWatchAction extends ScriptEvaluationAction { } else if (object instanceof ILaunch) { context = ((ILaunch) object).getDebugTarget(); } - + expression.setExpressionContext(context); } + @Override public void run() { Object selectedObject = getSelectedObject(); @@ -48,8 +48,8 @@ public class ScriptWatchAction extends ScriptEvaluationAction { Iterator elements = selection.iterator(); while (elements.hasNext()) { try { - createWatchExpression(((IScriptVariable) elements.next()) - .getName()); + createWatchExpression( + ((IScriptVariable) elements.next()).getName()); } catch (DebugException e) { DLTKDebugUIPlugin.log(e); return; diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/console/ConsoleRemoveAllTerminatedAction.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/console/ConsoleRemoveAllTerminatedAction.java index 103c28ffe..c2adf45e1 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/console/ConsoleRemoveAllTerminatedAction.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/console/ConsoleRemoveAllTerminatedAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -23,16 +23,14 @@ import org.eclipse.ui.texteditor.IUpdate; /** * ConsoleRemoveAllTerminatedAction */ -public class ConsoleRemoveAllTerminatedAction extends Action implements - IUpdate, ILaunchesListener2 { +public class ConsoleRemoveAllTerminatedAction extends Action + implements IUpdate, ILaunchesListener2 { public void dispose() { DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(this); } - /* - * @see org.eclipse.ui.texteditor.IUpdate#update() - */ + @Override public void update() { ILaunch[] launches = DebugPlugin.getDefault().getLaunchManager() .getLaunches(); @@ -47,9 +45,6 @@ public class ConsoleRemoveAllTerminatedAction extends Action implements } - /* - * @see org.eclipse.jface.action.IAction#run() - */ @Override public void run() { ILaunch[] launches = DebugPlugin.getDefault().getLaunchManager() @@ -64,38 +59,30 @@ public class ConsoleRemoveAllTerminatedAction extends Action implements setToolTipText(ConsoleMessages.ConsoleRemoveAllTerminatedAction_1); setImageDescriptor(DebugPluginImages .getImageDescriptor(IDebugUIConstants.IMG_LCL_REMOVE_ALL)); - setDisabledImageDescriptor(DebugPluginImages - .getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_REMOVE_ALL)); + setDisabledImageDescriptor(DebugPluginImages.getImageDescriptor( + IInternalDebugUIConstants.IMG_DLCL_REMOVE_ALL)); setHoverImageDescriptor(DebugPluginImages .getImageDescriptor(IDebugUIConstants.IMG_LCL_REMOVE_ALL)); DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this); update(); } - /* - * @see ILaunchesListener#launchesRemoved(ILaunch[]) - */ + @Override public void launchesRemoved(ILaunch[] launches) { if (isEnabled()) { update(); } } - /* - * @see ILaunchesListener#launchesAdded(ILaunch[]) - */ + @Override public void launchesAdded(ILaunch[] launches) { } - /* - * @see ILaunchesListener#launchesChanged(ILaunch[]) - */ + @Override public void launchesChanged(ILaunch[] launches) { } - /* - * @see ILaunchesListener2#launchesTerminated(ILaunch[]) - */ + @Override public void launchesTerminated(ILaunch[] launches) { update(); } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/console/ConsoleRemoveLaunchAction.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/console/ConsoleRemoveLaunchAction.java index e29476eea..bf78b1566 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/console/ConsoleRemoveLaunchAction.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/console/ConsoleRemoveLaunchAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -31,8 +31,8 @@ import org.eclipse.ui.console.IConsoleView; /** * ConsoleRemoveTerminatedAction */ -public class ConsoleRemoveLaunchAction extends Action implements - IViewActionDelegate, IConsoleListener, ILaunchesListener2 { +public class ConsoleRemoveLaunchAction extends Action + implements IViewActionDelegate, IConsoleListener, ILaunchesListener2 { private ILaunch fLaunch; @@ -62,8 +62,8 @@ public class ConsoleRemoveLaunchAction extends Action implements public void dispose() { DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(this); - ConsolePlugin.getDefault().getConsoleManager().removeConsoleListener( - this); + ConsolePlugin.getDefault().getConsoleManager() + .removeConsoleListener(this); } public synchronized void update() { @@ -85,6 +85,7 @@ public class ConsoleRemoveLaunchAction extends Action implements } } + @Override public void init(IViewPart view) { if (view instanceof IConsoleView) { fConsoleView = (IConsoleView) view; @@ -92,42 +93,38 @@ public class ConsoleRemoveLaunchAction extends Action implements update(); } + @Override public void run(IAction action) { run(); } + @Override public void selectionChanged(IAction action, ISelection selection) { } + @Override public void consolesAdded(IConsole[] consoles) { } + @Override public void consolesRemoved(IConsole[] consoles) { update(); } - /* - * @see ILaunchesListener2#launchesTerminated(ILaunch[]) - */ + @Override public void launchesTerminated(ILaunch[] launches) { update(); } - /* - * @see ILaunchesListener#launchesRemoved(ILaunch[]) - */ + @Override public void launchesRemoved(ILaunch[] launches) { } - /* - * @see ILaunchesListener#launchesAdded(ILaunch[]) - */ + @Override public void launchesAdded(ILaunch[] launches) { } - /* - * @see ILaunchesListener#launchesChanged(ILaunch[]) - */ + @Override public void launchesChanged(ILaunch[] launches) { } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/console/ConsoleTerminateAction.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/console/ConsoleTerminateAction.java index 2e8c1e2b9..c31d32f49 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/console/ConsoleTerminateAction.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/console/ConsoleTerminateAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -51,13 +51,7 @@ public class ConsoleTerminateAction extends Action implements IUpdate { @Override public void launchesTerminated(ILaunch[] launches) { - PlatformUI.getWorkbench().getDisplay() - .asyncExec(new Runnable() { - @Override - public void run() { - update(); - } - }); + PlatformUI.getWorkbench().getDisplay().asyncExec(() -> update()); } } @@ -76,27 +70,21 @@ public class ConsoleTerminateAction extends Action implements IUpdate { fConsole = console; fWindow = window; setToolTipText(ConsoleMessages.ConsoleTerminateAction_1); - setImageDescriptor(DebugPluginImages - .getImageDescriptor( - IInternalDebugUIConstants.IMG_LCL_TERMINATE)); - setDisabledImageDescriptor(DebugPluginImages - .getImageDescriptor( - IInternalDebugUIConstants.IMG_DLCL_TERMINATE)); - setHoverImageDescriptor(DebugPluginImages - .getImageDescriptor( - IInternalDebugUIConstants.IMG_LCL_TERMINATE)); + setImageDescriptor(DebugPluginImages.getImageDescriptor( + IInternalDebugUIConstants.IMG_LCL_TERMINATE)); + setDisabledImageDescriptor(DebugPluginImages.getImageDescriptor( + IInternalDebugUIConstants.IMG_DLCL_TERMINATE)); + setHoverImageDescriptor(DebugPluginImages.getImageDescriptor( + IInternalDebugUIConstants.IMG_LCL_TERMINATE)); listener = new TerminateListener(); - DebugPlugin.getDefault().getLaunchManager() - .addLaunchListener(listener); + DebugPlugin.getDefault().getLaunchManager().addLaunchListener(listener); // PlatformUI.getWorkbench().getHelpSystem().setHelp(this, // IDebugHelpContextIds.CONSOLE_TERMINATE_ACTION); update(); } - /* - * @see org.eclipse.ui.texteditor.IUpdate#update() - */ + @Override public void update() { if (fConsole != null) { ILaunch launch = fConsole.getLaunch(); @@ -104,12 +92,9 @@ public class ConsoleTerminateAction extends Action implements IUpdate { } } - /* - * @see org.eclipse.jface.action.IAction#run() - */ @Override public void run() { - final List<ITerminate> targets = new ArrayList<ITerminate>(); + final List<ITerminate> targets = new ArrayList<>(); final ILaunch launch = fConsole.getLaunch(); final IDebugTarget[] debugTargets = launch.getDebugTargets(); for (int k = 0; k < debugTargets.length; k++) { @@ -121,9 +106,8 @@ public class ConsoleTerminateAction extends Action implements IUpdate { } DebugCommandService service = DebugCommandService.getService(fWindow); - service - .executeCommand(ITerminateHandler.class, targets.toArray(), - null); + service.executeCommand(ITerminateHandler.class, targets.toArray(), + null); } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/handlers/AbstractOpenPreferencePageStatusHandler.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/handlers/AbstractOpenPreferencePageStatusHandler.java index 040911458..21ce46955 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/handlers/AbstractOpenPreferencePageStatusHandler.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/handlers/AbstractOpenPreferencePageStatusHandler.java @@ -1,13 +1,11 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ - package org.eclipse.dltk.internal.debug.ui.handlers; import org.eclipse.core.runtime.CoreException; @@ -19,18 +17,19 @@ import org.eclipse.jface.preference.PreferenceDialog; import org.eclipse.ui.dialogs.PreferencesUtil; /** - * + * * @author kds - * + * */ -public abstract class AbstractOpenPreferencePageStatusHandler implements - IStatusHandler { +public abstract class AbstractOpenPreferencePageStatusHandler + implements IStatusHandler { protected void showPreferencePage(String pageId) { final PreferenceDialog dialog = PreferencesUtil .createPreferenceDialogOn(null, pageId, null, null); dialog.open(); } + @Override public Object handleStatus(final IStatus status, Object source) throws CoreException { @@ -38,21 +37,20 @@ public abstract class AbstractOpenPreferencePageStatusHandler implements final boolean[] result = new boolean[1]; - DLTKDebugUIPlugin.getStandardDisplay().syncExec(new Runnable() { - public void run() { - final String title = getTitle(); - if (pageId == null) { - MessageDialog.openError(DLTKDebugUIPlugin - .getActiveWorkbenchShell(), title, status - .getMessage()); - } else { - final String message = status.getMessage() + " " //$NON-NLS-1$ - + getQuestion(); - result[0] = (MessageDialog.openQuestion(DLTKDebugUIPlugin - .getActiveWorkbenchShell(), title, message)); - if (result[0]) { - showPreferencePage(pageId); - } + DLTKDebugUIPlugin.getStandardDisplay().syncExec(() -> { + final String title = getTitle(); + if (pageId == null) { + MessageDialog.openError( + DLTKDebugUIPlugin.getActiveWorkbenchShell(), title, + status.getMessage()); + } else { + final String message = status.getMessage() + " " //$NON-NLS-1$ + + getQuestion(); + result[0] = (MessageDialog.openQuestion( + DLTKDebugUIPlugin.getActiveWorkbenchShell(), title, + message)); + if (result[0]) { + showPreferencePage(pageId); } } }); diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/handlers/DebuggingEngineNotConfiguredStatusHandler.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/handlers/DebuggingEngineNotConfiguredStatusHandler.java index 2e63e4d92..a84387732 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/handlers/DebuggingEngineNotConfiguredStatusHandler.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/handlers/DebuggingEngineNotConfiguredStatusHandler.java @@ -1,13 +1,11 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ - package org.eclipse.dltk.internal.debug.ui.handlers; import org.eclipse.dltk.launching.DebuggingEngineRunner; @@ -16,13 +14,14 @@ import org.eclipse.dltk.launching.debug.IDebuggingEngine; /** * Debugging engine configuration problem that prevents debugging engine from * starting - * + * * @author kds - * + * */ -public class DebuggingEngineNotConfiguredStatusHandler extends - AbstractOpenPreferencePageStatusHandler { +public class DebuggingEngineNotConfiguredStatusHandler + extends AbstractOpenPreferencePageStatusHandler { + @Override protected String getPreferencePageId(Object source) { if (source instanceof DebuggingEngineRunner) { final DebuggingEngineRunner runner = (DebuggingEngineRunner) source; @@ -35,10 +34,12 @@ public class DebuggingEngineNotConfiguredStatusHandler extends return null; } + @Override public String getTitle() { return HandlerMessages.DebuggingEngineNotConfiguredTitle; } + @Override protected String getQuestion() { return HandlerMessages.DebuggingEngineNotConfiguredQuestion; } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/handlers/InterpreterRunnerNotFoundStatusHandler.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/handlers/InterpreterRunnerNotFoundStatusHandler.java index 8c3ed0e1f..7c77bac5b 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/handlers/InterpreterRunnerNotFoundStatusHandler.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/handlers/InterpreterRunnerNotFoundStatusHandler.java @@ -1,13 +1,11 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ - package org.eclipse.dltk.internal.debug.ui.handlers; import org.eclipse.core.runtime.CoreException; @@ -17,21 +15,19 @@ import org.eclipse.dltk.debug.ui.DLTKDebugUIPlugin; import org.eclipse.jface.dialogs.MessageDialog; /** - * + * * @author kds - * + * */ public class InterpreterRunnerNotFoundStatusHandler implements IStatusHandler { + @Override public Object handleStatus(final IStatus status, Object source) throws CoreException { - DLTKDebugUIPlugin.getStandardDisplay().syncExec(new Runnable() { - public void run() { - MessageDialog.openError(DLTKDebugUIPlugin - .getActiveWorkbenchShell(), - HandlerMessages.InterpreterRunnerNotFound, status - .getMessage()); - } - }); + DLTKDebugUIPlugin.getStandardDisplay() + .syncExec(() -> MessageDialog.openError( + DLTKDebugUIPlugin.getActiveWorkbenchShell(), + HandlerMessages.InterpreterRunnerNotFound, + status.getMessage())); return null; } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/handlers/NoDefaultDebuggingEngineStatusHandler.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/handlers/NoDefaultDebuggingEngineStatusHandler.java index 1397df755..31aca49f5 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/handlers/NoDefaultDebuggingEngineStatusHandler.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/handlers/NoDefaultDebuggingEngineStatusHandler.java @@ -1,35 +1,37 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ - package org.eclipse.dltk.internal.debug.ui.handlers; import org.eclipse.dltk.launching.AbstractScriptLaunchConfigurationDelegate; import org.eclipse.dltk.ui.DLTKUILanguageManager; -public class NoDefaultDebuggingEngineStatusHandler extends - AbstractOpenPreferencePageStatusHandler { +public class NoDefaultDebuggingEngineStatusHandler + extends AbstractOpenPreferencePageStatusHandler { + @Override protected String getPreferencePageId(Object source) { if (source instanceof AbstractScriptLaunchConfigurationDelegate) { AbstractScriptLaunchConfigurationDelegate delegate = (AbstractScriptLaunchConfigurationDelegate) source; - return DLTKUILanguageManager.getLanguageToolkit( - delegate.getLanguageId()).getDebugPreferencePage(); + return DLTKUILanguageManager + .getLanguageToolkit(delegate.getLanguageId()) + .getDebugPreferencePage(); } return null; } + @Override protected String getQuestion() { return HandlerMessages.NoDefaultDebuggingEngineQuestion; } + @Override protected String getTitle() { return HandlerMessages.NoDefaultDebuggingEngineTitle; } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/handlers/NoDefaultInterperterStatusHandler.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/handlers/NoDefaultInterperterStatusHandler.java index 815f87dc6..db72392ed 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/handlers/NoDefaultInterperterStatusHandler.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/handlers/NoDefaultInterperterStatusHandler.java @@ -1,40 +1,42 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ - package org.eclipse.dltk.internal.debug.ui.handlers; import org.eclipse.dltk.launching.AbstractScriptLaunchConfigurationDelegate; import org.eclipse.dltk.ui.DLTKUILanguageManager; /** - * + * * @author kds - * + * */ -public class NoDefaultInterperterStatusHandler extends - AbstractOpenPreferencePageStatusHandler { +public class NoDefaultInterperterStatusHandler + extends AbstractOpenPreferencePageStatusHandler { + @Override protected String getPreferencePageId(Object source) { if (source instanceof AbstractScriptLaunchConfigurationDelegate) { AbstractScriptLaunchConfigurationDelegate delegate = (AbstractScriptLaunchConfigurationDelegate) source; - return DLTKUILanguageManager.getLanguageToolkit( - delegate.getLanguageId()).getInterpreterPreferencePage(); + return DLTKUILanguageManager + .getLanguageToolkit(delegate.getLanguageId()) + .getInterpreterPreferencePage(); } return null; } + @Override protected String getQuestion() { return HandlerMessages.NoDefaultInterpreterQuestion; } + @Override protected String getTitle() { return HandlerMessages.NoDefaultInterpreterTitle; } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/AbstractInterpreterComboBlock.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/AbstractInterpreterComboBlock.java index 709c752f3..ca2aa4bcd 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/AbstractInterpreterComboBlock.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/AbstractInterpreterComboBlock.java @@ -1,17 +1,15 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.internal.debug.ui.interpreters; import java.util.ArrayList; import java.util.Collections; -import java.util.Comparator; import java.util.List; import org.eclipse.core.runtime.IPath; @@ -46,9 +44,7 @@ import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.dialogs.PreferencesUtil; @@ -73,7 +69,7 @@ public class AbstractInterpreterComboBlock { /** * Interpreters being displayed */ - private List<IInterpreterInstall> fInterpreters = new ArrayList<IInterpreterInstall>(); + private List<IInterpreterInstall> fInterpreters = new ArrayList<>(); /** * The main control @@ -123,7 +119,8 @@ public class AbstractInterpreterComboBlock { /** * @since 2.0 */ - public AbstractInterpreterComboBlock(IInterpreterComboBlockContext context) { + public AbstractInterpreterComboBlock( + IInterpreterComboBlockContext context) { this.fContext = context; } @@ -154,7 +151,7 @@ public class AbstractInterpreterComboBlock { /** * Creates this block's control in the given control. - * + * * @param anscestor * containing control */ @@ -190,8 +187,7 @@ public class AbstractInterpreterComboBlock { if (fDefaultButton.getSelection()) { setUseDefaultInterpreter(); if (fInterpreters.isEmpty()) { - setStatus(new Status( - IStatus.ERROR, + setStatus(new Status(IStatus.ERROR, DLTKLaunchingPlugin.getUniqueIdentifier(), ScriptLaunchConfigurationConstants.ERR_NO_DEFAULT_INTERPRETER_INSTALL, InterpretersMessages.InterpretersComboBlock_0, @@ -226,8 +222,7 @@ public class AbstractInterpreterComboBlock { fCombo.select(0); } if (fInterpreters.isEmpty()) { - setStatus(new Status( - IStatus.ERROR, + setStatus(new Status(IStatus.ERROR, DLTKLaunchingPlugin.getUniqueIdentifier(), ScriptLaunchConfigurationConstants.ERR_NO_DEFAULT_INTERPRETER_INSTALL, InterpretersMessages.InterpretersComboBlock_0, @@ -250,8 +245,8 @@ public class AbstractInterpreterComboBlock { // data.widthHint = 100; data.horizontalSpan = 1; fCombo.setLayoutData(data); - ControlAccessibleListener - .addListener(fCombo, fSpecificButton.getText()); + ControlAccessibleListener.addListener(fCombo, + fSpecificButton.getText()); fCombo.addSelectionListener(new SelectionAdapter() { @Override @@ -262,16 +257,12 @@ public class AbstractInterpreterComboBlock { fManageButton = createPushButton(group, InterpretersMessages.InterpretersComboBlock_2); - fManageButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event event) { - showInterpreterPreferencePage(); - } - }); + fManageButton.addListener(SWT.Selection, + event -> showInterpreterPreferencePage()); fillWithWorkspaceInterpreters(); if (fInterpreters.isEmpty()) { - setStatus(new Status( - IStatus.ERROR, + setStatus(new Status(IStatus.ERROR, DLTKLaunchingPlugin.getUniqueIdentifier(), ScriptLaunchConfigurationConstants.ERR_NO_DEFAULT_INTERPRETER_INSTALL, InterpretersMessages.InterpretersComboBlock_0, null)); @@ -283,7 +274,7 @@ public class AbstractInterpreterComboBlock { /** * Opens the given preference page, and updates when closed. - * + * * @param id * pref page id * @param page @@ -314,7 +305,7 @@ public class AbstractInterpreterComboBlock { /** * Returns this block's control - * + * * @return control */ public Control getControl() { @@ -323,7 +314,7 @@ public class AbstractInterpreterComboBlock { /** * Sets the InterpreterEnvironments to be displayed in this block - * + * * @param Interpreters * InterpreterEnvironments to be displayed */ @@ -331,11 +322,8 @@ public class AbstractInterpreterComboBlock { fInterpreters.clear(); fInterpreters.addAll(interpreters); // sort by name - Collections.sort(fInterpreters, new Comparator<IInterpreterInstall>() { - public int compare(IInterpreterInstall o1, IInterpreterInstall o2) { - return o1.getName().compareToIgnoreCase(o2.getName()); - } - }); + Collections.sort(fInterpreters, + (o1, o2) -> o1.getName().compareToIgnoreCase(o2.getName())); // now make an array of names String[] names = new String[fInterpreters.size()]; for (int i = 0, size = fInterpreters.size(); i < size; ++i) { @@ -355,7 +343,7 @@ public class AbstractInterpreterComboBlock { /** * Selects a specific InterpreterEnvironment based on type/name. - * + * * @param Interpreter * InterpreterEnvironment */ @@ -372,7 +360,7 @@ public class AbstractInterpreterComboBlock { /** * Returns the selected InterpreterEnvironment or <code>null</code> if none. - * + * * @return the selected InterpreterEnvironment or <code>null</code> if none */ public IInterpreterInstall getInterpreter() { @@ -388,11 +376,12 @@ public class AbstractInterpreterComboBlock { /** * Sets the Default InterpreterEnvironment Descriptor for this block. - * + * * @param descriptor * default InterpreterEnvironment descriptor */ - public void setDefaultInterpreterDescriptor(InterpreterDescriptor descriptor) { + public void setDefaultInterpreterDescriptor( + InterpreterDescriptor descriptor) { fDefaultDescriptor = descriptor; setButtonTextFromDescriptor(fDefaultButton, descriptor); } @@ -413,7 +402,7 @@ public class AbstractInterpreterComboBlock { /** * Sets the specific InterpreterEnvironment Descriptor for this block. - * + * * @param descriptor * specific InterpreterEnvironment descriptor */ @@ -426,7 +415,7 @@ public class AbstractInterpreterComboBlock { /** * Returns whether the 'use default InterpreterEnvironment' button is * checked. - * + * * @return whether the 'use default InterpreterEnvironment' button is * checked */ @@ -451,7 +440,7 @@ public class AbstractInterpreterComboBlock { /** * Sets the title used for this InterpreterEnvironment block - * + * * @param title * title for this InterpreterEnvironment block */ @@ -470,8 +459,7 @@ public class AbstractInterpreterComboBlock { IInterpreterInstall prevInterpreter = getInterpreter(); fillWithWorkspaceInterpreters(); if (fInterpreters.isEmpty()) { - setStatus(new Status( - IStatus.ERROR, + setStatus(new Status(IStatus.ERROR, DLTKLaunchingPlugin.getUniqueIdentifier(), ScriptLaunchConfigurationConstants.ERR_NO_DEFAULT_INTERPRETER_INSTALL, InterpretersMessages.InterpretersComboBlock_0, null)); @@ -493,7 +481,7 @@ public class AbstractInterpreterComboBlock { /** * Returns a buildpath container path identifying the selected * InterpreterEnvironment. - * + * * @return buildpath container path or <code>null</code> */ public IPath getInterpreterPath() { @@ -515,28 +503,28 @@ public class AbstractInterpreterComboBlock { /** * Sets the selection based on the given container path and returns a status * indicating if the selection was successful. - * + * * @param containerPath * @return status */ public void setPath(IPath containerPath) { if (fInterpreters.isEmpty()) { - setStatus(new Status( - IStatus.ERROR, + setStatus(new Status(IStatus.ERROR, DLTKLaunchingPlugin.getUniqueIdentifier(), ScriptLaunchConfigurationConstants.ERR_NO_DEFAULT_INTERPRETER_INSTALL, InterpretersMessages.InterpretersComboBlock_0, null)); } else { setStatus(OK_STATUS); } - if (ScriptRuntime.newDefaultInterpreterContainerPath().equals( - containerPath)) { + if (ScriptRuntime.newDefaultInterpreterContainerPath() + .equals(containerPath)) { setUseDefaultInterpreter(); } else { final IEnvironment environment = fContext.getEnvironment(); - final IInterpreterInstall install = environment != null ? ScriptRuntime - .getInterpreterInstall(fContext.getNatureId(), environment - .getId(), containerPath) + final IInterpreterInstall install = environment != null + ? ScriptRuntime.getInterpreterInstall( + fContext.getNatureId(), environment.getId(), + containerPath) : null; if (install == null) { setError(InterpretersMessages.InterpretersComboBlock_8); @@ -553,14 +541,14 @@ public class AbstractInterpreterComboBlock { } private void setError(String message) { - setStatus(new Status(IStatus.ERROR, DLTKDebugUIPlugin - .getUniqueIdentifier(), IDLTKDebugUIConstants.INTERNAL_ERROR, - message, null)); + setStatus(new Status(IStatus.ERROR, + DLTKDebugUIPlugin.getUniqueIdentifier(), + IDLTKDebugUIConstants.INTERNAL_ERROR, message, null)); } /** * Returns the status of the interpreter selection. - * + * * @return status */ public IStatus getStatus() { @@ -587,7 +575,7 @@ public class AbstractInterpreterComboBlock { protected void fillWithWorkspaceInterpreters() { // fill with interpreters - final List<IInterpreterInstall> standins = new ArrayList<IInterpreterInstall>(); + final List<IInterpreterInstall> standins = new ArrayList<>(); final IInterpreterInstallType[] types = ScriptRuntime .getInterpreterInstallTypes(getCurrentLanguageNature()); final IEnvironment environment = fContext.getEnvironment(); @@ -597,9 +585,8 @@ public class AbstractInterpreterComboBlock { IInterpreterInstall[] installs = type.getInterpreterInstalls(); for (int j = 0; j < installs.length; j++) { final IInterpreterInstall install = installs[j]; - if (environment != null - && environment.getId().equals( - install.getEnvironmentId())) { + if (environment != null && environment.getId() + .equals(install.getEnvironmentId())) { standins.add(new InterpreterStandin(install)); } } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/AbstractInterpreterContainerWizardPage.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/AbstractInterpreterContainerWizardPage.java index 84b2fe70d..cfada2962 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/AbstractInterpreterContainerWizardPage.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/AbstractInterpreterContainerWizardPage.java @@ -1,11 +1,10 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.internal.debug.ui.interpreters; @@ -20,8 +19,6 @@ import org.eclipse.dltk.core.environment.IEnvironment; import org.eclipse.dltk.debug.ui.ScriptDebugImages; import org.eclipse.dltk.internal.ui.wizards.IBuildpathContainerPage; import org.eclipse.dltk.ui.wizards.IBuildpathContainerPageExtension; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; @@ -54,10 +51,10 @@ public abstract class AbstractInterpreterContainerWizardPage extends WizardPage * Constructs a new page. */ public AbstractInterpreterContainerWizardPage() { - super( - InterpretersMessages.InterpreterContainerWizardPage_Interpreter_System_Library_1); + super(InterpretersMessages.InterpreterContainerWizardPage_Interpreter_System_Library_1); } + @Override public boolean finish() { IStatus status = fInterpreterBlock.getStatus(); if (!status.isOK()) { @@ -67,10 +64,12 @@ public abstract class AbstractInterpreterContainerWizardPage extends WizardPage return true; } + @Override public IBuildpathEntry getSelection() { return fSelection; } + @Override public void setSelection(IBuildpathEntry containerEntry) { fSelection = containerEntry; initializeFromSelection(); @@ -93,8 +92,8 @@ public abstract class AbstractInterpreterContainerWizardPage extends WizardPage IStatusHandler handler = DebugPlugin.getDefault() .getStatusHandler(status); if (handler != null) { - Boolean b = (Boolean) handler - .handleStatus(status, this); + Boolean b = (Boolean) handler.handleStatus(status, + this); if (b.booleanValue()) { fInterpreterBlock.refreshInterpreters(); } @@ -113,9 +112,7 @@ public abstract class AbstractInterpreterContainerWizardPage extends WizardPage return new AbstractInterpreterComboBlock(context); } - /* - * @see IDialogPage#createControl(Composite) - */ + @Override public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); @@ -125,29 +122,27 @@ public abstract class AbstractInterpreterContainerWizardPage extends WizardPage composite.setFont(parent.getFont()); final IInterpreterComboBlockContext context = createInterpreterBlockHost(); fInterpreterBlock = createInterpreterBlock(context); - fInterpreterBlock - .setDefaultInterpreterDescriptor(new BuildInterpreterDescriptor( - context)); - fInterpreterBlock - .setTitle(InterpretersMessages.InterpreterContainerWizardPage_3); + fInterpreterBlock.setDefaultInterpreterDescriptor( + new BuildInterpreterDescriptor(context)); + fInterpreterBlock.setTitle( + InterpretersMessages.InterpreterContainerWizardPage_3); fInterpreterBlock.createControl(composite); // gd = new GridData(GridData.FILL_HORIZONTAL); // fInterpreterEnvironmentBlock.getControl().setLayoutData(gd); setControl(composite); - fInterpreterBlock - .addPropertyChangeListener(new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - IStatus status = fInterpreterBlock.getStatus(); - if (status.isOK()) { - setErrorMessage(null); - } else { - setErrorMessage(status.getMessage()); - } - } - }); + fInterpreterBlock.addPropertyChangeListener(event -> { + IStatus status = fInterpreterBlock.getStatus(); + if (status.isOK()) { + setErrorMessage(null); + } else { + setErrorMessage(status.getMessage()); + } + }); - setTitle(InterpretersMessages.InterpreterContainerWizardPage_Interpreter_System_Library_1); - setMessage(InterpretersMessages.InterpreterContainerWizardPage_Select_the_Interpreter_used_to_build_this_project__4); + setTitle( + InterpretersMessages.InterpreterContainerWizardPage_Interpreter_System_Library_1); + setMessage( + InterpretersMessages.InterpreterContainerWizardPage_Select_the_Interpreter_used_to_build_this_project__4); initializeFromSelection(); } @@ -158,14 +153,17 @@ public abstract class AbstractInterpreterContainerWizardPage extends WizardPage private IInterpreterComboBlockContext createInterpreterBlockHost() { return new IInterpreterComboBlockContext() { + @Override public int getMode() { return M_BUILDPATH; } + @Override public IEnvironment getEnvironment() { return EnvironmentManager.getEnvironment(getScriptProject()); } + @Override public String getNatureId() { return AbstractInterpreterContainerWizardPage.this .getScriptNature(); @@ -179,6 +177,7 @@ public abstract class AbstractInterpreterContainerWizardPage extends WizardPage return ScriptDebugImages.get(ScriptDebugImages.IMG_WIZBAN_LIBRARY); } + @Override public void initialize(IScriptProject project, IBuildpathEntry[] currentEntries) { this.scriptProject = project; diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/AbstractInterpreterEnvironmentVariablesBlock.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/AbstractInterpreterEnvironmentVariablesBlock.java index 3ca6c95d6..efc096a20 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/AbstractInterpreterEnvironmentVariablesBlock.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/AbstractInterpreterEnvironmentVariablesBlock.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2016 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,7 +10,6 @@ package org.eclipse.dltk.internal.debug.ui.interpreters; import java.io.File; import java.util.Arrays; -import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -90,7 +89,7 @@ public abstract class AbstractInterpreterEnvironmentVariablesBlock /** * Creates and returns the source lookup control. - * + * * @param parent * the parent widget of this control */ @@ -166,7 +165,7 @@ public abstract class AbstractInterpreterEnvironmentVariablesBlock /** * Creates and returns a button - * + * * @param parent * parent widget * @param label @@ -230,7 +229,7 @@ public abstract class AbstractInterpreterEnvironmentVariablesBlock /** * Determines if the present setup is the default location s for this * InterpreterEnvironment - * + * * @return true if the current set of locations are the defaults, false * otherwise */ @@ -260,7 +259,7 @@ public abstract class AbstractInterpreterEnvironmentVariablesBlock /** * Returns the Interpreter install associated with this library block or * <code>null</code> if new interpreter is being added. - * + * * @return Interpreter install */ protected IInterpreterInstall getInterpreterInstall() { @@ -280,20 +279,14 @@ public abstract class AbstractInterpreterEnvironmentVariablesBlock /** * Returns the Interpreter install type associated with this library block. - * + * * @return Interpreter install */ protected IInterpreterInstallType getInterpreterInstallType() { return fInterpreterInstallType; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt - * .events.SelectionEvent) - */ + @Override public void widgetSelected(SelectionEvent e) { Object source = e.getSource(); /* @@ -388,7 +381,7 @@ public abstract class AbstractInterpreterEnvironmentVariablesBlock if (vars != null) { EnvironmentVariable[] variables = this.fEnvironmentVariablesContentProvider .getVariables(); - Set<EnvironmentVariable> nvars = new HashSet<EnvironmentVariable>(); + Set<EnvironmentVariable> nvars = new HashSet<>(); nvars.addAll(Arrays.asList(vars)); nvars.addAll(Arrays.asList(variables)); this.fEnvironmentVariablesContentProvider.setVariables( @@ -433,12 +426,7 @@ public abstract class AbstractInterpreterEnvironmentVariablesBlock return true; } - /* - * (non-Javadoc) - * - * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org. - * eclipse .swt.events.SelectionEvent) - */ + @Override public void widgetDefaultSelected(SelectionEvent e) { } @@ -490,13 +478,7 @@ public abstract class AbstractInterpreterEnvironmentVariablesBlock fDialog.updateValidateInterpreterLocation(); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged( - * org.eclipse.jface.viewers.SelectionChangedEvent) - */ + @Override public void selectionChanged(SelectionChangedEvent event) { updateButtons(); } @@ -538,7 +520,7 @@ public abstract class AbstractInterpreterEnvironmentVariablesBlock /** * Initializes this control based on the settings in the given Interpreter * install and type. - * + * * @param interpreter * Interpreter or <code>null</code> if none * @param type @@ -634,6 +616,7 @@ public abstract class AbstractInterpreterEnvironmentVariablesBlock private IStructuredContentProvider createSelectionDialogContentProvider() { return new IStructuredContentProvider() { + @Override public Object[] getElements(Object inputElement) { if (inputElement instanceof Map<?, ?>) { @SuppressWarnings("unchecked") @@ -641,21 +624,18 @@ public abstract class AbstractInterpreterEnvironmentVariablesBlock final EnvironmentVariable[] elements = env.values() .toArray(new EnvironmentVariable[env.size()]); Arrays.sort(elements, - new Comparator<EnvironmentVariable>() { - public int compare(EnvironmentVariable s1, - EnvironmentVariable s2) { - return s1.getName().compareTo(s2.getName()); - } - }); + (s1, s2) -> s1.getName().compareTo(s2.getName())); return elements; } else { return new EnvironmentVariable[0]; } } + @Override public void dispose() { } + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } @@ -668,7 +648,7 @@ public abstract class AbstractInterpreterEnvironmentVariablesBlock .getAdapter(IExecutionEnvironment.class); Map<String, String> stringVars = execEnvironment .getEnvironmentVariables(true); - HashMap<String, EnvironmentVariable> vars = new HashMap<String, EnvironmentVariable>(); + HashMap<String, EnvironmentVariable> vars = new HashMap<>(); if (stringVars != null) { for (Map.Entry<String, String> entry : stringVars.entrySet()) { vars.put(entry.getKey(), new EnvironmentVariable(entry.getKey(), diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/AbstractInterpreterLibraryBlock.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/AbstractInterpreterLibraryBlock.java index 9cfc0e8f0..d0ddeac59 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/AbstractInterpreterLibraryBlock.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/AbstractInterpreterLibraryBlock.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2016 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -16,7 +16,6 @@ import java.util.Map; import java.util.Set; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Status; @@ -33,10 +32,7 @@ import org.eclipse.dltk.ui.dialogs.TimeTriggeredProgressMonitorDialog; import org.eclipse.dltk.ui.environment.IEnvironmentUI; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.viewers.DoubleClickEvent; import org.eclipse.jface.viewers.IBaseLabelProvider; -import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.SelectionChangedEvent; @@ -93,7 +89,7 @@ public abstract class AbstractInterpreterLibraryBlock /** * Creates and returns the source lookup control. - * + * * @param parent * the parent widget of this control */ @@ -137,17 +133,13 @@ public abstract class AbstractInterpreterLibraryBlock fEnabledButton.setText( InterpretersMessages.AbstractInterpreterLibraryBlock_setPathVisibleToDltk); fEnabledButton.addSelectionListener(this); - this.fLibraryViewer - .addDoubleClickListener(new IDoubleClickListener() { - public void doubleClick(DoubleClickEvent event) { - if (fLibraryContentProvider.canEnable( - (IStructuredSelection) fLibraryViewer - .getSelection())) { - fLibraryContentProvider.changeEnabled(); - updateButtons(); - } - } - }); + this.fLibraryViewer.addDoubleClickListener(event -> { + if (fLibraryContentProvider.canEnable( + (IStructuredSelection) fLibraryViewer.getSelection())) { + fLibraryContentProvider.changeEnabled(); + updateButtons(); + } + }); } Composite pathButtonComp = new Composite(comp, SWT.NONE); @@ -221,17 +213,10 @@ public abstract class AbstractInterpreterLibraryBlock ProgressMonitorDialog dialog = new TimeTriggeredProgressMonitorDialog( null, 1000); try { - dialog.run(true, true, new IRunnableWithProgress() { - - public void run(IProgressMonitor monitor) - throws InvocationTargetException, - InterruptedException { - libs[0] = getInterpreterInstallType() + dialog.run(true, true, + monitor -> libs[0] = getInterpreterInstallType() .getDefaultLibraryLocations(installLocation, - environmentVariables, monitor); - } - - }); + environmentVariables, monitor)); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (InterruptedException e) { @@ -243,7 +228,7 @@ public abstract class AbstractInterpreterLibraryBlock /** * Creates and returns a button - * + * * @param parent * parent widget * @param label @@ -337,7 +322,7 @@ public abstract class AbstractInterpreterLibraryBlock /** * Determines if the present setup is the default location s for this * InterpreterEnvironment - * + * * @return true if the current set of locations are the defaults, false * otherwise */ @@ -368,7 +353,7 @@ public abstract class AbstractInterpreterLibraryBlock /** * Returns the Interpreter install associated with this library block. - * + * * @return Interpreter install */ protected IInterpreterInstall getInterpreterInstall() { @@ -377,7 +362,7 @@ public abstract class AbstractInterpreterLibraryBlock /** * Returns the Interpreter install type associated with this library block. - * + * * @return Interpreter install */ protected IInterpreterInstallType getInterpreterInstallType() { @@ -386,11 +371,12 @@ public abstract class AbstractInterpreterLibraryBlock /* * (non-Javadoc) - * + * * @see * org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt * .events.SelectionEvent) */ + @Override public void widgetSelected(SelectionEvent e) { Object source = e.getSource(); if (source == fUpButton) { @@ -418,10 +404,11 @@ public abstract class AbstractInterpreterLibraryBlock /* * (non-Javadoc) - * + * * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org. * eclipse .swt.events.SelectionEvent) */ + @Override public void widgetDefaultSelected(SelectionEvent e) { } @@ -439,11 +426,12 @@ public abstract class AbstractInterpreterLibraryBlock /* * (non-Javadoc) - * + * * @see * org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged( * org.eclipse.jface.viewers.SelectionChangedEvent) */ + @Override public void selectionChanged(SelectionChangedEvent event) { updateButtons(); } @@ -496,7 +484,7 @@ public abstract class AbstractInterpreterLibraryBlock /** * Initializes this control based on the settings in the given Interpreter * install and type. - * + * * @param Interpreter * Interpreter or <code>null</code> if none * @param type @@ -515,16 +503,8 @@ public abstract class AbstractInterpreterLibraryBlock ProgressMonitorDialog dialog = new TimeTriggeredProgressMonitorDialog( null, 3000); try { - dialog.run(true, true, new IRunnableWithProgress() { - - public void run(IProgressMonitor monitor) - throws InvocationTargetException, - InterruptedException { - libs[0] = ScriptRuntime.getLibraryLocations( - getInterpreterInstall(), monitor); - } - - }); + dialog.run(true, true, monitor -> libs[0] = ScriptRuntime + .getLibraryLocations(getInterpreterInstall(), monitor)); } catch (InvocationTargetException e) { if (DLTKCore.DEBUG) { e.printStackTrace(); @@ -578,15 +558,15 @@ public abstract class AbstractInterpreterLibraryBlock /** * Rediscover using following technicue: - * + * * 1) Keep all user added entries. - * + * * 2) Remove all default entries. - * + * * 3) Rediscover - * + * * 4) Add all new entries to list. - * + * * @param environmentVariables * @param oldVars */ diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/AddScriptInterpreterDialog.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/AddScriptInterpreterDialog.java index 36dcd4ed8..b6568b9fb 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/AddScriptInterpreterDialog.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/AddScriptInterpreterDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2016 IBM Corporation and others. + * Copyright (c) 2005, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,7 +11,6 @@ package org.eclipse.dltk.internal.debug.ui.interpreters; import java.lang.reflect.InvocationTargetException; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; import org.eclipse.dltk.compiler.util.Util; @@ -21,9 +20,6 @@ import org.eclipse.dltk.core.environment.IFileHandle; import org.eclipse.dltk.core.internal.environment.LazyFileHandle; import org.eclipse.dltk.debug.ui.DLTKDebugUIPlugin; import org.eclipse.dltk.internal.ui.wizards.dialogfields.ComboDialogField; -import org.eclipse.dltk.internal.ui.wizards.dialogfields.DialogField; -import org.eclipse.dltk.internal.ui.wizards.dialogfields.IDialogFieldListener; -import org.eclipse.dltk.internal.ui.wizards.dialogfields.IStringButtonAdapter; import org.eclipse.dltk.internal.ui.wizards.dialogfields.StringButtonDialogField; import org.eclipse.dltk.internal.ui.wizards.dialogfields.StringDialogField; import org.eclipse.dltk.launching.EnvironmentVariable; @@ -38,7 +34,6 @@ import org.eclipse.dltk.utils.PlatformFileUtils; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.dialogs.StatusDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.window.Window; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; @@ -117,6 +112,7 @@ public abstract class AddScriptInterpreterDialog extends StatusDialog /** * @see Windows#configureShell */ + @Override protected void configureShell(Shell newShell) { super.configureShell(newShell); // PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, @@ -134,11 +130,7 @@ public abstract class AddScriptInterpreterDialog extends StatusDialog InterpretersMessages.addInterpreterDialog_InterpreterEnvironmentName); fInterpreterPath = new StringButtonDialogField( - new IStringButtonAdapter() { - public void changeControlPressed(DialogField field) { - browseForInstallation(); - } - }); + field -> browseForInstallation()); fInterpreterPath.setLabelText( InterpretersMessages.addInterpreterDialog_InterpreterExecutableName); fInterpreterPath.setButtonLabel( @@ -154,25 +146,17 @@ public abstract class AddScriptInterpreterDialog extends StatusDialog protected void createFieldListeners() { fInterpreterTypeCombo - .setDialogFieldListener(new IDialogFieldListener() { - public void dialogFieldChanged(DialogField field) { - updateInterpreterType(); - } - }); - - fInterpreterName.setDialogFieldListener(new IDialogFieldListener() { - public void dialogFieldChanged(DialogField field) { - setInterpreterNameStatus(validateInterpreterName()); - updateStatusLine(); - } + .setDialogFieldListener(field -> updateInterpreterType()); + + fInterpreterName.setDialogFieldListener(field -> { + setInterpreterNameStatus(validateInterpreterName()); + updateStatusLine(); }); - fInterpreterPath.setDialogFieldListener(new IDialogFieldListener() { - public void dialogFieldChanged(DialogField field) { - updateValidateInterpreterLocation(); - fLibraryBlock.restoreDefaultLibraries(); - updateStatusLine(); - } + fInterpreterPath.setDialogFieldListener(field -> { + updateValidateInterpreterLocation(); + fLibraryBlock.restoreDefaultLibraries(); + updateStatusLine(); }); } @@ -337,6 +321,7 @@ public abstract class AddScriptInterpreterDialog extends StatusDialog setInterpreterLocationStatus(validateInterpreterLocation()); } + @Override public void create() { super.create(); fInterpreterPath.setFocus(); @@ -447,19 +432,16 @@ public abstract class AddScriptInterpreterDialog extends StatusDialog TimeTriggeredProgressMonitorDialog progressDialog = new TimeTriggeredProgressMonitorDialog( this.getShell(), 200); try { - progressDialog.run(false, false, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) - throws InvocationTargetException, InterruptedException { - EnvironmentVariable[] environmentVariables = null; - if (fEnvironmentVariablesBlock != null) { - environmentVariables = fEnvironmentVariablesBlock - .getEnvironmentVariables(); - } - LibraryLocation[] locations = fLibraryBlock - .getLibraryLocations(); - temp[0] = getInterpreterType().validateInstallLocation(file, - environmentVariables, locations, monitor); + progressDialog.run(false, false, monitor -> { + EnvironmentVariable[] environmentVariables = null; + if (fEnvironmentVariablesBlock != null) { + environmentVariables = fEnvironmentVariablesBlock + .getEnvironmentVariables(); } + LibraryLocation[] locations = fLibraryBlock + .getLibraryLocations(); + temp[0] = getInterpreterType().validateInstallLocation(file, + environmentVariables, locations, monitor); }); } catch (InvocationTargetException e) { DLTKCore.error(e); @@ -471,7 +453,7 @@ public abstract class AddScriptInterpreterDialog extends StatusDialog /** * Generates unique interpreter name based on the file selected - * + * * @param file * @return generated name or <code>null</code> if it was not possible to * generate the suitable name @@ -499,7 +481,7 @@ public abstract class AddScriptInterpreterDialog extends StatusDialog /** * Validates the automatically generated interpreter name - * + * * @param name * @return <code>true</code> if specified name is unique and * <code>false</code> otherwise @@ -540,6 +522,7 @@ public abstract class AddScriptInterpreterDialog extends StatusDialog return status; } + @Override public void updateStatusLine() { IStatus max = null; for (int i = 0; i < fStati.length; i++) { @@ -569,6 +552,7 @@ public abstract class AddScriptInterpreterDialog extends StatusDialog } } + @Override protected void okPressed() { doOkPressed(); super.okPressed(); @@ -656,10 +640,11 @@ public abstract class AddScriptInterpreterDialog extends StatusDialog /** * Updates the status of the ok button to reflect the given status. * Subclasses may override this method to update additional buttons. - * + * * @param status * the status. */ + @Override protected void updateButtonsEnableState(IStatus status) { Button ok = getButton(IDialogConstants.OK_ID); if (ok != null && !ok.isDisposed()) @@ -669,6 +654,7 @@ public abstract class AddScriptInterpreterDialog extends StatusDialog /** * @see org.eclipse.jface.dialogs.Dialog#setButtonLayoutData(org.eclipse.swt.widgets.Button) */ + @Override public void setButtonLayoutData(Button button) { super.setButtonLayoutData(button); ((GridData) button.getLayoutData()).grabExcessHorizontalSpace = true; @@ -676,18 +662,14 @@ public abstract class AddScriptInterpreterDialog extends StatusDialog /** * Returns the name of the section that this dialog stores its settings in - * + * * @return String */ protected String getDialogSettingsSectionName() { return "ADD_INTERPRETER_DIALOG_SECTION"; //$NON-NLS-1$ } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.dialogs.Dialog#getDialogBoundsSettings() - */ + @Override protected IDialogSettings getDialogBoundsSettings() { IDialogSettings settings = DLTKDebugUIPlugin.getDefault() .getDialogSettings(); @@ -713,7 +695,7 @@ public abstract class AddScriptInterpreterDialog extends StatusDialog /** * Re discover libraries if environment variables are changed. - * + * * @param environmentVariables */ public void updateLibraries(EnvironmentVariable[] newVars, @@ -732,6 +714,7 @@ public abstract class AddScriptInterpreterDialog extends StatusDialog return this.lastInstall; } + @Override public boolean execute() { return open() == Window.OK; } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/EnvironmentVariableContentProvider.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/EnvironmentVariableContentProvider.java index 423e070b0..48b5afebc 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/EnvironmentVariableContentProvider.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/EnvironmentVariableContentProvider.java @@ -1,11 +1,10 @@ /******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. + * Copyright (c) 2006, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.internal.debug.ui.interpreters; @@ -24,19 +23,23 @@ import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.Viewer; import org.eclipse.osgi.util.NLS; -public class EnvironmentVariableContentProvider implements ITreeContentProvider { +public class EnvironmentVariableContentProvider + implements ITreeContentProvider { private Viewer fViewer; private EnvironmentVariable[] fVariables = new EnvironmentVariable[0]; + @Override public void dispose() { } + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { fViewer = viewer; } + @Override public Object[] getElements(Object inputElement) { return fVariables; } @@ -112,7 +115,7 @@ public class EnvironmentVariableContentProvider implements ITreeContentProvider * Remove the libraries contained in the given selection. */ public void remove(IStructuredSelection selection) { - List<EnvironmentVariable> newLibraries = new ArrayList<EnvironmentVariable>(); + List<EnvironmentVariable> newLibraries = new ArrayList<>(); for (int i = 0; i < fVariables.length; i++) { newLibraries.add(fVariables[i]); } @@ -124,8 +127,8 @@ public class EnvironmentVariableContentProvider implements ITreeContentProvider newLibraries.remove(element); } } - fVariables = newLibraries.toArray(new EnvironmentVariable[newLibraries - .size()]); + fVariables = newLibraries + .toArray(new EnvironmentVariable[newLibraries.size()]); fViewer.refresh(); } @@ -133,13 +136,14 @@ public class EnvironmentVariableContentProvider implements ITreeContentProvider * Add the given libraries before the selection, or after the existing * libraries if the selection is empty. */ - public void add(EnvironmentVariable[] libs, IStructuredSelection selection) { - List<EnvironmentVariable> newLibraries = new ArrayList<EnvironmentVariable>( + public void add(EnvironmentVariable[] libs, + IStructuredSelection selection) { + List<EnvironmentVariable> newLibraries = new ArrayList<>( fVariables.length + libs.length); for (int i = 0; i < fVariables.length; i++) { newLibraries.add(fVariables[i]); } - List<EnvironmentVariable> toAdd = new ArrayList<EnvironmentVariable>( + List<EnvironmentVariable> toAdd = new ArrayList<>( libs.length); for (int i = 0; i < libs.length; i++) { toAdd.add(new EnvironmentVariable(libs[i])); @@ -152,8 +156,8 @@ public class EnvironmentVariableContentProvider implements ITreeContentProvider int index = newLibraries.indexOf(firstLib); newLibraries.addAll(index, toAdd); } - fVariables = newLibraries.toArray(new EnvironmentVariable[newLibraries - .size()]); + fVariables = newLibraries + .toArray(new EnvironmentVariable[newLibraries.size()]); fViewer.refresh(); fViewer.setSelection(new StructuredSelection(libs), true); } @@ -162,7 +166,7 @@ public class EnvironmentVariableContentProvider implements ITreeContentProvider * Attempts to add the given variable. Returns whether the variable was * added or not (as when the user answers not to overwrite an existing * variable). - * + * * @param variable * the variable to add * @return whether the variable was added @@ -170,19 +174,18 @@ public class EnvironmentVariableContentProvider implements ITreeContentProvider */ public boolean addVariable(EnvironmentVariable variable) { String name = variable.getName(); - List<EnvironmentVariable> newVars = new ArrayList<EnvironmentVariable>(); + List<EnvironmentVariable> newVars = new ArrayList<>(); newVars.addAll(Arrays.asList(fVariables)); - for (Iterator<EnvironmentVariable> i = newVars.iterator(); i.hasNext();) { + for (Iterator<EnvironmentVariable> i = newVars.iterator(); i + .hasNext();) { EnvironmentVariable existingVariable = i.next(); if (existingVariable.getName().equals(name)) { - boolean overWrite = MessageDialog - .openQuestion( - fViewer.getControl().getShell(), - Messages.EnvironmentVariableContentProvider_overwriteVariableTitle, - NLS - .bind( - Messages.EnvironmentVariableContentProvider_overwriteVariableMessage, - name)); + boolean overWrite = MessageDialog.openQuestion( + fViewer.getControl().getShell(), + Messages.EnvironmentVariableContentProvider_overwriteVariableTitle, + NLS.bind( + Messages.EnvironmentVariableContentProvider_overwriteVariableMessage, + name)); if (!overWrite) { return false; } @@ -197,23 +200,26 @@ public class EnvironmentVariableContentProvider implements ITreeContentProvider /** * Returns the standin libraries being edited. - * + * * @return standins */ public EnvironmentVariable[] getStandins() { return fVariables; } + @Override public Object[] getChildren(Object parentElement) { // TODO Auto-generated method stub return null; } + @Override public Object getParent(Object element) { // TODO Auto-generated method stub return null; } + @Override public boolean hasChildren(Object element) { // TODO Auto-generated method stub return false; diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/InternalScriptInterpreterPreferenceBlock.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/InternalScriptInterpreterPreferenceBlock.java index 2f6947a63..12fdad5d1 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/InternalScriptInterpreterPreferenceBlock.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/InternalScriptInterpreterPreferenceBlock.java @@ -23,8 +23,8 @@ import org.eclipse.swt.widgets.Group; * Preference block that can be used to select an installed interpreter for * 'internal' editor, etc use. */ -public abstract class InternalScriptInterpreterPreferenceBlock extends - ImprovedAbstractConfigurationBlock { +public abstract class InternalScriptInterpreterPreferenceBlock + extends ImprovedAbstractConfigurationBlock { private ComboViewerBlock viewer; @@ -33,41 +33,45 @@ public abstract class InternalScriptInterpreterPreferenceBlock extends super(store, page); } - /* - * @see org.eclipse.dltk.ui.preferences.IPreferenceConfigurationBlock#createControl(org.eclipse.swt.widgets.Composite) - */ + @Override public final Control createControl(Composite parent) { - Composite composite = SWTFactory.createComposite(parent, parent - .getFont(), 1, 1, GridData.FILL); + Composite composite = SWTFactory.createComposite(parent, + parent.getFont(), 1, 1, GridData.FILL); - Group group = SWTFactory.createGroup(composite, - getSelectorGroupLabel(), 1, 1, GridData.FILL_HORIZONTAL); + Group group = SWTFactory.createGroup(composite, getSelectorGroupLabel(), + 1, 1, GridData.FILL_HORIZONTAL); SWTFactory.createLabel(group, getSelectorNameLabel(), 1); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); viewer = new ComboViewerBlock(group, gd) { + @Override protected String getObjectName(Object element) { return ((IInterpreterInstall) element).getName(); } + @Override protected void selectedObjectChanged(Object element) { setString(getPreferenceKey(), getObjectId(element)); } + @Override protected Object getDefaultObject() { return getDefaultSelectedInterpreter(); } + @Override protected String getObjectId(Object element) { - return ScriptRuntime - .getCompositeIdFromInterpreter((IInterpreterInstall) element); + return ScriptRuntime.getCompositeIdFromInterpreter( + (IInterpreterInstall) element); } + @Override protected String getSavedObjectId() { return getString(getPreferenceKey()); } + @Override protected Object getObjectById(String id) { return ScriptRuntime.getInterpreterFromCompositeId(id); } @@ -108,11 +112,9 @@ public abstract class InternalScriptInterpreterPreferenceBlock extends LocalEnvironment.getInstance()); } - /* - * @see org.eclipse.dltk.ui.preferences.ImprovedAbstractConfigurationBlock#createOverlayKeys() - */ + @Override protected List<OverlayKey> createOverlayKeys() { - ArrayList<OverlayKey> keys = new ArrayList<OverlayKey>(1); + ArrayList<OverlayKey> keys = new ArrayList<>(1); keys.add(new OverlayPreferenceStore.OverlayKey( OverlayPreferenceStore.STRING, getPreferenceKey())); @@ -120,16 +122,14 @@ public abstract class InternalScriptInterpreterPreferenceBlock extends return keys; } - /* - * @see org.eclipse.dltk.ui.preferences.ImprovedAbstractConfigurationBlock#performDefaults() - */ + @Override public void performDefaults() { super.performDefaults(); viewer.performDefaults(); } private IInterpreterInstall[] getInterpreterInstalls() { - List<IInterpreterInstall> interpreters = new ArrayList<IInterpreterInstall>(); + List<IInterpreterInstall> interpreters = new ArrayList<>(); IInterpreterInstallType[] types = ScriptRuntime .getInterpreterInstallTypes(getNatureId()); for (int i = 0; i < types.length; i++) { diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/InterpretersBlock.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/InterpretersBlock.java index 27dd904a4..45afab38c 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/InterpretersBlock.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/InterpretersBlock.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2016 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -36,11 +36,7 @@ import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.ProgressMonitorDialog; import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.viewers.CheckStateChangedEvent; import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.ICheckStateListener; -import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionProvider; @@ -65,9 +61,7 @@ import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; @@ -93,7 +87,7 @@ public abstract class InterpretersBlock /** * Interpreters being displayed */ - protected List<IInterpreterInstall> fInterpreters = new ArrayList<IInterpreterInstall>(); + protected List<IInterpreterInstall> fInterpreters = new ArrayList<>(); /** * The main list control @@ -112,7 +106,7 @@ public abstract class InterpretersBlock /** * Environment to checked interpreter. */ - private Map<IEnvironment, IInterpreterInstall> checkedInterpreters = new HashMap<IEnvironment, IInterpreterInstall>(); + private Map<IEnvironment, IInterpreterInstall> checkedInterpreters = new HashMap<>(); // index of column used for sorting private int fSortColumn = 0; @@ -133,14 +127,17 @@ public abstract class InterpretersBlock * Content provider to show a list of InterpreterEnvironments */ class InterpretersContentProvider implements IStructuredContentProvider { + @Override public Object[] getElements(Object input) { return getCurrentInterprers(); } + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } + @Override public void dispose() { } } @@ -154,6 +151,7 @@ public abstract class InterpretersBlock /** * @see ITableLabelProvider#getColumnText(Object, int) */ + @Override public String getColumnText(Object element, int columnIndex) { if (element instanceof IInterpreterInstall) { IInterpreterInstall interp = (IInterpreterInstall) element; @@ -172,6 +170,7 @@ public abstract class InterpretersBlock /** * @see ITableLabelProvider#getColumnImage(Object, int) */ + @Override public Image getColumnImage(Object element, int columnIndex) { if (columnIndex == 0) { // TODO: instert interpreter logo here @@ -183,11 +182,12 @@ public abstract class InterpretersBlock /* * (non-Javadoc) - * + * * @see * org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener * (org.eclipse.jface.viewers.ISelectionChangedListener) */ + @Override public void addSelectionChangedListener( ISelectionChangedListener listener) { fSelectionListeners.add(listener); @@ -195,20 +195,22 @@ public abstract class InterpretersBlock /* * (non-Javadoc) - * + * * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection() */ + @Override public ISelection getSelection() { return new StructuredSelection(fInterpreterList.getCheckedElements()); } /* * (non-Javadoc) - * + * * @see org.eclipse.jface.viewers.ISelectionProvider# * removeSelectionChangedListener * (org.eclipse.jface.viewers.ISelectionChangedListener) */ + @Override public void removeSelectionChangedListener( ISelectionChangedListener listener) { fSelectionListeners.remove(listener); @@ -216,11 +218,12 @@ public abstract class InterpretersBlock /* * (non-Javadoc) - * + * * @see * org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse * .jface.viewers.ISelection) */ + @Override public void setSelection(ISelection selection) { if (selection instanceof IStructuredSelection) { if (!selection.equals(fPrevSelection)) { @@ -243,7 +246,7 @@ public abstract class InterpretersBlock /** * Creates this block's control in the given control. - * + * * @param ancestor * containing control * @param useManageButton @@ -296,6 +299,7 @@ public abstract class InterpretersBlock this.fEnvironments.select(local); this.fEnvironments.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { Object install = checkedInterpreters .get(getCurrentEnvironment()); @@ -337,6 +341,7 @@ public abstract class InterpretersBlock TableColumn column1 = new TableColumn(fTable, SWT.NULL); column1.setText(InterpretersMessages.InstalledInterpretersBlock_0); column1.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { sortByName(); } @@ -346,6 +351,7 @@ public abstract class InterpretersBlock TableColumn column2 = new TableColumn(fTable, SWT.NULL); column2.setText(InterpretersMessages.InstalledInterpretersBlock_2); column2.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { sortByType(); } @@ -355,6 +361,7 @@ public abstract class InterpretersBlock TableColumn column3 = new TableColumn(fTable, SWT.NULL); column3.setText(InterpretersMessages.InstalledInterpretersBlock_1); column3.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { sortByLocation(); } @@ -367,32 +374,23 @@ public abstract class InterpretersBlock // by default, sort by name sortByName(); - fInterpreterList - .addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent evt) { - enableButtons(); - } - }); + fInterpreterList.addSelectionChangedListener(evt -> enableButtons()); - fInterpreterList.addCheckStateListener(new ICheckStateListener() { - public void checkStateChanged(CheckStateChangedEvent event) { - if (event.getChecked()) { - setCheckedInterpreter( - (IInterpreterInstall) event.getElement()); - } else { - setCheckedInterpreter(null); - } + fInterpreterList.addCheckStateListener(event -> { + if (event.getChecked()) { + setCheckedInterpreter((IInterpreterInstall) event.getElement()); + } else { + setCheckedInterpreter(null); } }); - fInterpreterList.addDoubleClickListener(new IDoubleClickListener() { - public void doubleClick(DoubleClickEvent e) { - if (!fInterpreterList.getSelection().isEmpty()) { - editInterpreter(); - } + fInterpreterList.addDoubleClickListener(e -> { + if (!fInterpreterList.getSelection().isEmpty()) { + editInterpreter(); } }); fTable.addKeyListener(new KeyAdapter() { + @Override public void keyPressed(KeyEvent event) { if (event.character == SWT.DEL && event.stateMask == 0) { if (fRemoveButton.getEnabled()) @@ -413,35 +411,19 @@ public abstract class InterpretersBlock fAddButton = createPushButton(buttons, InterpretersMessages.InstalledInterpretersBlock_3); - fAddButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event evt) { - addInterpreter(); - } - }); + fAddButton.addListener(SWT.Selection, evt -> addInterpreter()); fEditButton = createPushButton(buttons, InterpretersMessages.InstalledInterpretersBlock_4); - fEditButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event evt) { - editInterpreter(); - } - }); + fEditButton.addListener(SWT.Selection, evt -> editInterpreter()); fCopyButton = createPushButton(buttons, InterpretersMessages.InstalledInterpretersBlock_16); - fCopyButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event evt) { - copyInterpreter(); - } - }); + fCopyButton.addListener(SWT.Selection, evt -> copyInterpreter()); fRemoveButton = createPushButton(buttons, InterpretersMessages.InstalledInterpretersBlock_5); - fRemoveButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event evt) { - removeInterpreters(); - } - }); + fRemoveButton.addListener(SWT.Selection, evt -> removeInterpreters()); // copied from ListDialogField.CreateSeparator() Label separator = new Label(buttons, SWT.NONE); @@ -454,11 +436,7 @@ public abstract class InterpretersBlock fSearchButton = createPushButton(buttons, InterpretersMessages.InstalledInterpretersBlock_6); - fSearchButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event evt) { - search(); - } - }); + fSearchButton.addListener(SWT.Selection, evt -> search()); fillWithWorkspaceInterpreters(); enableButtons(); @@ -484,6 +462,7 @@ public abstract class InterpretersBlock */ private void sortByType() { fInterpreterList.setSorter(new ViewerSorter() { + @Override public int compare(Viewer viewer, Object e1, Object e2) { if ((e1 instanceof IInterpreterInstall) && (e2 instanceof IInterpreterInstall)) { @@ -502,6 +481,7 @@ public abstract class InterpretersBlock return super.compare(viewer, e1, e2); } + @Override public boolean isSorterProperty(Object element, String property) { return true; } @@ -514,6 +494,7 @@ public abstract class InterpretersBlock */ private void sortByName() { fInterpreterList.setSorter(new ViewerSorter() { + @Override public int compare(Viewer viewer, Object e1, Object e2) { if ((e1 instanceof IInterpreterInstall) && (e2 instanceof IInterpreterInstall)) { @@ -524,6 +505,7 @@ public abstract class InterpretersBlock return super.compare(viewer, e1, e2); } + @Override public boolean isSorterProperty(Object element, String property) { return true; } @@ -536,6 +518,7 @@ public abstract class InterpretersBlock */ private void sortByLocation() { fInterpreterList.setSorter(new ViewerSorter() { + @Override public int compare(Viewer viewer, Object e1, Object e2) { if ((e1 instanceof IInterpreterInstall) && (e2 instanceof IInterpreterInstall)) { @@ -548,6 +531,7 @@ public abstract class InterpretersBlock return super.compare(viewer, e1, e2); } + @Override public boolean isSorterProperty(Object element, String property) { return true; } @@ -587,7 +571,7 @@ public abstract class InterpretersBlock /** * Returns this block's control - * + * * @return control */ public Control getControl() { @@ -596,7 +580,7 @@ public abstract class InterpretersBlock /** * Sets the InterpreterEnvironments to be displayed in this block - * + * * @param Interpreters * InterpreterEnvironments to be displayed */ @@ -612,7 +596,7 @@ public abstract class InterpretersBlock /** * Returns the InterpreterEnvironments currently being displayed in this * block - * + * * @return InterpreterEnvironments currently being displayed in this block */ public IInterpreterInstall[] getInterpreters() { @@ -622,7 +606,7 @@ public abstract class InterpretersBlock public IInterpreterInstall[] getCurrentInterprers() { IEnvironment environment = getCurrentEnvironment(); - List<IInterpreterInstall> result = new ArrayList<IInterpreterInstall>(); + List<IInterpreterInstall> result = new ArrayList<>(); for (Iterator<IInterpreterInstall> iterator = fInterpreters .iterator(); iterator.hasNext();) { IInterpreterInstall install = iterator.next(); @@ -637,6 +621,7 @@ public abstract class InterpretersBlock /** * @see IAddInterpreterDialogRequestor#isDuplicateName(String) */ + @Override public boolean isDuplicateName(String name, IInterpreterInstall editedInterpreter) { for (int i = 0; i < fInterpreters.size(); i++) { @@ -679,7 +664,7 @@ public abstract class InterpretersBlock /** * Removes the given Interpreters from the table. - * + * * @param Interpreters */ public void removeInterpreters(IInterpreterInstall[] Interpreters) { @@ -707,7 +692,7 @@ public abstract class InterpretersBlock // choose a root directory for the search // ignore installed locations - final Set<IFileHandle> exstingLocations = new HashSet<IFileHandle>(); + final Set<IFileHandle> exstingLocations = new HashSet<>(); Iterator<IInterpreterInstall> iter = fInterpreters.iterator(); while (iter.hasNext()) { exstingLocations.add(iter.next().getInstallLocation()); @@ -718,18 +703,16 @@ public abstract class InterpretersBlock final IEnvironment currentEnvironment = getCurrentEnvironment(); - IRunnableWithProgress r = new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) { - try { - monitor.beginTask( - InterpretersMessages.InstalledInterpretersBlock_11, - IProgressMonitor.UNKNOWN); - - searcher.search(currentEnvironment, getCurrentNature(), - exstingLocations, 1, monitor); - } finally { - monitor.done(); - } + IRunnableWithProgress r = monitor -> { + try { + monitor.beginTask( + InterpretersMessages.InstalledInterpretersBlock_11, + IProgressMonitor.UNKNOWN); + + searcher.search(currentEnvironment, getCurrentNature(), + exstingLocations, 1, monitor); + } finally { + monitor.done(); } }; @@ -792,18 +775,16 @@ public abstract class InterpretersBlock InterpretersMessages.InstalledInterpretersBlock_12, InterpretersMessages.InstalledInterpretersBlock_113); } - fTable.getDisplay().asyncExec(new Runnable() { - public void run() { - PixelConverter conv = new PixelConverter(fTable); - for (int i = 0; i < 2; i++) { - int nw1 = conv.convertWidthInCharsToPixels(widths[i]); - TableColumn cl0 = fTable.getColumn(i); - if (cl0.getWidth() < nw1) { - cl0.setWidth(nw1); - } + fTable.getDisplay().asyncExec(() -> { + PixelConverter conv = new PixelConverter(fTable); + for (int i = 0; i < 2; i++) { + int nw1 = conv.convertWidthInCharsToPixels(widths[i]); + TableColumn cl0 = fTable.getColumn(i); + if (cl0.getWidth() < nw1) { + cl0.setWidth(nw1); } - fTable.layout(); } + fTable.layout(); }); } } @@ -814,7 +795,7 @@ public abstract class InterpretersBlock /** * Sets the checked InterpreterEnvironment, possible <code>null</code> - * + * * @param interpreter * InterpreterEnvironment or <code>null</code> */ @@ -831,7 +812,7 @@ public abstract class InterpretersBlock /** * Returns the checked Interpreter or <code>null</code> if none. - * + * * @return the checked Interpreter or <code>null</code> if none */ public IInterpreterInstall[] getCheckedInterpreters() { @@ -849,7 +830,7 @@ public abstract class InterpretersBlock /** * Persist table settings into the give dialog store, prefixed with the * given key. - * + * * @param settings * dialog store * @param qualifier @@ -866,7 +847,7 @@ public abstract class InterpretersBlock /** * Restore table settings from the given dialog store using the given key. - * + * * @param settings * dialog settings store * @param qualifier @@ -919,7 +900,7 @@ public abstract class InterpretersBlock */ protected void fillWithWorkspaceInterpreters() { // fill with interpreters - List<InterpreterStandin> standins = new ArrayList<InterpreterStandin>(); + List<InterpreterStandin> standins = new ArrayList<>(); IInterpreterInstallType[] types = ScriptRuntime .getInterpreterInstallTypes(getCurrentNature()); for (int i = 0; i < types.length; i++) { @@ -935,6 +916,7 @@ public abstract class InterpretersBlock standins.toArray(new IInterpreterInstall[standins.size()])); } + @Override public void interpreterAdded(IInterpreterInstall Interpreter) { fInterpreters.add(Interpreter); fInterpreterList.refresh(); @@ -981,11 +963,11 @@ public abstract class InterpretersBlock /** * Compares the given name against current names and adds the appropriate * numerical suffix to ensure that it is unique. - * + * * @param name * the name with which to ensure uniqueness * @return the unique version of the given name - * + * */ protected String generateName(String name) { if (!isDuplicateName(name, null)) { @@ -1010,7 +992,7 @@ public abstract class InterpretersBlock /** * Creates the {@link IInterpreterInstall} add/edit dialog. Should be * overridden. - * + * * @param environment * @param standin * @return @ @@ -1044,7 +1026,7 @@ public abstract class InterpretersBlock .getSelection(); Iterator it = selection.iterator(); - ArrayList<InterpreterStandin> newEntries = new ArrayList<InterpreterStandin>(); + ArrayList<InterpreterStandin> newEntries = new ArrayList<>(); while (it.hasNext()) { IInterpreterInstall selectedInterpreter = (IInterpreterInstall) it .next(); diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/LibraryContentProvider.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/LibraryContentProvider.java index da3bceafa..a8556394b 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/LibraryContentProvider.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/LibraryContentProvider.java @@ -1,11 +1,10 @@ /******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. + * Copyright (c) 2006, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.internal.debug.ui.interpreters; @@ -31,17 +30,19 @@ public class LibraryContentProvider implements ITreeContentProvider { protected LibraryStandin[] fLibraries = new LibraryStandin[0]; protected LibraryStandin[] fAllLibraries = new LibraryStandin[0]; - public LibraryContentProvider() { } + @Override public void dispose() { } + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { fViewer = (TreeViewer) viewer; } + @Override public Object[] getElements(Object inputElement) { return fLibraries; } @@ -59,7 +60,8 @@ public class LibraryContentProvider implements ITreeContentProvider { } public void initialize(IFileHandle file, - EnvironmentVariable[] environmentVariables, boolean restoreDefault) { + EnvironmentVariable[] environmentVariables, + boolean restoreDefault) { } @@ -159,8 +161,7 @@ public class LibraryContentProvider implements ITreeContentProvider { LibraryStandin firstLib = (LibraryStandin) element; int index = newLibraries.indexOf(firstLib); newLibraries.addAll(index, toAdd); - } - else { + } else { newLibraries.addAll(toAdd); } } @@ -172,23 +173,26 @@ public class LibraryContentProvider implements ITreeContentProvider { /** * Returns the standin libraries being edited. - * + * * @return standins */ public LibraryStandin[] getStandins() { return fLibraries; } + @Override public Object[] getChildren(Object parentElement) { // TODO Auto-generated method stub return null; } + @Override public Object getParent(Object element) { // TODO Auto-generated method stub return null; } + @Override public boolean hasChildren(Object element) { // TODO Auto-generated method stub return false; diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/LibraryLabelProvider.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/LibraryLabelProvider.java index e1df5f3c2..c727b295c 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/LibraryLabelProvider.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/LibraryLabelProvider.java @@ -1,11 +1,10 @@ /******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. + * Copyright (c) 2006, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.internal.debug.ui.interpreters; @@ -17,29 +16,32 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.graphics.Image; - public class LibraryLabelProvider extends LabelProvider { + @Override public Image getImage(Object element) { if (element instanceof LibraryStandin) { - LibraryStandin library= (LibraryStandin) element; + LibraryStandin library = (LibraryStandin) element; String key = null; key = DLTKPluginImages.IMG_OBJS_EXTJAR; IStatus status = library.validate(); if (!status.isOK()) { ImageDescriptor base = DLTKPluginImages.getDescriptor(key); - DebugImageDescriptor descriptor= new DebugImageDescriptor(base, DebugImageDescriptor.IS_OUT_OF_SYNCH); - return DLTKDebugUIPlugin.getImageDescriptorRegistry().get(descriptor); + DebugImageDescriptor descriptor = new DebugImageDescriptor(base, + DebugImageDescriptor.IS_OUT_OF_SYNCH); + return DLTKDebugUIPlugin.getImageDescriptorRegistry() + .get(descriptor); } return DLTKPluginImages.get(key); - } + } return null; } + @Override public String getText(Object element) { if (element instanceof LibraryStandin) { - return ((LibraryStandin)element).getLibraryPathString(); - } + return ((LibraryStandin) element).getLibraryPathString(); + } return null; } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/LibraryStandin.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/LibraryStandin.java index 72ba3eb4b..8fdb63a90 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/LibraryStandin.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/LibraryStandin.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - + *******************************************************************************/ package org.eclipse.dltk.internal.debug.ui.interpreters; @@ -21,7 +21,7 @@ import org.eclipse.osgi.util.NLS; /** * Wrapper for an original library location, to support editing. - * + * */ public final class LibraryStandin { private IPath fLibraryLocation; @@ -39,18 +39,14 @@ public final class LibraryStandin { /** * Returns the InterpreterEnvironment library archive location. - * + * * @return The InterpreterEnvironment library archive location. */ public String getLibraryPathString() { return EnvironmentPathUtils.getLocalPathString(fLibraryLocation); } - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ + @Override public boolean equals(Object obj) { if (obj instanceof LibraryStandin) { LibraryStandin lib = (LibraryStandin) obj; @@ -59,11 +55,7 @@ public final class LibraryStandin { return false; } - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ + @Override public int hashCode() { return fLibraryLocation.hashCode(); } @@ -71,7 +63,7 @@ public final class LibraryStandin { /** * Returns whether the given paths are equal - either may be * <code>null</code>. - * + * * @param path1 * path to be compared * @param path2 @@ -85,13 +77,13 @@ public final class LibraryStandin { /** * Returns whether the given objects are equal - either may be * <code>null</code>. - * + * * @param o1 * object to be compared * @param o2 * object to be compared * @return whether the given objects are equal or both null - * + * */ private boolean equalsOrNull(Object o1, Object o2) { if (o1 == null) { @@ -105,7 +97,7 @@ public final class LibraryStandin { /** * Returns an equivalent library location. - * + * * @return library location */ public LibraryLocation toLibraryLocation() { @@ -114,18 +106,19 @@ public final class LibraryStandin { /** * Returns a status for this library describing any error states - * + * * @param environment - * + * * @return */ public IStatus validate() { IFileHandle f = EnvironmentPathUtils.getFile(fLibraryLocation); if (!f.exists()) { return new Status(IStatus.ERROR, DLTKDebugUIPlugin.PLUGIN_ID, - IDLTKDebugUIConstants.INTERNAL_ERROR, NLS - .bind(InterpretersMessages.LibraryStandin_0, f - .toString()), null); + IDLTKDebugUIConstants.INTERNAL_ERROR, + NLS.bind(InterpretersMessages.LibraryStandin_0, + f.toString()), + null); } return Status.OK_STATUS; } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/ScriptInterpreterPreferencePage.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/ScriptInterpreterPreferencePage.java index 9df6404d5..450838cab 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/ScriptInterpreterPreferencePage.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/interpreters/ScriptInterpreterPreferencePage.java @@ -1,11 +1,10 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.internal.debug.ui.interpreters; @@ -25,8 +24,6 @@ import org.eclipse.dltk.launching.ScriptRuntime; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.preference.PreferencePage; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.swt.custom.BusyIndicator; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -54,9 +51,7 @@ public abstract class ScriptInterpreterPreferencePage extends PreferencePage setDescription(InterpretersMessages.InterpretersPreferencePage_2); } - /* - * @see IWorkbenchPreferencePage#init(IWorkbench) - */ + @Override public void init(IWorkbench workbench) { } @@ -89,9 +84,11 @@ public abstract class ScriptInterpreterPreferencePage extends PreferencePage if (!verified) { if (fInterpretersBlock.getInterpreters().length > 0) - setErrorMessage(InterpretersMessages.InterpreterPreferencePage_pleaseSetDefaultInterpreter); + setErrorMessage( + InterpretersMessages.InterpreterPreferencePage_pleaseSetDefaultInterpreter); else - setErrorMessage(InterpretersMessages.InterpreterPreferencePage_addInterpreter); + setErrorMessage( + InterpretersMessages.InterpreterPreferencePage_addInterpreter); } } } @@ -121,22 +118,21 @@ public abstract class ScriptInterpreterPreferencePage extends PreferencePage PlatformUI.getWorkbench().getHelpSystem().setHelp(ancestor, IScriptDebugHelpContextIds.INTERPRETER_PREFERENCE_PAGE); initDefaultInterpreter(); - fInterpretersBlock - .addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - IInterpreterInstall[] install = getCurrentDefaultInterpreters(); - - setErrorMessage(null); - if (fInterpretersBlock.getInterpreters().length > 0 - && install.length < fInterpretersBlock - .getEnvironmentsCount()) { - setErrorMessage(InterpretersMessages.InterpreterPreferencePage_pleaseSetDefaultInterpreter); - - } else if (fInterpretersBlock.getInterpreters().length == 0) { - setErrorMessage(InterpretersMessages.InterpreterPreferencePage_addInterpreter); - } - } - }); + fInterpretersBlock.addSelectionChangedListener(event -> { + IInterpreterInstall[] install = getCurrentDefaultInterpreters(); + + setErrorMessage(null); + if (fInterpretersBlock.getInterpreters().length > 0 + && install.length < fInterpretersBlock + .getEnvironmentsCount()) { + setErrorMessage( + InterpretersMessages.InterpreterPreferencePage_pleaseSetDefaultInterpreter); + + } else if (fInterpretersBlock.getInterpreters().length == 0) { + setErrorMessage( + InterpretersMessages.InterpreterPreferencePage_addInterpreter); + } + }); applyDialogFont(ancestor); return ancestor; } @@ -144,17 +140,16 @@ public abstract class ScriptInterpreterPreferencePage extends PreferencePage @Override public boolean performOk() { final boolean[] canceled = new boolean[] { false }; - BusyIndicator.showWhile(null, new Runnable() { - public void run() { - IInterpreterInstall[] defaultInterpreter = getCurrentDefaultInterpreters(); - IInterpreterInstall[] interpreters = fInterpretersBlock - .getInterpreters(); - - InterpretersUpdater updater = new InterpretersUpdater(); - if (!updater.updateInterpreterSettings(fInterpretersBlock - .getCurrentNature(), interpreters, defaultInterpreter)) { - canceled[0] = true; - } + BusyIndicator.showWhile(null, () -> { + IInterpreterInstall[] defaultInterpreter = getCurrentDefaultInterpreters(); + IInterpreterInstall[] interpreters = fInterpretersBlock + .getInterpreters(); + + InterpretersUpdater updater = new InterpretersUpdater(); + if (!updater.updateInterpreterSettings( + fInterpretersBlock.getCurrentNature(), interpreters, + defaultInterpreter)) { + canceled[0] = true; } }); @@ -206,8 +201,8 @@ public abstract class ScriptInterpreterPreferencePage extends PreferencePage if (exist) { fInterpretersBlock.setCheckedInterpreter(interpreter); } else { - fInterpretersBlock - .removeInterpreters(new IInterpreterInstall[] { interpreter }); + fInterpretersBlock.removeInterpreters( + new IInterpreterInstall[] { interpreter }); IInterpreterInstall def = null; def = ScriptRuntime.getDefaultInterpreterInstall( fInterpretersBlock.getCurrentNature(), @@ -217,17 +212,13 @@ public abstract class ScriptInterpreterPreferencePage extends PreferencePage } else { fInterpretersBlock.setCheckedInterpreter(def); } - ErrorDialog - .openError( - getControl().getShell(), - InterpretersMessages.InterpretersPreferencePage_1, - InterpretersMessages.InterpretersPreferencePage_10, - new Status( - IStatus.ERROR, - DLTKDebugUIPlugin.PLUGIN_ID, - IDLTKDebugUIConstants.INTERNAL_ERROR, - InterpretersMessages.InterpretersPreferencePage_11, - null)); + ErrorDialog.openError(getControl().getShell(), + InterpretersMessages.InterpretersPreferencePage_1, + InterpretersMessages.InterpretersPreferencePage_10, + new Status(IStatus.ERROR, DLTKDebugUIPlugin.PLUGIN_ID, + IDLTKDebugUIConstants.INTERNAL_ERROR, + InterpretersMessages.InterpretersPreferencePage_11, + null)); return; } } else { diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/launcher/AbstractScriptLaunchShortcut.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/launcher/AbstractScriptLaunchShortcut.java index a6c24de20..8f4ce5bd2 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/launcher/AbstractScriptLaunchShortcut.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/launcher/AbstractScriptLaunchShortcut.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2016 IBM Corporation and others. + * Copyright (c) 2005, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -53,6 +53,7 @@ import org.eclipse.ui.dialogs.ElementListSelectionDialog; import org.eclipse.ui.model.WorkbenchLabelProvider; public abstract class AbstractScriptLaunchShortcut implements ILaunchShortcut { + @Override public void launch(ISelection selection, String mode) { if (selection instanceof IStructuredSelection) { searchAndLaunch(((IStructuredSelection) selection).toArray(), mode, @@ -95,12 +96,12 @@ public abstract class AbstractScriptLaunchShortcut implements ILaunchShortcut { /** * Prompts the user to select a type from the given types. - * + * * @param types * the types to choose from * @param title * the selection dialog title - * + * * @return the selected type or <code>null</code> if none. */ protected IResource chooseScript(IResource[] scripts, String title) { @@ -118,7 +119,7 @@ public abstract class AbstractScriptLaunchShortcut implements ILaunchShortcut { /** * Opens an error dialog on the given excpetion. - * + * * @param exception */ protected void reportErorr(CoreException exception) { @@ -127,6 +128,7 @@ public abstract class AbstractScriptLaunchShortcut implements ILaunchShortcut { exception.getStatus().getMessage()); } + @Override public void launch(IEditorPart editor, String mode) { IEditorInput editorInput = editor.getEditorInput(); if (editorInput == null) @@ -150,7 +152,7 @@ public abstract class AbstractScriptLaunchShortcut implements ILaunchShortcut { /** * Returns the type of configuration this shortcut is applicable to. - * + * * @return the type of configuration this shortcut is applicable to */ protected abstract ILaunchConfigurationType getConfigurationType(); @@ -158,7 +160,7 @@ public abstract class AbstractScriptLaunchShortcut implements ILaunchShortcut { /** * Locate a configuration to relaunch for the given type. If one cannot be * found, create one. - * + * * @return a re-useable config or <code>null</code> if none */ protected ILaunchConfiguration findLaunchConfiguration(IResource script, @@ -167,19 +169,17 @@ public abstract class AbstractScriptLaunchShortcut implements ILaunchShortcut { try { ILaunchConfiguration[] configs = DebugPlugin.getDefault() .getLaunchManager().getLaunchConfigurations(configType); - candidateConfigs = new ArrayList<ILaunchConfiguration>( + candidateConfigs = new ArrayList<>( configs.length); for (int i = 0; i < configs.length; i++) { ILaunchConfiguration config = configs[i]; - if (config - .getAttribute( - ScriptLaunchConfigurationConstants.ATTR_MAIN_SCRIPT_NAME, - Util.EMPTY_STRING) + if (config.getAttribute( + ScriptLaunchConfigurationConstants.ATTR_MAIN_SCRIPT_NAME, + Util.EMPTY_STRING) .equals(script.getProjectRelativePath().toString()) - && config - .getAttribute( - ScriptLaunchConfigurationConstants.ATTR_PROJECT_NAME, - Util.EMPTY_STRING) + && config.getAttribute( + ScriptLaunchConfigurationConstants.ATTR_PROJECT_NAME, + Util.EMPTY_STRING) .equals(script.getProject().getName())) { candidateConfigs.add(config); } @@ -284,14 +284,14 @@ public abstract class AbstractScriptLaunchShortcut implements ILaunchShortcut { /** * Returns the model elements corresponding to the given objects. - * + * * @param objects * selected objects * @return corresponding Script elements */ private IResource[] getScriptResources(Object[] objects, IProgressMonitor pm) { - List<IResource> list = new ArrayList<IResource>(objects.length); + List<IResource> list = new ArrayList<>(objects.length); for (int i = 0; i < objects.length; i++) { Object object = objects[i]; try { @@ -340,7 +340,7 @@ public abstract class AbstractScriptLaunchShortcut implements ILaunchShortcut { /** * Finds and returns the launchable scripts in the given selection of * elements. - * + * * @param elements * scope to search for launchable types * @param context @@ -357,15 +357,12 @@ public abstract class AbstractScriptLaunchShortcut implements ILaunchShortcut { try { final IResource[][] res = new IResource[1][]; - IRunnableWithProgress runnable = new IRunnableWithProgress() { - public void run(IProgressMonitor pm) - throws InvocationTargetException { - pm.beginTask( - LaunchingMessages.LaunchShortcut_searchingForScripts, - 1); - res[0] = getScriptResources(elements, pm); - pm.done(); - } + IRunnableWithProgress runnable = pm -> { + pm.beginTask( + LaunchingMessages.LaunchShortcut_searchingForScripts, + 1); + res[0] = getScriptResources(elements, pm); + pm.done(); }; context.run(true, true, runnable); @@ -377,7 +374,7 @@ public abstract class AbstractScriptLaunchShortcut implements ILaunchShortcut { /** * Returns the title for type selection dialog for this launch shortcut. - * + * * @return type selection dialog title */ protected String getScriptSelectionTitle() { @@ -387,7 +384,7 @@ public abstract class AbstractScriptLaunchShortcut implements ILaunchShortcut { /** * Returns an error message to use when the selection does not contain a * launchable type. - * + * * @return error message */ protected String getSelectionEmptyMessage() { diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/launcher/InterpreterArgumentsBlock.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/launcher/InterpreterArgumentsBlock.java index 9b810d8d2..e99d9bace 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/launcher/InterpreterArgumentsBlock.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/launcher/InterpreterArgumentsBlock.java @@ -1,11 +1,10 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.internal.debug.ui.launcher; @@ -20,8 +19,6 @@ import org.eclipse.dltk.debug.ui.messages.ScriptLaunchMessages; import org.eclipse.dltk.launching.ScriptLaunchConfigurationConstants; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Font; @@ -41,9 +38,7 @@ public class InterpreterArgumentsBlock extends CommonScriptLaunchTab { protected Text fInterpreterArgumentsText; private Button fPgrmArgVariableButton; - /** - * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(Composite) - */ + @Override public void createControl(Composite parent) { Font font = parent.getFont(); @@ -54,30 +49,28 @@ public class InterpreterArgumentsBlock extends CommonScriptLaunchTab { GridData gd = new GridData(GridData.FILL_BOTH); group.setLayoutData(gd); group.setFont(font); - group - .setText(ScriptLaunchMessages.InterpreterArgumentsTab_Interpreter_ar_guments); + group.setText( + ScriptLaunchMessages.InterpreterArgumentsTab_Interpreter_ar_guments); - fInterpreterArgumentsText = new Text(group, SWT.MULTI | SWT.WRAP - | SWT.BORDER | SWT.V_SCROLL); + fInterpreterArgumentsText = new Text(group, + SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL); gd = new GridData(GridData.FILL_BOTH); gd.heightHint = 40; gd.widthHint = 100; fInterpreterArgumentsText.setLayoutData(gd); fInterpreterArgumentsText.setFont(font); - fInterpreterArgumentsText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent evt) { - updateLaunchConfigurationDialog(); - } - }); - ControlAccessibleListener.addListener(fInterpreterArgumentsText, group - .getText()); + fInterpreterArgumentsText + .addModifyListener(evt -> updateLaunchConfigurationDialog()); + ControlAccessibleListener.addListener(fInterpreterArgumentsText, + group.getText()); fPgrmArgVariableButton = createPushButton(group, ScriptLaunchMessages.InterpreterArgumentsBlock, null); fPgrmArgVariableButton.setFont(font); - fPgrmArgVariableButton.setLayoutData(new GridData( - GridData.HORIZONTAL_ALIGN_END)); + fPgrmArgVariableButton + .setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); fPgrmArgVariableButton.addSelectionListener(new SelectionListener() { + @Override public void widgetSelected(SelectionEvent e) { StringVariableSelectionDialog dialog = new StringVariableSelectionDialog( getShell()); @@ -88,59 +81,49 @@ public class InterpreterArgumentsBlock extends CommonScriptLaunchTab { } } + @Override public void widgetDefaultSelected(SelectionEvent e) { } }); } - /** - * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(ILaunchConfigurationWorkingCopy) - */ + @Override public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { configuration.setAttribute( ScriptLaunchConfigurationConstants.ATTR_INTERPRETER_ARGUMENTS, (String) null); } - /** - * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(ILaunchConfiguration) - */ + @Override public void initializeFrom(ILaunchConfiguration configuration) { try { - fInterpreterArgumentsText - .setText(configuration - .getAttribute( - ScriptLaunchConfigurationConstants.ATTR_INTERPRETER_ARGUMENTS, - "")); //$NON-NLS-1$ + fInterpreterArgumentsText.setText(configuration.getAttribute( + ScriptLaunchConfigurationConstants.ATTR_INTERPRETER_ARGUMENTS, + "")); //$NON-NLS-1$ } catch (CoreException e) { - setErrorMessage(NLS - .bind( - ScriptLaunchMessages.InterpreterArgumentsTab_Exception_occurred_reading_configuration, - e.getStatus().getMessage())); + setErrorMessage(NLS.bind( + ScriptLaunchMessages.InterpreterArgumentsTab_Exception_occurred_reading_configuration, + e.getStatus().getMessage())); DLTKDebugUIPlugin.log(e); } } - /** - * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(ILaunchConfigurationWorkingCopy) - */ + @Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { configuration.setAttribute( ScriptLaunchConfigurationConstants.ATTR_INTERPRETER_ARGUMENTS, getAttributeValueFrom(fInterpreterArgumentsText)); } - /** - * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName() - */ + @Override public String getName() { return ScriptLaunchMessages.InterpreterArgumentsBlock_Interpreter_Arguments; } /** * Retuns the string in the text widget, or <code>null</code> if empty. - * + * * @return text or <code>null</code> */ protected String getAttributeValueFrom(Text text) { diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/launcher/WorkingDirectoryBlock.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/launcher/WorkingDirectoryBlock.java index 05ea4f5cd..4a466321b 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/launcher/WorkingDirectoryBlock.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/launcher/WorkingDirectoryBlock.java @@ -1,11 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * Copyright (c) 2005, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - *******************************************************************************/ package org.eclipse.dltk.internal.debug.ui.launcher; @@ -68,46 +67,45 @@ public class WorkingDirectoryBlock extends CommonScriptLaunchTab { /** * A listener to update for text changes and widget selection */ - private class WidgetListener extends SelectionAdapter implements - ModifyListener { + private class WidgetListener extends SelectionAdapter + implements ModifyListener { + @Override public void modifyText(ModifyEvent e) { updateLaunchConfigurationDialog(); }// end modifyText + @Override public void widgetSelected(SelectionEvent e) { Object source = e.getSource(); if (source == fWorkspaceButton) { handleWorkspaceDirBrowseButtonSelected(); - }// end if + } // end if else if (source == fFileSystemButton) { handleWorkingDirBrowseButtonSelected(); - }// end if + } // end if else if (source == fVariablesButton) { handleWorkingDirVariablesButtonSelected(); - }// end if + } // end if else if (source == fUseDefaultDirButton) { // only perform the action if this is the button that was // selected if (fUseDefaultDirButton.getSelection()) { setDefaultWorkingDir(); - }// end if - }// end if + } // end if + } // end if else if (source == fUseOtherDirButton) { // only perform the action if this is the button that was // selected if (fUseOtherDirButton.getSelection()) { handleUseOtherWorkingDirButtonSelected(); - }// end if - }// end if + } // end if + } // end if }// end widgetSelected }// end WidgetListener class private WidgetListener fListener = new WidgetListener(); - /* - * @see - * org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(Composite) - */ + @Override public void createControl(Composite parent) { Font font = parent.getFont(); @@ -170,11 +168,7 @@ public class WorkingDirectoryBlock extends CommonScriptLaunchTab { fVariablesButton.addSelectionListener(fListener); } - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.ui.ILaunchConfigurationTab#dispose() - */ + @Override public void dispose() { } @@ -189,12 +183,12 @@ public class WorkingDirectoryBlock extends CommonScriptLaunchTab { File path = new File(currentWorkingDir); if (path.exists()) { dialog.setFilterPath(currentWorkingDir); - }// end if - }// end if + } // end if + } // end if String selectedDirectory = dialog.open(); if (selectedDirectory != null) { fOtherWorkingText.setText(selectedDirectory); - }// end if + } // end if }// end handleQWrokingDirBrowseBUttonSelected /** @@ -205,7 +199,7 @@ public class WorkingDirectoryBlock extends CommonScriptLaunchTab { IContainer currentContainer = getContainer(); if (currentContainer == null) { currentContainer = ResourcesPlugin.getWorkspace().getRoot(); - }// end if + } // end if ContainerSelectionDialog dialog = new ContainerSelectionDialog( getShell(), currentContainer, false, ScriptLaunchMessages.WorkingDirectoryBlock_4); @@ -216,8 +210,9 @@ public class WorkingDirectoryBlock extends CommonScriptLaunchTab { && (results[0] instanceof IPath)) { IPath path = (IPath) results[0]; String containerName = path.makeRelative().toString(); - setOtherWorkingDirectoryText("${workspace_loc:" + containerName + "}"); //$NON-NLS-1$ //$NON-NLS-2$ - }// end if + setOtherWorkingDirectoryText( + "${workspace_loc:" + containerName + "}"); //$NON-NLS-1$ //$NON-NLS-2$ + } // end if }// end handleWorkspaceDirBrowseButtonSelected /** @@ -237,18 +232,18 @@ public class WorkingDirectoryBlock extends CommonScriptLaunchTab { .findContainersForLocation(new Path(path)); if (containers.length > 0) { res = containers[0]; - }// end if - }// end try + } // end if + } // end try catch (CoreException e) { } - }// end if + } // end if else { res = root.findMember(path); - }// end else + } // end else if (res instanceof IContainer) { return (IContainer) res; - }// end if - }// end if + } // end if + } // end if return null; }// end getContainer @@ -265,8 +260,8 @@ public class WorkingDirectoryBlock extends CommonScriptLaunchTab { /** * The other working dir radio button has been selected - * - * + * + * */ private void handleUseOtherWorkingDirButtonSelected() { fOtherWorkingText.setEnabled(true); @@ -286,7 +281,7 @@ public class WorkingDirectoryBlock extends CommonScriptLaunchTab { String variableText = dialog.getVariableExpression(); if (variableText != null) { fOtherWorkingText.insert(variableText); - }// end if + } // end if }// end handleWorkingDirVariablesButtonSelected /** @@ -311,8 +306,8 @@ public class WorkingDirectoryBlock extends CommonScriptLaunchTab { IEnvironment environment = EnvironmentManager .getEnvironment(project); if (environment != null) { - path = path - .replace('/', environment.getSeparatorChar()); + path = path.replace('/', + environment.getSeparatorChar()); } setDefaultWorkingDirectoryText(path); return; @@ -326,7 +321,7 @@ public class WorkingDirectoryBlock extends CommonScriptLaunchTab { /** * Returns the project associated with the specified launch configuration or * <code>null</code> if none. - * + * * @param configuration * @return * @throws CoreException @@ -337,17 +332,13 @@ public class WorkingDirectoryBlock extends CommonScriptLaunchTab { ScriptLaunchConfigurationConstants.ATTR_PROJECT_NAME, Util.EMPTY_STRING); if (!projectName.equals(Util.EMPTY_STRING)) { - return DLTKCore.create(getWorkspaceRoot()).getScriptProject( - projectName); + return DLTKCore.create(getWorkspaceRoot()) + .getScriptProject(projectName); } return null; } - /* - * @see - * org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(ILaunchConfiguration - * ) - */ + @Override public boolean isValid(ILaunchConfiguration config) { setErrorMessage(null); setMessage(null); @@ -358,22 +349,22 @@ public class WorkingDirectoryBlock extends CommonScriptLaunchTab { .getStringVariableManager(); try { manager.validateStringVariables(workingDirPath); - }// end try + } // end try catch (CoreException e) { setErrorMessage(e.getMessage()); return false; - }// end catch - }// end if + } // end catch + } // end if else if (workingDirPath.length() > 0) { IContainer container = getContainer(); if (container == null) { File dir = new File(workingDirPath); if (dir.isDirectory()) { return true; - }// end if + } // end if setErrorMessage(ScriptLaunchMessages.WorkingDirectoryBlock_10); return false; - }// end if + } // end if } else if (workingDirPath.length() == 0) { setErrorMessage(ScriptLaunchMessages.WorkingDirectoryBlock_20); } @@ -382,23 +373,18 @@ public class WorkingDirectoryBlock extends CommonScriptLaunchTab { /** * Defaults are empty. - * + * * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse. * debug.core.ILaunchConfigurationWorkingCopy) */ + @Override public void setDefaults(ILaunchConfigurationWorkingCopy config) { config.setAttribute( ScriptLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse - * .debug.core.ILaunchConfiguration) - */ + @Override public void initializeFrom(ILaunchConfiguration configuration) { super.initializeFrom(configuration); try { @@ -408,77 +394,69 @@ public class WorkingDirectoryBlock extends CommonScriptLaunchTab { setDefaultWorkingDir(); if (wd != null) { setOtherWorkingDirectoryText(wd); - }// end else - }// end try + } // end else + } // end try catch (CoreException e) { - setErrorMessage(NLS - .bind( - ScriptLaunchMessages.ArgumentsTab_Exception_occurred_reading_configuration___15, - e.getStatus().getMessage())); + setErrorMessage(NLS.bind( + ScriptLaunchMessages.ArgumentsTab_Exception_occurred_reading_configuration___15, + e.getStatus().getMessage())); DLTKLaunchingPlugin.log(e); - }// end catch + } // end catch } - /* - * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply( - * ILaunchConfigurationWorkingCopy) - */ + @Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { if (fUseDefaultDirButton.getSelection()) { configuration.setAttribute( ScriptLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null); - }// end if + } // end if else { configuration.setAttribute( ScriptLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, getWorkingDirectoryText()); - }// end else + } // end else }// end performApply - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName() - */ + @Override public String getName() { return ScriptLaunchMessages.WorkingDirectoryBlock_Working_Directory_8; }// end getName /** * gets the path from the text box that is selected - * + * * @return the working directory the user wishes to use - * + * */ protected String getWorkingDirectoryText() { if (fUseDefaultDirButton.getSelection()) { return fWorkingDirText.getText().trim(); - }// end if + } // end if return fOtherWorkingText.getText().trim(); }// end getWorkingDirectoryPath /** * sets the default working directory text - * + * * @param dir * the dir to set the widget to - * + * */ protected void setDefaultWorkingDirectoryText(String dir) { if (dir != null) { fWorkingDirText.setText(dir); fUseDefaultDirButton.setSelection(true); handleUseDefaultWorkingDirButtonSelected(); - }// end if + } // end if }// setDefaultWorkingDirectoryText /** * sets the other dir text - * + * * @param dir * the new text - * + * */ protected void setOtherWorkingDirectoryText(String dir) { if (dir != null) { @@ -486,12 +464,12 @@ public class WorkingDirectoryBlock extends CommonScriptLaunchTab { fUseDefaultDirButton.setSelection(false); fUseOtherDirButton.setSelection(true); handleUseOtherWorkingDirButtonSelected(); - }// end if + } // end if }// end setOtherWorkingDirectoryText /** * Allows this entire block to be enabled/disabled - * + * * @param enabled * whether to enable it or not */ @@ -503,12 +481,12 @@ public class WorkingDirectoryBlock extends CommonScriptLaunchTab { fWorkspaceButton.setEnabled(enabled); fVariablesButton.setEnabled(enabled); fFileSystemButton.setEnabled(enabled); - }// end if - // in the case where the' other' text is selected and we want to enable + } // end if + // in the case where the' other' text is selected and we want to + // enable if (fUseOtherDirButton.getSelection() && enabled == true) { fOtherWorkingText.setEnabled(enabled); - }// end if + } // end if }// end setEnabled }// end class - diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/log/ScriptDebugLogContentProvider.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/log/ScriptDebugLogContentProvider.java index 2b7e7bb9f..2521d192b 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/log/ScriptDebugLogContentProvider.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/log/ScriptDebugLogContentProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 xored software, Inc. + * Copyright (c) 2008, 2017 xored software, Inc. and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -16,16 +16,19 @@ import java.util.List; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.Viewer; -public class ScriptDebugLogContentProvider implements - IStructuredContentProvider { +public class ScriptDebugLogContentProvider + implements IStructuredContentProvider { + @Override public void dispose() { // empty } + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { // empty } + @Override public Object[] getElements(Object inputElement) { if (inputElement instanceof List) { synchronized (inputElement) { diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/log/ScriptDebugLogCopyAction.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/log/ScriptDebugLogCopyAction.java index c880f0db5..fc8d4ed74 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/log/ScriptDebugLogCopyAction.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/log/ScriptDebugLogCopyAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 xored software, Inc. + * Copyright (c) 2008, 2017 xored software, Inc. and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -28,6 +28,7 @@ public class ScriptDebugLogCopyAction extends Action { this.viewer = viewer; } + @Override public void run() { final ISelection selection = viewer.getSelection(); if (!selection.isEmpty() && selection instanceof IStructuredSelection) { @@ -46,8 +47,8 @@ public class ScriptDebugLogCopyAction extends Action { } private void setClipboardText(final StringBuffer sb) { - final Clipboard clipboard = new Clipboard(viewer.getTable() - .getDisplay()); + final Clipboard clipboard = new Clipboard( + viewer.getTable().getDisplay()); try { clipboard.setContents(new Object[] { sb.toString() }, new Transfer[] { TextTransfer.getInstance() }); diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/log/ScriptDebugLogItem.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/log/ScriptDebugLogItem.java index 8fa1a163d..3cf3d0739 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/log/ScriptDebugLogItem.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/log/ScriptDebugLogItem.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 xored software, Inc. + * Copyright (c) 2008, 2017 xored software, Inc. and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -27,7 +27,8 @@ public class ScriptDebugLogItem { this.message = message; } - public ScriptDebugLogItem(String type, int sessionId, IDbgpRawPacket message) { + public ScriptDebugLogItem(String type, int sessionId, + IDbgpRawPacket message) { this(System.currentTimeMillis(), type, sessionId, message); } @@ -60,11 +61,7 @@ public class ScriptDebugLogItem { return message; } - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ + @Override public String toString() { return type + '\t' + message; } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/log/ScriptDebugLogLabelProvider.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/log/ScriptDebugLogLabelProvider.java index 818c15f49..f89e3c867 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/log/ScriptDebugLogLabelProvider.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/log/ScriptDebugLogLabelProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 xored software, Inc. + * Copyright (c) 2008, 2017 xored software, Inc. and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -24,8 +24,8 @@ import org.eclipse.swt.graphics.RGB; import com.ibm.icu.text.SimpleDateFormat; -public class ScriptDebugLogLabelProvider extends LabelProvider implements - ITableLabelProvider, IColorProvider { +public class ScriptDebugLogLabelProvider extends LabelProvider + implements ITableLabelProvider, IColorProvider { private final IColorManager colorManager = new DLTKColorManager(false); @@ -41,10 +41,12 @@ public class ScriptDebugLogLabelProvider extends LabelProvider implements colorManager.dispose(); } + @Override public Image getColumnImage(Object element, int columnIndex) { return null; } + @Override public String getColumnText(Object element, int columnIndex) { if (element instanceof ScriptDebugLogItem) { final ScriptDebugLogItem item = (ScriptDebugLogItem) element; @@ -87,6 +89,7 @@ public class ScriptDebugLogLabelProvider extends LabelProvider implements return result.replaceAll("[\\p{Cntrl}]+", ""); //$NON-NLS-1$ //$NON-NLS-2$ } + @Override public Color getBackground(Object element) { return null; } @@ -95,6 +98,7 @@ public class ScriptDebugLogLabelProvider extends LabelProvider implements private final RGB inputColor = new RGB(0, 0, 255); private final RGB outputColor = new RGB(0, 128, 0); + @Override public Color getForeground(Object element) { if (element instanceof ScriptDebugLogItem) { final ScriptDebugLogItem item = (ScriptDebugLogItem) element; diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/log/ScriptDebugLogManager.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/log/ScriptDebugLogManager.java index d3f19ff8a..7970dcd06 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/log/ScriptDebugLogManager.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/log/ScriptDebugLogManager.java @@ -1,11 +1,10 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html ******************************************************************************/ - package org.eclipse.dltk.internal.debug.ui.log; import org.eclipse.debug.core.DebugEvent; @@ -26,8 +25,8 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PartInitException; -public class ScriptDebugLogManager implements ILaunchListener, - IDebugEventSetListener, IDbgpRawListener { +public class ScriptDebugLogManager + implements ILaunchListener, IDebugEventSetListener, IDbgpRawListener { private static ScriptDebugLogManager instance; @@ -45,30 +44,19 @@ public class ScriptDebugLogManager implements ILaunchListener, return instance; } - /* - * @see - * org.eclipse.dltk.dbgp.IDbgpRawListener#dbgpPacketReceived(java.lang.String - * ) - */ + @Override public void dbgpPacketReceived(int sessionId, IDbgpRawPacket content) { append(new ScriptDebugLogItem(Messages.ItemType_Input, sessionId, content)); } - /* - * @see - * org.eclipse.dltk.dbgp.IDbgpRawListener#dbgpPacketSent(java.lang.String) - */ + @Override public void dbgpPacketSent(int sessionId, IDbgpRawPacket content) { append(new ScriptDebugLogItem(Messages.ItemType_Output, sessionId, content)); } - /* - * @see - * org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse - * .debug.core.DebugEvent[]) - */ + @Override public void handleDebugEvents(DebugEvent[] events) { if (view == null) { return; @@ -78,13 +66,13 @@ public class ScriptDebugLogManager implements ILaunchListener, DebugEvent event = events[i]; append(new ScriptDebugLogItem(Messages.ItemType_Event, - getDebugEventKind(event) - + " from " + event.getSource().getClass().getName()));//$NON-NLS-1$ + getDebugEventKind(event) + " from " //$NON-NLS-1$ + + event.getSource().getClass().getName())); if (event.getKind() == DebugEvent.CREATE) { handleCreateEvent(event); - } else if (event.getKind() == DebugEvent.MODEL_SPECIFIC - && event.getDetail() == ExtendedDebugEventDetails.DGBP_NEW_CONNECTION) { + } else if (event.getKind() == DebugEvent.MODEL_SPECIFIC && event + .getDetail() == ExtendedDebugEventDetails.DGBP_NEW_CONNECTION) { if (event.getSource() instanceof IDbgpDebugingEngine) { ((IDbgpDebugingEngine) event.getSource()) .addRawListener(this); @@ -95,20 +83,12 @@ public class ScriptDebugLogManager implements ILaunchListener, } } - /* - * @see - * org.eclipse.debug.core.ILaunchListener#launchAdded(org.eclipse.debug. - * core.ILaunch) - */ + @Override public void launchAdded(ILaunch launch) { // empty implementation } - /* - * @see - * org.eclipse.debug.core.ILaunchListener#launchChanged(org.eclipse.debug - * .core.ILaunch) - */ + @Override public void launchChanged(ILaunch launch) { IDebugTarget target = launch.getDebugTarget(); boolean loggingEnabled = LaunchConfigurationUtils @@ -119,30 +99,24 @@ public class ScriptDebugLogManager implements ILaunchListener, return; } - Display.getDefault().asyncExec(new Runnable() { - public void run() { - IWorkbenchPage page = DLTKDebugUIPlugin.getActivePage(); + Display.getDefault().asyncExec(() -> { + IWorkbenchPage page = DLTKDebugUIPlugin.getActivePage(); - if (page != null) { - try { - view = (ScriptDebugLogView) page - .showView(ScriptDebugLogView.VIEW_ID); + if (page != null) { + try { + view = (ScriptDebugLogView) page + .showView(ScriptDebugLogView.VIEW_ID); - DebugPlugin.getDefault().addDebugEventListener( - ScriptDebugLogManager.this); - } catch (PartInitException e) { - DLTKDebugUIPlugin.log(e); - } + DebugPlugin.getDefault() + .addDebugEventListener(ScriptDebugLogManager.this); + } catch (PartInitException e) { + DLTKDebugUIPlugin.log(e); } } }); } - /* - * @see - * org.eclipse.debug.core.ILaunchListener#launchRemoved(org.eclipse.debug - * .core.ILaunch) - */ + @Override public void launchRemoved(ILaunch launch) { // empty implementation } diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/log/ScriptDebugLogView.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/log/ScriptDebugLogView.java index 2b7d4757a..58bc37d41 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/log/ScriptDebugLogView.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/log/ScriptDebugLogView.java @@ -1,12 +1,11 @@ /******************************************************************************* - * Copyright (c) 2000, 2016 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * *******************************************************************************/ - package org.eclipse.dltk.internal.debug.ui.log; import java.util.ArrayList; @@ -15,7 +14,6 @@ import java.util.List; import org.eclipse.dltk.ui.DLTKUIPlugin; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.MenuManager; @@ -26,16 +24,12 @@ import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.TextViewer; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; @@ -59,10 +53,12 @@ public class ScriptDebugLogView extends ViewPart { super(); } + @Override public void setFocus() { viewer.getControl().setFocus(); } + @Override public void createPartControl(Composite parent) { final SashForm sashForm = new SashForm(parent, SWT.HORIZONTAL); viewer = new TableViewer(sashForm, SWT.H_SCROLL | SWT.V_SCROLL @@ -74,36 +70,27 @@ public class ScriptDebugLogView extends ViewPart { addColumn(Messages.Column_Type, 80, true); addColumn(Messages.Column_Session, 80, true); addColumn(Messages.Column_Message, 400, false); - viewer.getTable().addListener(SWT.Resize, new Listener() { - - public void handleEvent(Event event) { - final Table table = (Table) event.widget; - final int columnCount = table.getColumnCount(); - int w = table.getClientArea().width; - for (int i = 0; i < columnCount - 1; ++i) { - w -= table.getColumn(i).getWidth(); - } - if (w > 0) { - table.getColumn(columnCount - 1).setWidth(w); - } + viewer.getTable().addListener(SWT.Resize, event -> { + final Table table = (Table) event.widget; + final int columnCount = table.getColumnCount(); + int w = table.getClientArea().width; + for (int i = 0; i < columnCount - 1; ++i) { + w -= table.getColumn(i).getWidth(); + } + if (w > 0) { + table.getColumn(columnCount - 1).setWidth(w); } - }); - viewer.addSelectionChangedListener(new ISelectionChangedListener() { - - public void selectionChanged(SelectionChangedEvent event) { - if (event.getSelection() instanceof IStructuredSelection) { - final Object first = ((IStructuredSelection) event - .getSelection()).getFirstElement(); - if (first instanceof ScriptDebugLogItem) { - textDocument - .set(((ScriptDebugLogItem) first).getMessage()); - return; - } + viewer.addSelectionChangedListener(event -> { + if (event.getSelection() instanceof IStructuredSelection) { + final Object first = ((IStructuredSelection) event + .getSelection()).getFirstElement(); + if (first instanceof ScriptDebugLogItem) { + textDocument.set(((ScriptDebugLogItem) first).getMessage()); + return; } - textDocument.set(""); //$NON-NLS-1$ } - + textDocument.set(""); //$NON-NLS-1$ }); viewer.setContentProvider(new ScriptDebugLogContentProvider()); viewer.setLabelProvider(new ScriptDebugLogLabelProvider()); @@ -112,11 +99,7 @@ public class ScriptDebugLogView extends ViewPart { textViewer = new TextViewer(sashForm, SWT.V_SCROLL | SWT.H_SCROLL | SWT.WRAP | SWT.READ_ONLY); textViewer.setDocument(textDocument); - fontRegistryChangeListener = new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - handlePropertyChangeEvent(event); - } - }; + fontRegistryChangeListener = event -> handlePropertyChangeEvent(event); JFaceResources.getFontRegistry() .addListener(fontRegistryChangeListener); @@ -134,6 +117,7 @@ public class ScriptDebugLogView extends ViewPart { } } + @Override public void dispose() { if (fContextActivation != null) { IContextService ctxService = getSite() @@ -184,18 +168,14 @@ public class ScriptDebugLogView extends ViewPart { final Display display = table.getDisplay(); if (display.isDisposed()) return; - display.asyncExec(new Runnable() { - - public void run() { - viewer.refresh(false, false); - if (table.isDisposed() || table.getDisplay().isDisposed()) - return; - final int itemCount = table.getItemCount(); - if (itemCount > 0) { - table.showItem(table.getItem(itemCount - 1)); - } + display.asyncExec(() -> { + viewer.refresh(false, false); + if (table.isDisposed() || table.getDisplay().isDisposed()) + return; + final int itemCount = table.getItemCount(); + if (itemCount > 0) { + table.showItem(table.getItem(itemCount - 1)); } - }); } @@ -205,6 +185,7 @@ public class ScriptDebugLogView extends ViewPart { public void createActions() { copyAction = new ScriptDebugLogCopyAction(viewer); clearAction = new Action(Messages.ScriptDebugLogView_clear) { + @Override public void run() { synchronized (items) { items.clear(); @@ -231,11 +212,7 @@ public class ScriptDebugLogView extends ViewPart { // Create menu manager. MenuManager menuManager = new MenuManager(); menuManager.setRemoveAllWhenShown(true); - menuManager.addMenuListener(new IMenuListener() { - public void menuAboutToShow(IMenuManager manager) { - fillContextMenu(manager); - } - }); + menuManager.addMenuListener(manager -> fillContextMenu(manager)); // Create menu. Menu menu = menuManager.createContextMenu(viewer.getControl()); diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/variables/ScriptVariableLabelProvider.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/variables/ScriptVariableLabelProvider.java index 86525479b..6dc212b1b 100644 --- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/variables/ScriptVariableLabelProvider.java +++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/variables/ScriptVariableLabelProvider.java @@ -27,19 +27,20 @@ public class ScriptVariableLabelProvider extends VariableLabelProvider store = null; } + @Override protected IDebugModelPresentation getModelPresentation( IPresentationContext context, String modelId) { /* * no longer here for 3.3 compatibility... - * + * * we need to use the langugage specific implementation so we can get * access to addtional presentation methods by downcasting to the * ScriptDebugModelPresentation. - * + * * the IDebugModelPresentation impl normally returned from a this method * is an instance of LazyModelPresentation, which does not provide a way * to obtain the underlying model presentation it is being lazy for. - * + * * the jdt instanciates its IDebugModelPresentation implementation * outright in its VariableLabelProvider implenentation, so this should * be ok to do. @@ -47,6 +48,7 @@ public class ScriptVariableLabelProvider extends VariableLabelProvider return DLTKDebugUIPlugin.getDefault().getModelPresentation(modelId); } + @Override protected String getVariableName(IVariable variable, IPresentationContext context) throws CoreException { IDebugModelPresentation presentation = getModelPresentation(context, @@ -59,6 +61,7 @@ public class ScriptVariableLabelProvider extends VariableLabelProvider return super.getVariableName(variable, context); } + @Override protected String getValueText(IVariable variable, IValue value, IPresentationContext context) throws CoreException { IDebugModelPresentation presentation = getModelPresentation(context, @@ -70,6 +73,7 @@ public class ScriptVariableLabelProvider extends VariableLabelProvider return super.getValueText(variable, value, context); } + @Override public void propertyChange(PropertyChangeEvent event) { // TODO: support for fq name vs 'last segment' } |