Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No ALE Run Configuration created when launching ALE through the contextual menu shortcut #60

Closed
echebbi opened this issue Aug 22, 2019 · 1 comment · Fixed by #89
Closed
Assignees

Comments

@echebbi
Copy link
Collaborator

echebbi commented Aug 22, 2019

Expected behavior

When ALE is launched through the contextual menu shortcut a new ALE launch Run Configuration should be created. The main benefit is that we could easily run a same script multiple times in a row by just typing Ctrl+F11 or searching a previously launched script through the Run History.

Note: what I mean by "contextual menu shortcut" is:

  • Right clicking on a .dsl file > Run As > ALE launch

Current behavior

No Run Configuration is created. Hence, we have use the contextual menu each time we want to launch the same script or manually create a dedicated Run Configuration.

Solution

To solve this, the usual algorithm is (within a launch shortcut instance):

  1. Retrieve the template of the desired Launch Configuration
  2. Create a new Launch Configuration instance based on the template
  3. Set the Launch Configuration's attributes
  4. Run the Launch Configuration

For example:

public class LaunchShortcut implements ILaunchShortcut {

    @Override
    void launch(ISelection selection, String mode) {
        ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
        ILaunchConfigurationType type = manager.getLaunchConfigurationType(AleRunConfiguration.ID);
        ILaunchConfiguration[] configurations = manager.getLaunchConfigurations(type);

        // Create a new launch configuration

        String baseConfigurationName = configurationNameFor(dslFileName);
        String launchConfigurationName = availableLaunchConfigurationName(baseConfigurationName, configurations);
	
        ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(null, launchConfigurationName);        
        workingCopy.setAttribute(AleRunConfiguration.MODEL_FILE, ...);
        workingCopy.setAttribute(AleRunConfiguration.DSL_FILE, ...);
        ILaunchConfiguration configuration = workingCopy.doSave();
		
        // Run the new launch configuration
        configuration.launch(ILaunchManager.RUN_MODE, null);
    }

}
echebbi added a commit that referenced this issue Dec 4, 2019
…textual menu shortcut (fix #60)

Because:
 - we currently have to either create one manually or right-click > Run As, which is tedious
 - we can now do it once then use the "Run Last Configuration" shortcut (CTRL+F11 on Windows)
   to automatically re-run ALE

Signed-off-by: Emmanuel Chebbi <emmanuel.chebbi@outlook.fr>
@echebbi echebbi self-assigned this Dec 5, 2019
echebbi added a commit that referenced this issue Dec 12, 2019
…textual menu shortcut (fix #60)

Because:
 - we currently have to either create one manually or right-click > Run As, which is tedious
 - we can now do it once then use the "Run Last Configuration" shortcut (CTRL+F11 on Windows)
   to automatically re-run ALE

Signed-off-by: Emmanuel Chebbi <emmanuel.chebbi@outlook.fr>
echebbi added a commit that referenced this issue Dec 13, 2019
…textual menu shortcut (fix #60)

Because:
 - we currently have to either create one manually or right-click > Run As, which is tedious
 - we can now do it once then use the "Run Last Configuration" shortcut (CTRL+F11 on Windows)
   to automatically re-run ALE

Signed-off-by: Emmanuel Chebbi <emmanuel.chebbi@outlook.fr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants