Search in sources :

Example 1 with Attributes

use of org.eclipse.xtext.util.MergeableManifest2.Attributes in project xtext-core by eclipse.

the class ManifestMerger2Test method testMergeRequiredBundles.

@Test
public void testMergeRequiredBundles() throws Exception {
    String packageName = getClass().getPackage().getName().replace('.', '/');
    InputStream resourceAsStream = getClass().getResourceAsStream("/" + packageName + "/Test_Manifest.MF");
    MergeableManifest2 manifest = new MergeableManifest2(resourceAsStream);
    Attributes attrs = manifest.getMainAttributes();
    String before = attrs.get(MergeableManifest2.REQUIRE_BUNDLE).replaceAll("\\s", "");
    manifest.addRequiredBundles(Collections.singleton("foo.bar.baz"));
    String after = attrs.get(MergeableManifest2.REQUIRE_BUNDLE);
    assertEquals(before + ",foo.bar.baz", after.replaceAll("\\s", ""));
}
Also used : StringInputStream(org.eclipse.xtext.util.StringInputStream) InputStream(java.io.InputStream) Attributes(org.eclipse.xtext.util.MergeableManifest2.Attributes) MergeableManifest2(org.eclipse.xtext.util.MergeableManifest2) Test(org.junit.Test)

Example 2 with Attributes

use of org.eclipse.xtext.util.MergeableManifest2.Attributes in project xtext-core by eclipse.

the class ManifestMerger2Test method testNoChanges.

@Test
public void testNoChanges() throws Exception {
    String packageName = getClass().getPackage().getName().replace('.', '/');
    InputStream resourceAsStream = getClass().getResourceAsStream("/" + packageName + "/Test_Manifest.MF");
    MergeableManifest2 manifest = new MergeableManifest2(resourceAsStream);
    Attributes attrs = manifest.getMainAttributes();
    String before = attrs.get(MergeableManifest2.EXPORT_PACKAGE).replaceAll("\\s", "");
    manifest.addExportedPackages(Collections.singleton("foo.bar.baz"));
    String after = attrs.get(MergeableManifest2.EXPORT_PACKAGE);
    assertEquals(before + ",foo.bar.baz", after.replaceAll("\\s", ""));
}
Also used : StringInputStream(org.eclipse.xtext.util.StringInputStream) InputStream(java.io.InputStream) Attributes(org.eclipse.xtext.util.MergeableManifest2.Attributes) MergeableManifest2(org.eclipse.xtext.util.MergeableManifest2) Test(org.junit.Test)

Example 3 with Attributes

use of org.eclipse.xtext.util.MergeableManifest2.Attributes in project certmgr by hdecarne.

the class StoreController method updateDetailsViewHelper.

private void updateDetailsViewHelper(TreeItem<AttributeModel> parentItem, Attributes attribute, boolean expand) {
    TreeItem<AttributeModel> attributeItem = new TreeItem<>(new AttributeModel(attribute));
    List<Attributes> attributeChildren = attribute.children();
    int childCount = attributeChildren.size();
    int childIndex = 0;
    for (Attributes child : attributeChildren) {
        if (childIndex >= DETAILS_VIEW_ATTRIBUTE_LIMIT) {
            attributeItem.getChildren().add(new TreeItem<>(new AttributeModel(StoreI18N.formatSTR_TEXT_DETAILS_OMITTED(childCount - childIndex))));
            break;
        }
        updateDetailsViewHelper(attributeItem, child, false);
        childIndex++;
    }
    parentItem.getChildren().add(attributeItem);
    attributeItem.setExpanded(expand);
}
Also used : TreeItem(javafx.scene.control.TreeItem) Attributes(de.carne.certmgr.certs.x509.Attributes)

Example 4 with Attributes

use of org.eclipse.xtext.util.MergeableManifest2.Attributes in project omegat by omegat-org.

the class XMLUtils method convertAttributes.

/**
 * Converts attributes from org.xml.sax package to OmegaT's.
 */
public static Attributes convertAttributes(org.xml.sax.Attributes attributes) {
    Attributes res = new Attributes();
    if (attributes == null) {
        return res;
    }
    for (int i = 0; i < attributes.getLength(); i++) {
        String name = StringUtil.makeValidXML(attributes.getQName(i));
        String value = StringUtil.makeValidXML(attributes.getValue(i));
        Attribute attr = new Attribute(name, value);
        res.add(attr);
    }
    return res;
}
Also used : Attribute(org.omegat.filters3.Attribute) Attributes(org.omegat.filters3.Attributes)

Aggregations

InputStream (java.io.InputStream)2 MergeableManifest2 (org.eclipse.xtext.util.MergeableManifest2)2 Attributes (org.eclipse.xtext.util.MergeableManifest2.Attributes)2 StringInputStream (org.eclipse.xtext.util.StringInputStream)2 Test (org.junit.Test)2 Attributes (de.carne.certmgr.certs.x509.Attributes)1 TreeItem (javafx.scene.control.TreeItem)1 Attribute (org.omegat.filters3.Attribute)1 Attributes (org.omegat.filters3.Attributes)1