Search in sources :

Example 1 with NamedPlugin

use of org.bndtools.api.NamedPlugin in project bndtools by bndtools.

the class GeneratedResourcesPreferencePage method init.

@Override
public void init(IWorkbench workbench) {
    BndPreferences prefs = new BndPreferences();
    enableSubs = prefs.getEnableSubBundles();
    noAskPackageInfo = prefs.getNoAskPackageInfo();
    useAliasRequirements = prefs.getUseAliasRequirements();
    headlessBuildCreate = prefs.getHeadlessBuildCreate();
    Collection<NamedPlugin> pluginsInformation = headlessBuildManager.getAllPluginsInformation();
    if (pluginsInformation.size() > 0) {
        headlessBuildPlugins.clear();
        headlessBuildPlugins.putAll(prefs.getHeadlessBuildPlugins(pluginsInformation, false));
    }
    versionControlIgnoresCreate = prefs.getVersionControlIgnoresCreate();
    pluginsInformation = versionControlIgnoresManager.getAllPluginsInformation();
    if (pluginsInformation.size() > 0) {
        versionControlIgnoresPlugins.clear();
        versionControlIgnoresPlugins.putAll(prefs.getVersionControlIgnoresPlugins(versionControlIgnoresManager.getAllPluginsInformation(), false));
    }
}
Also used : BndPreferences(bndtools.preferences.BndPreferences) NamedPlugin(org.bndtools.api.NamedPlugin)

Example 2 with NamedPlugin

use of org.bndtools.api.NamedPlugin in project bndtools by bndtools.

the class VersionControlIgnoresManagerImpl method addPlugin.

@Reference(cardinality = ReferenceCardinality.AT_LEAST_ONE, policy = ReferencePolicy.DYNAMIC)
void addPlugin(VersionControlIgnoresPlugin plugin) {
    if (plugin == null) {
        return;
    }
    NamedPlugin pluginInformation = plugin.getInformation();
    String name = pluginInformation.getName();
    synchronized (plugins) {
        plugins.put(name, plugin);
        pluginsInformation.put(name, pluginInformation);
    }
}
Also used : NamedPlugin(org.bndtools.api.NamedPlugin) Reference(org.osgi.service.component.annotations.Reference)

Example 3 with NamedPlugin

use of org.bndtools.api.NamedPlugin in project bndtools by bndtools.

the class HeadlessBuildManagerImpl method addPlugin.

@Reference(cardinality = ReferenceCardinality.AT_LEAST_ONE, policy = ReferencePolicy.DYNAMIC)
void addPlugin(HeadlessBuildPlugin plugin) {
    if (plugin == null) {
        return;
    }
    NamedPlugin pluginInformation = plugin.getInformation();
    String name = pluginInformation.getName();
    synchronized (plugins) {
        plugins.put(name, plugin);
        pluginsInformation.put(name, pluginInformation);
    }
}
Also used : NamedPlugin(org.bndtools.api.NamedPlugin) Reference(org.osgi.service.component.annotations.Reference)

Example 4 with NamedPlugin

use of org.bndtools.api.NamedPlugin in project bndtools by bndtools.

the class BndPreferences method preferenceToMap.

private Map<String, Boolean> preferenceToMap(String preference, Collection<? extends NamedPlugin> allPluginsInformation, boolean onlyEnabled) {
    List<String> names = null;
    if (preference != null && !preference.isEmpty()) {
        names = Arrays.asList(preference.split("\\|"));
    }
    boolean atLeastOneEnabled = false;
    Map<String, Boolean> map = new TreeMap<String, Boolean>();
    for (NamedPlugin info : allPluginsInformation) {
        boolean enabled = (names == null) ? (info.isEnabledByDefault() && !info.isDeprecated()) : names.contains(info.getName());
        map.put(info.getName(), enabled);
        atLeastOneEnabled = atLeastOneEnabled || enabled;
    }
    if (!atLeastOneEnabled && (map.size() > 0)) {
        for (String name : map.keySet()) {
            map.put(name, Boolean.TRUE);
        }
    }
    if (onlyEnabled) {
        Set<String> pluginsToRemove = new HashSet<String>();
        for (Map.Entry<String, Boolean> entry : map.entrySet()) {
            if (!entry.getValue().booleanValue()) {
                pluginsToRemove.add(entry.getKey());
            }
        }
        for (String plugin : pluginsToRemove) {
            map.remove(plugin);
        }
    }
    return map;
}
Also used : NamedPlugin(org.bndtools.api.NamedPlugin) TreeMap(java.util.TreeMap) TreeMap(java.util.TreeMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 5 with NamedPlugin

use of org.bndtools.api.NamedPlugin in project bndtools by bndtools.

the class GeneratedResourcesPreferencePage method createHeadlessBuildSystemsGroup.

private Control createHeadlessBuildSystemsGroup(Composite parent) {
    Collection<NamedPlugin> allPluginsInformation = headlessBuildManager.getAllPluginsInformation();
    if (allPluginsInformation == null || allPluginsInformation.isEmpty()) {
        Label lbl = new Label(parent, SWT.None);
        lbl.setText("No headless build system support detected");
        return lbl;
    }
    Group headlessMainGroup = new Group(parent, SWT.NONE);
    headlessMainGroup.setText(Messages.BndPreferencePage_headlessGroup);
    final Button btnHeadlessCreate = new Button(headlessMainGroup, SWT.CHECK);
    btnHeadlessCreate.setText(Messages.BndPreferencePage_headlessCreate_text);
    btnHeadlessCreate.setSelection(headlessBuildCreate);
    final Group headlessGroup = new Group(headlessMainGroup, SWT.NONE);
    final Set<Button> headlessGroupButtons = new HashSet<Button>();
    for (NamedPlugin info : allPluginsInformation) {
        final String pluginName = info.getName();
        final Button btnHeadlessPlugin = new Button(headlessGroup, SWT.CHECK);
        headlessGroupButtons.add(btnHeadlessPlugin);
        if (info.isDeprecated()) {
            btnHeadlessPlugin.setText(pluginName + Messages.BndPreferencePage_namedPluginDeprecated_text);
        } else {
            btnHeadlessPlugin.setText(pluginName);
        }
        Boolean checked = headlessBuildPlugins.get(pluginName);
        if (checked == null) {
            checked = Boolean.FALSE;
            headlessBuildPlugins.put(pluginName, checked);
        }
        btnHeadlessPlugin.setSelection(checked.booleanValue());
        btnHeadlessPlugin.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                headlessBuildPlugins.put(pluginName, Boolean.valueOf(btnHeadlessPlugin.getSelection()));
                checkValid();
            }
        });
    }
    headlessGroup.setLayout(new GridLayout(Math.max(4, allPluginsInformation.size()), true));
    headlessMainGroup.setLayout(new GridLayout(1, true));
    btnHeadlessCreate.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            headlessBuildCreate = btnHeadlessCreate.getSelection();
            for (Button button : headlessGroupButtons) {
                button.setEnabled(headlessBuildCreate);
            }
            checkValid();
        }
    });
    return headlessMainGroup;
}
Also used : Group(org.eclipse.swt.widgets.Group) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) NamedPlugin(org.bndtools.api.NamedPlugin) HashSet(java.util.HashSet)

Aggregations

NamedPlugin (org.bndtools.api.NamedPlugin)7 HashSet (java.util.HashSet)3 BndPreferences (bndtools.preferences.BndPreferences)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Button (org.eclipse.swt.widgets.Button)2 Group (org.eclipse.swt.widgets.Group)2 Label (org.eclipse.swt.widgets.Label)2 Reference (org.osgi.service.component.annotations.Reference)2 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 GridData (org.eclipse.swt.layout.GridData)1