@Override @SuppressWarnings("rawtypes") public Map getParameterValues() { ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); Map<String, String> modes = new HashMap<>(); for (String modeId : LocalAppEngineServerLaunchConfigurationDelegate.SUPPORTED_LAUNCH_MODES) { ILaunchMode mode = manager.getLaunchMode(modeId); if (mode != null) { // label is intended to be shown in menus and buttons and often has // embedded '&' for mnemonics, which isn't useful here String label = mode.getLabel(); label = label.replace("&", ""); modes.put(label, mode.getIdentifier()); } } return modes; }
private static int compare( ILaunchMode launchMode1, ILaunchMode launchMode2 ) { int result; if( isRunMode( launchMode1 ) ) { result = -1; } else if( isRunMode( launchMode2 ) ) { result = 1; } else if( isDebugMode( launchMode1 ) ) { if( isRunMode( launchMode2 ) ) { result = 1; } else { result = -1; } } else if( isDebugMode( launchMode2 ) ) { if( isRunMode( launchMode1 ) ) { result = -1; } else { result = 1; } } else { result = launchMode1.getLabel().compareTo( launchMode2.getLabel() ); } return result; }
public LaunchConfigStarter( DebugUIPreferences preferences, ILaunchMode launchMode, ILaunchConfiguration... launchConfigs ) { this.preferences = requireNonNull( preferences ); this.preferredLaunchMode = requireNonNull( launchMode ); this.launchConfigs = launchConfigs; }
private IStatus validateExistingLaunchConfig() { IStatus result = okStatus(); ILaunchMode launchMode = computeActualLaunchMode(); if( launchMode == null ) { result = new Status( ERROR, PLUGIN_ID, 0, NO_LAUNCH_MODE_FOUND, null ); } else if( !preferredLaunchMode.getIdentifier().equals( launchMode.getIdentifier() ) ) { result = new Status( INFO, PLUGIN_ID, INFO, getLaunchModeWarningMessage( launchMode ), null ); } return result; }
public ILaunchMode computeLaunchMode() { ILaunchMode result; if( isLaunchModeSupported( preferredLaunchMode ) ) { result = preferredLaunchMode; } else { result = findAlternativeLaunchMode(); } return result; }
public ILaunchGroup computeLaunchGroup() { ILaunchGroup result = null; ILaunchMode launchMode = computeLaunchMode(); if( launchMode != null ) { result = DebugUITools.getLaunchGroup( launchConfig, launchMode.getIdentifier() ); } return result; }
private boolean isLaunchModeSupported( ILaunchMode launchMode ) { try { return launchMode != null && launchConfig.supportsMode( launchMode.getIdentifier() ); } catch( CoreException ignore ) { return false; } }
private void updateOkButtonLabel() { Button okButton = getButton( OK_ID ); LaunchModeSetting launchModeSetting = new LaunchModeSetting( launchManager, getDialogSettings() ); ILaunchMode launchMode = launchModeSetting.getLaunchMode(); if( okButton != null && launchMode != null ) { okButton.setText( launchMode.getLabel() ); okButton.getParent().layout(); } }
@Test public void testDefaultLaunchMode() { ILaunchMode debug = createLaunchMode( DEBUG_MODE ); setSupportedLaunchModes( debug ); String launchModeId = launchModeSetting.getLaunchModeId(); assertThat( launchModeId ).isEqualTo( DEBUG_MODE ); }
@Test public void testSetLaunchMode() { ILaunchMode debug = createLaunchMode( DEBUG_MODE ); ILaunchMode run = createLaunchMode( RUN_MODE ); setSupportedLaunchModes( debug, run ); launchModeSetting.setLaunchModeId( RUN_MODE ); assertThat( launchModeSetting.getLaunchModeId() ).isEqualTo( RUN_MODE ); }
@Test public void testGetUnknownLaunchMode() { ILaunchMode debug = createLaunchMode( DEBUG_MODE ); setSupportedLaunchModes( debug ); launchModeSetting.setLaunchModeId( RUN_MODE ); assertThat( launchModeSetting.getLaunchModeId() ).isEqualTo( DEBUG_MODE ); }
@Test public void testComputeLaunchModeWithSupportedMode() { ILaunchMode supportedMode = getSupportedMode(); ILaunchMode launchMode = computeLaunchMode( supportedMode ); assertThat( launchMode ).isEqualTo( supportedMode ); }
@Test public void testComputeLaunchModeWithUnsupportedMode() { ILaunchMode unsupportedMode = getUnsupportedMode(); ILaunchMode launchMode = computeLaunchMode( unsupportedMode ); assertThat( launchMode ).isEqualTo( getSupportedMode() ); }
@Test public void testComputeLaunchModeWithDeletedLaunchConfig() throws CoreException { ILaunchMode supportedMode = getSupportedMode(); ILaunchConfiguration deletedLaunchConfig = launchConfig.doSave(); deletedLaunchConfig.delete(); ILaunchMode launchMode = new LaunchModeComputer( deletedLaunchConfig, supportedMode ).computeLaunchMode(); assertThat( launchMode ).isNull(); }
@Test public void testComputeLaunchGroupWithSupportedMode() { ILaunchMode supportedMode = getSupportedMode(); ILaunchGroup launchMode = computeLaunchGroup( supportedMode ); assertThat( launchMode.getMode() ).isEqualTo( supportedMode.getIdentifier() ); }
@Test public void testComputeLaunchGroupWithUnsupportedMode() { ILaunchMode unsupportedMode = getUnsupportedMode(); ILaunchGroup launchMode = computeLaunchGroup( unsupportedMode ); assertThat( launchMode.getMode() ).isEqualTo( getSupportedMode().getIdentifier() ); }
@Test public void testComputeLaunchGroupWithDeletedLaunchConfig() throws CoreException { ILaunchMode supportedMode = getSupportedMode(); ILaunchConfiguration deletedLaunchConfig = launchConfig.doSave(); deletedLaunchConfig.delete(); ILaunchGroup launchGroup = new LaunchModeComputer( deletedLaunchConfig, supportedMode ).computeLaunchGroup(); assertThat( launchGroup ).isNull(); }
private int compare( ILaunchConfiguration launchConfig1, ILaunchConfiguration launchConfig2, String mode ) { ILaunchMode launchMode = DebugPlugin.getDefault().getLaunchManager().getLaunchMode( mode ); LaunchConfigComparator comparator = new LaunchConfigComparator( launchConfigHistory, launchMode ); return comparator.compare( launchConfig1, launchConfig2 ); }
@Before public void setUp() { launchManager = mock( ILaunchManager.class ); when( launchManager.getLaunchModes() ).thenReturn( new ILaunchMode[ 0 ] ); DialogSettings dialogSettings = new DialogSettings( "section-name" ); launchModeSetting = new LaunchModeSetting( launchManager, dialogSettings ); }
@Test public void testGetMenuForMenu() { ILaunchMode run = createLaunchMode( RUN_MODE ); ILaunchMode debug = createLaunchMode( DEBUG_MODE ); when( launchManager.getLaunchModes() ).thenReturn( new ILaunchMode[]{ run, debug } ); LaunchModeDropDownAction action = new LaunchModeDropDownAction( launchModeSetting ); Menu menu = action.getMenu( new Menu( displayHelper.createShell() ) ); assertThat( menu.getItemCount() ).isEqualTo( 2 ); assertThat( menu.getItem( 0 ).getText() ).isNotEmpty(); assertThat( menu.getItem( 0 ).getImage() ).isNull(); }
@Test public void testDispose() { ILaunchMode run = createLaunchMode( RUN_MODE ); when( launchManager.getLaunchModes() ).thenReturn( new ILaunchMode[]{ run } ); LaunchModeDropDownAction action = new LaunchModeDropDownAction( launchModeSetting ); Menu menu = action.getMenu( new Menu( displayHelper.createShell() ) ); action.dispose(); assertThat( menu.isDisposed() ).isTrue(); }
private LaunchModeAction addLaunchMode( String identifier, String label ) { ILaunchMode launchMode = createLaunchMode( identifier, label ); LaunchModeAction launchModeAction = mock( LaunchModeAction.class ); when( launchModeAction.getLaunchMode() ).thenReturn( launchMode ); launchModes.add( launchModeAction ); return launchModeAction; }
@Override public void launch(ILaunchMode mode) { StandaloneLaunchConfigExecutor.launchProcess(generator.generate(cfg), mode.getIdentifier(), true, false, null); }
private String getLaunchGroupId( ILaunchConfiguration launchConfig ) { ILaunchMode preferredLaunchMode = launchSelectionDialog.getLaunchMode(); LaunchModeComputer launchModeComputer = new LaunchModeComputer( launchConfig, preferredLaunchMode ); ILaunchGroup launchGroup = launchModeComputer.computeLaunchGroup(); return launchGroup == null ? null : launchGroup.getIdentifier(); }
public LaunchModeAction( LaunchModeSetting launchModeSetting, ILaunchMode launchMode ) { super( launchMode.getLabel(), IAction.AS_RADIO_BUTTON ); this.launchModeSetting = launchModeSetting; this.launchMode = launchMode; update(); }
public ILaunchMode getLaunchMode() { return launchMode; }
public LaunchConfigStarter( ILaunchMode launchMode, ILaunchConfiguration... launchConfigs ) { this( new DebugUIPreferences(), launchMode, launchConfigs ); }
private void startLaunchConfig( ILaunchConfiguration launchConfig ) { ILaunchMode launchMode = new LaunchModeComputer( launchConfig, preferredLaunchMode ).computeLaunchMode(); DebugUITools.launch( launchConfig, launchMode.getIdentifier() ); }
public LaunchConfigValidator( ILaunchConfiguration launchConfig, ILaunchMode preferredLaunchMode ) { requireNonNull( launchConfig, "launchConfig" ); this.launchConfig = launchConfig; this.preferredLaunchMode = preferredLaunchMode; }
private ILaunchMode computeActualLaunchMode() { return new LaunchModeComputer( launchConfig, preferredLaunchMode ).computeLaunchMode(); }
private static String getLaunchModeWarningMessage( ILaunchMode launchMode ) { String label = launchMode.getLabel().replace( "&", "" ); return format( "Selection will be launched in ''{0}'' mode", label ); }
private static void startLaunchConfigs( ILaunchMode launchMode, ILaunchConfiguration[] launchConfigs ) { new LaunchConfigStarter( launchMode, launchConfigs ).start(); }
private LaunchModeAction createLaunchModeAction( ILaunchMode launchMode ) { LaunchModeAction result = new LaunchModeAction( launchModeSetting, launchMode ); result.addPropertyChangeListener( this::launchModeActionPropertyChanged ); return result; }
private static boolean isRunMode( ILaunchMode launchMode ) { return RUN_MODE.equals( launchMode.getIdentifier() ); }
private static boolean isDebugMode( ILaunchMode launchMode ) { return DEBUG_MODE.equals( launchMode.getIdentifier() ); }
public LaunchModeComputer( ILaunchConfiguration launchConfig, ILaunchMode preferredLaunchMode ) { requireNonNull( launchConfig, "launchConfig" ); this.launchConfig = launchConfig; this.preferredLaunchMode = preferredLaunchMode; }
private ILaunchMode findAlternativeLaunchMode() { return Stream.of( allLaunchModes() ).filter( this::isLaunchModeSupported ).findFirst().orElse( null ); }
private static ILaunchMode[] allLaunchModes() { return DebugPlugin.getDefault().getLaunchManager().getLaunchModes(); }
public ILaunchMode getLaunchMode() { return new LaunchModeSetting( launchManager, getDialogSettings() ).getLaunchMode(); }
@Override protected IStatus validateItem( Object item ) { ILaunchMode preferredLaunchMode = getLaunchMode(); ILaunchConfiguration launchConfig = ( ILaunchConfiguration )item; return new LaunchConfigValidator( launchConfig, preferredLaunchMode ).validate(); }