Skip to content

Commit c6e4024

Browse files
committedMar 29, 2019
Added SchemaManagerFilter
1 parent c998f96 commit c6e4024

File tree

7 files changed

+227
-4
lines changed

7 files changed

+227
-4
lines changed
 

‎frameworks/legaldocml/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/target/
2+
.project
3+
.classpath
4+
.settings

‎frameworks/legaldocml/assembly.xml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
<!-- This is an assembly file used for all the sample plugins. -->
3+
4+
<assembly
5+
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
6+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
7+
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
8+
<id>package</id>
9+
<formats>
10+
<format>zip</format>
11+
</formats>
12+
<includeBaseDirectory>false</includeBaseDirectory>
13+
14+
<fileSets>
15+
<fileSet>
16+
<directory>/</directory>
17+
<outputDirectory>/legaldocml</outputDirectory>
18+
<includes>
19+
<include>legaldocml.framework</include>
20+
<include>css/**</include>
21+
<include>schemas/**</include>
22+
</includes>
23+
</fileSet>
24+
</fileSets>
25+
26+
<files>
27+
<file>
28+
<source>target/${project.build.finalName}.jar</source>
29+
<destName>legaldocml.jar</destName>
30+
<outputDirectory>/legaldocml</outputDirectory>
31+
</file>
32+
</files>
33+
</assembly>

‎frameworks/legaldocml/legaldocml.framework

+7-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
</docTypeSchema>
2323
</field>
2424
<field name="classpath">
25-
<String-array/>
25+
<String-array>
26+
<String>${framework}/target/classes/</String>
27+
<String>${framework}/legaldocml.jar</String>
28+
</String-array>
2629
</field>
2730
<field name="parentClassLoaderID">
2831
<null/>
@@ -268,13 +271,13 @@
268271
<null/>
269272
</field>
270273
<field name="extensionsBundleClassName">
271-
<null/>
274+
<String>com.oxygenxml.samples.legaldocml.LegalDocMLExtensionsBundle</String>
272275
</field>
273276
<field name="useImposedInitialPage">
274-
<Boolean>false</Boolean>
277+
<Boolean>true</Boolean>
275278
</field>
276279
<field name="imposedInitialPage">
277-
<String>Text</String>
280+
<String>Author</String>
278281
</field>
279282
<field name="elementLocatorExtension">
280283
<null/>

‎frameworks/legaldocml/legaldocml.jar

7.58 KB
Binary file not shown.

‎frameworks/legaldocml/pom.xml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?xml version="1.0"?>
2+
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>com.oxygenxml.samples</groupId>
6+
<artifactId>legal-doc-ml</artifactId>
7+
<version>21.0-SNAPSHOT</version>
8+
9+
<properties>
10+
<maven.compiler.source>1.8</maven.compiler.source>
11+
<maven.compiler.target>1.8</maven.compiler.target>
12+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
13+
</properties>
14+
15+
<repositories>
16+
<!-- Download artifacts from the oXygem XML Maven Repository-->
17+
<repository>
18+
<id>oxygenxml</id>
19+
<name>oXygen XML SDK Maven Repository</name>
20+
<url>http://oxygenxml.com/maven/</url>
21+
</repository>
22+
</repositories>
23+
<dependencies>
24+
<dependency>
25+
<groupId>com.oxygenxml</groupId>
26+
<artifactId>oxygen</artifactId>
27+
<version>21.0.0.0</version>
28+
</dependency>
29+
</dependencies>
30+
31+
<build>
32+
<plugins>
33+
<plugin>
34+
<artifactId>maven-assembly-plugin</artifactId>
35+
<version>2.4</version>
36+
<executions>
37+
<execution>
38+
<id>make-assembly</id>
39+
<phase>package</phase>
40+
<goals>
41+
<goal>single</goal>
42+
</goals>
43+
<configuration>
44+
<archiveBaseDirectory>${project.basedir}</archiveBaseDirectory>
45+
<descriptors>
46+
<descriptor>assembly.xml</descriptor>
47+
</descriptors>
48+
</configuration>
49+
</execution>
50+
</executions>
51+
</plugin>
52+
</plugins>
53+
</build>
54+
55+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package com.oxygenxml.samples.legaldocml;
2+
3+
import ro.sync.contentcompletion.xml.SchemaManagerFilter;
4+
import ro.sync.ecss.extensions.api.AuthorAccess;
5+
import ro.sync.ecss.extensions.api.AuthorAccessProvider;
6+
import ro.sync.ecss.extensions.api.AuthorExtensionStateListener;
7+
import ro.sync.ecss.extensions.api.ExtensionsBundle;
8+
9+
/**
10+
* Legal doc ML extensions bundle.
11+
*
12+
* @author cristi_talau
13+
*/
14+
public class LegalDocMLExtensionsBundle extends ExtensionsBundle implements AuthorAccessProvider {
15+
16+
/**
17+
* The current author access.
18+
*/
19+
private AuthorAccess authorAccess = null;
20+
21+
@Override
22+
public AuthorExtensionStateListener createAuthorExtensionStateListener() {
23+
return new AuthorExtensionStateListener() {
24+
25+
public String getDescription() {
26+
return "Keeps track of the current AuthorAccess";
27+
}
28+
29+
public void deactivated(AuthorAccess authorAccess) {
30+
LegalDocMLExtensionsBundle.this.authorAccess = null;
31+
}
32+
33+
public void activated(AuthorAccess authorAccess) {
34+
LegalDocMLExtensionsBundle.this.authorAccess = authorAccess;
35+
}
36+
};
37+
}
38+
39+
@Override
40+
public SchemaManagerFilter createSchemaManagerFilter() {
41+
return new LegalDocMLSchemaManagerFilter(this);
42+
}
43+
44+
public String getDescription() {
45+
return "LegalDocML (Akoma Ntoso)";
46+
}
47+
48+
@Override
49+
public String getDocumentTypeID() {
50+
return "legal-doc-ml";
51+
}
52+
53+
@Override
54+
public AuthorAccess getAuthorAccess() {
55+
return authorAccess;
56+
}
57+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package com.oxygenxml.samples.legaldocml;
2+
3+
import static java.util.stream.Collectors.toList;
4+
5+
import java.util.Arrays;
6+
import java.util.List;
7+
8+
import ro.sync.contentcompletion.xml.CIAttribute;
9+
import ro.sync.contentcompletion.xml.CIElement;
10+
import ro.sync.contentcompletion.xml.CIValue;
11+
import ro.sync.contentcompletion.xml.Context;
12+
import ro.sync.contentcompletion.xml.SchemaManagerFilter;
13+
import ro.sync.contentcompletion.xml.WhatAttributesCanGoHereContext;
14+
import ro.sync.contentcompletion.xml.WhatElementsCanGoHereContext;
15+
import ro.sync.contentcompletion.xml.WhatPossibleValuesHasAttributeContext;
16+
import ro.sync.ecss.extensions.api.AuthorAccess;
17+
import ro.sync.ecss.extensions.api.AuthorAccessProvider;
18+
import ro.sync.ecss.extensions.api.node.AuthorNode;
19+
20+
/**
21+
* Schema Manager filter.
22+
*
23+
* @author cristi_talau
24+
*/
25+
public class LegalDocMLSchemaManagerFilter implements SchemaManagerFilter {
26+
27+
/**
28+
* Access provider.
29+
*/
30+
private final AuthorAccessProvider accessProvider;
31+
32+
public LegalDocMLSchemaManagerFilter(AuthorAccessProvider accessProvider) {
33+
this.accessProvider = accessProvider;
34+
}
35+
36+
/**
37+
* Do not propose these elements to surround a paragraph.
38+
*/
39+
private final List<String> invalidParagraphParents = Arrays.asList("p", "table");
40+
41+
public List<CIElement> filterElements(List<CIElement> elements, WhatElementsCanGoHereContext context) {
42+
List<CIElement> toReturn = elements;
43+
AuthorAccess authorAccess = this.accessProvider.getAuthorAccess();
44+
if (authorAccess != null) {
45+
AuthorNode fullySelectedNode = authorAccess.getEditorAccess().getFullySelectedNode();
46+
if (fullySelectedNode != null && fullySelectedNode.getName().equals("p")) {
47+
toReturn = elements.stream()
48+
.filter(elem -> !invalidParagraphParents.contains(elem.getName()))
49+
.collect(toList());
50+
}
51+
}
52+
return toReturn;
53+
}
54+
55+
public String getDescription() {
56+
return "Used to filter content completion items";
57+
}
58+
59+
public List<CIValue> filterAttributeValues(List<CIValue> values, WhatPossibleValuesHasAttributeContext context) {
60+
return values;
61+
}
62+
63+
public List<CIAttribute> filterAttributes(List<CIAttribute> attributes, WhatAttributesCanGoHereContext context) {
64+
return attributes;
65+
}
66+
67+
public List<CIValue> filterElementValues(List<CIValue> values, Context context) {
68+
return values;
69+
}
70+
71+
}

0 commit comments

Comments
 (0)
Please sign in to comment.