Home

# Class goog.editor.plugins.AbstractDialogPlugin

An abstract superclass for a Trogedit plugin that creates exactly one dialog. By default dialogs are not reused -- each time execCommand is called, a new instance of the dialog object is created (and the old one disposed of). To enable reusing of the dialog object, subclasses should call setReuseDialog() after calling the superclass constructor.

extends goog.editor.Plugin

Instance Method Summary
| `createDialog(!goog.dom.DomHelper dialogDomHelper, <Any Type> opt_arg) ⇒ ?goog.ui.editor.AbstractDialog` Creates a new instance of this plugin's dialog. Must be overridden by subclasses.
| `disposeDialog_()` Disposes of the dialog if needed. It is this abstract class' responsibility to dispose of the dialog. The "if needed" refers to the fact this method might be called twice (nested calls, not sequential) in the dispose flow, so if the dialog was already disposed once it should not be disposed again.

`disposeInternal()`

Unattach listeners from this object. Classes that extend EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners, it should be something like this:

    MyClass.prototype.disposeInternal = function() {
    MyClass.superClass_.disposeInternal.call(this);
    // Dispose logic for MyClass
    };

| `disposeOriginalSelection()` Cleans up the structure used to save the original selection before the dialog was opened. Should be used by subclasses that don't restore the original selection via restoreOriginalSelection.
| `execCommand(string command, <Any Type> var_args) ⇒ <Any Type>` Handles execCommand. Dialog plugins don't make any changes when they open a dialog, just when the dialog closes (because only modal dialogs are supported). Hence this method does not dispatch the change events that the superclass method does.
| `getDialog() ⇒ ?goog.ui.editor.AbstractDialog` Returns the current dialog that was created and opened by this plugin.

`handleAfterHide(?goog.events.Event e)`

Cleans up after the dialog has closed, including restoring the selection to what it was before the dialog was opened. If a subclass modifies the editable field's content such that the original selection is no longer valid (usually the case when the user clicks OK, and sometimes also on Cancel), it is that subclass' responsibility to place the selection in the desired place during the OK or Cancel (or other) handler. In that case, this method will leave the selection in place.

| `isSupportedCommand(string command) ⇒ boolean` Whether the string corresponds to a command this plugin handles.
| `restoreOriginalSelection()` Restores the selection in the editable field to what it was before the dialog was opened. This is not guaranteed to work if the contents of the field have changed.
| `setReuseDialog(boolean reuse)` Sets whether this plugin should reuse the same instance of the dialog each time execCommand is called or create a new one. This is intended for use by subclasses only, hence protected.