|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.nuiton.widget.editor.Editor
public class Editor
L'idee de cette editor, est qu'il ne fait rien lui meme, mais delegue a un autre editeur enregistré. L'enregistrement ce fait par le nom de la classe sous forme de String, ce qui permet d'enregistrer des editeurs qui ne peuvent pas etre chargé car il manque des jars. Par exemple NetBeansEditor qui demande beaucoup de jar, peu ne pas etre chargé convenablement, dans ce cas un autre editeur sera choisi.
L'ordre d'enregistrement est important. Le premier editor enregistré sera le premier editeur essayé.
Si l'on souhaite creer un nouvel editeur, il faut implanter
EditorInterface et etendre au moins Component
Si aucun editeur n'est trouvé alors DefaultEditor est utilisé
Editeur permet d'utiliser Ctrl-s pour sauver le fichier courant quel que soit l'editeur.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.JPanel |
|---|
JPanel.AccessibleJPanel |
| Nested classes/interfaces inherited from class javax.swing.JComponent |
|---|
JComponent.AccessibleJComponent |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary | |
|---|---|
protected boolean |
askIfNotSaved
If the edited file is modifier, before switch to other or close it, ask the user if he want save the modification |
protected Set<CaretListener> |
caretListeners
All caret listener registered on this editor |
protected EditorInterface |
currentEditor
currentEditor is currently opened editor in this editor |
protected static EditorInterface |
DEFAULT_EDITOR
|
protected Set<DocumentListener> |
documentListeners
All document listener registered on this editor |
protected boolean |
forceDefault
force usage of default editor |
protected static EditorInterface |
nullEditor
|
protected File |
openedFile
current opened file |
protected static List<EditorInterface> |
registered
tous les Editors enregistré |
protected Map<EditorInterface,EditorInterface> |
usedEditor
editor already instanciate for this editor |
| Fields inherited from class javax.swing.JComponent |
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
Editor()
|
|
| Method Summary | |
|---|---|
boolean |
accept(File file)
if return true, this editor support this file type. |
void |
addCaretListener(CaretListener listener)
Add caret listener. |
void |
addDocumentListener(DocumentListener listener)
Add document listener. |
protected void |
addKeyBinding()
|
protected boolean |
askAndSaveOrCancel()
ask the user to save the current opened file if necessary (current file is modified) |
boolean |
close()
Closs current file |
void |
copy()
Copy current current selection into system clipboard. |
void |
cut()
Cut current editor selection into system clipboard. |
EditorInterface |
getCurrentEditor()
|
EditorInterface |
getEditor(File file)
try to find better editor for this file |
File |
getOpenedFile()
|
String |
getText()
Return the current content text of the editor as String. |
boolean |
isAskIfNotSaved()
|
boolean |
isForceDefault()
|
boolean |
isModified()
indicate if current opened file has been modified |
boolean |
open(File file)
Replace the current edited file by file passed in argument. |
void |
paste()
Paste current clicboard content into editor at caret position. |
void |
removeCaretListener(CaretListener listener)
Remove caret listener. |
void |
removeDocumentListener(DocumentListener listener)
Remove document listener. |
boolean |
save()
Save current opened file |
boolean |
saveAs(File file)
Replace the current edited file by file passed in argument |
void |
setAskIfNotSaved(boolean askIfNotSaved)
|
void |
setCurrentEditor(EditorInterface editor)
|
void |
setEnabled(boolean b)
Enable/disable editor. |
void |
setForceDefault(boolean forceDefault)
|
void |
setOpenedFile(File openedFile)
|
void |
setText(String text)
Set all text with text in argument. |
| Methods inherited from class javax.swing.JPanel |
|---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static EditorInterface DEFAULT_EDITOR
protected static List<EditorInterface> registered
protected static EditorInterface nullEditor
protected Map<EditorInterface,EditorInterface> usedEditor
protected EditorInterface currentEditor
protected File openedFile
protected Set<DocumentListener> documentListeners
protected Set<CaretListener> caretListeners
protected boolean askIfNotSaved
protected boolean forceDefault
| Constructor Detail |
|---|
public Editor()
| Method Detail |
|---|
protected void addKeyBinding()
public boolean isAskIfNotSaved()
public void setAskIfNotSaved(boolean askIfNotSaved)
askIfNotSaved - the askIfNotSaved to setpublic boolean isForceDefault()
public void setForceDefault(boolean forceDefault)
forceDefault - the forceDefault to setpublic EditorInterface getEditor(File file)
file -
public void setCurrentEditor(EditorInterface editor)
public EditorInterface getCurrentEditor()
public File getOpenedFile()
public void setOpenedFile(File openedFile)
openedFile - the openedFile to setpublic boolean close()
protected boolean askAndSaveOrCancel()
public boolean save()
public boolean accept(File file)
accept in interface EditorInterfacefile -
public boolean isModified()
isModified in interface EditorInterfacepublic boolean open(File file)
setOpenedFile(File)
open in interface EditorInterfacefile - the file to open
public boolean saveAs(File file)
saveAs in interface EditorInterfacefile - the file to open
public String getText()
EditorInterfaceString.
getText in interface EditorInterfaceStringpublic void setText(String text)
EditorInterface
setText in interface EditorInterfacetext - test to setpublic void copy()
EditorInterface
copy in interface EditorInterfacepublic void cut()
EditorInterface
cut in interface EditorInterfacepublic void paste()
EditorInterface
paste in interface EditorInterfacepublic void setEnabled(boolean b)
EditorInterface
setEnabled in interface EditorInterfacesetEnabled in class JComponentb - enablepublic void addDocumentListener(DocumentListener listener)
EditorInterface
addDocumentListener in interface EditorInterfacelistener - listenerpublic void removeDocumentListener(DocumentListener listener)
EditorInterface
removeDocumentListener in interface EditorInterfacelistener - listenerpublic void addCaretListener(CaretListener listener)
EditorInterface
addCaretListener in interface EditorInterfacelistener - listenerpublic void removeCaretListener(CaretListener listener)
EditorInterface
removeCaretListener in interface EditorInterfacelistener - listener
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||