InteractiveToolBase.js 3.6 KB

12345
  1. /*
  2. All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. See https://js.arcgis.com/4.25/esri/copyright.txt for details.
  4. */
  5. 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 a}from"../../core/promiseUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/accessorSupport/ensureType.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import{EditableFlag as n}from"./interfaces.js";import{ManipulatorCollection as l}from"./ManipulatorCollection.js";let p=class extends e{constructor(t){super(t),this.manipulators=new l,this.automaticManipulatorSelection=!0,this.hasGrabbedManipulators=!1,this.hasHoveredManipulators=!1,this.firstGrabbedManipulator=null,this.created=!1,this.removeIncompleteOnCancel=!0,this._editableFlags=new Map([[n.MANAGER,!0],[n.USER,!0]]),this._creationFinishedResolver=a()}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(n.USER)}set editable(t){this.setEditableFlag(n.USER,t)}get updating(){return!1}get cursor(){return null}get hasFocusedManipulators(){return this.hasGrabbedManipulators||this.hasHoveredManipulators}destroy(){this.manipulators.destroy(),this._set("view",null)}onAdd(){this._syncVisible()}activate(){o(this.view)?i.getLogger(this.declaredClass).error("Can't activate tool if view is not defined."):(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===n.USER&&this.notifyChange("editable"),this.onEditableChange(),this.onManipulatorSelectionChanged()}getEditableFlag(t){return this._editableFlags.get(t)}whenCreated(){return this._creationFinishedResolver.promise}onManipulatorSelectionChanged(){}onActivate(){}onDeactivate(){}onShow(){}onHide(){}onEditableChange(){}onInputEvent(t){}onInputEventAfter(t){}get internallyEditable(){return this.getEditableFlag(n.USER)&&this.getEditableFlag(n.MANAGER)}finishToolCreation(){this.created||this._creationFinishedResolver.resolve(this),this._set("created",!0)}_syncVisible(){if(this.initialized)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([s({constructOnly:!0})],p.prototype,"view",void 0),t([s({readOnly:!0})],p.prototype,"active",null),t([s({value:!0})],p.prototype,"visible",null),t([s({value:!0})],p.prototype,"editable",null),t([s({readOnly:!0})],p.prototype,"manipulators",void 0),t([s({readOnly:!0})],p.prototype,"updating",null),t([s()],p.prototype,"cursor",null),t([s({readOnly:!0})],p.prototype,"automaticManipulatorSelection",void 0),t([s()],p.prototype,"hasFocusedManipulators",null),t([s()],p.prototype,"hasGrabbedManipulators",void 0),t([s()],p.prototype,"hasHoveredManipulators",void 0),t([s()],p.prototype,"firstGrabbedManipulator",void 0),t([s({readOnly:!0})],p.prototype,"created",void 0),t([s({readOnly:!0})],p.prototype,"removeIncompleteOnCancel",void 0),p=t([r("esri.views.interactive.InteractiveToolBase")],p);export{p as InteractiveToolBase};