null
, no completions will be known.
- * @see BasicCompletion
- */
- public DefaultCompletionProvider(String[] words) {
- init();
- addWordCompletions(words);
- }
-
-
- /**
- * Returns the text just before the current caret position that could be
- * the start of something auto-completable.
- *
- * This method returns all characters before the caret that are matched
- * by {@link #isValidChar(char)}.
- *
- * {@inheritDoc}
- */
- public String getAlreadyEnteredText(JTextComponent comp) {
-
- Document doc = comp.getDocument();
-
- int dot = comp.getCaretPosition();
- Element root = doc.getDefaultRootElement();
- int index = root.getElementIndex(dot);
- Element elem = root.getElement(index);
- int start = elem.getStartOffset();
- int len = dot-start;
- try {
- doc.getText(start, len, seg);
- } catch (BadLocationException ble) {
-
- return EMPTY_STRING;
- }
-
- int segEnd = seg.offset + len;
- start = segEnd - 1;
- while (start>=seg.offset && isValidChar(seg.array[start])) {
- start--;
- }
- start++;
-
- len = segEnd - start;
- return len==0 ? EMPTY_STRING : new String(seg.array, start, len);
-
- }
-
-
- /**
- * {@inheritDoc}
- */
- public List
+ *
+ * This method returns all characters before the caret that are matched
+ * by {@link #isValidChar(char)}.
+ *
+ * {@inheritDoc}
+ */
+ public String getAlreadyEnteredText(JTextComponent comp) {
+
+ Document doc = comp.getDocument();
+
+ int dot = comp.getCaretPosition();
+ Element root = doc.getDefaultRootElement();
+ int index = root.getElementIndex(dot);
+ Element elem = root.getElement(index);
+ int start = elem.getStartOffset();
+ int len = dot - start;
+ try {
+ doc.getText(start, len, seg);
+ } catch (BadLocationException ble) {
+
+ return EMPTY_STRING;
+ }
+
+ int segEnd = seg.offset + len;
+ start = segEnd - 1;
+ while (start >= seg.offset && isValidChar(seg.array[start])) {
+ start--;
+ }
+ start++;
+
+ len = segEnd - start;
+ return len == 0 ? EMPTY_STRING : new String(seg.array, start, len);
+
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public ListCharacter.isLetterOrDigit(ch) || ch=='_'
". Subclasses
- * can override this method to change what characters are matched.
- *
- * @param ch The character.
- * @return Whether the character is valid.
- */
- protected boolean isValidChar(char ch) {
- return Character.isLetterOrDigit(ch) || ch=='_';
- }
-
-
- /**
- * Loads completions from an XML file. The XML should validate against
- * CompletionXml.dtd
.
- *
- * @param file An XML file to load from.
- * @throws IOException If an IO error occurs.
- */
- public void loadFromXML(File file) throws IOException {
- BufferedInputStream bin = new BufferedInputStream(
- new FileInputStream(file));
- try {
- loadFromXML(bin);
- } finally {
- bin.close();
- }
- }
-
-
- /**
- * Loads completions from an XML input stream. The XML should validate
- * against CompletionXml.dtd
.
- *
- * @param in The input stream to read from.
- * @throws IOException If an IO error occurs.
- */
- public void loadFromXML(InputStream in) throws IOException {
- loadFromXML(in, null);
- }
-
-
- /**
- * Loads completions from an XML input stream. The XML should validate
- * against CompletionXml.dtd
.
- *
- * @param in The input stream to read from.
- * @param cl The class loader to use when loading any extra classes defined
- * in the XML, such as custom {@link FunctionCompletion}s. This
- * may be null
if the default is to be used, or if no
- * custom completions are defined in the XML.
- * @throws IOException If an IO error occurs.
- */
- public void loadFromXML(InputStream in, ClassLoader cl) throws IOException {
-
- //long start = System.currentTimeMillis();
-
- SAXParserFactory factory = SAXParserFactory.newInstance();
- factory.setValidating(true);
- CompletionXMLParser handler = new CompletionXMLParser(this, cl);
- BufferedInputStream bin = new BufferedInputStream(in);
- try {
- SAXParser saxParser = factory.newSAXParser();
- saxParser.parse(bin, handler);
- ListCompletionXml.dtd
.
- *
- * @param resource A resource the current ClassLoader can get to.
- * @throws IOException If an IO error occurs.
- */
- public void loadFromXML(String resource) throws IOException {
- ClassLoader cl = getClass().getClassLoader();
- InputStream in = cl.getResourceAsStream(resource);
- if (in==null) {
- File file = new File(resource);
- if (file.isFile()) {
- in = new FileInputStream(file);
- }
- else {
- throw new IOException("No such resource: " + resource);
- }
- }
- BufferedInputStream bin = new BufferedInputStream(in);
- try {
- loadFromXML(bin);
- } finally {
- bin.close();
- }
- }
+ protected Segment seg;
+
+ /**
+ * Used to speed up {@link #getCompletionsAt(JTextComponent, Point)}.
+ */
+ private String lastCompletionsAtText;
+
+ /**
+ * Used to speed up {@link #getCompletionsAt(JTextComponent, Point)},
+ * since this may be called multiple times in succession (this is usually
+ * called by JTextComponent.getToolTipText(), and if the user
+ * wiggles the mouse while a tool tip is displayed, this method gets
+ * repeatedly called. It can be costly so we try to speed it up a tad).
+ */
+ private Listnull
, no completions will be known.
+ * @see BasicCompletion
+ */
+ public DefaultCompletionProvider(String[] words) {
+ init();
+ addWordCompletions(words);
+ }
+
+
+ /**
+ * Returns the text just before the current caret position that could be
+ * the start of something auto-completable.Character.isLetterOrDigit(ch) || ch=='_'
". Subclasses
+ * can override this method to change what characters are matched.
+ *
+ * @param ch The character.
+ * @return Whether the character is valid.
+ */
+ protected boolean isValidChar(char ch) {
+ return Character.isLetterOrDigit(ch) || ch == '_';
+ }
+
+
+ /**
+ * Loads completions from an XML file. The XML should validate against
+ * CompletionXml.dtd
.
+ *
+ * @param file An XML file to load from.
+ * @throws IOException If an IO error occurs.
+ */
+ public void loadFromXML(File file) throws IOException {
+ BufferedInputStream bin = new BufferedInputStream(
+ new FileInputStream(file));
+ try {
+ loadFromXML(bin);
+ } finally {
+ bin.close();
+ }
+ }
+
+
+ /**
+ * Loads completions from an XML input stream. The XML should validate
+ * against CompletionXml.dtd
.
+ *
+ * @param in The input stream to read from.
+ * @throws IOException If an IO error occurs.
+ */
+ public void loadFromXML(InputStream in) throws IOException {
+ loadFromXML(in, null);
+ }
+
+
+ /**
+ * Loads completions from an XML input stream. The XML should validate
+ * against CompletionXml.dtd
.
+ *
+ * @param in The input stream to read from.
+ * @param cl The class loader to use when loading any extra classes defined
+ * in the XML, such as custom {@link FunctionCompletion}s. This
+ * may be null
if the default is to be used, or if no
+ * custom completions are defined in the XML.
+ * @throws IOException If an IO error occurs.
+ */
+ public void loadFromXML(InputStream in, ClassLoader cl) throws IOException {
+
+ //long start = System.currentTimeMillis();
+
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ try {
+ factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
+ factory.setFeature("http://xml.org/sax/features/external-general-entities", false);
+ factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
+ factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
+ } catch (ParserConfigurationException | SAXNotSupportedException | SAXNotRecognizedException e) {
+ FineLoggerFactory.getLogger().warn(e.getMessage(), e);
+ }
+
+ factory.setValidating(true);
+ CompletionXMLParser handler = new CompletionXMLParser(this, cl);
+ BufferedInputStream bin = new BufferedInputStream(in);
+ try {
+ SAXParser saxParser = factory.newSAXParser();
+ saxParser.parse(bin, handler);
+ ListCompletionXml.dtd
.
+ *
+ * @param resource A resource the current ClassLoader can get to.
+ * @throws IOException If an IO error occurs.
+ */
+ public void loadFromXML(String resource) throws IOException {
+ ClassLoader cl = getClass().getClassLoader();
+ InputStream in = cl.getResourceAsStream(resource);
+ if (in == null) {
+ File file = new File(resource);
+ if (file.isFile()) {
+ in = new FileInputStream(file);
+ } else {
+ throw new IOException("No such resource: " + resource);
+ }
+ }
+ BufferedInputStream bin = new BufferedInputStream(in);
+ try {
+ loadFromXML(bin);
+ } finally {
+ bin.close();
+ }
+ }
}
\ No newline at end of file
diff --git a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/SyntaxScheme.java b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/SyntaxScheme.java
index dbaaf4c6f3..8bbedf0be2 100644
--- a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/SyntaxScheme.java
+++ b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/SyntaxScheme.java
@@ -624,6 +624,10 @@ public class SyntaxScheme implements Cloneable, TokenTypes {
SyntaxSchemeLoader parser = null;
try {
XMLReader reader = XMLReaderFactory.createXMLReader();
+ reader.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
+ reader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
+ reader.setFeature("http://xml.org/sax/features/external-general-entities", false);
+ reader.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
parser = new SyntaxSchemeLoader(baseFont);
parser.baseFont = baseFont;
reader.setContentHandler(parser);
diff --git a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/Theme.java b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/Theme.java
index 3b422f5742..896a5eec41 100644
--- a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/Theme.java
+++ b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/Theme.java
@@ -22,6 +22,7 @@ import java.lang.reflect.Field;
import javax.swing.UIManager;
import javax.swing.plaf.ColorUIResource;
import javax.swing.text.StyleContext;
+import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.SAXParser;
@@ -493,6 +494,8 @@ public class Theme {
StreamResult result = new StreamResult(new PrintWriter(
new UnicodeWriter(bout, "UTF-8")));
TransformerFactory transFac = TransformerFactory.newInstance();
+ transFac.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
+ transFac.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
Transformer transformer = transFac.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
@@ -580,8 +583,12 @@ public class Theme {
public static void load(Theme theme, InputStream in) throws IOException {
SAXParserFactory spf = SAXParserFactory.newInstance();
- spf.setValidating(true);
try {
+ spf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
+ spf.setFeature("http://xml.org/sax/features/external-general-entities", false);
+ spf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
+ spf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
+ spf.setValidating(true);
SAXParser parser = spf.newSAXParser();
XMLReader reader = parser.getXMLReader();
XmlHandler handler = new XmlHandler();
diff --git a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/Macro.java b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/Macro.java
index 8a0ba741cb..2558eafe04 100644
--- a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/Macro.java
+++ b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/Macro.java
@@ -14,6 +14,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import javax.xml.XMLConstants;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
@@ -94,6 +95,11 @@ public class Macro {
DocumentBuilder db = null;
Document doc = null;
try {
+ dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
+ dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);
+ dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
+ dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
+ dbf.setXIncludeAware(false);
db = dbf.newDocumentBuilder();
//InputSource is = new InputSource(new FileReader(file));
InputSource is = new InputSource(new UnicodeReader(
@@ -374,6 +380,8 @@ public class Macro {
StreamResult result = new StreamResult(new File(fileName));
DOMSource source = new DOMSource(doc);
TransformerFactory transFac = TransformerFactory.newInstance();
+ transFac.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
+ transFac.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
Transformer transformer = transFac.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.ENCODING, FILE_ENCODING);
diff --git a/designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java b/designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java
index 36b86cb89e..5fa8173d4b 100644
--- a/designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java
+++ b/designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java
@@ -12,6 +12,7 @@ import com.fr.third.springframework.web.context.support.AnnotationConfigWebAppli
import com.fr.workspace.WorkContext;
import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException;
+import org.apache.catalina.Wrapper;
import org.apache.catalina.loader.WebappLoader;
import org.apache.catalina.startup.Tomcat;
import org.apache.catalina.webresources.StandardRoot;
@@ -73,6 +74,10 @@ public class FineEmbedServerActivator extends Activator {
String contextPath = "/" + ProductConstants.getAppFolderName();
final Context context = tomcat.addContext(contextPath, docBase);
context.setResources(new StandardRoot(context));
+ Wrapper servlet = Tomcat.addServlet(context, "DruidStatView", "com.fr.third.alibaba.druid.support.http.StatViewServlet");
+ context.addServletMappingDecoded("/druid/*", "DruidStatView");
+ servlet.setLoadOnStartup(1);
+ servlet.setOverridable(true);
Tomcat.initWebappDefaults(context);
//覆盖tomcat的WebAppClassLoader
context.setLoader(new FRTomcatLoader());