This repository has been archived by the owner on Feb 22, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Commit all changes before repo transfer.
- Loading branch information
Showing
90 changed files
with
2,323 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
org.nasdanika.cdo/src/org/nasdanika/cdo/util/NasdanikaCDOUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package org.nasdanika.cdo.util; | ||
|
||
import org.apache.commons.lang3.StringEscapeUtils; | ||
import org.eclipse.emf.ecore.EModelElement; | ||
import org.eclipse.emf.ecore.util.EcoreUtil; | ||
|
||
public class NasdanikaCDOUtil { | ||
|
||
private static final String HTML_CLOSE_TAG = "</html>"; | ||
private static final String HTML_OPEN_TAG = "<html>"; | ||
|
||
private NasdanikaCDOUtil() { | ||
// Singleton | ||
} | ||
|
||
|
||
public static String stripExtension(String str) { | ||
int idx = str.lastIndexOf('.'); | ||
return idx==-1 ? str : str.substring(0, idx); | ||
} | ||
|
||
public static String getDocumentation(EModelElement modelElement) { | ||
String doc = EcoreUtil.getDocumentation(modelElement); | ||
if (doc==null) { | ||
return " "; | ||
} | ||
String trimmedDoc = doc.trim(); | ||
if (trimmedDoc.startsWith(HTML_OPEN_TAG) && trimmedDoc.endsWith(HTML_CLOSE_TAG)) { | ||
return trimmedDoc.substring(HTML_OPEN_TAG.length(), trimmedDoc.length()-HTML_CLOSE_TAG.length()); | ||
} | ||
|
||
return "<pre>"+StringEscapeUtils.escapeHtml4(doc)+"</pre>"; | ||
} | ||
|
||
/** | ||
* Returns first sentence (till first dot) of the documentation. | ||
* @param modelElement | ||
* @return | ||
*/ | ||
public static String getSummary(EModelElement modelElement) { | ||
String doc = EcoreUtil.getDocumentation(modelElement); | ||
if (doc==null) { | ||
return " "; | ||
} | ||
String trimmedDoc = doc.trim(); | ||
if (trimmedDoc.startsWith(HTML_OPEN_TAG) && trimmedDoc.endsWith(HTML_CLOSE_TAG)) { | ||
String htmlDoc = trimmedDoc.substring(HTML_OPEN_TAG.length(), trimmedDoc.length()-HTML_CLOSE_TAG.length()); | ||
int idx = htmlDoc.indexOf("."); | ||
return idx==-1 ? htmlDoc : htmlDoc.substring(0, idx+1); | ||
} | ||
|
||
String escapedDoc = StringEscapeUtils.escapeHtml4(doc); | ||
int idx = escapedDoc.indexOf("."); | ||
return idx==-1 ? "<pre>"+escapedDoc+"</pre>" : escapedDoc.substring(0, idx+1); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.