Search in sources :

Example 1 with ILaunchGroup

use of org.eclipse.debug.ui.ILaunchGroup in project linuxtools by eclipse.

the class BuildDockerImageLaunchConfigurationDelegate method launch.

@Override
public void launch(final ILaunchConfiguration configuration, final String mode, final ILaunch launch, final IProgressMonitor monitor) throws CoreException {
    final String sourcePathLocation = configuration.getAttribute(SOURCE_PATH_LOCATION, (String) null);
    final boolean sourcePathWorkspaceRelativeLocation = configuration.getAttribute(SOURCE_PATH_WORKSPACE_RELATIVE_LOCATION, false);
    final IPath sourcePath = BuildDockerImageUtils.getPath(sourcePathLocation, sourcePathWorkspaceRelativeLocation);
    final String connectionName = configuration.getAttribute(DOCKER_CONNECTION, (String) null);
    final String repoName = configuration.getAttribute(REPO_NAME, (String) null);
    final IDockerConnection connection = DockerConnectionManager.getInstance().getConnectionByName(connectionName);
    final Map<String, Object> buildOptions = new HashMap<>();
    buildOptions.put(QUIET_BUILD, configuration.getAttribute(QUIET_BUILD, false));
    buildOptions.put(NO_CACHE, configuration.getAttribute(NO_CACHE, false));
    buildOptions.put(RM_INTERMEDIATE_CONTAINERS, configuration.getAttribute(RM_INTERMEDIATE_CONTAINERS, true));
    buildOptions.put(FORCE_RM_INTERMEDIATE_CONTAINERS, configuration.getAttribute(FORCE_RM_INTERMEDIATE_CONTAINERS, false));
    if (connection != null && sourcePath != null) {
        final Job buildImageJob = new BuildDockerImageJob(connection, sourcePath, repoName, buildOptions);
        buildImageJob.schedule();
    } else {
        final ILaunchGroup launchGroup = DebugUITools.getLaunchGroup(configuration, // $NON-NLS-1$
        "run");
        // prompt the user with the launch configuration editor
        Display.getDefault().syncExec(() -> DebugUITools.openLaunchConfigurationDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), configuration, launchGroup.getIdentifier(), null));
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) HashMap(java.util.HashMap) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) BuildDockerImageJob(org.eclipse.linuxtools.internal.docker.ui.jobs.BuildDockerImageJob) ILaunchGroup(org.eclipse.debug.ui.ILaunchGroup) Job(org.eclipse.core.runtime.jobs.Job) BuildDockerImageJob(org.eclipse.linuxtools.internal.docker.ui.jobs.BuildDockerImageJob)

Example 2 with ILaunchGroup

use of org.eclipse.debug.ui.ILaunchGroup in project linuxtools by eclipse.

the class DockerComposeUpLaunchConfigurationDelegate method launch.

@Override
public void launch(final ILaunchConfiguration configuration, final String mode, final ILaunch launch, final IProgressMonitor monitor) throws CoreException {
    final String sourcePathLocation = configuration.getAttribute(WORKING_DIR, (String) null);
    final boolean sourcePathWorkspaceRelativeLocation = configuration.getAttribute(WORKING_DIR_WORKSPACE_RELATIVE_LOCATION, false);
    final IPath sourcePath = BuildDockerImageUtils.getPath(sourcePathLocation, sourcePathWorkspaceRelativeLocation);
    final String connectionName = configuration.getAttribute(DOCKER_CONNECTION, (String) null);
    final IDockerConnection connection = DockerConnectionManager.getInstance().getConnectionByName(connectionName);
    if (connection != null && sourcePath != null) {
        final Job dockerComposeUpJob = new DockerComposeUpJob(connection, sourcePath.toOSString(), configuration);
        dockerComposeUpJob.schedule();
    } else {
        final ILaunchGroup launchGroup = DebugUITools.getLaunchGroup(configuration, // $NON-NLS-1$
        "run");
        // prompt the user with the launch configuration editor
        Display.getDefault().syncExec(() -> DebugUITools.openLaunchConfigurationDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), configuration, launchGroup.getIdentifier(), null));
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) DockerComposeUpJob(org.eclipse.linuxtools.internal.docker.ui.jobs.DockerComposeUpJob) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) ILaunchGroup(org.eclipse.debug.ui.ILaunchGroup) Job(org.eclipse.core.runtime.jobs.Job) DockerComposeUpJob(org.eclipse.linuxtools.internal.docker.ui.jobs.DockerComposeUpJob)

Example 3 with ILaunchGroup

use of org.eclipse.debug.ui.ILaunchGroup in project dbeaver by dbeaver.

the class DatabaseLaunchContributionItem method fill.

@Override
public void fill(Menu menu, int index) {
    Object[] selected = extractSelectedObjects();
    int accelerator = 1;
    List<ILaunchConfiguration> configurations = extractSharedConfigurations(selected);
    for (ILaunchConfiguration configuration : configurations) {
        IAction action = DebugUIInternals.createConfigurationAction(configuration, mode, accelerator);
        if (action != null) {
            accelerator++;
            ActionContributionItem item = new ActionContributionItem(action);
            item.fill(menu, -1);
        }
    }
    Map<IAction, String> shortcutActions = DebugUIInternals.createShortcutActions(selected, mode, accelerator);
    // and there are following shortcuts
    if (menu.getItemCount() > 0 && shortcutActions.size() > 0) {
        new MenuItem(menu, SWT.SEPARATOR);
    }
    List<String> categories = new ArrayList<String>();
    Set<IAction> actions = shortcutActions.keySet();
    for (IAction action : actions) {
        String category = shortcutActions.get(action);
        // NOTE: category can be null
        if (category != null && !categories.contains(category)) {
            categories.add(category);
        }
        ActionContributionItem item = new ActionContributionItem(action);
        item.fill(menu, -1);
    }
    // add in the open ... dialog shortcut(s)
    if (categories.isEmpty()) {
        if (defaultGroup != null) {
            if (accelerator > 1) {
                new MenuItem(menu, SWT.SEPARATOR);
            }
            IAction action = new OpenLaunchDialogAction(defaultGroup.getIdentifier());
            ActionContributionItem item = new ActionContributionItem(action);
            item.fill(menu, -1);
        }
    } else {
        boolean addedSep = false;
        for (String category : categories) {
            ILaunchGroup group = defaultGroup;
            if (category != null) {
                group = groupsByCategory.get(category);
            }
            if (group != null) {
                if (accelerator > 1 && !addedSep) {
                    new MenuItem(menu, SWT.SEPARATOR);
                    addedSep = true;
                }
                IAction action = new OpenLaunchDialogAction(group.getIdentifier());
                ActionContributionItem item = new ActionContributionItem(action);
                item.fill(menu, -1);
            }
        }
    }
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) IAction(org.eclipse.jface.action.IAction) ArrayList(java.util.ArrayList) MenuItem(org.eclipse.swt.widgets.MenuItem) ILaunchGroup(org.eclipse.debug.ui.ILaunchGroup) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) OpenLaunchDialogAction(org.eclipse.debug.ui.actions.OpenLaunchDialogAction)

Example 4 with ILaunchGroup

use of org.eclipse.debug.ui.ILaunchGroup in project dbeaver by serge-rider.

the class DatabaseLaunchContributionItem method fill.

@Override
public void fill(Menu menu, int index) {
    Object[] selected = extractSelectedObjects();
    int accelerator = 1;
    List<ILaunchConfiguration> configurations = extractSharedConfigurations(selected);
    for (ILaunchConfiguration configuration : configurations) {
        IAction action = DebugUIInternals.createConfigurationAction(configuration, mode, accelerator);
        if (action != null) {
            accelerator++;
            ActionContributionItem item = new ActionContributionItem(action);
            item.fill(menu, -1);
        }
    }
    Map<IAction, String> shortcutActions = DebugUIInternals.createShortcutActions(selected, mode, accelerator);
    // and there are following shortcuts
    if (menu.getItemCount() > 0 && shortcutActions.size() > 0) {
        new MenuItem(menu, SWT.SEPARATOR);
    }
    List<String> categories = new ArrayList<String>();
    Set<IAction> actions = shortcutActions.keySet();
    for (IAction action : actions) {
        String category = shortcutActions.get(action);
        // NOTE: category can be null
        if (category != null && !categories.contains(category)) {
            categories.add(category);
        }
        ActionContributionItem item = new ActionContributionItem(action);
        item.fill(menu, -1);
    }
    // add in the open ... dialog shortcut(s)
    if (categories.isEmpty()) {
        if (defaultGroup != null) {
            if (accelerator > 1) {
                new MenuItem(menu, SWT.SEPARATOR);
            }
            IAction action = new OpenLaunchDialogAction(defaultGroup.getIdentifier());
            ActionContributionItem item = new ActionContributionItem(action);
            item.fill(menu, -1);
        }
    } else {
        boolean addedSep = false;
        for (String category : categories) {
            ILaunchGroup group = defaultGroup;
            if (category != null) {
                group = groupsByCategory.get(category);
            }
            if (group != null) {
                if (accelerator > 1 && !addedSep) {
                    new MenuItem(menu, SWT.SEPARATOR);
                    addedSep = true;
                }
                IAction action = new OpenLaunchDialogAction(group.getIdentifier());
                ActionContributionItem item = new ActionContributionItem(action);
                item.fill(menu, -1);
            }
        }
    }
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) IAction(org.eclipse.jface.action.IAction) MenuItem(org.eclipse.swt.widgets.MenuItem) ILaunchGroup(org.eclipse.debug.ui.ILaunchGroup) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) OpenLaunchDialogAction(org.eclipse.debug.ui.actions.OpenLaunchDialogAction)

Aggregations

ILaunchGroup (org.eclipse.debug.ui.ILaunchGroup)4 IPath (org.eclipse.core.runtime.IPath)2 Job (org.eclipse.core.runtime.jobs.Job)2 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)2 OpenLaunchDialogAction (org.eclipse.debug.ui.actions.OpenLaunchDialogAction)2 ActionContributionItem (org.eclipse.jface.action.ActionContributionItem)2 IAction (org.eclipse.jface.action.IAction)2 IDockerConnection (org.eclipse.linuxtools.docker.core.IDockerConnection)2 MenuItem (org.eclipse.swt.widgets.MenuItem)2 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 BuildDockerImageJob (org.eclipse.linuxtools.internal.docker.ui.jobs.BuildDockerImageJob)1 DockerComposeUpJob (org.eclipse.linuxtools.internal.docker.ui.jobs.DockerComposeUpJob)1