Interface Editor
public interface Editor
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Cancels the ongoing edit without accepting any changes.boolean
Returns true if this editor is currently editing an object, false otherwise.void
startEdit
(EditSupport support, int x, int y) Starts editing with the help of the support, or returns without doing anything if the support is not recognized by this editor.void
stopAll()
Stops all edits on the edit stack in order.boolean
stopEdit()
Stops the ongoing edit accepting any partial changes and returns true, or returns false if the partial changes cannot be accepted.
-
Method Details
-
isEditing
boolean isEditing()Returns true if this editor is currently editing an object, false otherwise.- Returns:
- true if this editor is currently editing an object, false otherwise.
-
startEdit
Starts editing with the help of the support, or returns without doing anything if the support is not recognized by this editor. If this editor is already editingsupport
, nothing happens. If this editor is editing some other support object, a stack is set up by this editor. Any ongoing edit will be put on the stack and the new object (support
) will be edited. When that edit is done, cancelled or stopped, the stack is popped and the popped object will be edited. This will continue until either stopAll is called or the stack is empty. This is only relevant to editors that are reused by their factories. If the factory creates a new editor on each call togetEditor
, then this method will never be called for multiple supports and no stack is needed.- Parameters:
support
- A support object containing information about the object to edit. The support object is created by the factory that created this editor and it is thus up to implementations to create support objects with enough information to carry out an edit.x
- A requested x coordinate in the screens coordinate system. Depending on the editor, it might disregard this. If this number is negative, it means that the caller does not care where the editor appears.y
- A requested y coordinate in the screens coordinate system. Depending on the editor, it might disregard this. If this number is negative, it means that the caller does not care where the editor appears.
-
cancelEdit
void cancelEdit()Cancels the ongoing edit without accepting any changes. If multiple objects are on the editors stack, the object on top of the stack will be edited instead. If there are no object to edit left or this method is called when no editing is occuring, nothing happens. -
stopEdit
boolean stopEdit()Stops the ongoing edit accepting any partial changes and returns true, or returns false if the partial changes cannot be accepted. This is useful for editors that validate and can not accept invalid entries.
If multiple objects are on the editors stack, the object on top of the stack will be edited if true is returned. Otherwise the currently edited object will continue to be edited. If there are no object to edit left or this method is called when no editing is occuring, nothing happens and true is returned.- Returns:
- true if the partial changes are accepted, false otherwise.
-
stopAll
void stopAll()Stops all edits on the edit stack in order. If any of the edits cannot be stopped with that object's current state, the edit will instead be cancelled. This means that when this method returns, any change on any object in this editor's stack will either be completely discarded or completely set on the object. This method is the functional equivalent ofwhile(editor.isEditing()) { if(!editor.stopEdit()) { editor.cancelEdit(); } }
Nothing happens if this method is called when the edit stack is empty or when no edit is occuring.
-