Search in sources :

Example 11 with DebugOptions

use of org.eclipse.osgi.service.debug.DebugOptions in project eclipse.platform.runtime by eclipse.

the class Plugin method setDebugging.

/**
 * Sets whether this plug-in is in debug mode.
 * By default plug-ins are not in debug mode.  A plug-in can put itself
 * into debug mode or the user can set a debug option to do so.
 * <p>
 * Note that the plug-in's debug flag is initialized when the
 * plug-in is started. The result of calling this method before the plug-in
 * has started is unspecified.
 * </p>
 *
 * @param value whether or not this plug-in is in debug mode
 * XXX deprecate use the service and cache as needed
 */
public void setDebugging(boolean value) {
    Bundle debugBundle = getBundle();
    if (debugBundle == null) {
        this.debug = value;
        return;
    }
    // $NON-NLS-1$
    String key = debugBundle.getSymbolicName() + "/debug";
    final DebugOptions options = getDebugOptions();
    if (options == null)
        this.debug = value;
    else {
        if (!options.isDebugEnabled())
            options.setDebugEnabled(true);
        options.setOption(key, value ? Boolean.TRUE.toString() : Boolean.FALSE.toString());
    }
}
Also used : DebugOptions(org.eclipse.osgi.service.debug.DebugOptions)

Example 12 with DebugOptions

use of org.eclipse.osgi.service.debug.DebugOptions in project egit by eclipse.

the class GitTraceConfigurationDialog method performOk.

private void performOk() {
    DebugOptions options = getOptions();
    if (isDirty) {
        options.setDebugEnabled(platformSwitch.getSelection());
        if (platformSwitch.getSelection()) {
            // if this is off, we won't be able to save anything
            List<String> checkedKeys = new ArrayList<>();
            for (Object checked : Arrays.asList(tv.getCheckedElements())) {
                if (checked instanceof PluginNode)
                    checkedKeys.add(((PluginNode) checked).getPlugin() + MAINSWITCH);
                else if (checked instanceof OptionNode)
                    checkedKeys.add(((OptionNode) checked).getOption());
            }
            for (PluginNode plugin : optionsMap.keySet()) {
                Properties props = optionsMap.get(plugin);
                for (Object keyObject : props.keySet()) {
                    String key = (String) keyObject;
                    boolean isOn = options.getBooleanOption(key, false);
                    boolean shouldBeOn = checkedKeys.contains(key);
                    if (isOn != shouldBeOn) {
                        options.setOption(key, Boolean.toString(shouldBeOn));
                    }
                }
            }
        }
        fillOptionsMapFromCurrent(options);
        tv.refresh();
        setDirty(false);
    }
}
Also used : ArrayList(java.util.ArrayList) Properties(java.util.Properties) DebugOptions(org.eclipse.osgi.service.debug.DebugOptions)

Example 13 with DebugOptions

use of org.eclipse.osgi.service.debug.DebugOptions in project egit by eclipse.

the class GitTraceConfigurationDialog method initValues.

private void initValues() {
    DebugOptions options = getOptions();
    fillOptionsMapFromCurrent(options);
    tv.setCheckStateProvider(new ICheckStateProvider() {

        @Override
        public boolean isGrayed(Object element) {
            return false;
        }

        @Override
        public boolean isChecked(Object element) {
            Object data = element;
            Properties props;
            String key;
            if (data instanceof PluginNode) {
                PluginNode node = (PluginNode) data;
                props = optionsMap.get(node);
                key = node.getPlugin() + MAINSWITCH;
            } else if (data instanceof OptionNode) {
                OptionNode node = (OptionNode) data;
                props = optionsMap.get(node.getPlugin());
                key = node.getOption();
            } else {
                return false;
            }
            boolean active = Boolean.valueOf(props.getProperty(key)).booleanValue();
            return active;
        }
    });
    tv.setInput(PLUGIN_LIST);
    tv.expandAll();
    if (platformSwitch.getSelection() != options.isDebugEnabled()) {
        platformSwitch.setSelection(options.isDebugEnabled());
    }
    traceFileLocation.setText(getOptions().getFile().getPath());
    updateEnablement();
}
Also used : ICheckStateProvider(org.eclipse.jface.viewers.ICheckStateProvider) Properties(java.util.Properties) DebugOptions(org.eclipse.osgi.service.debug.DebugOptions)

Example 14 with DebugOptions

use of org.eclipse.osgi.service.debug.DebugOptions in project ecf by eclipse.

the class Activator method getDebugOptions.

@SuppressWarnings({ "unchecked", "rawtypes" })
public synchronized DebugOptions getDebugOptions() {
    if (context == null)
        return null;
    if (debugOptionsTracker == null) {
        debugOptionsTracker = new ServiceTracker(context, DebugOptions.class.getName(), null);
        debugOptionsTracker.open();
    }
    return (DebugOptions) debugOptionsTracker.getService();
}
Also used : ServiceTracker(org.osgi.util.tracker.ServiceTracker) DebugOptions(org.eclipse.osgi.service.debug.DebugOptions)

Aggregations

DebugOptions (org.eclipse.osgi.service.debug.DebugOptions)14 ServiceTracker (org.osgi.util.tracker.ServiceTracker)3 Hashtable (java.util.Hashtable)2 Properties (java.util.Properties)2 DebugOptionsListener (org.eclipse.osgi.service.debug.DebugOptionsListener)2 DebugTrace (org.eclipse.osgi.service.debug.DebugTrace)2 ArrayList (java.util.ArrayList)1 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)1 Activator (org.eclipse.ecf.internal.core.identity.Activator)1 ResourceProvider (org.eclipse.epp.internal.mpc.ui.catalog.ResourceProvider)1 IMarketplaceClientService (org.eclipse.epp.mpc.ui.IMarketplaceClientService)1 ICheckStateProvider (org.eclipse.jface.viewers.ICheckStateProvider)1 Test (org.junit.Test)1 Bundle (org.osgi.framework.Bundle)1 BundleActivator (org.osgi.framework.BundleActivator)1 BundleContext (org.osgi.framework.BundleContext)1