Package com.eclipserunner.views.actions

Source Code of com.eclipserunner.views.actions.ShowLaunchConfigurationsDialogAction

package com.eclipserunner.views.actions;

import static org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsDialog.LAUNCH_CONFIGURATION_DIALOG_OPEN_ON_LAST_LAUNCHED;
import static org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsDialog.LAUNCH_CONFIGURATION_DIALOG_OPEN_ON_SELECTION;

import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsDialog;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;

import com.eclipserunner.RunnerPlugin;
import com.eclipserunner.model.ILaunchNode;
import com.eclipserunner.model.INodeSelection;

/**
* Action responsible for showing LaunchConfigurationsDialog.
*
* @author bary
*/
@SuppressWarnings("restriction")
public class ShowLaunchConfigurationsDialogAction extends AbstractLaunchAction {

  private INodeSelection selection;

  public ShowLaunchConfigurationsDialogAction(INodeSelection selection, String launchGroupId) {
    super(launchGroupId);
    this.selection = selection;
  }

  @Override
  public void run() {
    LaunchConfigurationsDialog dialog = new LaunchConfigurationsDialog(
      RunnerPlugin.getRunnerShell(),
      getLaunchConfigurationManager().getLaunchGroup(getLaunchGroupId())
    );

    if (selection.hasExactlyOneNode() && selection.firstNodeHasType(ILaunchNode.class)) {
      dialog.setOpenMode(LAUNCH_CONFIGURATION_DIALOG_OPEN_ON_SELECTION);
      dialog.setInitialSelection(
        asStructuredSelection(selection.getFirstNodeAs(ILaunchNode.class).getLaunchConfiguration())
      );
    }
    else {
      dialog.setOpenMode(LAUNCH_CONFIGURATION_DIALOG_OPEN_ON_LAST_LAUNCHED);
    }

    dialog.open();
  }
 
  public static IStructuredSelection asStructuredSelection(Object object) {
    return new StructuredSelection(object);
  }

}
TOP

Related Classes of com.eclipserunner.views.actions.ShowLaunchConfigurationsDialogAction

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.