Copying
|
@ -0,0 +1,59 @@
|
|||
# Alltogether: opening a JavaScript debugger within Oxygen [JS Operations](https://www.oxygenxml.com/doc/versions/23.1/ug-editor/topics/dg-default-author-operations.html#dg-default-author-operations__jsoperation) through inclusion
|
||||
|
||||
This rambling shows how a [debugger](../js-debugger) can be launched using an [inclusion](../js-include).
|
||||
|
||||
## Installation
|
||||
|
||||
To do so:
|
||||
### 1) add the include() function to your commons.js file:
|
||||
|
||||
```javascript
|
||||
include = function (filepath, isAbsolute) {
|
||||
if (isAbsolute === undefined || isAbsolute == false) {
|
||||
filepath = Packages.ro.sync.ecss.extensions.commons.operations.CommonsOperationsUtil.expandAndResolvePath(authorAccess, filepath);
|
||||
}
|
||||
var text = new java.lang.String(java.nio.file.Files.readAllBytes(java.nio.file.Paths. get (java.net.URI(filepath))));
|
||||
text = String(text);
|
||||
eval(text);
|
||||
}
|
||||
```
|
||||
### 2) create a debugger.js file:
|
||||
```javascript
|
||||
startDebugger = function () {
|
||||
|
||||
var runnable = {
|
||||
run: function () {
|
||||
main.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var context = Packages.org.mozilla.javascript.Context.getCurrentContext();
|
||||
// Within the current context...
|
||||
var contextFactory = context.getFactory();
|
||||
var scope = Packages.org.mozilla.javascript.tools.shell.Environment(runnable.__parent__);
|
||||
// and the scope of the runnable variable's parent ...
|
||||
var main = Packages.org.mozilla.javascript.tools. debugger.Main.mainEmbedded(contextFactory, scope, 'Debugger');
|
||||
// start a debugging session ...
|
||||
main.setExitAction(java.lang.Runnable(runnable));
|
||||
// , clean the resources at exit time...
|
||||
main.setVisible(true);
|
||||
// and make it visible/
|
||||
}
|
||||
```
|
||||
### 3) Use these functions in your doOperation() method:
|
||||
```javascript
|
||||
doOperation = function () {
|
||||
include('debugger.js');
|
||||
startDebugger();
|
||||
}
|
||||
```
|
||||
## See also
|
||||
More details on these hacks:
|
||||
* [debugger](../js-debugger)
|
||||
* [inclusion](../js-include)
|
||||
# Framework
|
||||
|
||||
This directory includes the Oxygen sample framework on which ou can test these techniques but they should work on any framework.
|
||||
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0"?>
|
||||
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
|
||||
<system
|
||||
systemId="http://www.oxygenxml.com/SDF/sdf.xsd"
|
||||
uri="schema/sdf.xsd"/>
|
||||
<system
|
||||
systemId="http://www.oxygenxml.com/SDF/abs.xsd"
|
||||
uri="schema/abs.xsd"/>
|
||||
</catalog>
|
|
@ -0,0 +1,8 @@
|
|||
include = function (filepath, isAbsolute) {
|
||||
if (isAbsolute === undefined || isAbsolute == false) {
|
||||
filepath = Packages.ro.sync.ecss.extensions.commons.operations.CommonsOperationsUtil.expandAndResolvePath(authorAccess, filepath);
|
||||
}
|
||||
var text = new java.lang.String(java.nio.file.Files.readAllBytes(java.nio.file.Paths. get (java.net.URI(filepath))));
|
||||
text = String(text);
|
||||
eval(text);
|
||||
}
|
|
@ -0,0 +1,145 @@
|
|||
/* Element from another namespace */
|
||||
@namespace abs "http://www.oxygenxml.com/sample/documentation/abstracts";
|
||||
|
||||
abs|def{
|
||||
font-family:monospace;
|
||||
font-size:smaller;
|
||||
}
|
||||
abs|def:before{
|
||||
content:"Definition:";
|
||||
color:gray;
|
||||
}
|
||||
|
||||
/* Vertical flow */
|
||||
book,
|
||||
section,
|
||||
para,
|
||||
title,
|
||||
image,
|
||||
ref {
|
||||
display:block;
|
||||
}
|
||||
|
||||
/* Horizontal flow */
|
||||
b,i {
|
||||
display:inline;
|
||||
}
|
||||
|
||||
section{
|
||||
margin-left:1em;
|
||||
margin-top:1em;
|
||||
}
|
||||
|
||||
section{
|
||||
-oxy-foldable:true;
|
||||
-oxy-not-foldable-child: title;
|
||||
}
|
||||
|
||||
link[href]:before{
|
||||
display:inline;
|
||||
link:attr(href);
|
||||
content: "Click to open: " attr(href);
|
||||
}
|
||||
|
||||
link:before {
|
||||
content:oxy_link-text();
|
||||
}
|
||||
|
||||
/* Title rendering*/
|
||||
title{
|
||||
font-size: 2.4em;
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
* * title{
|
||||
font-size: 2.0em;
|
||||
}
|
||||
* * * title{
|
||||
font-size: 1.6em;
|
||||
}
|
||||
* * * * title{
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
book,
|
||||
article{
|
||||
counter-reset:sect;
|
||||
}
|
||||
book > section,
|
||||
article > section{
|
||||
counter-increment:sect;
|
||||
}
|
||||
book > section > title:before,
|
||||
article > section > title:before{
|
||||
content: "Section: " counter(sect) " ";
|
||||
}
|
||||
|
||||
/* Inlines rendering*/
|
||||
b {
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
i {
|
||||
font-style:italic;
|
||||
}
|
||||
|
||||
/*Table rendering */
|
||||
table{
|
||||
display:table;
|
||||
border:1px solid navy;
|
||||
margin:1em;
|
||||
max-width:1000px;
|
||||
min-width:150px;
|
||||
}
|
||||
|
||||
table[width]{
|
||||
width:attr(width, length);
|
||||
}
|
||||
|
||||
table[bgcolor],
|
||||
tr[bgcolor],
|
||||
td[bgcolor]{
|
||||
background-color:attr(bgcolor);
|
||||
color:inherit;
|
||||
}
|
||||
|
||||
tr, header{
|
||||
display:table-row;
|
||||
}
|
||||
|
||||
customcol {
|
||||
text-align:left;
|
||||
display:block;
|
||||
color:#444444;
|
||||
background-color:inherit;
|
||||
margin:0.2em;
|
||||
padding:2px;
|
||||
font-family:monospace;
|
||||
font-size:small;
|
||||
}
|
||||
|
||||
header{
|
||||
background-color: silver;
|
||||
color:inherit
|
||||
}
|
||||
|
||||
td{
|
||||
display:table-cell;
|
||||
border:1px solid navy;
|
||||
padding:1em;
|
||||
}
|
||||
|
||||
image{
|
||||
display:block;
|
||||
content: attr(href, url);
|
||||
margin-left:2em;
|
||||
}
|
||||
|
||||
author, name, country {
|
||||
display:block;
|
||||
margin-left:20px;
|
||||
}
|
||||
|
||||
name:before {
|
||||
content: oxy_label(text, "Author: ", width, 100px, color, gray);
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
startDebugger = function () {
|
||||
|
||||
var runnable = {
|
||||
run: function () {
|
||||
main.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var context = Packages.org.mozilla.javascript.Context.getCurrentContext();
|
||||
// Within the current context...
|
||||
var contextFactory = context.getFactory();
|
||||
var scope = Packages.org.mozilla.javascript.tools.shell.Environment(runnable.__parent__);
|
||||
// and the scope of the runnable variable's parent ...
|
||||
var main = Packages.org.mozilla.javascript.tools. debugger.Main.mainEmbedded(contextFactory, scope, 'Debugger');
|
||||
// start a debugging session ...
|
||||
main.setExitAction(java.lang.Runnable(runnable));
|
||||
// , clean the resources at exit time...
|
||||
main.setVisible(true);
|
||||
// and make it visible/
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
hello = function (){
|
||||
Packages.java.lang.System.out.println("Hello world.");
|
||||
}
|
After Width: | Height: | Size: 777 B |
After Width: | Height: | Size: 927 B |
After Width: | Height: | Size: 762 B |
After Width: | Height: | Size: 826 B |
After Width: | Height: | Size: 811 B |
After Width: | Height: | Size: 928 B |
After Width: | Height: | Size: 800 B |
After Width: | Height: | Size: 946 B |
After Width: | Height: | Size: 766 B |
After Width: | Height: | Size: 870 B |
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="21.1">
|
||||
<meta>
|
||||
<filters directoryPatterns="" filePatterns="\Qjs-debugger.xpr\E" positiveFilePatterns="" showHiddenFiles="false"/>
|
||||
<options>
|
||||
<serialized version="21.1" xml:space="preserve">
|
||||
<serializableOrderedMap>
|
||||
<entry>
|
||||
<String>additional.frameworks.directories</String>
|
||||
<String-array>
|
||||
<String>/home/vdv/projects/pro/Remix/oxygen/frameworks/http___oxygen.remix.rece.hachette_livre.fr_oxygenUpdate.xml</String>
|
||||
<String>/home/vdv/projects/tea/dyomedea/ramblings/oxygen/js-debugger-include</String>
|
||||
</String-array>
|
||||
</entry>
|
||||
<entry>
|
||||
<String>key.editor.document.type.custom.locations.option.pane</String>
|
||||
<Boolean>true</Boolean>
|
||||
</entry>
|
||||
</serializableOrderedMap>
|
||||
</serialized>
|
||||
</options>
|
||||
</meta>
|
||||
<projectTree name="js-debugger-include.xpr">
|
||||
<folder path="."/>
|
||||
</projectTree>
|
||||
</project>
|
|
@ -0,0 +1 @@
|
|||
France, Spain, Great Britain
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||
targetNamespace=
|
||||
"http://www.oxygenxml.com/sample/documentation/abstracts">
|
||||
<xs:element name="def" type="xs:string"/>
|
||||
</xs:schema>
|
|
@ -0,0 +1,112 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||
targetNamespace="http://www.oxygenxml.com/sample/documentation"
|
||||
xmlns:doc="http://www.oxygenxml.com/sample/documentation"
|
||||
xmlns:abs="http://www.oxygenxml.com/sample/documentation/abstracts"
|
||||
elementFormDefault="qualified">
|
||||
<xs:import namespace="http://www.oxygenxml.com/sample/documentation/abstracts"
|
||||
schemaLocation="abs.xsd"/>
|
||||
<xs:element name="book" type="doc:articleType"/>
|
||||
<xs:element name="article" type="doc:articleType"/>
|
||||
<xs:element name="section" type="doc:sectionType"/>
|
||||
<xs:complexType name="sectionType">
|
||||
<xs:complexContent>
|
||||
<xs:restriction base="doc:articleType">
|
||||
<xs:sequence>
|
||||
<xs:element name="title" type="xs:string"/>
|
||||
<xs:element ref="abs:def" minOccurs="0"/>
|
||||
<xs:choice>
|
||||
<xs:sequence>
|
||||
<xs:element ref="doc:section" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
<xs:choice maxOccurs="unbounded">
|
||||
<xs:element ref="doc:para"/>
|
||||
<xs:element ref="doc:ref"/>
|
||||
<xs:element ref="doc:image"/>
|
||||
<xs:element ref="doc:table"/>
|
||||
</xs:choice>
|
||||
</xs:choice>
|
||||
</xs:sequence>
|
||||
</xs:restriction>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="para" type="doc:paragraphType"/>
|
||||
<xs:complexType name="paragraphType" mixed="true">
|
||||
<xs:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:element name="b"/>
|
||||
<xs:element name="i"/>
|
||||
<xs:element name="link"/>
|
||||
</xs:choice>
|
||||
</xs:complexType>
|
||||
<xs:element name="ref">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="location" type="xs:anyURI" use="required"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="image">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="href" type="xs:anyURI" use="required"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="table">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element form="qualified" minOccurs="0" name="title" type="xs:string"/>
|
||||
<xs:element name="customcol" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="width" type="xs:string"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="header" minOccurs="0">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="td" maxOccurs="unbounded" type="doc:paragraphType"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="tr" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="td" type="doc:tdType" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="width" type="xs:string"/>
|
||||
<xs:attribute name="bgcolor" type="xs:string"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:complexType name="tdType">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="doc:paragraphType">
|
||||
<xs:attribute name="row_span" type="xs:integer"/>
|
||||
<xs:attribute name="column_span" type="xs:integer"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="articleType">
|
||||
<xs:sequence>
|
||||
<xs:element name="title" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" name="author">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="name"/>
|
||||
<xs:element name="country"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element ref="abs:def" minOccurs="0"/>
|
||||
<xs:choice>
|
||||
<xs:sequence>
|
||||
<xs:element ref="doc:section" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
<xs:choice maxOccurs="unbounded">
|
||||
<xs:element ref="doc:para"/>
|
||||
<xs:element ref="doc:ref"/>
|
||||
<xs:element ref="doc:image"/>
|
||||
<xs:element ref="doc:table"/>
|
||||
</xs:choice>
|
||||
</xs:choice>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:schema>
|
|
@ -0,0 +1,91 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<book xmlns="http://www.oxygenxml.com/sample/documentation"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:abs="http://www.oxygenxml.com/sample/documentation/abstracts">
|
||||
<title>My Technical Book</title>
|
||||
<author>
|
||||
<name>Jean</name>
|
||||
<country>France</country>
|
||||
</author>
|
||||
<section>
|
||||
<title>XML</title>
|
||||
<abs:def>Extensible Markup Language</abs:def>
|
||||
<para>In this section of the book I will explain different XML applications.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Accessing XML data.</title>
|
||||
<section>
|
||||
<title>XSLT</title>
|
||||
<abs:def>Extensible stylesheet language transformation (XSLT) is a language for
|
||||
transforming XML documents into other XML documents.</abs:def>
|
||||
<para>A list of XSL elements and what they do..</para>
|
||||
<table>
|
||||
<header>
|
||||
<td>XSLT Elements</td>
|
||||
<td>Description</td>
|
||||
</header>
|
||||
<tr>
|
||||
<td>
|
||||
<b>xsl:stylesheet</b>
|
||||
</td>
|
||||
<td>The <i>xsl:stylesheet</i> element is always the top-level element of an XSL
|
||||
stylesheet. The name <i>xsl:transform</i> may be used as a synonym.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<b>xsl:template</b>
|
||||
</td>
|
||||
<td>The <i>xsl:template</i> element has an optional mode attribute. If this is
|
||||
present, the template will only be matched when the same mode is used in the
|
||||
invoking <i>xsl:apply-templates</i> element.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<b>for-each</b>
|
||||
</td>
|
||||
<td>The xsl:for-each element causes iteration over the nodes selected by a
|
||||
node-set expression.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td column_span="2">End of the list</td>
|
||||
</tr>
|
||||
</table>
|
||||
</section>
|
||||
<section>
|
||||
<title>XPath</title>
|
||||
<abs:def>XPath (XML Path Language) is a terse (non-XML) syntax for addressing portions
|
||||
of an XML document. </abs:def>
|
||||
<para>Some of the XPath functions.</para>
|
||||
<table>
|
||||
<header>
|
||||
<td>Function</td>
|
||||
<td>Description</td>
|
||||
</header>
|
||||
<tr>
|
||||
<td>format-number</td>
|
||||
<td>The <i>format-number</i> function converts its first argument to a string
|
||||
using the format pattern string specified by the second argument and the
|
||||
decimal-format named by the third argument, or the default decimal-format,
|
||||
if there is no third argument</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>current</td>
|
||||
<td>The <i>current</i> function returns a node-set that has the current node as
|
||||
its only member.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>generate-id</td>
|
||||
<td>The <i>generate-id</i> function returns a string that uniquely identifies
|
||||
the node in the argument node-set that is first in document order.</td>
|
||||
</tr>
|
||||
</table>
|
||||
</section>
|
||||
</section>
|
||||
<section>
|
||||
<title>Documentation frameworks</title>
|
||||
<para>One of the most important documentation frameworks is Docbook.</para>
|
||||
<image href="http://www.xmlhack.com/images/docbook.gif"/>
|
||||
<para>The other is the topic oriented DITA, promoted by OASIS.</para>
|
||||
<image href="http://www.oasis-open.org/images/standards/oasis_standard.jpg"/>
|
||||
</section>
|
||||
</book>
|
|
@ -0,0 +1,16 @@
|
|||
package simple.documentation.framework;
|
||||
|
||||
import ro.sync.ecss.extensions.api.AuthorAccess;
|
||||
|
||||
/**
|
||||
* Provides access to Author functions, to specific components corresponding to
|
||||
* editor, document, workspace, tables, change tracking and utility informations and actions.
|
||||
*/
|
||||
public interface AuthorAccessProvider {
|
||||
/**
|
||||
* Gets access to Author functions and components.
|
||||
*
|
||||
* @return The Author access.
|
||||
*/
|
||||
AuthorAccess getAuthorAccess();
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package simple.documentation.framework;
|
||||
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
import ro.sync.ecss.extensions.api.DocumentTypeCustomRuleMatcher;
|
||||
|
||||
/**
|
||||
* Matching rule to the SDF document type.
|
||||
*
|
||||
*/
|
||||
public class CustomRule implements DocumentTypeCustomRuleMatcher {
|
||||
|
||||
/**
|
||||
* Check if the SDF document type should be used for the given document properties.
|
||||
*/
|
||||
public boolean matches(
|
||||
String systemID,
|
||||
String rootNamespace,
|
||||
String rootLocalName,
|
||||
String doctypePublicID,
|
||||
Attributes rootAttributes) {
|
||||
boolean matches = true;
|
||||
int attributesCount = rootAttributes.getLength();
|
||||
for (int i = 0; i < attributesCount; i++) {
|
||||
String localName = rootAttributes.getLocalName(i);
|
||||
if ("version".equals(localName)) {
|
||||
if ("2.0".equals(rootAttributes.getValue(i))) {
|
||||
// Do not match the documents with "2.0" version
|
||||
matches = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return matches;
|
||||
}
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*/
|
||||
public String getDescription() {
|
||||
return "Checks if the current Document Type Association"
|
||||
+ " is matching the document.";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,552 @@
|
|||
package simple.documentation.framework;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import ro.sync.contentcompletion.xml.CIAttribute;
|
||||
import ro.sync.contentcompletion.xml.CIElement;
|
||||
import ro.sync.contentcompletion.xml.CIElementAdapter;
|
||||
|
||||
/**
|
||||
* Simple Documentation Framework element.
|
||||
*/
|
||||
public class SDFElement extends CIElementAdapter {
|
||||
/**
|
||||
* The namespace.
|
||||
*/
|
||||
protected String namespace = null;
|
||||
|
||||
/**
|
||||
* The element name.
|
||||
*/
|
||||
protected String name = null;
|
||||
|
||||
/**
|
||||
* The proxy.
|
||||
*/
|
||||
protected String proxy = null;
|
||||
|
||||
/**
|
||||
* The type description.
|
||||
*/
|
||||
private String typeDescription = null;
|
||||
|
||||
/**
|
||||
* List of attributes.
|
||||
*/
|
||||
protected List<CIAttribute> attributes = null;
|
||||
|
||||
/**
|
||||
* The possible values as <code>String</code> list.
|
||||
*/
|
||||
private List<String> possiblesValuesList;
|
||||
|
||||
/**
|
||||
* The element model description.
|
||||
*/
|
||||
private String modelDescription;
|
||||
|
||||
/**
|
||||
* The facets. One facet can be null if it is not defined.
|
||||
*/
|
||||
private String lengthFacetValue;
|
||||
|
||||
/**
|
||||
* The content type of the element.
|
||||
*/
|
||||
private int contentType = CONTENT_TYPE_NOT_DETERMINED;
|
||||
|
||||
/**
|
||||
* True if content is nillable. Used only for XML Schema.
|
||||
*/
|
||||
private boolean nillable;
|
||||
|
||||
/**
|
||||
* Facet values.
|
||||
*/
|
||||
private String minLengthFacetValue;
|
||||
private String maxLengthFacetValue;
|
||||
private String whitespaceFacetValue;
|
||||
private String minInclusiveFacetValue;
|
||||
private String minExclusiveFacetValue;
|
||||
private String maxInclusiveFacetValue;
|
||||
private String maxExclusiveFacetValue;
|
||||
private String totalDigitsFacetValue;
|
||||
private String fractionDigitsFacetValue;
|
||||
private String facetPatternValue;
|
||||
|
||||
/**
|
||||
* Guess some following elements if possible
|
||||
*/
|
||||
protected List<CIElement> guessElements = null;
|
||||
|
||||
/**
|
||||
* @see ro.sync.contentcompletion.xml.CIElement#getGuessElements()
|
||||
*/
|
||||
@Override
|
||||
public List<CIElement> getGuessElements() {
|
||||
if (guessElements != null && guessElements.isEmpty()) {
|
||||
// Return null is the list is empty.
|
||||
return null;
|
||||
}
|
||||
return guessElements;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ro.sync.contentcompletion.xml.CIElement#addGuessElement(ro.sync.contentcompletion.xml.CIElement)
|
||||
*/
|
||||
@Override
|
||||
public void addGuessElement(CIElement e) {
|
||||
if (guessElements == null) {
|
||||
guessElements = new ArrayList<CIElement>();
|
||||
}
|
||||
guessElements.add(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The string representing the name or null.
|
||||
*/
|
||||
@Override
|
||||
public String getName(){
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ro.sync.contentcompletion.xml.CIElement#getNamespace()
|
||||
*/
|
||||
@Override
|
||||
public String getNamespace(){
|
||||
return namespace;
|
||||
}
|
||||
|
||||
/**
|
||||
* True if the element has a namespace.
|
||||
*/
|
||||
private boolean xmlns;
|
||||
|
||||
/**
|
||||
* @see ro.sync.contentcompletion.xml.CIElement#setDeclareXmlns(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setDeclareXmlns(boolean xmlns) {
|
||||
this.xmlns = xmlns;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ro.sync.contentcompletion.xml.CIElement#setContentType(int)
|
||||
*/
|
||||
@Override
|
||||
public void setContentType(int contentType) {
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ro.sync.contentcompletion.xml.CIElement#isEmpty()
|
||||
*/
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return getContentType() == CONTENT_TYPE_EMPTY;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ro.sync.contentcompletion.xml.CIElement#getContentType()
|
||||
*/
|
||||
@Override
|
||||
public int getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ro.sync.contentcompletion.xml.CIElement#isDeclareXmlns()
|
||||
*/
|
||||
@Override
|
||||
public boolean isDeclareXmlns() {
|
||||
return xmlns;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ro.sync.contentcompletion.xml.CIElement#setName(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
/**
|
||||
* @see ro.sync.contentcompletion.xml.CIElement#setPrefix(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setPrefix(String proxy) {
|
||||
this.proxy = proxy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ro.sync.contentcompletion.xml.CIElement#setNamespace(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setNamespace(String namespace) {
|
||||
this.namespace = namespace;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see ro.sync.contentcompletion.xml.CIElement#getQName()
|
||||
*/
|
||||
@Override
|
||||
public String getQName() {
|
||||
if (getPrefix() != null && !"".equals(getPrefix())) {
|
||||
return getPrefix() + ":" + getName();
|
||||
} else {
|
||||
return getName();
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
boolean result = false;
|
||||
if (o instanceof SDFElement) {
|
||||
CIElement cie = (CIElement) o;
|
||||
result = compareTo(cie) == 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ro.sync.contentcompletion.xml.CIElement#getAttributes()
|
||||
*/
|
||||
@Override
|
||||
public List<CIAttribute> getAttributes() {
|
||||
return attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ro.sync.contentcompletion.xml.CIElement#setAttributes(java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public void setAttributes(List<CIAttribute> attributes) {
|
||||
this.attributes = attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Concatenates the name and the namespace and compares it with the other name and namespace,
|
||||
* as strings.
|
||||
* @param other The object to compare to.
|
||||
* @return The value <code>0</code> if the argument object is equal to this object.
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(CIElement other){
|
||||
String n1 = getName() == null ? "": getName();
|
||||
String nm1 = getNamespace() == null ? "": getNamespace();
|
||||
|
||||
String n2 = other.getName() == null ? "": other.getName();
|
||||
String nm2 = other.getNamespace() == null ? "": other.getNamespace();
|
||||
|
||||
int result = n1.compareTo(n2);
|
||||
if(result == 0) {
|
||||
result = nm1.compareTo(nm2);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name.
|
||||
*
|
||||
* @return The name.
|
||||
*/
|
||||
@Override
|
||||
public String toString(){
|
||||
String toRet = String.valueOf(getName());
|
||||
return toRet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ro.sync.contentcompletion.xml.CIElement#hasPrefix()
|
||||
*/
|
||||
@Override
|
||||
public boolean hasPrefix() {
|
||||
return getPrefix() != null && !"".equals(getPrefix());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ro.sync.contentcompletion.xml.CIElement#getPrefix()
|
||||
*/
|
||||
@Override
|
||||
public String getPrefix() {
|
||||
return proxy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param modelDescription The modelDescription to set.
|
||||
*/
|
||||
@Override
|
||||
public void setModelDescription(String modelDescription) {
|
||||
this.modelDescription = modelDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fractionDigitsFacetValue The fractionDigitsFacetValue to set.
|
||||
*/
|
||||
@Override
|
||||
public void setFacetFractionDigitsValue(String fractionDigitsFacetValue) {
|
||||
this.fractionDigitsFacetValue = fractionDigitsFacetValue;
|
||||
}
|
||||
/**
|
||||
* @param maxExclusiveFacetValue The maxExclusiveFacetValue to set.
|
||||
*/
|
||||
@Override
|
||||
public void setFacetMaxExclusiveValue(String maxExclusiveFacetValue) {
|
||||
this.maxExclusiveFacetValue = maxExclusiveFacetValue;
|
||||
}
|
||||
/**
|
||||
* @param maxInclusiveFacetValue The maxInclusiveFacetValue to set.
|
||||
*/
|
||||
@Override
|
||||
public void setFacetMaxInclusiveValue(String maxInclusiveFacetValue) {
|
||||
this.maxInclusiveFacetValue = maxInclusiveFacetValue;
|
||||
}
|
||||
/**
|
||||
* @param maxLengthFacetValue The maxLengthFacetValue to set.
|
||||
*/
|
||||
@Override
|
||||
public void setFacetMaxLengthValue(String maxLengthFacetValue) {
|
||||
this.maxLengthFacetValue = maxLengthFacetValue;
|
||||
}
|
||||
/**
|
||||
* @param minInclusiveFacetValue The minInclusiveFacetValue to set.
|
||||
*/
|
||||
@Override
|
||||
public void setFacetMinInclusiveValue(String minInclusiveFacetValue) {
|
||||
this.minInclusiveFacetValue = minInclusiveFacetValue;
|
||||
}
|
||||
/**
|
||||
* @param possiblesValuesList The possiblesValuesList to set.
|
||||
*/
|
||||
@Override
|
||||
public void setPossiblesValues(List<String> possiblesValuesList) {
|
||||
this.possiblesValuesList = possiblesValuesList;
|
||||
}
|
||||
/**
|
||||
* @param totalDigitsFacetValue The totalDigitsFacetValue to set.
|
||||
*/
|
||||
@Override
|
||||
public void setFacetTotalDigitsValue(String totalDigitsFacetValue) {
|
||||
this.totalDigitsFacetValue = totalDigitsFacetValue;
|
||||
}
|
||||
/**
|
||||
* @param whitespaceFacetValue The whitespaceFacetValue to set.
|
||||
*/
|
||||
@Override
|
||||
public void setFacetWhitespaceValue(String whitespaceFacetValue) {
|
||||
this.whitespaceFacetValue = whitespaceFacetValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param lengthFacetValue The lengthFacetValue to set.
|
||||
*/
|
||||
@Override
|
||||
public void setFacetLengthValue(String lengthFacetValue) {
|
||||
this.lengthFacetValue = lengthFacetValue;
|
||||
}
|
||||
/**
|
||||
* @param minLengthFacetValue The minLengthFacetValue to set.
|
||||
*/
|
||||
@Override
|
||||
public void setFacetMinLengthValue(String minLengthFacetValue) {
|
||||
this.minLengthFacetValue = minLengthFacetValue;
|
||||
}
|
||||
/**
|
||||
* @param minExclusiveFacetValue The minExclusiveFacetValue to set.
|
||||
*/
|
||||
@Override
|
||||
public void setFacetMinExclusiveValue(String minExclusiveFacetValue) {
|
||||
this.minExclusiveFacetValue = minExclusiveFacetValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ro.sync.contentcompletion.xml.NodeDescription#getFacetFractionDigitsValue()
|
||||
*/
|
||||
@Override
|
||||
public String getFacetFractionDigitsValue() {
|
||||
return fractionDigitsFacetValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see ro.sync.contentcompletion.xml.NodeDescription#getFacetTotalDigitsValue()
|
||||
*/
|
||||
@Override
|
||||
public String getFacetTotalDigitsValue() {
|
||||
return totalDigitsFacetValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see ro.sync.contentcompletion.xml.NodeDescription#getFacetMaxInclusiveValue()
|
||||
*/
|
||||
@Override
|
||||
public String getFacetMaxInclusiveValue() {
|
||||
return maxInclusiveFacetValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ro.sync.contentcompletion.xml.NodeDescription#getFacetMaxExclusiveValue()
|
||||
*/
|
||||
@Override
|
||||
public String getFacetMaxExclusiveValue() {
|
||||
return maxExclusiveFacetValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the value of MIN_INCLUSIVE facet, can be null if it is not defined.
|
||||
*
|
||||
* @return The value of MIN_INCLUSIVE facet.
|
||||
*/
|
||||
@Override
|
||||
public String getFacetMinInclusiveValue() {
|
||||
return minInclusiveFacetValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of MIN_EXCLUSIVE facet, can be null if it is not defined.
|
||||
*
|
||||
* @return The value of MIN_EXCLUSIVE facet.
|
||||
*/
|
||||
@Override
|
||||
public String getFacetMinExclusiveValue() {
|
||||
return minExclusiveFacetValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the possible values as <code>String</code> list.
|
||||
*
|
||||
* @return The possible values.
|
||||
*/
|
||||
@Override
|
||||
public List<String> getPossibleValues() {
|
||||
return possiblesValuesList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the model description.
|
||||
* @return The model description.
|
||||
*/
|
||||
@Override
|
||||
public String getModelDescription() {
|
||||
return modelDescription;
|
||||
}
|
||||
/**
|
||||
* Get the value of LENGTH facet, can be null if it is not defined.
|
||||
*
|
||||
* @return The value of length facet.
|
||||
*/
|
||||
@Override
|
||||
public String getFacetLengthValue() {
|
||||
return lengthFacetValue;
|
||||
}
|
||||
/**
|
||||
* Get the value of MIN LENGTH facet, can be null if it is not defined.
|
||||
*
|
||||
* @return The value of MIN LENGTH facet.
|
||||
*/
|
||||
@Override
|
||||
public String getFacetMinLengthValue() {
|
||||
return minLengthFacetValue;
|
||||
}
|
||||
/**
|
||||
* Get the value of MAX LENGTH facet, can be null if it is not defined.
|
||||
*
|
||||
* @return The value of MAX LENGTH facet.
|
||||
*/
|
||||
@Override
|
||||
public String getFacetMaxLengthValue() {
|
||||
return maxLengthFacetValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of WHITESPACE facet, can be null if it is not defined.
|
||||
*
|
||||
* @return The value of WHITESPACE facet.
|
||||
*/
|
||||
@Override
|
||||
public String getFacetWhitespaceValue() {
|
||||
return whitespaceFacetValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list with pattern facets.
|
||||
*
|
||||
* @return The list with pattern facets, can be null if no FACET_PATTERN defined.
|
||||
*/
|
||||
@Override
|
||||
public String getFacetPattern(){
|
||||
return facetPatternValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the list with pattern facets.
|
||||
*
|
||||
* @param patternFacets The list with pattern facets.
|
||||
*/
|
||||
@Override
|
||||
public void setFacetPattern(String patternFacets){
|
||||
this.facetPatternValue = patternFacets;
|
||||
}
|
||||
|
||||
/**
|
||||
* The annotation string, null as default.
|
||||
*/
|
||||
protected String annotation;
|
||||
|
||||
/**
|
||||
* Get the annotation for the element.
|
||||
*
|
||||
* @return A text that explain how to use the attribute, or null.
|
||||
*/
|
||||
@Override
|
||||
public String getAnnotation() {
|
||||
return annotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ro.sync.contentcompletion.xml.CIElement#setAnnotation(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setAnnotation(String annotation){
|
||||
this.annotation = annotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ro.sync.contentcompletion.xml.CIElement#getTypeDescription()
|
||||
*/
|
||||
@Override
|
||||
public String getTypeDescription() {
|
||||
return typeDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ro.sync.contentcompletion.xml.CIElement#setTypeDescription(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setTypeDescription(String typeDescription) {
|
||||
this.typeDescription = typeDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ro.sync.contentcompletion.xml.CIElement#setNillable(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setNillable(boolean nillable) {
|
||||
this.nillable = nillable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ro.sync.contentcompletion.xml.CIElement#isNillable()
|
||||
*/
|
||||
@Override
|
||||
public boolean isNillable() {
|
||||
return nillable;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,173 @@
|
|||
package simple.documentation.framework;
|
||||
|
||||
import ro.sync.contentcompletion.xml.SchemaManagerFilter;
|
||||
import ro.sync.ecss.extensions.api.AuthorAccess;
|
||||
import ro.sync.ecss.extensions.api.AuthorExtensionStateListener;
|
||||
import ro.sync.ecss.extensions.api.AuthorExternalObjectInsertionHandler;
|
||||
import ro.sync.ecss.extensions.api.AuthorReferenceResolver;
|
||||
import ro.sync.ecss.extensions.api.AuthorSchemaAwareEditingHandler;
|
||||
import ro.sync.ecss.extensions.api.AuthorTableCellSpanProvider;
|
||||
import ro.sync.ecss.extensions.api.AuthorTableColumnWidthProvider;
|
||||
import ro.sync.ecss.extensions.api.CustomAttributeValueEditor;
|
||||
import ro.sync.ecss.extensions.api.ExtensionsBundle;
|
||||
import ro.sync.ecss.extensions.api.StylesFilter;
|
||||
import ro.sync.ecss.extensions.api.link.ElementLocatorProvider;
|
||||
import ro.sync.ecss.extensions.api.link.LinkTextResolver;
|
||||
import ro.sync.ecss.extensions.api.structure.AuthorBreadCrumbCustomizer;
|
||||
import ro.sync.ecss.extensions.api.structure.AuthorOutlineCustomizer;
|
||||
import ro.sync.ecss.extensions.commons.DefaultElementLocatorProvider;
|
||||
import simple.documentation.framework.extensions.SDFAttributesValueEditor;
|
||||
import simple.documentation.framework.extensions.SDFAuthorBreadCrumbCustomizer;
|
||||
import simple.documentation.framework.extensions.SDFAuthorExtensionStateListener;
|
||||
import simple.documentation.framework.extensions.SDFAuthorOutlineCustomizer;
|
||||
import simple.documentation.framework.extensions.SDFExternalObjectInsertionHandler;
|
||||
import simple.documentation.framework.extensions.SDFReferencesResolver;
|
||||
import simple.documentation.framework.extensions.SDFSchemaAwareEditingHandler;
|
||||
import simple.documentation.framework.extensions.SDFSchemaManagerFilter;
|
||||
import simple.documentation.framework.extensions.SDFStylesFilter;
|
||||
import simple.documentation.framework.extensions.TableCellSpanProvider;
|
||||
import simple.documentation.framework.extensions.TableColumnWidthProvider;
|
||||
|
||||
/**
|
||||
* Simple Document Framework extension bundle.
|
||||
*
|
||||
*/
|
||||
public class SDFExtensionsBundle extends ExtensionsBundle {
|
||||
/**
|
||||
* Simple documentation framework state listener.
|
||||
*/
|
||||
private SDFAuthorExtensionStateListener sdfAuthorExtensionStateListener;
|
||||
|
||||
/**
|
||||
* Editor for attributes values.
|
||||
*/
|
||||
@Override
|
||||
public CustomAttributeValueEditor createCustomAttributeValueEditor(boolean forEclipsePlugin) {
|
||||
return new SDFAttributesValueEditor(new AuthorAccessProvider() {
|
||||
|
||||
public AuthorAccess getAuthorAccess() {
|
||||
AuthorAccess access = null;
|
||||
if (sdfAuthorExtensionStateListener != null) {
|
||||
// Get the Author access.
|
||||
access = sdfAuthorExtensionStateListener.getAuthorAccess();
|
||||
}
|
||||
return access;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple documentation framework state listener.
|
||||
*/
|
||||
@Override
|
||||
public AuthorExtensionStateListener createAuthorExtensionStateListener() {
|
||||
sdfAuthorExtensionStateListener = new SDFAuthorExtensionStateListener();
|
||||
return sdfAuthorExtensionStateListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter for content completion proposals from the schema manager.
|
||||
*/
|
||||
@Override
|
||||
public SchemaManagerFilter createSchemaManagerFilter() {
|
||||
return new SDFSchemaManagerFilter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Default element locator.
|
||||
*/
|
||||
@Override
|
||||
public ElementLocatorProvider createElementLocatorProvider() {
|
||||
return new DefaultElementLocatorProvider();
|
||||
}
|
||||
|
||||
/**
|
||||
* Expand content references.
|
||||
*/
|
||||
@Override
|
||||
public AuthorReferenceResolver createAuthorReferenceResolver() {
|
||||
return new SDFReferencesResolver();
|
||||
}
|
||||
|
||||
/**
|
||||
* CSS styles filtering.
|
||||
*/
|
||||
@Override
|
||||
public StylesFilter createAuthorStylesFilter() {
|
||||
return new SDFStylesFilter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provider for table cell span informations.
|
||||
*/
|
||||
@Override
|
||||
public AuthorTableCellSpanProvider createAuthorTableCellSpanProvider() {
|
||||
return new TableCellSpanProvider();
|
||||
}
|
||||
|
||||
/**
|
||||
* Table column width provider responsible of handling modifications regarding
|
||||
* table width and column widths.
|
||||
*/
|
||||
@Override
|
||||
public AuthorTableColumnWidthProvider createAuthorTableColumnWidthProvider() {
|
||||
return new TableColumnWidthProvider();
|
||||
}
|
||||
|
||||
/**
|
||||
* Editing support for SDF documents responsible of handling typing and paste events inside section and tables.
|
||||
*/
|
||||
@Override
|
||||
public AuthorSchemaAwareEditingHandler getAuthorSchemaAwareEditingHandler() {
|
||||
return new SDFSchemaAwareEditingHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Author Outline customizer used for custom filtering and nodes rendering in the Outline.
|
||||
*/
|
||||
@Override
|
||||
public AuthorOutlineCustomizer createAuthorOutlineCustomizer() {
|
||||
return new SDFAuthorOutlineCustomizer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple Document Framework Author customizer used for custom nodes rendering
|
||||
* in the Breadcrumb.
|
||||
*/
|
||||
@Override
|
||||
public AuthorBreadCrumbCustomizer createAuthorBreadCrumbCustomizer() {
|
||||
return new SDFAuthorBreadCrumbCustomizer();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ro.sync.ecss.extensions.api.ExtensionsBundle#createExternalObjectInsertionHandler()
|
||||
*/
|
||||
@Override
|
||||
public AuthorExternalObjectInsertionHandler createExternalObjectInsertionHandler() {
|
||||
return new SDFExternalObjectInsertionHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* The unique identifier of the Document Type.
|
||||
* This identifier will be used to store custom SDF options.
|
||||
*/
|
||||
@Override
|
||||
public String getDocumentTypeID() {
|
||||
return "Simple.Document.Framework.document.type";
|
||||
}
|
||||
|
||||
/**
|
||||
* Bundle description.
|
||||
*/
|
||||
public String getDescription() {
|
||||
return "A custom extensions bundle used for the Simple Document Framework";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ro.sync.ecss.extensions.api.ExtensionsBundle#createLinkTextResolver()
|
||||
*/
|
||||
@Override
|
||||
public LinkTextResolver createLinkTextResolver() {
|
||||
return new SDFLinkTextResolver();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package simple.documentation.framework;
|
||||
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.URIResolver;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import ro.sync.ecss.extensions.api.AuthorAccess;
|
||||
import ro.sync.ecss.extensions.api.link.InvalidLinkException;
|
||||
import ro.sync.ecss.extensions.api.link.LinkTextResolver;
|
||||
import ro.sync.ecss.extensions.api.node.AttrValue;
|
||||
import ro.sync.ecss.extensions.api.node.AuthorElement;
|
||||
import ro.sync.ecss.extensions.api.node.AuthorNode;
|
||||
|
||||
/**
|
||||
* Resolve a link and obtains a text representation. The content of the link represent the name and
|
||||
* the absolute location of the referred file.
|
||||
*/
|
||||
public class SDFLinkTextResolver extends LinkTextResolver {
|
||||
|
||||
/**
|
||||
* The author access.
|
||||
*/
|
||||
private AuthorAccess authorAccess;
|
||||
|
||||
/**
|
||||
* Logger for logging.
|
||||
*/
|
||||
private static final Logger logger = LogManager.getLogger(SDFLinkTextResolver.class.getName());
|
||||
|
||||
|
||||
/**
|
||||
* @see ro.sync.ecss.extensions.api.link.LinkTextResolver#resolveReference(ro.sync.ecss.extensions.api.node.AuthorNode)
|
||||
*/
|
||||
@Override
|
||||
public String resolveReference(AuthorNode node) throws InvalidLinkException {
|
||||
String linkText = null;
|
||||
if (node.getType() == AuthorNode.NODE_TYPE_ELEMENT
|
||||
&& "link".equals(ro.sync.basic.xml.BasicXmlUtil.getLocalName(node.getName()))) {
|
||||
AuthorElement element = (AuthorElement) node;
|
||||
AuthorElement[] authorElements = element.getElementsByLocalName("ref");
|
||||
|
||||
if (authorElements != null && authorElements.length > 0) {
|
||||
// Get the first 'ref' element from link.
|
||||
AuthorElement refElem = authorElements[0];
|
||||
AttrValue locationAttribute = refElem.getAttribute("location");
|
||||
String locationVal = locationAttribute.getValue();
|
||||
URIResolver uriResolver = authorAccess.getXMLUtilAccess().getURIResolver();
|
||||
try {
|
||||
Source resolve = uriResolver.resolve(locationVal, authorAccess.getEditorAccess().getEditorLocation().toString());
|
||||
String systemId = resolve.getSystemId();
|
||||
linkText = "[" + locationVal + "] - " + systemId;
|
||||
} catch (TransformerException e) {
|
||||
logger.warn(e, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return linkText;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see ro.sync.ecss.extensions.api.link.LinkTextResolver#activated(ro.sync.ecss.extensions.api.AuthorAccess)
|
||||
*/
|
||||
@Override
|
||||
public void activated(AuthorAccess authorAccess) {
|
||||
this.authorAccess = authorAccess;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
package simple.documentation.framework.callouts;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||