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;
}
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;
}
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);
}
}
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);
}
Aggregations