Author: sletellier Date: 2010-11-09 12:39:40 +0100 (Tue, 09 Nov 2010) New Revision: 296 Url: http://nuiton.org/repositories/revision/nuiton-widgets/296 Log: - Can be used without file - Clean code Modified: trunk/src/main/java/org/nuiton/widget/editor/DefaultEditor.java trunk/src/main/java/org/nuiton/widget/editor/Editor.java trunk/src/main/java/org/nuiton/widget/editor/EditorInterface.java trunk/src/main/java/org/nuiton/widget/editor/JEditEditor.java trunk/src/main/java/org/nuiton/widget/editor/NullEditor.java trunk/src/main/java/org/nuiton/widget/editor/RSyntaxEditor.java trunk/src/main/java/org/nuiton/widget/editor/SDocEditor.java trunk/src/main/resources/i18n/nuiton-widgets-en_GB.properties trunk/src/main/resources/i18n/nuiton-widgets-fr_FR.properties Modified: trunk/src/main/java/org/nuiton/widget/editor/DefaultEditor.java =================================================================== --- trunk/src/main/java/org/nuiton/widget/editor/DefaultEditor.java 2010-11-05 13:13:52 UTC (rev 295) +++ trunk/src/main/java/org/nuiton/widget/editor/DefaultEditor.java 2010-11-09 11:39:40 UTC (rev 296) @@ -39,12 +39,10 @@ import java.awt.BorderLayout; import java.io.BufferedReader; -import java.io.BufferedWriter; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileReader; -import java.io.FileWriter; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.Reader; @@ -86,56 +84,46 @@ add(scrollPane, BorderLayout.CENTER); } - /* - * @see org.nuiton.widget.editor.EditorInterface#addDocumentListener(javax.swing.event.DocumentListener) - */ @Override public void addDocumentListener(DocumentListener listener) { editor.getDocument().addDocumentListener(listener); } - /* - * @see org.nuiton.widget.editor.EditorInterface#removeDocumentListener(javax.swing.event.DocumentListener) - */ @Override public void removeDocumentListener(DocumentListener listener) { editor.getDocument().removeDocumentListener(listener); } - - /* - * @see org.nuiton.widget.editor.EditorInterface#addCaretListener(javax.swing.event.CaretListener) - */ @Override public void addCaretListener(CaretListener listener) { editor.addCaretListener(listener); } - /* - * @see org.nuiton.widget.editor.EditorInterface#removeCaretListener(javax.swing.event.CaretListener) - */ @Override public void removeCaretListener(CaretListener listener) { editor.removeCaretListener(listener); } - /* - * @see org.nuiton.widget.editor.EditorInterface#accept(java.io.File) - */ + @Override public boolean accept(File file) { return true; } - /* - * @see org.nuiton.widget.editor.EditorInterface#isModified() - */ + @Override + public boolean accept(Editor.EditorSyntaxConstant editorSyntaxConstant) { + return true; + } + + @Override public boolean isModified() { return isModified; } - /* - * @see org.nuiton.widget.Editor#open(java.io.File) - */ + @Override + public void setSyntax(Editor.EditorSyntaxConstant editorSyntax) { + } + + @Override public boolean open(File file) { try { Document doc = editor.getDocument(); @@ -160,9 +148,7 @@ return false; } - /* - * @see org.nuiton.widget.Editor#saveAs(java.io.File) - */ + @Override public boolean saveAs(File file) { try { FileOutputStream outf = new FileOutputStream(file); @@ -178,65 +164,42 @@ return false; } - /* - * (non-Javadoc) - * - * @see org.nuiton.widget.editor.EditorInterface#getText() - */ + @Override public String getText() { String result = editor.getText(); return result; } - /* - * @see org.nuiton.widget.editor.EditorInterface#setText(java.lang.String) - */ + @Override public void setText(String text) { editor.setText(text); } - /* - * @seejavax.swing.event.DocumentListener#insertUpdate(javax.swing.event.DocumentEvent) - */ + @Override public void insertUpdate(DocumentEvent e) { isModified = true; } - /* - * @seejavax.swing.event.DocumentListener#removeUpdate(javax.swing.event.DocumentEvent) - */ @Override public void removeUpdate(DocumentEvent e) { isModified = true; } - /* - * @seejavax.swing.event.DocumentListener#changedUpdate(javax.swing.event.DocumentEvent) - */ @Override public void changedUpdate(DocumentEvent e) { isModified = true; } - /* - * @see org.nuiton.widget.editor.EditorInterface#copy() - */ @Override public void copy() { editor.copy(); } - /* - * @see org.nuiton.widget.editor.EditorInterface#cut() - */ @Override public void cut() { editor.cut(); } - /* - * @see org.nuiton.widget.editor.EditorInterface#paste() - */ @Override public void paste() { editor.paste(); Modified: trunk/src/main/java/org/nuiton/widget/editor/Editor.java =================================================================== --- trunk/src/main/java/org/nuiton/widget/editor/Editor.java 2010-11-05 13:13:52 UTC (rev 295) +++ trunk/src/main/java/org/nuiton/widget/editor/Editor.java 2010-11-09 11:39:40 UTC (rev 296) @@ -95,6 +95,40 @@ static protected EditorInterface DEFAULT_EDITOR = new DefaultEditor(); + /** + * Disponible syntax + * + * Used to force syntax to use on editor + * @see + */ + public enum EditorSyntaxConstant { + + // TODO sletellier 09/11/10 : implement others languages + XML(_("nuitonwidgets.editor.syntax.xml")), + JAVA(_("nuitonwidgets.editor.syntax.java")), + SQL(_("nuitonwidgets.editor.syntax.sql")), + R(_("nuitonwidgets.editor.syntax.r")); + + protected String name; + + EditorSyntaxConstant(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public boolean isSupported(EditorSyntaxConstant ... constantsSupported) { + for (EditorSyntaxConstant supported : constantsSupported) { + if (supported.equals(this)) { + return true; + } + } + return false; + } + } + static { registered = new ArrayList<EditorInterface>(); @@ -110,6 +144,7 @@ /** * register new editor * + * @param editorClassName class name of new editor * @return the new registered Editor, or null, if new editor can't be * instanciant. */ @@ -213,6 +248,25 @@ } /** + * Force to use syntaxe without file, try to find the better editor for this syntax + * + * Work only for regis + */ + @Override + public void setSyntax(EditorSyntaxConstant editorSyntax) { + + // No file so dont save + setAskIfNotSaved(false); + + // Get concerned editor + EditorInterface editor = getEditor(editorSyntax); + setCurrentEditor(editor); + + // Apply syntax + editor.setSyntax(editorSyntax); + } + + /** * @return the askIfNotSaved */ public boolean isAskIfNotSaved() { @@ -243,9 +297,55 @@ /** * try to find better editor for this file * - * @param file + * @param editorSyntaxConstant type of syntaxe * @return the better editor, or Default Editor */ + public EditorInterface getEditor(EditorSyntaxConstant editorSyntaxConstant) { + // if no editor found, DEFAULT_EDITOR will be used + EditorInterface editor = DEFAULT_EDITOR; + if (!isForceDefault()) { + for (EditorInterface e : Editor.registered) { + if (e.accept(editorSyntaxConstant)) { + editor = e; + } + } + } + + EditorInterface newEditor = usedEditor.get(editor); + try { + if (newEditor == null) { + // create new instance for this editor + newEditor = editor.getClass().newInstance(); + usedEditor.put(editor, newEditor); + } + } catch (InstantiationException eee) { + if (log.isDebugEnabled()) { + log.debug("Can't instanciant your Editor class: " + + editor.getClass().getName(), eee); + } + if (log.isInfoEnabled()) { + log.info("Can't instanciant your Editor class: " + + editor.getClass().getName()); + } + } catch (IllegalAccessException eee) { + if (log.isDebugEnabled()) { + log.debug("Can't access your Editor class: " + + editor.getClass().getName(), eee); + } + if (log.isInfoEnabled()) { + log.info("Can't access your Editor class: " + + editor.getClass().getName()); + } + } + return newEditor; + } + + /** + * try to find better editor for this file + * + * @param file concerned + * @return the better editor, or Default Editor + */ public EditorInterface getEditor(File file) { // if no editor found, DEFAULT_EDITOR will be used EditorInterface editor = DEFAULT_EDITOR; @@ -288,9 +388,11 @@ public void setCurrentEditor(EditorInterface editor) { // remove old editor - if (this.currentEditor != null) { - remove((Component) this.currentEditor); + if (this.currentEditor == null) { + // Do nothing + return; } + remove((Component) this.currentEditor); // remove all listener on old editor for (DocumentListener l : documentListeners) { @@ -389,7 +491,7 @@ * if return true, this editor support this file type. Default implantation * return true * - * @param file + * @param file to check * @return if return true, this editor support this file type. */ public boolean accept(File file) { @@ -397,6 +499,17 @@ } /** + * if return true, this editor support this syntax type. Default implantation + * return true + * + * @param editorSyntaxConstant to check + * @return if return true, this editor support this syntax type. + */ + public boolean accept(Editor.EditorSyntaxConstant editorSyntaxConstant) { + return true; + } + + /** * indicate if current opened file has been modified * * @return true if currend file is modified Modified: trunk/src/main/java/org/nuiton/widget/editor/EditorInterface.java =================================================================== --- trunk/src/main/java/org/nuiton/widget/editor/EditorInterface.java 2010-11-05 13:13:52 UTC (rev 295) +++ trunk/src/main/java/org/nuiton/widget/editor/EditorInterface.java 2010-11-09 11:39:40 UTC (rev 296) @@ -50,28 +50,28 @@ * * @param listener listener */ - public void addDocumentListener(DocumentListener listener); + void addDocumentListener(DocumentListener listener); /** * Remove document listener. * * @param listener listener */ - public void removeDocumentListener(DocumentListener listener); + void removeDocumentListener(DocumentListener listener); /** * Add caret listener. * * @param listener listener */ - public void addCaretListener(CaretListener listener); + void addCaretListener(CaretListener listener); /** * Remove caret listener. * * @param listener listener */ - public void removeCaretListener(CaretListener listener); + void removeCaretListener(CaretListener listener); /** * If return true, this editor support this file type. @@ -80,64 +80,80 @@ * @param file file to test * @return if return {@code true}, this editor support this file type. */ - public boolean accept(File file); + boolean accept(File file); /** + * If return true, this editor support the syntax type. + * Default implementation return {@code true}. + * + * @param editorSyntaxConstant syntaxe type to test + * @return if return {@code true}, this editor support this syntax type. + */ + boolean accept(Editor.EditorSyntaxConstant editorSyntaxConstant); + + /** * Indicate if current opened file has been modified. - * + * * @return {@code true} if current file is modified */ - public boolean isModified(); + boolean isModified(); /** * Replace the current edited file by file passed in argument. - * + * * @param file the file to open * @return true if file has been opened */ - public boolean open(File file); + boolean open(File file); /** * Replace the current edited file by file passed in argument. - * + * * @param file the file to open * @return true if file has been saved and reopen with new name */ - public boolean saveAs(File file); + boolean saveAs(File file); /** * Return the current content text of the editor as {@link String}. - * + * * @return return the current content text of the editor as {@link String} */ - public String getText(); + String getText(); /** * Set all text with text in argument. - * + * * @param text test to set */ - public void setText(String text); - + void setText(String text); + /** * Cut current editor selection into system clipboard. */ - public void cut(); - + void cut(); + /** * Copy current current selection into system clipboard. */ - public void copy(); - + void copy(); + /** * Paste current clicboard content into editor at caret position. */ - public void paste(); - + void paste(); + /** * Enable/disable editor. - * + * * @param b enable */ - public void setEnabled(boolean b); + void setEnabled(boolean b); + + /** + * Force syntax to use + * + * @param editorSyntax to use + */ + void setSyntax(Editor.EditorSyntaxConstant editorSyntax); } Modified: trunk/src/main/java/org/nuiton/widget/editor/JEditEditor.java =================================================================== --- trunk/src/main/java/org/nuiton/widget/editor/JEditEditor.java 2010-11-05 13:13:52 UTC (rev 295) +++ trunk/src/main/java/org/nuiton/widget/editor/JEditEditor.java 2010-11-09 11:39:40 UTC (rev 296) @@ -43,6 +43,7 @@ import org.nuiton.util.FileUtil; import org.syntax.jedit.JEditTextArea; import org.syntax.jedit.tokenmarker.JavaTokenMarker; +import org.syntax.jedit.tokenmarker.TokenMarker; import org.syntax.jedit.tokenmarker.XMLTokenMarker; /** @@ -80,11 +81,29 @@ result = result || "xml".equalsIgnoreCase(ext); return result; } - - /* - * @see org.nuiton.widget.editor.DefaultEditor#open(java.io.File) - */ + @Override + public boolean accept(Editor.EditorSyntaxConstant editorSyntaxConstant) { + return editorSyntaxConstant.isSupported(Editor.EditorSyntaxConstant.JAVA, Editor.EditorSyntaxConstant.XML); + } + + @Override + public void setSyntax(Editor.EditorSyntaxConstant editorSyntax) { + TokenMarker tokenMarker = null; + if (editorSyntax.equals(Editor.EditorSyntaxConstant.JAVA)) { + tokenMarker = new JavaTokenMarker(); + } else if (editorSyntax.equals(Editor.EditorSyntaxConstant.XML)) { + tokenMarker = new XMLTokenMarker(); + } else { + log.warn("Syntax '" + editorSyntax.getName() + "' is not yet supported by JEditEditor"); + } + + if (tokenMarker != null) { + editor.setTokenMarker(tokenMarker); + } + } + + @Override public boolean open(File file) { try { @@ -96,7 +115,7 @@ String text = ""; char c; - int last = 0; + int last; while ((last = in.read()) != -1) { c = (char) last; @@ -141,67 +160,43 @@ return false; } - /* - * @see org.nuiton.widget.editor.EditorInterface#addDocumentListener(javax.swing.event.DocumentListener) - */ @Override public void addDocumentListener(DocumentListener listener) { editor.getDocument().addDocumentListener(listener); } - /* - * @see org.nuiton.widget.editor.EditorInterface#removeDocumentListener(javax.swing.event.DocumentListener) - */ @Override public void removeDocumentListener(DocumentListener listener) { editor.getDocument().removeDocumentListener(listener); } - /* - * @see org.nuiton.widget.editor.EditorInterface#addCaretListener(javax.swing.event.CaretListener) - */ @Override public void addCaretListener(CaretListener listener) { editor.addCaretListener(listener); } - /* - * @see org.nuiton.widget.editor.EditorInterface#removeCaretListener(javax.swing.event.CaretListener) - */ @Override public void removeCaretListener(CaretListener listener) { editor.removeCaretListener(listener); } - /* - * @see org.nuiton.widget.editor.EditorInterface#getText() - */ @Override public String getText() { String result = editor.getText(); return result; } - /* - * @see javax.swing.JComponent#setEnabled(boolean) - */ @Override public void setEnabled(boolean b) { super.setEnabled(b); editor.setEnabled(b); } - /* - * @see org.nuiton.widget.editor.EditorInterface#isModified() - */ @Override public boolean isModified() { return isModified; } - /* - * @see org.nuiton.widget.editor.EditorInterface#saveAs(java.io.File) - */ @Override public boolean saveAs(File file) { try { @@ -216,57 +211,36 @@ return false; } - /* - * @see org.nuiton.widget.editor.EditorInterface#setText(java.lang.String) - */ @Override public void setText(String text) { editor.setText(text); } - /* - * @see javax.swing.event.DocumentListener#changedUpdate(javax.swing.event.DocumentEvent) - */ @Override public void changedUpdate(DocumentEvent e) { isModified = true; } - /* - * @see javax.swing.event.DocumentListener#insertUpdate(javax.swing.event.DocumentEvent) - */ @Override public void insertUpdate(DocumentEvent e) { isModified = true; } - /* - * @see javax.swing.event.DocumentListener#removeUpdate(javax.swing.event.DocumentEvent) - */ @Override public void removeUpdate(DocumentEvent e) { isModified = true; } - /* - * @see org.nuiton.widget.editor.EditorInterface#copy() - */ @Override public void copy() { editor.copy(); } - /* - * @see org.nuiton.widget.editor.EditorInterface#cut() - */ @Override public void cut() { editor.cut(); } - /* - * @see org.nuiton.widget.editor.EditorInterface#paste() - */ @Override public void paste() { editor.paste(); Modified: trunk/src/main/java/org/nuiton/widget/editor/NullEditor.java =================================================================== --- trunk/src/main/java/org/nuiton/widget/editor/NullEditor.java 2010-11-05 13:13:52 UTC (rev 295) +++ trunk/src/main/java/org/nuiton/widget/editor/NullEditor.java 2010-11-09 11:39:40 UTC (rev 296) @@ -57,44 +57,38 @@ add(noFileLabel, BorderLayout.CENTER); } - /* - * @see org.nuiton.widget.editor.EditorInterface#addDocumentListener(javax.swing.event.DocumentListener) - */ @Override public void addDocumentListener(DocumentListener listener) { } - /* - * @see org.nuiton.widget.editor.EditorInterface#removeDocumentListener(javax.swing.event.DocumentListener) - */ @Override public void removeDocumentListener(DocumentListener listener) { } - /* - * @see org.nuiton.widget.editor.EditorInterface#addCaretListener(javax.swing.event.CaretListener) - */ @Override public void addCaretListener(CaretListener listener) { } - /* - * @see org.nuiton.widget.editor.EditorInterface#removeCaretListener(javax.swing.event.CaretListener) - */ @Override public void removeCaretListener(CaretListener listener) { } - /* - * @see org.nuiton.widget.editor.EditorInterface#accept(java.io.File) - */ @Override public boolean accept(File file) { return false; } + @Override + public boolean accept(Editor.EditorSyntaxConstant editorSyntaxConstant) { + return false; + } + + @Override + public void setSyntax(Editor.EditorSyntaxConstant editorSyntax) { + } + /** * when there is no file opened, the file is not modified. * @@ -129,41 +123,26 @@ return true; } - /* - * @see org.nuiton.widget.editor.EditorInterface#getText() - */ @Override public String getText() { String result = ""; return result; } - /* - * @see org.nuiton.widget.editor.EditorInterface#setText(java.lang.String) - */ @Override public void setText(String text) { } - /* - * @see org.nuiton.widget.editor.EditorInterface#copy() - */ @Override public void copy() { } - /* - * @see org.nuiton.widget.editor.EditorInterface#cut() - */ @Override public void cut() { } - /* - * @see org.nuiton.widget.editor.EditorInterface#paste() - */ @Override public void paste() { Modified: trunk/src/main/java/org/nuiton/widget/editor/RSyntaxEditor.java =================================================================== --- trunk/src/main/java/org/nuiton/widget/editor/RSyntaxEditor.java 2010-11-05 13:13:52 UTC (rev 295) +++ trunk/src/main/java/org/nuiton/widget/editor/RSyntaxEditor.java 2010-11-09 11:39:40 UTC (rev 296) @@ -86,11 +86,36 @@ result = result || "r".equalsIgnoreCase(ext); return result; } - - /* - * @see org.nuiton.widget.editor.DefaultEditor#open(java.io.File) - */ + @Override + public boolean accept(Editor.EditorSyntaxConstant editorSyntaxConstant) { + return editorSyntaxConstant.isSupported( + Editor.EditorSyntaxConstant.JAVA, + Editor.EditorSyntaxConstant.XML, + Editor.EditorSyntaxConstant.SQL, + Editor.EditorSyntaxConstant.R); + } + + @Override + public void setSyntax(Editor.EditorSyntaxConstant editorSyntax) { + String constant = null; + if (editorSyntax.equals(Editor.EditorSyntaxConstant.SQL)) { + constant = SyntaxConstants.SYNTAX_STYLE_SQL; + } else if (editorSyntax.equals(Editor.EditorSyntaxConstant.JAVA)) { + constant = SyntaxConstants.SYNTAX_STYLE_JAVA; + } else if (editorSyntax.equals(Editor.EditorSyntaxConstant.XML)) { + constant = SyntaxConstants.SYNTAX_STYLE_XML; + } else if (editorSyntax.equals(Editor.EditorSyntaxConstant.R)) { + constant = SyntaxConstants.SYNTAX_STYLE_PERL; + } else { + log.warn("Syntax '" + editorSyntax.getName() + "' is not yet supported by RSyntaxEditor"); + } + if (constant != null) { + editor.setSyntaxEditingStyle(constant); + } + } + + @Override public boolean open(File file) { try { @@ -102,7 +127,7 @@ String text = ""; char c; - int last = 0; + int last; while ((last = in.read()) != -1) { c = (char) last; @@ -151,58 +176,37 @@ return false; } - /* - * @see org.nuiton.widget.editor.EditorInterface#addDocumentListener(javax.swing.event.DocumentListener) - */ @Override public void addDocumentListener(DocumentListener listener) { editor.getDocument().addDocumentListener(listener); } - /* - * @see org.nuiton.widget.editor.EditorInterface#removeDocumentListener(javax.swing.event.DocumentListener) - */ @Override public void removeDocumentListener(DocumentListener listener) { editor.getDocument().removeDocumentListener(listener); } - /* - * @see org.nuiton.widget.editor.EditorInterface#addCaretListener(javax.swing.event.CaretListener) - */ @Override public void addCaretListener(CaretListener listener) { editor.addCaretListener(listener); } - /* - * @see org.nuiton.widget.editor.EditorInterface#removeCaretListener(javax.swing.event.CaretListener) - */ @Override public void removeCaretListener(CaretListener listener) { editor.removeCaretListener(listener); } - /* - * @see org.nuiton.widget.editor.EditorInterface#getText() - */ @Override public String getText() { String result = editor.getText(); return result; } - /* - * @see org.nuiton.widget.editor.EditorInterface#isModified() - */ @Override public boolean isModified() { return isModified; } - /* - * @see org.nuiton.widget.editor.EditorInterface#saveAs(java.io.File) - */ @Override public boolean saveAs(File file) { Writer out = null; @@ -231,66 +235,42 @@ return false; } - /* - * @see org.nuiton.widget.editor.EditorInterface#setText(java.lang.String) - */ @Override public void setText(String text) { editor.setText(text); } - /* - * @see javax.swing.JComponent#setEnabled(boolean) - */ @Override public void setEnabled(boolean b) { super.setEnabled(b); editor.setEnabled(b); } - /* - * @see javax.swing.event.DocumentListener#changedUpdate(javax.swing.event.DocumentEvent) - */ @Override public void changedUpdate(DocumentEvent e) { isModified = true; } - /* - * @see javax.swing.event.DocumentListener#insertUpdate(javax.swing.event.DocumentEvent) - */ @Override public void insertUpdate(DocumentEvent e) { isModified = true; } - /* - * @see javax.swing.event.DocumentListener#removeUpdate(javax.swing.event.DocumentEvent) - */ @Override public void removeUpdate(DocumentEvent e) { isModified = true; } - /* - * @see org.nuiton.widget.editor.EditorInterface#copy() - */ @Override public void copy() { editor.copy(); } - /* - * @see org.nuiton.widget.editor.EditorInterface#cut() - */ @Override public void cut() { editor.cut(); } - /* - * @see org.nuiton.widget.editor.EditorInterface#paste() - */ @Override public void paste() { editor.paste(); Modified: trunk/src/main/java/org/nuiton/widget/editor/SDocEditor.java =================================================================== --- trunk/src/main/java/org/nuiton/widget/editor/SDocEditor.java 2010-11-05 13:13:52 UTC (rev 295) +++ trunk/src/main/java/org/nuiton/widget/editor/SDocEditor.java 2010-11-09 11:39:40 UTC (rev 296) @@ -74,12 +74,24 @@ scrollPane.setRowHeaderView(new Gutter(editor, scrollPane)); } - /* - * (non-Javadoc) - * - * @see org.nuiton.widget.editor.DefaultEditor#accept(java.io.File) - */ @Override + public void setSyntax(Editor.EditorSyntaxConstant editorSyntax) { + Integer constant = null; + if (editorSyntax.equals(Editor.EditorSyntaxConstant.SQL)) { + constant = SyntaxSupport.SQL_LEXER; + } else if (editorSyntax.equals(Editor.EditorSyntaxConstant.JAVA)) { + constant = SyntaxSupport.JAVA_LEXER; + } else if (editorSyntax.equals(Editor.EditorSyntaxConstant.XML)) { + constant = SyntaxSupport.XML_LEXER; + } else { + log.warn("Syntax '" + editorSyntax.getName() + "' is not yet supported by SDocEditor"); + } + if (constant != null) { + syntaxSupport.addSupport(constant, editor); + } + } + + @Override public boolean accept(File file) { String ext = FileUtil.extension(file); boolean result = "java".equalsIgnoreCase(ext); @@ -88,12 +100,16 @@ return result; } - /* - * (non-Javadoc) - * - * @see org.nuiton.widget.editor.DefaultEditor#open(java.io.File) - */ @Override + public boolean accept(Editor.EditorSyntaxConstant editorSyntaxConstant) { + return editorSyntaxConstant.isSupported( + Editor.EditorSyntaxConstant.JAVA, + Editor.EditorSyntaxConstant.XML, + Editor.EditorSyntaxConstant.SQL, + Editor.EditorSyntaxConstant.R); + } + + @Override public boolean open(File file) { try { Document doc = editor.getDocument(); @@ -106,7 +122,7 @@ String text = ""; char c; - int last = 0; + int last; while ((last = in.read()) != -1) { c = (char) last; Modified: trunk/src/main/resources/i18n/nuiton-widgets-en_GB.properties =================================================================== --- trunk/src/main/resources/i18n/nuiton-widgets-en_GB.properties 2010-11-05 13:13:52 UTC (rev 295) +++ trunk/src/main/resources/i18n/nuiton-widgets-en_GB.properties 2010-11-09 11:39:40 UTC (rev 296) @@ -3,6 +3,10 @@ nuitonwidgets.aboutframe.ok=OK nuitonwidgets.common.copy=Copy nuitonwidgets.editor.saveorcancel=Do you want to save current opened file ? +nuitonwidgets.editor.syntax.java=Java +nuitonwidgets.editor.syntax.r=R +nuitonwidgets.editor.syntax.sql=SQL +nuitonwidgets.editor.syntax.xml=XML nuitonwidgets.message.file=File nuitonwidgets.message.folder=Folder nuitonwidgets.message.nofile=No file Modified: trunk/src/main/resources/i18n/nuiton-widgets-fr_FR.properties =================================================================== --- trunk/src/main/resources/i18n/nuiton-widgets-fr_FR.properties 2010-11-05 13:13:52 UTC (rev 295) +++ trunk/src/main/resources/i18n/nuiton-widgets-fr_FR.properties 2010-11-09 11:39:40 UTC (rev 296) @@ -3,6 +3,10 @@ nuitonwidgets.aboutframe.ok=OK nuitonwidgets.common.copy=Copier nuitonwidgets.editor.saveorcancel=Voulez vous sauver le fichier modifi\u00E9 ? +nuitonwidgets.editor.syntax.java=Java +nuitonwidgets.editor.syntax.r=R +nuitonwidgets.editor.syntax.sql=SQL +nuitonwidgets.editor.syntax.xml=XML nuitonwidgets.message.file=Fichier nuitonwidgets.message.folder=R\u00E9pertoire nuitonwidgets.message.nofile=Aucun fichier