fixed import and init errors

development
mcyph 2021-03-21 17:46:06 +11:00
parent 4e8e71de7d
commit b257b5c5c9
21 changed files with 423 additions and 365 deletions

View File

@ -3,6 +3,8 @@
* Copyright (c) 2006-2015, Gaudenz Alder
* Updated to ES9 syntax by David Morrissey 2021
*/
import mxConstants from "../util/mxConstants";
import mxEvent from "../util/mxEvent";
class mxCellHighlight {
/**

View File

@ -3,6 +3,10 @@
* Copyright (c) 2006-2015, Gaudenz Alder
* Updated to ES9 syntax by David Morrissey 2021
*/
import mxImage from "../util/mxImage";
import mxClient from "../mxClient";
import mxConstants from "../util/mxConstants";
import mxEvent from "../util/mxEvent";
class mxConstraintHandler {
/**

View File

@ -4,6 +4,10 @@
* Updated to ES9 syntax by David Morrissey 2021
*/
import mxClient from "../mxClient";
import mxEvent from "../util/mxEvent";
import mxUtils from "../util/mxUtils";
class mxGraphHandler {
/**
* Variable: graph

View File

@ -6,6 +6,7 @@
import mxEventSource from "../util/mxEventSource";
import mxUtils from "../util/mxUtils";
import mxEventObject from "../util/mxEventObject";
import mxEvent from "../util/mxEvent";
class mxPanningHandler extends mxEventSource {
/**

View File

@ -4,6 +4,8 @@
* Updated to ES9 syntax by David Morrissey 2021
*/
import mxPopupMenu from "../util/mxPopupMenu";
import mxEvent from "../util/mxEvent";
import mxUtils from "../util/mxUtils";
class mxPopupMenuHandler extends mxPopupMenu {
/**
@ -92,7 +94,7 @@ class mxPopupMenuHandler extends mxPopupMenu {
*/
init = () => {
// Supercall
init.apply(this);
super.init();
// Hides the tooltip if the mouse is over
// the context menu

View File

@ -6,6 +6,7 @@
import mxEventSource from "../util/mxEventSource";
import mxDictionary from "../util/mxDictionary";
import mxEventObject from "../util/mxEventObject";
import mxEvent from "../util/mxEvent";
class mxSelectionCellsHandler extends mxEventSource {
/**

View File

@ -0,0 +1,62 @@
class mxCellAttributeChange {
/**
* Class: mxCellAttributeChange
*
* Action to change the attribute of a cell's user object.
* There is no method on the graph model that uses this
* action. To use the action, you can use the code shown
* in the example below.
*
* Example:
*
* To change the attributeName in the cell's user object
* to attributeValue, use the following code:
*
* (code)
* model.beginUpdate();
* try
* {
* let edit = new mxCellAttributeChange(
* cell, attributeName, attributeValue);
* model.execute(edit);
* }
* finally
* {
* model.endUpdate();
* }
* (end)
*
* Constructor: mxCellAttributeChange
*
* Constructs a change of a attribute of the DOM node
* stored as the value of the given <mxCell>.
*/
constructor(cell, attribute, value) {
this.cell = cell;
this.attribute = attribute;
this.value = value;
this.previous = value;
};
/**
* Function: execute
*
* Changes the attribute of the cell's user object by
* using <mxCell.setAttribute>.
*/
execute = () => {
if (this.cell != null) {
let tmp = this.cell.getAttribute(this.attribute);
if (this.previous == null) {
this.cell.value.removeAttribute(this.attribute);
} else {
this.cell.setAttribute(this.attribute, this.previous);
}
this.previous = tmp;
}
};
}
export default mxCellAttributeChange;

View File

@ -0,0 +1,92 @@
class mxChildChange {
/**
* Class: mxChildChange
*
* Action to add or remove a child in a model.
*
* Constructor: mxChildChange
*
* Constructs a change of a child in the
* specified model.
*/
constructor(model, parent, child, index) {
this.model = model;
this.parent = parent;
this.previous = parent;
this.child = child;
this.index = index;
this.previousIndex = index;
};
/**
* Function: execute
*
* Changes the parent of <child> using
* <mxGraphModel.parentForCellChanged> and
* removes or restores the cell's
* connections.
*/
execute = () => {
if (this.child != null) {
let tmp = this.model.getParent(this.child);
var tmp2 = (tmp != null) ? tmp.getIndex(this.child) : 0;
if (this.previous == null) {
this.connect(this.child, false);
}
tmp = this.model.parentForCellChanged(
this.child, this.previous, this.previousIndex);
if (this.previous != null) {
this.connect(this.child, true);
}
this.parent = this.previous;
this.previous = tmp;
this.index = this.previousIndex;
this.previousIndex = tmp2;
}
};
/**
* Function: disconnect
*
* Disconnects the given cell recursively from its
* terminals and stores the previous terminal in the
* cell's terminals.
*/
connect = (cell, isConnect) => {
isConnect = (isConnect != null) ? isConnect : true;
let source = cell.getTerminal(true);
let target = cell.getTerminal(false);
if (source != null) {
if (isConnect) {
this.model.terminalForCellChanged(cell, source, true);
} else {
this.model.terminalForCellChanged(cell, null, true);
}
}
if (target != null) {
if (isConnect) {
this.model.terminalForCellChanged(cell, target, false);
} else {
this.model.terminalForCellChanged(cell, null, false);
}
}
cell.setTerminal(source, true);
cell.setTerminal(target, false);
let childCount = this.model.getChildCount(cell);
for (let i = 0; i < childCount; i++) {
this.connect(this.model.getChildAt(cell, i), isConnect);
}
};
}
export default mxChildChange;

View File

@ -0,0 +1,34 @@
class mxCollapseChange {
/**
* Class: mxCollapseChange
*
* Action to change a cell's collapsed state in a model.
*
* Constructor: mxCollapseChange
*
* Constructs a change of a collapsed state in the
* specified model.
*/
constructor(model, cell, collapsed) {
this.model = model;
this.cell = cell;
this.collapsed = collapsed;
this.previous = collapsed;
};
/**
* Function: execute
*
* Changes the collapsed state of <cell> to <previous> using
* <mxGraphModel.collapsedStateForCellChanged>.
*/
execute = () => {
if (this.cell != null) {
this.collapsed = this.previous;
this.previous = this.model.collapsedStateForCellChanged(
this.cell, this.previous);
}
};
}
export default mxCollapseChange;

View File

@ -0,0 +1,34 @@
class mxGeometryChange {
/**
* Class: mxGeometryChange
*
* Action to change a cell's geometry in a model.
*
* Constructor: mxGeometryChange
*
* Constructs a change of a geometry in the
* specified model.
*/
constructor(model, cell, geometry) {
this.model = model;
this.cell = cell;
this.geometry = geometry;
this.previous = geometry;
};
/**
* Function: execute
*
* Changes the geometry of <cell> ro <previous> using
* <mxGraphModel.geometryForCellChanged>.
*/
execute = () => {
if (this.cell != null) {
this.geometry = this.previous;
this.previous = this.model.geometryForCellChanged(
this.cell, this.previous);
}
};
}
export default mxGeometryChange;

View File

@ -0,0 +1,30 @@
class mxRootChange {
/**
* Class: mxRootChange
*
* Action to change the root in a model.
*
* Constructor: mxRootChange
*
* Constructs a change of the root in the
* specified model.
*/
constructor(model, root) {
this.model = model;
this.root = root;
this.previous = root;
};
/**
* Function: execute
*
* Carries out a change of the root using
* <mxGraphModel.rootChanged>.
*/
execute = () => {
this.root = this.previous;
this.previous = this.model.rootChanged(this.previous);
};
}
export default mxRootChange;

View File

@ -0,0 +1,34 @@
class mxStyleChange {
/**
* Class: mxStyleChange
*
* Action to change a cell's style in a model.
*
* Constructor: mxStyleChange
*
* Constructs a change of a style in the
* specified model.
*/
constructor(model, cell, style) {
this.model = model;
this.cell = cell;
this.style = style;
this.previous = style;
};
/**
* Function: execute
*
* Changes the style of <cell> to <previous> using
* <mxGraphModel.styleForCellChanged>.
*/
execute = () => {
if (this.cell != null) {
this.style = this.previous;
this.previous = this.model.styleForCellChanged(
this.cell, this.previous);
}
};
}
export default mxStyleChange;

View File

@ -0,0 +1,35 @@
class mxTerminalChange {
/**
* Class: mxTerminalChange
*
* Action to change a terminal in a model.
*
* Constructor: mxTerminalChange
*
* Constructs a change of a terminal in the
* specified model.
*/
constructor(model, cell, terminal, source) {
this.model = model;
this.cell = cell;
this.terminal = terminal;
this.previous = terminal;
this.source = source;
};
/**
* Function: execute
*
* Changes the terminal of <cell> to <previous> using
* <mxGraphModel.terminalForCellChanged>.
*/
execute = () => {
if (this.cell != null) {
this.terminal = this.previous;
this.previous = this.model.terminalForCellChanged(
this.cell, this.previous, this.source);
}
};
}
export default mxTerminalChange;

View File

@ -0,0 +1,33 @@
class mxValueChange {
/**
* Class: mxValueChange
*
* Action to change a user object in a model.
*
* Constructor: mxValueChange
*
* Constructs a change of a user object in the
* specified model.
*/
constructor(model, cell, value) {
this.model = model;
this.cell = cell;
this.value = value;
this.previous = value;
};
/**
* Function: execute
*
* Changes the value of <cell> to <previous> using
* <mxGraphModel.valueForCellChanged>.
*/
execute = () => {
if (this.cell != null) {
this.value = this.previous;
this.previous = this.model.valueForCellChanged(
this.cell, this.previous);
}
};
}
export default mxValueChange;

View File

@ -0,0 +1,34 @@
class mxVisibleChange {
/**
* Class: mxVisibleChange
*
* Action to change a cell's visible state in a model.
*
* Constructor: mxVisibleChange
*
* Constructs a change of a visible state in the
* specified model.
*/
constructor(model, cell, visible) {
this.model = model;
this.cell = cell;
this.visible = visible;
this.previous = visible;
};
/**
* Function: execute
*
* Changes the visible state of <cell> to <previous> using
* <mxGraphModel.visibleStateForCellChanged>.
*/
execute = () => {
if (this.cell != null) {
this.visible = this.previous;
this.previous = this.model.visibleStateForCellChanged(
this.cell, this.previous);
}
};
}
export default mxVisibleChange;

View File

@ -9,6 +9,19 @@ import mxCellPath from "./mxCellPath";
import mxDictionary from "../util/mxDictionary";
import mxObjectIdentity from "../util/mxObjectIdentity";
import mxCell from "./mxCell";
import mxUtils from "../util/mxUtils";
import mxEventObject from "../util/mxEventObject";
import mxEvent from "../util/mxEvent";
import mxCellAttributeChange from "./atomic_changes/mxCellAttributeChange";
import mxChildChange from "./atomic_changes/mxChildChange";
import mxCollapseChange from "./atomic_changes/mxCollapseChange";
import mxGeometryChange from "./atomic_changes/mxGeometryChange";
import mxRootChange from "./atomic_changes/mxRootChange";
import mxStyleChange from "./atomic_changes/mxStyleChange";
import mxTerminalChange from "./atomic_changes/mxTerminalChange";
import mxValueChange from "./atomic_changes/mxValueChange";
import mxVisibleChange from "./atomic_changes/mxVisibleChange";
class mxGraphModel extends mxEventSource {
/**
@ -2099,372 +2112,9 @@ class mxGraphModel extends mxEventSource {
this.getChildAt(cell, i), mapping);
}
};
}
//
// Atomic changes
//
/**
* Class: mxRootChange
*
* Action to change the root in a model.
*
* Constructor: mxRootChange
*
* Constructs a change of the root in the
* specified model.
*/
mxRootChange = (model, root) => {
this.model = model;
this.root = root;
this.previous = root;
};
/**
* Function: execute
*
* Carries out a change of the root using
* <mxGraphModel.rootChanged>.
*/
execute = () => {
this.root = this.previous;
this.previous = this.model.rootChanged(this.previous);
};
/**
* Class: mxChildChange
*
* Action to add or remove a child in a model.
*
* Constructor: mxChildChange
*
* Constructs a change of a child in the
* specified model.
*/
mxChildChange = (model, parent, child, index) => {
this.model = model;
this.parent = parent;
this.previous = parent;
this.child = child;
this.index = index;
this.previousIndex = index;
};
/**
* Function: execute
*
* Changes the parent of <child> using
* <mxGraphModel.parentForCellChanged> and
* removes or restores the cell's
* connections.
*/
execute = () => {
if (this.child != null) {
let tmp = this.model.getParent(this.child);
var tmp2 = (tmp != null) ? tmp.getIndex(this.child) : 0;
if (this.previous == null) {
this.connect(this.child, false);
}
tmp = this.model.parentForCellChanged(
this.child, this.previous, this.previousIndex);
if (this.previous != null) {
this.connect(this.child, true);
}
this.parent = this.previous;
this.previous = tmp;
this.index = this.previousIndex;
this.previousIndex = tmp2;
}
};
/**
* Function: disconnect
*
* Disconnects the given cell recursively from its
* terminals and stores the previous terminal in the
* cell's terminals.
*/
connect = (cell, isConnect) => {
isConnect = (isConnect != null) ? isConnect : true;
let source = cell.getTerminal(true);
let target = cell.getTerminal(false);
if (source != null) {
if (isConnect) {
this.model.terminalForCellChanged(cell, source, true);
} else {
this.model.terminalForCellChanged(cell, null, true);
}
}
if (target != null) {
if (isConnect) {
this.model.terminalForCellChanged(cell, target, false);
} else {
this.model.terminalForCellChanged(cell, null, false);
}
}
cell.setTerminal(source, true);
cell.setTerminal(target, false);
let childCount = this.model.getChildCount(cell);
for (let i = 0; i < childCount; i++) {
this.connect(this.model.getChildAt(cell, i), isConnect);
}
};
/**
* Class: mxTerminalChange
*
* Action to change a terminal in a model.
*
* Constructor: mxTerminalChange
*
* Constructs a change of a terminal in the
* specified model.
*/
mxTerminalChange = (model, cell, terminal, source) => {
this.model = model;
this.cell = cell;
this.terminal = terminal;
this.previous = terminal;
this.source = source;
};
/**
* Function: execute
*
* Changes the terminal of <cell> to <previous> using
* <mxGraphModel.terminalForCellChanged>.
*/
execute = () => {
if (this.cell != null) {
this.terminal = this.previous;
this.previous = this.model.terminalForCellChanged(
this.cell, this.previous, this.source);
}
};
/**
* Class: mxValueChange
*
* Action to change a user object in a model.
*
* Constructor: mxValueChange
*
* Constructs a change of a user object in the
* specified model.
*/
mxValueChange = (model, cell, value) => {
this.model = model;
this.cell = cell;
this.value = value;
this.previous = value;
};
/**
* Function: execute
*
* Changes the value of <cell> to <previous> using
* <mxGraphModel.valueForCellChanged>.
*/
execute = () => {
if (this.cell != null) {
this.value = this.previous;
this.previous = this.model.valueForCellChanged(
this.cell, this.previous);
}
};
/**
* Class: mxStyleChange
*
* Action to change a cell's style in a model.
*
* Constructor: mxStyleChange
*
* Constructs a change of a style in the
* specified model.
*/
mxStyleChange = (model, cell, style) => {
this.model = model;
this.cell = cell;
this.style = style;
this.previous = style;
};
/**
* Function: execute
*
* Changes the style of <cell> to <previous> using
* <mxGraphModel.styleForCellChanged>.
*/
execute = () => {
if (this.cell != null) {
this.style = this.previous;
this.previous = this.model.styleForCellChanged(
this.cell, this.previous);
}
};
/**
* Class: mxGeometryChange
*
* Action to change a cell's geometry in a model.
*
* Constructor: mxGeometryChange
*
* Constructs a change of a geometry in the
* specified model.
*/
mxGeometryChange = (model, cell, geometry) => {
this.model = model;
this.cell = cell;
this.geometry = geometry;
this.previous = geometry;
};
/**
* Function: execute
*
* Changes the geometry of <cell> ro <previous> using
* <mxGraphModel.geometryForCellChanged>.
*/
execute = () => {
if (this.cell != null) {
this.geometry = this.previous;
this.previous = this.model.geometryForCellChanged(
this.cell, this.previous);
}
};
/**
* Class: mxCollapseChange
*
* Action to change a cell's collapsed state in a model.
*
* Constructor: mxCollapseChange
*
* Constructs a change of a collapsed state in the
* specified model.
*/
mxCollapseChange = (model, cell, collapsed) => {
this.model = model;
this.cell = cell;
this.collapsed = collapsed;
this.previous = collapsed;
};
/**
* Function: execute
*
* Changes the collapsed state of <cell> to <previous> using
* <mxGraphModel.collapsedStateForCellChanged>.
*/
execute = () => {
if (this.cell != null) {
this.collapsed = this.previous;
this.previous = this.model.collapsedStateForCellChanged(
this.cell, this.previous);
}
};
/**
* Class: mxVisibleChange
*
* Action to change a cell's visible state in a model.
*
* Constructor: mxVisibleChange
*
* Constructs a change of a visible state in the
* specified model.
*/
mxVisibleChange = (model, cell, visible) => {
this.model = model;
this.cell = cell;
this.visible = visible;
this.previous = visible;
};
/**
* Function: execute
*
* Changes the visible state of <cell> to <previous> using
* <mxGraphModel.visibleStateForCellChanged>.
*/
execute = () => {
if (this.cell != null) {
this.visible = this.previous;
this.previous = this.model.visibleStateForCellChanged(
this.cell, this.previous);
}
};
/**
* Class: mxCellAttributeChange
*
* Action to change the attribute of a cell's user object.
* There is no method on the graph model that uses this
* action. To use the action, you can use the code shown
* in the example below.
*
* Example:
*
* To change the attributeName in the cell's user object
* to attributeValue, use the following code:
*
* (code)
* model.beginUpdate();
* try
* {
* let edit = new mxCellAttributeChange(
* cell, attributeName, attributeValue);
* model.execute(edit);
* }
* finally
* {
* model.endUpdate();
* }
* (end)
*
* Constructor: mxCellAttributeChange
*
* Constructs a change of a attribute of the DOM node
* stored as the value of the given <mxCell>.
*/
mxCellAttributeChange = (cell, attribute, value) => {
this.cell = cell;
this.attribute = attribute;
this.value = value;
this.previous = value;
};
/**
* Function: execute
*
* Changes the attribute of the cell's user object by
* using <mxCell.setAttribute>.
*/
execute = () => {
if (this.cell != null) {
let tmp = this.cell.getAttribute(this.attribute);
if (this.previous == null) {
this.cell.value.removeAttribute(this.attribute);
} else {
this.cell.setAttribute(this.attribute, this.previous);
}
this.previous = tmp;
}
};
}
export default mxGraphModel;

View File

@ -6,6 +6,8 @@
import mxEventSource from "./mxEventSource";
import mxUtils from "./mxUtils";
import mxEventObject from "./mxEventObject";
import mxClient from "../mxClient";
import mxEvent from "./mxEvent";
class mxPopupMenu extends mxEventSource {
/**

View File

@ -37,6 +37,7 @@ import mxResources from "../util/mxResources";
import mxGeometry from "../model/mxGeometry";
import mxCell from "../model/mxCell";
import mxGraphModel from "../model/mxGraphModel";
import mxStylesheet from "./mxStylesheet";
class mxGraph extends mxEventSource {
/**

View File

@ -7,6 +7,7 @@
import mxUndoableEdit from "../util/mxUndoableEdit";
import mxEventSource from "../util/mxEventSource";
import mxEventObject from "../util/mxEventObject";
import mxClient from "../mxClient";
class mxGraphSelectionModel extends mxEventSource {
/**

View File

@ -11,6 +11,7 @@ import mxEventSource from "../util/mxEventSource";
import mxEventObject from "../util/mxEventObject";
import mxRectangleShape from "../shape/mxRectangleShape";
import mxConstants from "../util/mxConstants";
import mxClient from "../mxClient";
class mxGraphView extends mxEventSource {
EMPTY_POINT = new mxPoint();

View File

@ -4,6 +4,7 @@
* Updated to ES9 syntax by David Morrissey 2021
*/
import mxConstants from "../util/mxConstants";
import mxPerimeter from "./mxPerimeter";
class mxStylesheet {
/**