Search in sources :

Example 6 with HeaderClause

use of aQute.bnd.build.model.clauses.HeaderClause in project bndtools by bndtools.

the class PkgRenameParticipant method makeNewHeaders.

@SuppressWarnings("unchecked")
private static <T> List<T> makeNewHeaders(List<T> headers, String oldName, String newName) {
    if (headers != null) {
        boolean changed = false;
        List<T> newHeaders = new ArrayList<>();
        for (T header : headers) {
            if (header instanceof HeaderClause) {
                HeaderClause newHeader = ((HeaderClause) header).clone();
                newHeaders.add((T) newHeader);
                if (newHeader.getName().equals(oldName)) {
                    newHeader.setName(newName);
                    changed = true;
                }
            } else if (header instanceof String) {
                String newPrivatePackage = header.toString();
                if (newPrivatePackage.equals(oldName)) {
                    newPrivatePackage = newName;
                    changed = true;
                }
                newHeaders.add((T) newPrivatePackage);
            }
        }
        if (changed) {
            return newHeaders;
        }
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) HeaderClause(aQute.bnd.build.model.clauses.HeaderClause)

Example 7 with HeaderClause

use of aQute.bnd.build.model.clauses.HeaderClause in project bndtools by bndtools.

the class RepositoriesEditModel method remove.

boolean remove(Repository repository) throws Exception {
    HeaderClause clause = toHeaderClause(repository);
    if (clause != null && standalone != null) {
        standalone.remove(clause);
        model.setStandaloneLinks(standalone);
        updateStandaloneWorkspace(model);
        commitToModel(model);
        return true;
    }
    return false;
}
Also used : HeaderClause(aQute.bnd.build.model.clauses.HeaderClause)

Example 8 with HeaderClause

use of aQute.bnd.build.model.clauses.HeaderClause in project bndtools by bndtools.

the class RepositorySelectionPart method doAddStandaloneLink.

private void doAddStandaloneLink() {
    try {
        URLDialog dialog = new URLDialog(editor.getSite().getShell(), "Add repository URL");
        if (dialog.open() == Window.OK) {
            URI location = dialog.getLocation();
            Attrs attrs = new Attrs();
            if (dialog.getName() != null)
                attrs.put("name", dialog.getName());
            HeaderClause clause = new HeaderClause(location.toString(), attrs);
            repositories.add(clause);
            refreshFromModel();
            markDirty();
        }
    } catch (Exception e) {
        throw Exceptions.duck(e);
    }
}
Also used : URLDialog(bndtools.shared.URLDialog) Attrs(aQute.bnd.header.Attrs) URI(java.net.URI) HeaderClause(aQute.bnd.build.model.clauses.HeaderClause) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 9 with HeaderClause

use of aQute.bnd.build.model.clauses.HeaderClause in project bndtools by bndtools.

the class PluginClauseLabelProvider method update.

@Override
public void update(ViewerCell cell) {
    HeaderClause header = (HeaderClause) cell.getElement();
    String className = header.getName();
    StyledString label = new StyledString(className);
    Map<String, String> attribs = header.getAttribs();
    if (!attribs.isEmpty())
        label.append(" ");
    for (Iterator<Entry<String, String>> iter = attribs.entrySet().iterator(); iter.hasNext(); ) {
        Entry<String, String> entry = iter.next();
        label.append(entry.getKey(), StyledString.QUALIFIER_STYLER);
        label.append("=", StyledString.QUALIFIER_STYLER);
        label.append(entry.getValue(), StyledString.COUNTER_STYLER);
        if (iter.hasNext())
            label.append(", ");
    }
    cell.setText(label.toString());
    cell.setStyleRanges(label.getStyleRanges());
    Image image = images.get(className);
    if (image == null) {
        IConfigurationElement configElem = configElements.get(className);
        if (configElem != null) {
            String iconPath = configElem.getAttribute("icon");
            if (iconPath != null) {
                ImageDescriptor descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(configElem.getContributor().getName(), iconPath);
                if (descriptor != null) {
                    image = descriptor.createImage();
                    images.put(className, image);
                }
            }
        }
    }
    if (image == null) {
        image = images.get("__DEFAULT__");
        if (image == null) {
            image = AbstractUIPlugin.imageDescriptorFromPlugin(Plugin.PLUGIN_ID, "/icons/plugin.png").createImage();
            images.put("__DEFAULT__", image);
        }
    }
    cell.setImage(image);
}
Also used : Entry(java.util.Map.Entry) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString) Image(org.eclipse.swt.graphics.Image) HeaderClause(aQute.bnd.build.model.clauses.HeaderClause) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Aggregations

HeaderClause (aQute.bnd.build.model.clauses.HeaderClause)9 Attrs (aQute.bnd.header.Attrs)3 ArrayList (java.util.ArrayList)3 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)2 WizardDialog (org.eclipse.jface.wizard.WizardDialog)2 Parameters (aQute.bnd.header.Parameters)1 URLDialog (bndtools.shared.URLDialog)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 URI (java.net.URI)1 Entry (java.util.Map.Entry)1 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)1 StyledString (org.eclipse.jface.viewers.StyledString)1 Image (org.eclipse.swt.graphics.Image)1