Search in sources :

Example 11 with BndPreferences

use of bndtools.preferences.BndPreferences in project bndtools by bndtools.

the class BndBuildPreferencePage method init.

@Override
public void init(IWorkbench workbench) {
    prefs = new BndPreferences();
    buildLogging = prefs.getBuildLogging();
}
Also used : BndPreferences(bndtools.preferences.BndPreferences)

Example 12 with BndPreferences

use of bndtools.preferences.BndPreferences in project bndtools by bndtools.

the class NativeBndLaunchDelegate method isAlreadyRunning.

/**
     * Check if we already have a configuration running
     */
public boolean isAlreadyRunning(ILaunchConfiguration configuration) throws CoreException {
    // Check for existing launches of same resource
    BndPreferences prefs = new BndPreferences();
    if (prefs.getWarnExistingLaunches()) {
        IResource launchResource = LaunchUtils.getTargetResource(configuration);
        if (launchResource == null)
            return false;
        int processCount = 0;
        for (ILaunch l : DebugPlugin.getDefault().getLaunchManager().getLaunches()) {
            // ... is it the same launch resource?
            ILaunchConfiguration launchConfig = l.getLaunchConfiguration();
            if (launchConfig == null) {
                continue;
            }
            if (launchResource.equals(LaunchUtils.getTargetResource(launchConfig))) {
                // Iterate existing processes
                for (IProcess process : l.getProcesses()) {
                    if (!process.isTerminated())
                        processCount++;
                }
            }
        }
        // Warn if existing processes running
        if (processCount > 0) {
            Status status = new Status(IStatus.WARNING, Plugin.PLUGIN_ID, 0, "One or more OSGi Frameworks have already been launched for this configuration. Additional framework instances may interfere with each other due to the shared storage directory.", null);
            IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(status);
            if (prompter != null) {
                boolean okay = (Boolean) prompter.handleStatus(status, launchResource);
                return !okay;
            }
        }
    }
    return false;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) BndPreferences(bndtools.preferences.BndPreferences) IStatusHandler(org.eclipse.debug.core.IStatusHandler) ILaunch(org.eclipse.debug.core.ILaunch) IProcess(org.eclipse.debug.core.model.IProcess) IResource(org.eclipse.core.resources.IResource)

Example 13 with BndPreferences

use of bndtools.preferences.BndPreferences in project bndtools by bndtools.

the class AbstractOSGiLaunchDelegate method finalLaunchCheck.

@Override
public boolean finalLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
    // Check for existing launches of same resource
    BndPreferences prefs = new BndPreferences();
    if (prefs.getWarnExistingLaunches()) {
        IResource launchResource = LaunchUtils.getTargetResource(configuration);
        if (launchResource == null)
            throw new CoreException(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Bnd launch target was not specified or does not exist.", null));
        int processCount = 0;
        for (ILaunch l : DebugPlugin.getDefault().getLaunchManager().getLaunches()) {
            // ... is it the same launch resource?
            ILaunchConfiguration launchConfig = l.getLaunchConfiguration();
            if (launchConfig == null) {
                continue;
            }
            if (launchResource.equals(LaunchUtils.getTargetResource(launchConfig))) {
                // Iterate existing processes
                for (IProcess process : l.getProcesses()) {
                    if (!process.isTerminated())
                        processCount++;
                }
            }
        }
        // Warn if existing processes running
        if (processCount > 0) {
            Status status = new Status(IStatus.WARNING, Plugin.PLUGIN_ID, 0, "One or more OSGi Frameworks have already been launched for this configuration. Additional framework instances may interfere with each other due to the shared storage directory.", null);
            IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(status);
            if (prompter != null) {
                boolean okay = (Boolean) prompter.handleStatus(status, launchResource);
                if (!okay)
                    return okay;
            }
        }
    }
    IStatus launchStatus = getLauncherStatus();
    IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(launchStatus);
    if (prompter != null)
        return (Boolean) prompter.handleStatus(launchStatus, run);
    return true;
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) IStatus(org.eclipse.core.runtime.IStatus) BndPreferences(bndtools.preferences.BndPreferences) CoreException(org.eclipse.core.runtime.CoreException) IStatusHandler(org.eclipse.debug.core.IStatusHandler) ILaunch(org.eclipse.debug.core.ILaunch) IProcess(org.eclipse.debug.core.model.IProcess) IResource(org.eclipse.core.resources.IResource)

Example 14 with BndPreferences

use of bndtools.preferences.BndPreferences in project bndtools by bndtools.

the class AbstractOSGiLaunchDelegate method buildForLaunch.

@Override
public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
    BndPreferences prefs = new BndPreferences();
    boolean result = !prefs.getBuildBeforeLaunch() || super.buildForLaunch(configuration, mode, monitor);
    try {
        run = LaunchUtils.createRun(configuration);
        initialiseBndLauncher(configuration, run);
    } catch (Exception e) {
        throw new CoreException(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error initialising bnd launcher", e));
    }
    return result;
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) BndPreferences(bndtools.preferences.BndPreferences) CoreException(org.eclipse.core.runtime.CoreException) CoreException(org.eclipse.core.runtime.CoreException)

Example 15 with BndPreferences

use of bndtools.preferences.BndPreferences in project bndtools by bndtools.

the class BndEditor method showHighestPriorityPage.

void showHighestPriorityPage() {
    int selectedPrio = Integer.MIN_VALUE;
    String selected = null;
    BndPreferences prefs = new BndPreferences();
    if (prefs.getEditorOpenSourceTab()) {
        selected = SOURCE_PAGE;
        selectedPrio = 0;
    } else {
        for (Object pageObj : pages) {
            IFormPage page = (IFormPage) pageObj;
            int priority = 0;
            if (page instanceof IPriority)
                priority = ((IPriority) page).getPriority();
            if (priority > selectedPrio) {
                selected = page.getId();
                selectedPrio = priority;
            }
        }
    }
    if (selected != null)
        setActivePage(selected);
}
Also used : BndPreferences(bndtools.preferences.BndPreferences) IFormPage(org.eclipse.ui.forms.editor.IFormPage) IPriority(bndtools.editor.common.IPriority)

Aggregations

BndPreferences (bndtools.preferences.BndPreferences)18 CoreException (org.eclipse.core.runtime.CoreException)6 IStatus (org.eclipse.core.runtime.IStatus)6 Status (org.eclipse.core.runtime.Status)6 MultiStatus (org.eclipse.core.runtime.MultiStatus)4 IResource (org.eclipse.core.resources.IResource)3 Attrs (aQute.bnd.header.Attrs)2 File (java.io.File)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 URISyntaxException (java.net.URISyntaxException)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 TimeoutException (java.util.concurrent.TimeoutException)2 NamedPlugin (org.bndtools.api.NamedPlugin)2 HeadlessBuildManager (org.bndtools.headless.build.manager.api.HeadlessBuildManager)2 VersionControlIgnoresManager (org.bndtools.versioncontrol.ignores.manager.api.VersionControlIgnoresManager)2 IFile (org.eclipse.core.resources.IFile)2 IProject (org.eclipse.core.resources.IProject)2 ILaunch (org.eclipse.debug.core.ILaunch)2 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)2