Class AbstractLaunchShortcut

  • All Implemented Interfaces:
    org.eclipse.debug.ui.ILaunchShortcut, org.eclipse.debug.ui.ILaunchShortcut2
    Direct Known Subclasses:
    AbstractMobileLaunchShortcut, RemoteMobileApplicationLaunchShortcut, RemoteRuntimeDebugLaunchShortcut

    public abstract class AbstractLaunchShortcut
    extends Object
    implements org.eclipse.debug.ui.ILaunchShortcut2
    Abstract launch shortcut. Uses project from the current selected context. Shortcut locates V8 configuration project from selection, locates run or debug configuration (or creates new), validates and launches it.

    If this configuration is not valid, launch configuration dialog will be shown.

    • Constructor Detail

      • AbstractLaunchShortcut

        public AbstractLaunchShortcut()
    • Method Detail

      • launch

        public void launch​(ISelection selection,
                           String mode)
        Specified by:
        launch in interface org.eclipse.debug.ui.ILaunchShortcut
      • launch

        public void launch​(org.eclipse.ui.IEditorPart editor,
                           String mode)
        Specified by:
        launch in interface org.eclipse.debug.ui.ILaunchShortcut
      • getLaunchConfigurations

        public org.eclipse.debug.core.ILaunchConfiguration[] getLaunchConfigurations​(ISelection selection)
        Specified by:
        getLaunchConfigurations in interface org.eclipse.debug.ui.ILaunchShortcut2
      • getLaunchConfigurations

        public org.eclipse.debug.core.ILaunchConfiguration[] getLaunchConfigurations​(org.eclipse.ui.IEditorPart editor)
        Specified by:
        getLaunchConfigurations in interface org.eclipse.debug.ui.ILaunchShortcut2
      • getLaunchableResource

        public org.eclipse.core.resources.IProject getLaunchableResource​(ISelection selection)
        Specified by:
        getLaunchableResource in interface org.eclipse.debug.ui.ILaunchShortcut2
      • getLaunchableResource

        public org.eclipse.core.resources.IProject getLaunchableResource​(org.eclipse.ui.IEditorPart editorpart)
        Specified by:
        getLaunchableResource in interface org.eclipse.debug.ui.ILaunchShortcut2
      • launch

        protected void launch​(org.eclipse.core.resources.IProject project,
                              org.eclipse.emf.ecore.EObject object,
                              String mode)
        Launches an application with given project in the specified mode.
        Parameters:
        project - the project to launch, cannot be null
        object - the object to launch or null if none
        mode - one of the launch modes defined by the launch manager, cannot be null
      • getLaunchableResource

        protected org.eclipse.core.resources.IProject getLaunchableResource()
        Returns project to launch without any context. Method will search for existing projects and returns one if found exact one project. If found more than 1, selection dialog will be opened.

        Can return null than no project is needed to launch.

        Returns:
        project to launch, or null if none projects is needed to launch
      • getLaunchConfiguration

        protected org.eclipse.debug.core.ILaunchConfiguration getLaunchConfiguration​(org.eclipse.core.resources.IProject project,
                                                                                     org.eclipse.emf.ecore.EObject object,
                                                                                     String mode)
                                                                              throws org.eclipse.core.runtime.CoreException
        Returns launch configuration for project. Method will search for existing launch configurations, then if not found, create new. If found more than 1, selection dialog will be opened.

        Can return null than no launch configuration is needed to launch.

        Parameters:
        project - the project to get launch configuration for, cannot be null
        object - the object to get launch configuration for or null if none
        mode - one of the launch modes defined by the launch manager, cannot be null
        Returns:
        launch configuration for given project to launch, or null if none launch configuration is needed to launch
        Throws:
        org.eclipse.core.runtime.CoreException - if getting fails
      • showNoProjectsInfo

        protected void showNoProjectsInfo()
        Shows information to user that no appropriate projects was found.
      • prepareConfiguration

        protected org.eclipse.debug.core.ILaunchConfigurationWorkingCopy prepareConfiguration​(org.eclipse.debug.core.ILaunchConfiguration launchConfiguration)
                                                                                       throws org.eclipse.core.runtime.CoreException
        Prepares launch configuration to use with this type of shortcut. Default implementation does nothing and returnd the given configuration working copy.
        Parameters:
        launchConfiguration - the launch configuration to prepare, cannot be null
        Returns:
        working copy of the launch configuration, configured to launch this type of shortcut, never null
        Throws:
        org.eclipse.core.runtime.CoreException - if preparing fails
      • isValid

        protected boolean isValid​(org.eclipse.debug.core.ILaunchConfiguration configuration,
                                  String mode)
                           throws org.eclipse.core.runtime.CoreException
        Validates the given launch configuration. Returns whether launch configuration has valid and ready-to-launch attributes.
        Parameters:
        configuration - launch configuration to validate, cannot be null
        mode - one of the launch modes defined by the launch manager, cannot be null
        Returns:
        whether launch configuration has valid and ready-to-launch values
        Throws:
        org.eclipse.core.runtime.CoreException - if validation fails
      • isInfobaseValid

        protected boolean isInfobaseValid​(org.eclipse.debug.core.ILaunchConfiguration configuration,
                                          String mode)
                                   throws org.eclipse.core.runtime.CoreException
        Returns whether infobase launch attributes are valid.
        Parameters:
        configuration - launch configuration to validate, cannot be null
        mode - one of the launch modes defined by the launch manager, cannot be null
        Returns:
        whether infobase launch attributes are valid
        Throws:
        org.eclipse.core.runtime.CoreException - if validation fails
      • shouldSave

        protected boolean shouldSave​(org.eclipse.debug.core.ILaunchConfiguration configuration,
                                     String mode)
                              throws org.eclipse.core.runtime.CoreException
        Returns whether need to save the given configuration before or after execution. Default implementation always returns true.
        Parameters:
        configuration - launch configuration to check, cannot be null
        mode - one of the launch modes defined by the launch manager, cannot be null
        Returns:
        whether need to save the given configuration before or after execution
        Throws:
        org.eclipse.core.runtime.CoreException - if check fails
      • createLaunchConfiguration

        protected org.eclipse.debug.core.ILaunchConfigurationWorkingCopy createLaunchConfiguration​(org.eclipse.core.resources.IProject project,
                                                                                                   org.eclipse.emf.ecore.EObject object,
                                                                                                   String mode)
                                                                                            throws org.eclipse.core.runtime.CoreException
        Creates a launch configuration for the given project. Launch configuration will be configured with default attributes for this project.
        Parameters:
        project - the project to create launch configuration for, cannot be null
        object - the object to create launch configuration for or null if none
        mode - one of the launch modes defined by the launch manager, cannot be null
        Returns:
        launch configuration copy or null if cannot create
        Throws:
        org.eclipse.core.runtime.CoreException - if creation fails
      • setDefaults

        protected void setDefaults​(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy configuration,
                                   org.eclipse.core.resources.IProject project)
                            throws org.eclipse.core.runtime.CoreException
        Sets default attributes for the provided launch configuration.
        Parameters:
        configuration - the launch configuration, cannot be null
        project - the launcning project, cannot be null
        Throws:
        org.eclipse.core.runtime.CoreException - if request fails
      • getLaunchConfigurations

        protected org.eclipse.debug.core.ILaunchConfiguration[] getLaunchConfigurations​(org.eclipse.core.resources.IProject project,
                                                                                        org.eclipse.emf.ecore.EObject object,
                                                                                        boolean forLaunch)
        Returns an array of existing ILaunchConfigurations that could be used to launch the given project.

        Default implementation returns all project launch configuration of this type.

        Parameters:
        project - the project to find candidates for, cannot be null
        object - the object to find candidates for, cannot be null
        forLaunch - if true then launch configuration will be filetered for launch purposes, if false then launch configuration will be filetered for selection launch configuration listing
        Returns:
        an array of existing ILaunchConfigurations that could be used to launch the given project, an empty array if one could be created but does not exist, never null
      • matches

        protected boolean matches​(org.eclipse.core.resources.IProject project,
                                  org.eclipse.emf.ecore.EObject object,
                                  org.eclipse.debug.core.ILaunchConfiguration candidate,
                                  boolean forLaunch)
        Returns whether the given launch configuration candidate of the shortcut type mathces with the given project for launch purposes.

        Default implementation returns true if project default attribute matches with the given project.

        Parameters:
        project - the project to get candidates for, cannot be null
        object - the object to find candidates for, cannot be null
        candidate - the candidate launch configuration, cannot be null
        forLaunch - if true then launch configuration will be filetered for launch purposes, if false then launch configuration will be filetered for selection launch configuration listing
        Returns:
        whether the given launch configuration candidate of the shortcut type mathces with the given project for launch purposes
      • getLaunchConfigurationType

        protected org.eclipse.debug.core.ILaunchConfigurationType getLaunchConfigurationType()
        Returns the launch shortcut configuration type.
        Returns:
        the launch shortcut configuration type, never null
      • getConfigurationProjects

        protected Collection<org.eclipse.core.resources.IProject> getConfigurationProjects()
        Returns a collection of all workspace V8 configuration projects.
        Returns:
        a collection of all workspace V8 configuration projects, never null
      • getNameSuffix

        protected String getNameSuffix()
        Returns the name suffix for newly created launch configuration, will be appended to the generated name or null if suffix not needed. Default implementation returns null.
        Returns:
        the name suffix for newly created launch configuration, or null if suffix not needed
      • getLaunchConfigurationTypeId

        protected abstract String getLaunchConfigurationTypeId()
        Returns the launch shortcut configuration type identifier.
        Returns:
        the launch shortcut configuration type identifier, never null
      • getLaunchConfigurationSelectionTitle

        protected abstract String getLaunchConfigurationSelectionTitle()
        Returns existing launch configuration selection dialog title message.
        Returns:
        existing launch configuration selection dialog title message, never null