12345 |
- /*
- All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- See https://js.arcgis.com/4.24/esri/copyright.txt for details.
- */
- import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import i from"../../core/Logger.js";import{isNone as o}from"../../core/maybe.js";import{createResolver as s}from"../../core/promiseUtils.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{isDOMContainer as n}from"../DOMContainer.js";import{EditableFlag as l}from"./interfaces.js";import{ManipulatorCollection as p}from"./ManipulatorCollection.js";const h=i.getLogger("esri.views.interactive.InteractiveToolBase");let c=class extends e{constructor(t){super(t),this.manipulators=new p,this.preferManipulatorCursor=!1,this.automaticManipulatorSelection=!0,this.hasFocusedManipulators=!1,this.created=!1,this.removeIncompleteOnCancel=!0,this._editableFlags=new Map([[l.MANAGER,!0],[l.USER,!0]]),this._creationFinishedResolver=s()}get active(){return null!=this.view&&this.view.activeTool===this}set visible(t){this._get("visible")!==t&&(this._set("visible",t),this._syncVisible())}get editable(){return this.getEditableFlag(l.USER)}set editable(t){this.setEditableFlag(l.USER,t)}get updating(){return!1}get cursor(){return null}destroy(){this.manipulators.destroy(),this._set("view",null)}onAdd(){this._syncVisible()}activate(){o(this.view)?h.error("Can't activate tool if view is not defined."):(n(this.view)&&this.view.focus(),this.onActivate())}deactivate(){this.onDeactivate()}handleInputEvent(t){this.onInputEvent(t)}handleInputEventAfter(t){this.onInputEventAfter(t)}setEditableFlag(t,e){this._editableFlags.set(t,e),this.manipulators.isToolEditable=this.internallyEditable,this._updateManipulatorAttachment(),t===l.USER&&this.notifyChange("editable"),this.onEditableChange()}getEditableFlag(t){return this._editableFlags.get(t)}whenCreated(){return this._creationFinishedResolver.promise}onActivate(){}onDeactivate(){}onShow(){}onHide(){}onEditableChange(){}onInputEvent(t){}onInputEventAfter(t){}get internallyEditable(){return this.getEditableFlag(l.USER)&&this.getEditableFlag(l.MANAGER)}finishToolCreation(){this.created||this._creationFinishedResolver.resolve(this),this._set("created",!0)}_syncVisible(){if(this.constructed)if(this.visible)this._show();else if(this._hide(),this.active)return void(this.view.activeTool=null)}_show(){this._updateManipulatorAttachment(),this.onShow()}_hide(){this._updateManipulatorAttachment(),this.onHide()}_updateManipulatorAttachment(){this.visible?this.manipulators.attach():this.manipulators.detach()}};t([r({constructOnly:!0})],c.prototype,"view",void 0),t([r({readOnly:!0})],c.prototype,"active",null),t([r({value:!0})],c.prototype,"visible",null),t([r({value:!0})],c.prototype,"editable",null),t([r({readOnly:!0})],c.prototype,"manipulators",void 0),t([r({readOnly:!0})],c.prototype,"updating",null),t([r()],c.prototype,"cursor",null),t([r({readOnly:!0})],c.prototype,"preferManipulatorCursor",void 0),t([r({readOnly:!0})],c.prototype,"automaticManipulatorSelection",void 0),t([r()],c.prototype,"hasFocusedManipulators",void 0),t([r({readOnly:!0})],c.prototype,"created",void 0),t([r({readOnly:!0})],c.prototype,"removeIncompleteOnCancel",void 0),c=t([a("esri.views.interactive.InteractiveToolBase")],c);export{c as InteractiveToolBase};
|