mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-22 22:57:57 +01:00
Convert to classess
This commit is contained in:
parent
6f613c8f05
commit
d4da83497b
@ -19,6 +19,7 @@
|
|||||||
"plugins": ["only-warn"],
|
"plugins": ["only-warn"],
|
||||||
"rules": {
|
"rules": {
|
||||||
"no-underscore-dangle": "off",
|
"no-underscore-dangle": "off",
|
||||||
|
"no-plusplus": "off",
|
||||||
"import/no-extraneous-dependencies": ["error", {"devDependencies": ["!cypress/**/*.js"]}]
|
"import/no-extraneous-dependencies": ["error", {"devDependencies": ["!cypress/**/*.js"]}]
|
||||||
},
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
import { $assert } from '@wisemapping/core-js';
|
||||||
import Events from './Events';
|
import Events from './Events';
|
||||||
|
|
||||||
// noinspection JSUnusedLocalSymbols
|
// noinspection JSUnusedLocalSymbols
|
||||||
@ -102,12 +103,10 @@ const ActionDispatcher = new Class({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
ActionDispatcher.setInstance = function (dispatcher) {
|
ActionDispatcher.setInstance = (dispatcher) => {
|
||||||
ActionDispatcher._instance = dispatcher;
|
ActionDispatcher._instance = dispatcher;
|
||||||
};
|
};
|
||||||
|
|
||||||
ActionDispatcher.getInstance = function () {
|
ActionDispatcher.getInstance = () => ActionDispatcher._instance;
|
||||||
return ActionDispatcher._instance;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default ActionDispatcher;
|
export default ActionDispatcher;
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
import { $assert } from '@wisemapping/core-js';
|
||||||
|
|
||||||
import Events from './Events';
|
import Events from './Events';
|
||||||
import Messages from './Messages';
|
import Messages from './Messages';
|
||||||
|
|
||||||
@ -35,7 +37,7 @@ import Relationship from './Relationship';
|
|||||||
import TopicEventDispatcher, { TopicEvent } from './TopicEventDispatcher';
|
import TopicEventDispatcher, { TopicEvent } from './TopicEventDispatcher';
|
||||||
import TopicFeature from './TopicFeature';
|
import TopicFeature from './TopicFeature';
|
||||||
|
|
||||||
import NodeGraphUtils from './NodeGraphUtils';
|
import { create } from './NodeGraphUtils';
|
||||||
|
|
||||||
import EventBus from './layout/EventBus';
|
import EventBus from './layout/EventBus';
|
||||||
import EventBusDispatcher from './layout/EventBusDispatcher';
|
import EventBusDispatcher from './layout/EventBusDispatcher';
|
||||||
@ -129,7 +131,7 @@ const Designer = new Class(
|
|||||||
* forwards to the TopicEventDispatcher or the parent Events class, depending on the type
|
* forwards to the TopicEventDispatcher or the parent Events class, depending on the type
|
||||||
*/
|
*/
|
||||||
addEvent(type, listener) {
|
addEvent(type, listener) {
|
||||||
if (type == TopicEvent.EDIT || type == TopicEvent.CLICK) {
|
if (type === TopicEvent.EDIT || type === TopicEvent.CLICK) {
|
||||||
const editor = TopicEventDispatcher.getInstance();
|
const editor = TopicEventDispatcher.getInstance();
|
||||||
editor.addEvent(type, listener);
|
editor.addEvent(type, listener);
|
||||||
} else {
|
} else {
|
||||||
@ -238,7 +240,7 @@ const Designer = new Class(
|
|||||||
*/
|
*/
|
||||||
_buildNodeGraph(model, readOnly) {
|
_buildNodeGraph(model, readOnly) {
|
||||||
// Create node graph ...
|
// Create node graph ...
|
||||||
const topic = NodeGraphUtils.create(model, { readOnly });
|
const topic = create(model, { readOnly });
|
||||||
this.getModel().addTopic(topic);
|
this.getModel().addTopic(topic);
|
||||||
const me = this;
|
const me = this;
|
||||||
// Add Topic events ...
|
// Add Topic events ...
|
||||||
@ -249,7 +251,7 @@ const Designer = new Class(
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Register node listeners ...
|
// Register node listeners ...
|
||||||
if (topic.getType() != INodeModel.CENTRAL_TOPIC_TYPE) {
|
if (topic.getType() !== INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||||
// Central Topic doesn't support to be dragged
|
// Central Topic doesn't support to be dragged
|
||||||
this._dragManager.add(topic);
|
this._dragManager.add(topic);
|
||||||
}
|
}
|
||||||
@ -265,7 +267,7 @@ const Designer = new Class(
|
|||||||
const topics = this.getModel().getTopics();
|
const topics = this.getModel().getTopics();
|
||||||
for (let i = 0; i < topics.length; i++) {
|
for (let i = 0; i < topics.length; i++) {
|
||||||
const t = topics[i];
|
const t = topics[i];
|
||||||
if (t.getModel() == targetTopicModel) {
|
if (t.getModel() === targetTopicModel) {
|
||||||
targetTopic = t;
|
targetTopic = t;
|
||||||
// Disconnect the node. It will be connected again later ...
|
// Disconnect the node. It will be connected again later ...
|
||||||
model.disconnect();
|
model.disconnect();
|
||||||
@ -280,7 +282,7 @@ const Designer = new Class(
|
|||||||
const topics = me.getModel().filterSelectedTopics();
|
const topics = me.getModel().filterSelectedTopics();
|
||||||
const rels = me.getModel().filterSelectedRelationships();
|
const rels = me.getModel().filterSelectedRelationships();
|
||||||
|
|
||||||
if (topics.length == 0 || rels.length == 0) {
|
if (topics.length === 0 || rels.length === 0) {
|
||||||
me.fireEvent('onblur');
|
me.fireEvent('onblur');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -289,7 +291,7 @@ const Designer = new Class(
|
|||||||
const topics = me.getModel().filterSelectedTopics();
|
const topics = me.getModel().filterSelectedTopics();
|
||||||
const rels = me.getModel().filterSelectedRelationships();
|
const rels = me.getModel().filterSelectedRelationships();
|
||||||
|
|
||||||
if (topics.length == 1 || rels.length == 1) {
|
if (topics.length === 1 || rels.length === 1) {
|
||||||
me.fireEvent('onfocus');
|
me.fireEvent('onfocus');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -315,7 +317,7 @@ const Designer = new Class(
|
|||||||
_.each(objects, (object) => {
|
_.each(objects, (object) => {
|
||||||
// Disable all nodes on focus but not the current if Ctrl key isn't being pressed
|
// Disable all nodes on focus but not the current if Ctrl key isn't being pressed
|
||||||
if (!$defined(event) || (!event.ctrlKey && !event.metaKey)) {
|
if (!$defined(event) || (!event.ctrlKey && !event.metaKey)) {
|
||||||
if (object.isOnFocus() && object != currentObject) {
|
if (object.isOnFocus() && object !== currentObject) {
|
||||||
object.setOnFocus(false);
|
object.setOnFocus(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -357,7 +359,9 @@ const Designer = new Class(
|
|||||||
* zoom out by the given factor, or 1.2, if undefined
|
* zoom out by the given factor, or 1.2, if undefined
|
||||||
*/
|
*/
|
||||||
zoomOut(factor) {
|
zoomOut(factor) {
|
||||||
if (!factor) factor = 1.2;
|
if (!factor) {
|
||||||
|
factor = 1.2;
|
||||||
|
}
|
||||||
|
|
||||||
const model = this.getModel();
|
const model = this.getModel();
|
||||||
const scale = model.getZoom() * factor;
|
const scale = model.getZoom() * factor;
|
||||||
@ -414,7 +418,7 @@ const Designer = new Class(
|
|||||||
|
|
||||||
/** paste clipboard contents to the mindmap */
|
/** paste clipboard contents to the mindmap */
|
||||||
pasteClipboard() {
|
pasteClipboard() {
|
||||||
if (this._clipboard.length == 0) {
|
if (this._clipboard.length === 0) {
|
||||||
$notify($msg('CLIPBOARD_IS_EMPTY'));
|
$notify($msg('CLIPBOARD_IS_EMPTY'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -430,14 +434,14 @@ const Designer = new Class(
|
|||||||
/** collapse the subtree of the selected topic */
|
/** collapse the subtree of the selected topic */
|
||||||
shrinkSelectedBranch() {
|
shrinkSelectedBranch() {
|
||||||
const nodes = this.getModel().filterSelectedTopics();
|
const nodes = this.getModel().filterSelectedTopics();
|
||||||
if (nodes.length <= 0 || nodes.length != 1) {
|
if (nodes.length <= 0 || nodes.length !== 1) {
|
||||||
// If there are more than one node selected,
|
// If there are more than one node selected,
|
||||||
$notify($msg('ONLY_ONE_TOPIC_MUST_BE_SELECTED_COLLAPSE'));
|
$notify($msg('ONLY_ONE_TOPIC_MUST_BE_SELECTED_COLLAPSE'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Execute event ...
|
// Execute event ...
|
||||||
const topic = nodes[0];
|
const topic = nodes[0];
|
||||||
if (topic.getType() != INodeModel.CENTRAL_TOPIC_TYPE) {
|
if (topic.getType() !== INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||||
this._actionDispatcher.shrinkBranch([topic.getId()], !topic.areChildrenShrunken());
|
this._actionDispatcher.shrinkBranch([topic.getId()], !topic.areChildrenShrunken());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -450,7 +454,7 @@ const Designer = new Class(
|
|||||||
$notify($msg('ONE_TOPIC_MUST_BE_SELECTED'));
|
$notify($msg('ONE_TOPIC_MUST_BE_SELECTED'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (nodes.length != 1) {
|
if (nodes.length !== 1) {
|
||||||
// If there are more than one node selected,
|
// If there are more than one node selected,
|
||||||
$notify($msg('ONLY_ONE_TOPIC_MUST_BE_SELECTED'));
|
$notify($msg('ONLY_ONE_TOPIC_MUST_BE_SELECTED'));
|
||||||
return;
|
return;
|
||||||
@ -470,7 +474,7 @@ const Designer = new Class(
|
|||||||
*/
|
*/
|
||||||
_copyNodeProps(sourceModel, targetModel) {
|
_copyNodeProps(sourceModel, targetModel) {
|
||||||
// I don't copy the font size if the target is the source is the central topic.
|
// I don't copy the font size if the target is the source is the central topic.
|
||||||
if (sourceModel.getType() != INodeModel.CENTRAL_TOPIC_TYPE) {
|
if (sourceModel.getType() !== INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||||
const fontSize = sourceModel.getFontSize();
|
const fontSize = sourceModel.getFontSize();
|
||||||
if (fontSize) {
|
if (fontSize) {
|
||||||
targetModel.setFontSize(fontSize);
|
targetModel.setFontSize(fontSize);
|
||||||
@ -585,7 +589,7 @@ const Designer = new Class(
|
|||||||
|
|
||||||
// Hack: if parent is central topic, add node below not on opposite side.
|
// Hack: if parent is central topic, add node below not on opposite side.
|
||||||
// This should be done in the layout
|
// This should be done in the layout
|
||||||
if (parentTopic.getType() == INodeModel.CENTRAL_TOPIC_TYPE) {
|
if (parentTopic.getType() === INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||||
siblingModel.setOrder(topic.getOrder() + 2);
|
siblingModel.setOrder(topic.getOrder() + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -601,10 +605,11 @@ const Designer = new Class(
|
|||||||
*/
|
*/
|
||||||
_createSiblingModel(topic) {
|
_createSiblingModel(topic) {
|
||||||
let result = null;
|
let result = null;
|
||||||
|
let model = null;
|
||||||
const parentTopic = topic.getOutgoingConnectedTopic();
|
const parentTopic = topic.getOutgoingConnectedTopic();
|
||||||
if (parentTopic != null) {
|
if (parentTopic != null) {
|
||||||
// Create a new node ...
|
// Create a new node ...
|
||||||
var model = topic.getModel();
|
model = topic.getModel();
|
||||||
const mindmap = model.getMindmap();
|
const mindmap = model.getMindmap();
|
||||||
result = mindmap.createNode();
|
result = mindmap.createNode();
|
||||||
|
|
||||||
@ -812,7 +817,7 @@ const Designer = new Class(
|
|||||||
const topics = me.getModel().filterSelectedTopics();
|
const topics = me.getModel().filterSelectedTopics();
|
||||||
const rels = me.getModel().filterSelectedRelationships();
|
const rels = me.getModel().filterSelectedRelationships();
|
||||||
|
|
||||||
if (topics.length == 0 || rels.length == 0) {
|
if (topics.length === 0 || rels.length === 0) {
|
||||||
me.fireEvent('onblur');
|
me.fireEvent('onblur');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -821,7 +826,7 @@ const Designer = new Class(
|
|||||||
const topics = me.getModel().filterSelectedTopics();
|
const topics = me.getModel().filterSelectedTopics();
|
||||||
const rels = me.getModel().filterSelectedRelationships();
|
const rels = me.getModel().filterSelectedRelationships();
|
||||||
|
|
||||||
if (topics.length == 1 || rels.length == 1) {
|
if (topics.length === 1 || rels.length === 1) {
|
||||||
me.fireEvent('onfocus');
|
me.fireEvent('onfocus');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -881,7 +886,7 @@ const Designer = new Class(
|
|||||||
$notify($msg('ENTITIES_COULD_NOT_BE_DELETED'));
|
$notify($msg('ENTITIES_COULD_NOT_BE_DELETED'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (topics.length == 1 && topics[0].isCentralTopic()) {
|
if (topics.length === 1 && topics[0].isCentralTopic()) {
|
||||||
$notify($msg('CENTRAL_TOPIC_CAN_NOT_BE_DELETED'));
|
$notify($msg('CENTRAL_TOPIC_CAN_NOT_BE_DELETED'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -927,9 +932,7 @@ const Designer = new Class(
|
|||||||
|
|
||||||
/** */
|
/** */
|
||||||
changeBackgroundColor(color) {
|
changeBackgroundColor(color) {
|
||||||
const validateFunc = function (topic) {
|
const validateFunc = (topic) => topic.getShapeType() !== TopicShape.LINE;
|
||||||
return topic.getShapeType() != TopicShape.LINE;
|
|
||||||
};
|
|
||||||
const validateError = 'Color can not be set to line topics.';
|
const validateError = 'Color can not be set to line topics.';
|
||||||
|
|
||||||
const topicsIds = this.getModel().filterTopicsIds(validateFunc, validateError);
|
const topicsIds = this.getModel().filterTopicsIds(validateFunc, validateError);
|
||||||
@ -940,9 +943,7 @@ const Designer = new Class(
|
|||||||
|
|
||||||
/** */
|
/** */
|
||||||
changeBorderColor(color) {
|
changeBorderColor(color) {
|
||||||
const validateFunc = function (topic) {
|
const validateFunc = (topic) => topic.getShapeType() !== TopicShape.LINE;
|
||||||
return topic.getShapeType() != TopicShape.LINE;
|
|
||||||
};
|
|
||||||
const validateError = 'Color can not be set to line topics.';
|
const validateError = 'Color can not be set to line topics.';
|
||||||
const topicsIds = this.getModel().filterTopicsIds(validateFunc, validateError);
|
const topicsIds = this.getModel().filterTopicsIds(validateFunc, validateError);
|
||||||
if (topicsIds.length > 0) {
|
if (topicsIds.length > 0) {
|
||||||
@ -960,11 +961,8 @@ const Designer = new Class(
|
|||||||
|
|
||||||
/** */
|
/** */
|
||||||
changeTopicShape(shape) {
|
changeTopicShape(shape) {
|
||||||
const validateFunc = function (topic) {
|
const validateFunc = (topic) => !(topic.getType() === INodeModel.CENTRAL_TOPIC_TYPE && shape === TopicShape.LINE
|
||||||
return !(
|
|
||||||
topic.getType() == INodeModel.CENTRAL_TOPIC_TYPE && shape == TopicShape.LINE
|
|
||||||
);
|
);
|
||||||
};
|
|
||||||
|
|
||||||
const validateError = 'Central Topic shape can not be changed to line figure.';
|
const validateError = 'Central Topic shape can not be changed to line figure.';
|
||||||
const topicsIds = this.getModel().filterTopicsIds(validateFunc, validateError);
|
const topicsIds = this.getModel().filterTopicsIds(validateFunc, validateError);
|
||||||
|
@ -15,17 +15,18 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
import { $assert } from '@wisemapping/core-js';
|
||||||
import DesignerUndoManager from './DesignerUndoManager';
|
import DesignerUndoManager from './DesignerUndoManager';
|
||||||
import EventBus from './layout/EventBus';
|
import EventBus from './layout/EventBus';
|
||||||
|
|
||||||
const DesignerActionRunner = new Class({
|
class DesignerActionRunner {
|
||||||
initialize(commandContext, notifier) {
|
constructor(commandContext, notifier) {
|
||||||
$assert(commandContext, 'commandContext can not be null');
|
$assert(commandContext, 'commandContext can not be null');
|
||||||
|
|
||||||
this._undoManager = new DesignerUndoManager();
|
this._undoManager = new DesignerUndoManager();
|
||||||
this._context = commandContext;
|
this._context = commandContext;
|
||||||
this._notifier = notifier;
|
this._notifier = notifier;
|
||||||
},
|
}
|
||||||
|
|
||||||
execute(command) {
|
execute(command) {
|
||||||
$assert(command, 'command can not be null');
|
$assert(command, 'command can not be null');
|
||||||
@ -33,24 +34,24 @@ const DesignerActionRunner = new Class({
|
|||||||
this._undoManager.enqueue(command);
|
this._undoManager.enqueue(command);
|
||||||
this.fireChangeEvent();
|
this.fireChangeEvent();
|
||||||
EventBus.instance.fireEvent(EventBus.events.DoLayout);
|
EventBus.instance.fireEvent(EventBus.events.DoLayout);
|
||||||
},
|
}
|
||||||
|
|
||||||
undo() {
|
undo() {
|
||||||
this._undoManager.execUndo(this._context);
|
this._undoManager.execUndo(this._context);
|
||||||
this.fireChangeEvent();
|
this.fireChangeEvent();
|
||||||
EventBus.instance.fireEvent(EventBus.events.DoLayout);
|
EventBus.instance.fireEvent(EventBus.events.DoLayout);
|
||||||
},
|
}
|
||||||
|
|
||||||
redo() {
|
redo() {
|
||||||
this._undoManager.execRedo(this._context);
|
this._undoManager.execRedo(this._context);
|
||||||
this.fireChangeEvent();
|
this.fireChangeEvent();
|
||||||
EventBus.instance.fireEvent(EventBus.events.DoLayout);
|
EventBus.instance.fireEvent(EventBus.events.DoLayout);
|
||||||
},
|
}
|
||||||
|
|
||||||
fireChangeEvent() {
|
fireChangeEvent() {
|
||||||
const event = this._undoManager.buildEvent();
|
const event = this._undoManager.buildEvent();
|
||||||
this._notifier.fireEvent('modelUpdate', event);
|
this._notifier.fireEvent('modelUpdate', event);
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
export default DesignerActionRunner;
|
export default DesignerActionRunner;
|
||||||
|
@ -15,22 +15,24 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
import { $defined } from '@wisemapping/core-js';
|
||||||
|
|
||||||
const Messages = new Class({
|
class Messages {
|
||||||
|
static init(locale) {
|
||||||
});
|
let userLocale = $defined(locale) ? locale : 'en';
|
||||||
|
|
||||||
Messages.init = (locale) => {
|
|
||||||
locale = $defined(locale) ? locale : 'en';
|
|
||||||
let bundle = Messages.BUNDLES[locale];
|
let bundle = Messages.BUNDLES[locale];
|
||||||
|
|
||||||
if (bundle == null && locale.indexOf('_') !== -1) {
|
if (bundle == null && locale.indexOf('_') !== -1) {
|
||||||
// Try to locate without the specialization ...
|
// Try to locate without the specialization ...
|
||||||
locale = locale.substring(0, locale.indexOf('_'));
|
userLocale = locale.substring(0, locale.indexOf('_'));
|
||||||
bundle = Messages.BUNDLES[locale];
|
bundle = Messages.BUNDLES[locale];
|
||||||
}
|
}
|
||||||
|
global.locale = userLocale;
|
||||||
Messages.__bundle = bundle || {};
|
Messages.__bundle = bundle || {};
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Todo: fix global assignment.
|
||||||
global.$msg = function $msg(key) {
|
global.$msg = function $msg(key) {
|
||||||
if (!Messages.__bundle) {
|
if (!Messages.__bundle) {
|
||||||
Messages.init('en');
|
Messages.init('en');
|
||||||
@ -40,5 +42,4 @@ global.$msg = function $msg(key) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Messages.BUNDLES = {};
|
Messages.BUNDLES = {};
|
||||||
|
|
||||||
export default Messages;
|
export default Messages;
|
||||||
|
@ -15,13 +15,11 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import Core from '@wisemapping/core-js';
|
import { $assert, innerXML } from '@wisemapping/core-js';
|
||||||
import XMLSerializerFactory from './persistence/XMLSerializerFactory';
|
import XMLSerializerFactory from './persistence/XMLSerializerFactory';
|
||||||
|
|
||||||
const core = Core();
|
|
||||||
|
|
||||||
const PersistenceManager = new Class({
|
const PersistenceManager = new Class({
|
||||||
initialize() {},
|
initialize() { },
|
||||||
|
|
||||||
save(mindmap, editorProperties, saveHistory, events, sync) {
|
save(mindmap, editorProperties, saveHistory, events, sync) {
|
||||||
$assert(mindmap, 'mindmap can not be null');
|
$assert(mindmap, 'mindmap can not be null');
|
||||||
@ -32,7 +30,7 @@ const PersistenceManager = new Class({
|
|||||||
|
|
||||||
const serializer = XMLSerializerFactory.getSerializerFromMindmap(mindmap);
|
const serializer = XMLSerializerFactory.getSerializerFromMindmap(mindmap);
|
||||||
const domMap = serializer.toXML(mindmap);
|
const domMap = serializer.toXML(mindmap);
|
||||||
const mapXml = core.Utils.innerXML(domMap);
|
const mapXml = innerXML(domMap);
|
||||||
|
|
||||||
const pref = JSON.stringify(editorProperties);
|
const pref = JSON.stringify(editorProperties);
|
||||||
try {
|
try {
|
||||||
|
@ -16,7 +16,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import web2d from '@wisemapping/web2d';
|
import web2d from '@wisemapping/web2d';
|
||||||
|
import { $assert } from '@wisemapping/core-js';
|
||||||
|
import Relationship from './Relationship';
|
||||||
import INodeModel from './model/INodeModel';
|
import INodeModel from './model/INodeModel';
|
||||||
import Shape from './util/Shape';
|
import Shape from './util/Shape';
|
||||||
|
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
import { $assert } from '@wisemapping/core-js';
|
||||||
import web2d from '@wisemapping/web2d';
|
import web2d from '@wisemapping/web2d';
|
||||||
|
|
||||||
const ScreenManager = new Class({
|
class ScreenManager {
|
||||||
initialize(divElement) {
|
constructor(divElement) {
|
||||||
$assert(divElement, 'can not be null');
|
$assert(divElement, 'can not be null');
|
||||||
this._divContainer = divElement;
|
this._divContainer = divElement;
|
||||||
this._padding = { x: 0, y: 0 };
|
this._padding = { x: 0, y: 0 };
|
||||||
@ -33,17 +34,17 @@ const ScreenManager = new Class({
|
|||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
setScale(scale) {
|
setScale(scale) {
|
||||||
$assert(scale, 'Screen scale can not be null');
|
$assert(scale, 'Screen scale can not be null');
|
||||||
this._scale = scale;
|
this._scale = scale;
|
||||||
},
|
}
|
||||||
|
|
||||||
addEvent(event, listener) {
|
addEvent(event, listener) {
|
||||||
if (event === 'click') this._clickEvents.push(listener);
|
if (event === 'click') this._clickEvents.push(listener);
|
||||||
else this._divContainer.bind(event, listener);
|
else this._divContainer.bind(event, listener);
|
||||||
},
|
}
|
||||||
|
|
||||||
removeEvent(event, listener) {
|
removeEvent(event, listener) {
|
||||||
if (event === 'click') {
|
if (event === 'click') {
|
||||||
@ -51,7 +52,7 @@ const ScreenManager = new Class({
|
|||||||
} else {
|
} else {
|
||||||
this._divContainer.unbind(event, listener);
|
this._divContainer.unbind(event, listener);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
fireEvent(type, event) {
|
fireEvent(type, event) {
|
||||||
if (type === 'click') {
|
if (type === 'click') {
|
||||||
@ -61,7 +62,7 @@ const ScreenManager = new Class({
|
|||||||
} else {
|
} else {
|
||||||
this._divContainer.trigger(type, event);
|
this._divContainer.trigger(type, event);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
_getElementPosition(elem) {
|
_getElementPosition(elem) {
|
||||||
// Retrieve current element position.
|
// Retrieve current element position.
|
||||||
@ -79,7 +80,7 @@ const ScreenManager = new Class({
|
|||||||
|
|
||||||
// Remove decimal part..
|
// Remove decimal part..
|
||||||
return { x, y };
|
return { x, y };
|
||||||
},
|
}
|
||||||
|
|
||||||
getWorkspaceIconPosition(e) {
|
getWorkspaceIconPosition(e) {
|
||||||
// Retrieve current icon position.
|
// Retrieve current icon position.
|
||||||
@ -114,7 +115,7 @@ const ScreenManager = new Class({
|
|||||||
|
|
||||||
// Remove decimal part..
|
// Remove decimal part..
|
||||||
return { x: x + topicPosition.x, y: y + topicPosition.y };
|
return { x: x + topicPosition.x, y: y + topicPosition.y };
|
||||||
},
|
}
|
||||||
|
|
||||||
getWorkspaceMousePosition(event) {
|
getWorkspaceMousePosition(event) {
|
||||||
// Retrieve current mouse position.
|
// Retrieve current mouse position.
|
||||||
@ -136,16 +137,16 @@ const ScreenManager = new Class({
|
|||||||
|
|
||||||
// Remove decimal part..
|
// Remove decimal part..
|
||||||
return new web2d.Point(x, y);
|
return new web2d.Point(x, y);
|
||||||
},
|
}
|
||||||
|
|
||||||
getContainer() {
|
getContainer() {
|
||||||
return this._divContainer;
|
return this._divContainer;
|
||||||
},
|
}
|
||||||
|
|
||||||
setOffset(x, y) {
|
setOffset(x, y) {
|
||||||
this._padding.x = x;
|
this._padding.x = x;
|
||||||
this._padding.y = y;
|
this._padding.y = y;
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
export default ScreenManager;
|
export default ScreenManager;
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
import { $defined, $assert } from '@wisemapping/core-js';
|
||||||
import ActionDispatcher from './ActionDispatcher';
|
import ActionDispatcher from './ActionDispatcher';
|
||||||
import DesignerActionRunner from './DesignerActionRunner';
|
import DesignerActionRunner from './DesignerActionRunner';
|
||||||
import AddTopicCommand from './commands/AddTopicCommand';
|
import AddTopicCommand from './commands/AddTopicCommand';
|
||||||
@ -27,6 +28,7 @@ import GenericFunctionCommand from './commands/GenericFunctionCommand';
|
|||||||
import MoveControlPointCommand from './commands/MoveControlPointCommand';
|
import MoveControlPointCommand from './commands/MoveControlPointCommand';
|
||||||
import ChangeFeatureToTopicCommand from './commands/ChangeFeatureToTopicCommand';
|
import ChangeFeatureToTopicCommand from './commands/ChangeFeatureToTopicCommand';
|
||||||
import NodeModel from './model/NodeModel';
|
import NodeModel from './model/NodeModel';
|
||||||
|
import EventBus from './layout/EventBus';
|
||||||
|
|
||||||
const StandaloneActionDispatcher = new Class(
|
const StandaloneActionDispatcher = new Class(
|
||||||
/** @lends StandaloneActionDispatcher */ {
|
/** @lends StandaloneActionDispatcher */ {
|
||||||
@ -70,7 +72,7 @@ const StandaloneActionDispatcher = new Class(
|
|||||||
$assert($defined(topicId), 'topicsId can not be null');
|
$assert($defined(topicId), 'topicsId can not be null');
|
||||||
$assert($defined(position), 'position can not be null');
|
$assert($defined(position), 'position can not be null');
|
||||||
|
|
||||||
const commandFunc = function (topic, value) {
|
const commandFunc = (topic, value) => {
|
||||||
const result = topic.getPosition();
|
const result = topic.getPosition();
|
||||||
EventBus.instance.fireEvent(EventBus.events.NodeMoveEvent, {
|
EventBus.instance.fireEvent(EventBus.events.NodeMoveEvent, {
|
||||||
node: topic.getModel(),
|
node: topic.getModel(),
|
||||||
@ -91,7 +93,7 @@ const StandaloneActionDispatcher = new Class(
|
|||||||
|
|
||||||
/** */
|
/** */
|
||||||
changeFontStyleToTopic(topicsIds) {
|
changeFontStyleToTopic(topicsIds) {
|
||||||
const commandFunc = function (topic) {
|
const commandFunc = (topic) => {
|
||||||
const result = topic.getFontStyle();
|
const result = topic.getFontStyle();
|
||||||
const style = result === 'italic' ? 'normal' : 'italic';
|
const style = result === 'italic' ? 'normal' : 'italic';
|
||||||
topic.setFontStyle(style, true);
|
topic.setFontStyle(style, true);
|
||||||
@ -105,7 +107,7 @@ const StandaloneActionDispatcher = new Class(
|
|||||||
changeTextToTopic(topicsIds, text) {
|
changeTextToTopic(topicsIds, text) {
|
||||||
$assert($defined(topicsIds), 'topicsIds can not be null');
|
$assert($defined(topicsIds), 'topicsIds can not be null');
|
||||||
|
|
||||||
const commandFunc = function (topic, value) {
|
const commandFunc = (topic, value) => {
|
||||||
const result = topic.getText();
|
const result = topic.getText();
|
||||||
topic.setText(value);
|
topic.setText(value);
|
||||||
return result;
|
return result;
|
||||||
@ -121,7 +123,7 @@ const StandaloneActionDispatcher = new Class(
|
|||||||
$assert(topicIds, 'topicIds can not be null');
|
$assert(topicIds, 'topicIds can not be null');
|
||||||
$assert(fontFamily, 'fontFamily can not be null');
|
$assert(fontFamily, 'fontFamily can not be null');
|
||||||
|
|
||||||
const commandFunc = function (topic, fontFamily) {
|
const commandFunc = (topic, fontFamily) => {
|
||||||
const result = topic.getFontFamily();
|
const result = topic.getFontFamily();
|
||||||
topic.setFontFamily(fontFamily, true);
|
topic.setFontFamily(fontFamily, true);
|
||||||
|
|
||||||
@ -138,7 +140,7 @@ const StandaloneActionDispatcher = new Class(
|
|||||||
$assert(topicsIds, 'topicIds can not be null');
|
$assert(topicsIds, 'topicIds can not be null');
|
||||||
$assert(color, 'color can not be null');
|
$assert(color, 'color can not be null');
|
||||||
|
|
||||||
const commandFunc = function (topic, color) {
|
const commandFunc = (topic, color) => {
|
||||||
const result = topic.getFontColor();
|
const result = topic.getFontColor();
|
||||||
topic.setFontColor(color, true);
|
topic.setFontColor(color, true);
|
||||||
return result;
|
return result;
|
||||||
@ -154,7 +156,7 @@ const StandaloneActionDispatcher = new Class(
|
|||||||
$assert(topicsIds, 'topicIds can not be null');
|
$assert(topicsIds, 'topicIds can not be null');
|
||||||
$assert(color, 'color can not be null');
|
$assert(color, 'color can not be null');
|
||||||
|
|
||||||
const commandFunc = function (topic, color) {
|
const commandFunc = (topic, color) => {
|
||||||
const result = topic.getBackgroundColor();
|
const result = topic.getBackgroundColor();
|
||||||
topic.setBackgroundColor(color);
|
topic.setBackgroundColor(color);
|
||||||
return result;
|
return result;
|
||||||
@ -170,7 +172,7 @@ const StandaloneActionDispatcher = new Class(
|
|||||||
$assert(topicsIds, 'topicIds can not be null');
|
$assert(topicsIds, 'topicIds can not be null');
|
||||||
$assert(color, 'topicIds can not be null');
|
$assert(color, 'topicIds can not be null');
|
||||||
|
|
||||||
const commandFunc = function (topic, color) {
|
const commandFunc = (topic, color) => {
|
||||||
const result = topic.getBorderColor();
|
const result = topic.getBorderColor();
|
||||||
topic.setBorderColor(color);
|
topic.setBorderColor(color);
|
||||||
return result;
|
return result;
|
||||||
@ -186,7 +188,7 @@ const StandaloneActionDispatcher = new Class(
|
|||||||
$assert(topicsIds, 'topicIds can not be null');
|
$assert(topicsIds, 'topicIds can not be null');
|
||||||
$assert(size, 'size can not be null');
|
$assert(size, 'size can not be null');
|
||||||
|
|
||||||
const commandFunc = function (topic, size) {
|
const commandFunc = (topic, size) => {
|
||||||
const result = topic.getFontSize();
|
const result = topic.getFontSize();
|
||||||
topic.setFontSize(size, true);
|
topic.setFontSize(size, true);
|
||||||
|
|
||||||
@ -203,7 +205,7 @@ const StandaloneActionDispatcher = new Class(
|
|||||||
$assert(topicsIds, 'topicsIds can not be null');
|
$assert(topicsIds, 'topicsIds can not be null');
|
||||||
$assert(shapeType, 'shapeType can not be null');
|
$assert(shapeType, 'shapeType can not be null');
|
||||||
|
|
||||||
const commandFunc = function (topic, shapeType) {
|
const commandFunc = (topic, shapeType) => {
|
||||||
const result = topic.getShapeType();
|
const result = topic.getShapeType();
|
||||||
topic.setShapeType(shapeType, true);
|
topic.setShapeType(shapeType, true);
|
||||||
return result;
|
return result;
|
||||||
@ -217,7 +219,7 @@ const StandaloneActionDispatcher = new Class(
|
|||||||
changeFontWeightToTopic(topicsIds) {
|
changeFontWeightToTopic(topicsIds) {
|
||||||
$assert(topicsIds, 'topicsIds can not be null');
|
$assert(topicsIds, 'topicsIds can not be null');
|
||||||
|
|
||||||
const commandFunc = function (topic) {
|
const commandFunc = (topic) => {
|
||||||
const result = topic.getFontWeight();
|
const result = topic.getFontWeight();
|
||||||
const weight = result === 'bold' ? 'normal' : 'bold';
|
const weight = result === 'bold' ? 'normal' : 'bold';
|
||||||
topic.setFontWeight(weight, true);
|
topic.setFontWeight(weight, true);
|
||||||
@ -234,7 +236,7 @@ const StandaloneActionDispatcher = new Class(
|
|||||||
shrinkBranch(topicsIds, collapse) {
|
shrinkBranch(topicsIds, collapse) {
|
||||||
$assert(topicsIds, 'topicsIds can not be null');
|
$assert(topicsIds, 'topicsIds can not be null');
|
||||||
|
|
||||||
const commandFunc = function (topic, isShrink) {
|
const commandFunc = (topic, isShrink) => {
|
||||||
topic.setChildrenShrunken(isShrink);
|
topic.setChildrenShrunken(isShrink);
|
||||||
return !isShrink;
|
return !isShrink;
|
||||||
};
|
};
|
||||||
@ -293,12 +295,9 @@ const CommandContext = new Class(
|
|||||||
const ids = designerTopics.map((topic) => topic.getId());
|
const ids = designerTopics.map((topic) => topic.getId());
|
||||||
$assert(
|
$assert(
|
||||||
result.length === topicsIds.length,
|
result.length === topicsIds.length,
|
||||||
`Could not find topic. Result:${
|
`Could not find topic. Result:${result
|
||||||
result
|
}, Filter Criteria:${topicsIds
|
||||||
}, Filter Criteria:${
|
}, Current Topics: [${ids
|
||||||
topicsIds
|
|
||||||
}, Current Topics: [${
|
|
||||||
ids
|
|
||||||
}]`,
|
}]`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
import { $assert } from '@wisemapping/core-js';
|
||||||
import web2d from '@wisemapping/web2d';
|
import web2d from '@wisemapping/web2d';
|
||||||
|
|
||||||
const Workspace = new Class({
|
class Workspace {
|
||||||
initialize(screenManager, zoom) {
|
constructor(screenManager, zoom) {
|
||||||
// Create a suitable container ...
|
// Create a suitable container ...
|
||||||
$assert(screenManager, 'Div container can not be null');
|
$assert(screenManager, 'Div container can not be null');
|
||||||
$assert(zoom, 'zoom container can not be null');
|
$assert(zoom, 'zoom container can not be null');
|
||||||
@ -41,7 +42,7 @@ const Workspace = new Class({
|
|||||||
// Register drag events ...
|
// Register drag events ...
|
||||||
this._registerDragEvents();
|
this._registerDragEvents();
|
||||||
this._eventsEnabled = true;
|
this._eventsEnabled = true;
|
||||||
},
|
}
|
||||||
|
|
||||||
_createWorkspace() {
|
_createWorkspace() {
|
||||||
// Initialize workspace ...
|
// Initialize workspace ...
|
||||||
@ -60,7 +61,7 @@ const Workspace = new Class({
|
|||||||
};
|
};
|
||||||
web2d.Toolkit.init();
|
web2d.Toolkit.init();
|
||||||
return new web2d.Workspace(workspaceProfile);
|
return new web2d.Workspace(workspaceProfile);
|
||||||
},
|
}
|
||||||
|
|
||||||
append(shape) {
|
append(shape) {
|
||||||
if ($defined(shape.addToWorkspace)) {
|
if ($defined(shape.addToWorkspace)) {
|
||||||
@ -68,7 +69,7 @@ const Workspace = new Class({
|
|||||||
} else {
|
} else {
|
||||||
this._workspace.append(shape);
|
this._workspace.append(shape);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
removeChild(shape) {
|
removeChild(shape) {
|
||||||
// Element is a node, not a web2d element?
|
// Element is a node, not a web2d element?
|
||||||
@ -77,21 +78,21 @@ const Workspace = new Class({
|
|||||||
} else {
|
} else {
|
||||||
this._workspace.removeChild(shape);
|
this._workspace.removeChild(shape);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
addEvent(type, listener) {
|
addEvent(type, listener) {
|
||||||
this._workspace.addEvent(type, listener);
|
this._workspace.addEvent(type, listener);
|
||||||
},
|
}
|
||||||
|
|
||||||
removeEvent(type, listener) {
|
removeEvent(type, listener) {
|
||||||
$assert(type, 'type can not be null');
|
$assert(type, 'type can not be null');
|
||||||
$assert(listener, 'listener can not be null');
|
$assert(listener, 'listener can not be null');
|
||||||
this._workspace.removeEvent(type, listener);
|
this._workspace.removeEvent(type, listener);
|
||||||
},
|
}
|
||||||
|
|
||||||
getSize() {
|
getSize() {
|
||||||
return this._workspace.getCoordSize();
|
return this._workspace.getCoordSize();
|
||||||
},
|
}
|
||||||
|
|
||||||
setZoom(zoom, center) {
|
setZoom(zoom, center) {
|
||||||
this._zoom = zoom;
|
this._zoom = zoom;
|
||||||
@ -134,23 +135,23 @@ const Workspace = new Class({
|
|||||||
|
|
||||||
// Some changes in the screen. Let's fire an update event...
|
// Some changes in the screen. Let's fire an update event...
|
||||||
this._screenManager.fireEvent('update');
|
this._screenManager.fireEvent('update');
|
||||||
},
|
}
|
||||||
|
|
||||||
getScreenManager() {
|
getScreenManager() {
|
||||||
return this._screenManager;
|
return this._screenManager;
|
||||||
},
|
}
|
||||||
|
|
||||||
enableWorkspaceEvents(value) {
|
enableWorkspaceEvents(value) {
|
||||||
this._eventsEnabled = value;
|
this._eventsEnabled = value;
|
||||||
},
|
}
|
||||||
|
|
||||||
isWorkspaceEventsEnabled() {
|
isWorkspaceEventsEnabled() {
|
||||||
return this._eventsEnabled;
|
return this._eventsEnabled;
|
||||||
},
|
}
|
||||||
|
|
||||||
dumpNativeChart() {
|
dumpNativeChart() {
|
||||||
return this._workspace.dumpNativeChart();
|
return this._workspace.dumpNativeChart();
|
||||||
},
|
}
|
||||||
|
|
||||||
_registerDragEvents() {
|
_registerDragEvents() {
|
||||||
const workspace = this._workspace;
|
const workspace = this._workspace;
|
||||||
@ -191,7 +192,7 @@ const Workspace = new Class({
|
|||||||
screenManager.addEvent('mousemove', workspace._mouseMoveListener);
|
screenManager.addEvent('mousemove', workspace._mouseMoveListener);
|
||||||
|
|
||||||
// Register mouse up listeners ...
|
// Register mouse up listeners ...
|
||||||
workspace._mouseUpListener = function (event) {
|
workspace._mouseUpListener = function () {
|
||||||
screenManager.removeEvent('mousemove', workspace._mouseMoveListener);
|
screenManager.removeEvent('mousemove', workspace._mouseMoveListener);
|
||||||
screenManager.removeEvent('mouseup', workspace._mouseUpListener);
|
screenManager.removeEvent('mouseup', workspace._mouseUpListener);
|
||||||
workspace._mouseUpListener = null;
|
workspace._mouseUpListener = null;
|
||||||
@ -214,11 +215,11 @@ const Workspace = new Class({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
screenManager.addEvent('mousedown', mouseDownListener);
|
screenManager.addEvent('mousedown', mouseDownListener);
|
||||||
},
|
}
|
||||||
|
|
||||||
setViewPort(size) {
|
setViewPort(size) {
|
||||||
this._viewPort = size;
|
this._viewPort = size;
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
export default Workspace;
|
export default Workspace;
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import $ from '@libraries/jquery-2.1.0';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$(document).trigger('loadcomplete', 'mind');
|
$(document).trigger('loadcomplete', 'mind');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -16,14 +16,14 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const FeatureModel = new Class(/** @lends FeatureModel */{
|
class FeatureModel {
|
||||||
/**
|
/**
|
||||||
* @constructs
|
* @constructs
|
||||||
* @param type
|
* @param type
|
||||||
* @throws will throw an exception if type is null or undefined
|
* @throws will throw an exception if type is null or undefined
|
||||||
* assigns a unique id and the given type to the new model
|
* assigns a unique id and the given type to the new model
|
||||||
*/
|
*/
|
||||||
initialize(type) {
|
constructor(type) {
|
||||||
$assert(type, 'type can not be null');
|
$assert(type, 'type can not be null');
|
||||||
this._id = FeatureModel._nextUUID();
|
this._id = FeatureModel._nextUUID();
|
||||||
|
|
||||||
@ -31,51 +31,49 @@ const FeatureModel = new Class(/** @lends FeatureModel */{
|
|||||||
this._attributes = {};
|
this._attributes = {};
|
||||||
|
|
||||||
// Create type method ...
|
// Create type method ...
|
||||||
this[`is${$.camelCase(type)}Model`] = function () {
|
this[`is${$.camelCase(type)}Model`] = () => true;
|
||||||
return true;
|
}
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getAttributes() {
|
getAttributes() {
|
||||||
return Object.clone(this._attributes);
|
return Object.clone(this._attributes);
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
setAttributes(attributes) {
|
setAttributes(attributes) {
|
||||||
for (key in attributes) {
|
for (key in attributes) {
|
||||||
this[`set${key.capitalize()}`](attributes[key]);
|
this[`set${key.capitalize()}`](attributes[key]);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
setAttribute(key, value) {
|
setAttribute(key, value) {
|
||||||
$assert(key, 'key id can not be null');
|
$assert(key, 'key id can not be null');
|
||||||
this._attributes[key] = value;
|
this._attributes[key] = value;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getAttribute(key) {
|
getAttribute(key) {
|
||||||
$assert(key, 'key id can not be null');
|
$assert(key, 'key id can not be null');
|
||||||
|
|
||||||
return this._attributes[key];
|
return this._attributes[key];
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getId() {
|
getId() {
|
||||||
return this._id;
|
return this._id;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
setId(id) {
|
setId(id) {
|
||||||
this._id = id;
|
this._id = id;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getType() {
|
getType() {
|
||||||
return this._type;
|
return this._type;
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
FeatureModel._nextUUID = function _nextUUID() {
|
FeatureModel._nextUUID = function _nextUUID() {
|
||||||
if (!$defined(FeatureModel._uuid)) {
|
if (!$defined(FeatureModel._uuid)) {
|
||||||
|
@ -16,69 +16,60 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const IMindmap = new Class(/** @lends IMindmap */{
|
class IMindmap {
|
||||||
/**
|
|
||||||
* @constructs
|
|
||||||
* @abstract
|
|
||||||
*/
|
|
||||||
initialize() {
|
|
||||||
throw 'Unsupported operation';
|
|
||||||
},
|
|
||||||
|
|
||||||
/** */
|
|
||||||
getCentralTopic() {
|
getCentralTopic() {
|
||||||
return this.getBranches()[0];
|
return this.getBranches()[0];
|
||||||
},
|
}
|
||||||
|
|
||||||
/** @abstract */
|
/** @abstract */
|
||||||
getDescription() {
|
getDescription() {
|
||||||
throw 'Unsupported operation';
|
throw 'Unsupported operation';
|
||||||
},
|
}
|
||||||
|
|
||||||
/** @abstract */
|
/** @abstract */
|
||||||
setDescription(value) {
|
setDescription(value) {
|
||||||
throw 'Unsupported operation';
|
throw 'Unsupported operation';
|
||||||
},
|
}
|
||||||
|
|
||||||
/** @abstract */
|
/** @abstract */
|
||||||
getId() {
|
getId() {
|
||||||
throw 'Unsupported operation';
|
throw 'Unsupported operation';
|
||||||
},
|
}
|
||||||
|
|
||||||
/** @abstract */
|
/** @abstract */
|
||||||
setId(id) {
|
setId(id) {
|
||||||
throw 'Unsupported operation';
|
throw 'Unsupported operation';
|
||||||
},
|
}
|
||||||
|
|
||||||
/** @abstract */
|
/** @abstract */
|
||||||
getVersion() {
|
getVersion() {
|
||||||
throw 'Unsupported operation';
|
throw 'Unsupported operation';
|
||||||
},
|
}
|
||||||
|
|
||||||
/** @abstract */
|
/** @abstract */
|
||||||
setVersion(version) {
|
setVersion(version) {
|
||||||
throw 'Unsupported operation';
|
throw 'Unsupported operation';
|
||||||
},
|
}
|
||||||
|
|
||||||
/** @abstract */
|
/** @abstract */
|
||||||
addBranch(nodeModel) {
|
addBranch(nodeModel) {
|
||||||
throw 'Unsupported operation';
|
throw 'Unsupported operation';
|
||||||
},
|
}
|
||||||
|
|
||||||
/** @abstract */
|
/** @abstract */
|
||||||
getBranches() {
|
getBranches() {
|
||||||
throw 'Unsupported operation';
|
throw 'Unsupported operation';
|
||||||
},
|
}
|
||||||
|
|
||||||
/** @abstract */
|
/** @abstract */
|
||||||
removeBranch(node) {
|
removeBranch(node) {
|
||||||
throw 'Unsupported operation';
|
throw 'Unsupported operation';
|
||||||
},
|
}
|
||||||
|
|
||||||
/** @abstract */
|
/** @abstract */
|
||||||
getRelationships() {
|
getRelationships() {
|
||||||
throw 'Unsupported operation';
|
throw 'Unsupported operation';
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param parent
|
* @param parent
|
||||||
@ -94,7 +85,7 @@ const IMindmap = new Class(/** @lends IMindmap */{
|
|||||||
|
|
||||||
// Remove from the branch ...
|
// Remove from the branch ...
|
||||||
this.removeBranch(child);
|
this.removeBranch(child);
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param child
|
* @param child
|
||||||
@ -108,32 +99,32 @@ const IMindmap = new Class(/** @lends IMindmap */{
|
|||||||
|
|
||||||
parent.removeChild(child);
|
parent.removeChild(child);
|
||||||
this.addBranch(child);
|
this.addBranch(child);
|
||||||
},
|
}
|
||||||
|
|
||||||
/** @abstract */
|
/** @abstract */
|
||||||
hasAlreadyAdded(node) {
|
hasAlreadyAdded(node) {
|
||||||
throw 'Unsupported operation';
|
throw 'Unsupported operation';
|
||||||
},
|
}
|
||||||
|
|
||||||
/** @abstract */
|
/** @abstract */
|
||||||
createNode(type, id) {
|
createNode(type, id) {
|
||||||
throw 'Unsupported operation';
|
throw 'Unsupported operation';
|
||||||
},
|
}
|
||||||
|
|
||||||
/** @abstract */
|
/** @abstract */
|
||||||
createRelationship(fromNode, toNode) {
|
createRelationship(fromNode, toNode) {
|
||||||
throw 'Unsupported operation';
|
throw 'Unsupported operation';
|
||||||
},
|
}
|
||||||
|
|
||||||
/** @abstract */
|
/** @abstract */
|
||||||
addRelationship(rel) {
|
addRelationship(rel) {
|
||||||
throw 'Unsupported operation';
|
throw 'Unsupported operation';
|
||||||
},
|
}
|
||||||
|
|
||||||
/** @abstract */
|
/** @abstract */
|
||||||
deleteRelationship(relationship) {
|
deleteRelationship(relationship) {
|
||||||
throw 'Unsupported operation';
|
throw 'Unsupported operation';
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
inspect() {
|
inspect() {
|
||||||
@ -155,7 +146,7 @@ const IMindmap = new Class(/** @lends IMindmap */{
|
|||||||
|
|
||||||
result = `${result} } `;
|
result = `${result} } `;
|
||||||
return result;
|
return result;
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param target
|
* @param target
|
||||||
@ -175,7 +166,7 @@ const IMindmap = new Class(/** @lends IMindmap */{
|
|||||||
snode.copyTo(tnode);
|
snode.copyTo(tnode);
|
||||||
target.addBranch(tnode);
|
target.addBranch(tnode);
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
export default IMindmap;
|
export default IMindmap;
|
||||||
|
@ -1,11 +1,3 @@
|
|||||||
/* eslint-disable no-shadow */
|
|
||||||
/* eslint-disable no-throw-literal */
|
|
||||||
/* eslint-disable no-unused-vars */
|
|
||||||
/* eslint-disable no-eval */
|
|
||||||
/* eslint-disable radix */
|
|
||||||
/* eslint-disable no-restricted-globals */
|
|
||||||
/* eslint-disable no-param-reassign */
|
|
||||||
/* eslint-disable no-underscore-dangle */
|
|
||||||
/*
|
/*
|
||||||
* Copyright [2015] [wisemapping]
|
* Copyright [2015] [wisemapping]
|
||||||
*
|
*
|
||||||
@ -23,65 +15,58 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import coreJs from '@wisemapping/core-js';
|
import { $assert, $defined } from '@wisemapping/core-js';
|
||||||
import _ from '../../../../../libraries/underscore-min';
|
import _ from '../../../../../libraries/underscore-min';
|
||||||
|
|
||||||
const core = coreJs();
|
class INodeModel {
|
||||||
|
constructor(mindmap) {
|
||||||
const INodeModel = new Class(
|
$assert(mindmap && mindmap.getBranches, 'mindmap can not be null');
|
||||||
/** @lends INodeModel */ {
|
|
||||||
/**
|
|
||||||
* @constructs
|
|
||||||
* @param mindmap
|
|
||||||
*/
|
|
||||||
initialize(mindmap) {
|
|
||||||
core.Function.$assert(mindmap && mindmap.getBranches, 'mindmap can not be null');
|
|
||||||
this._mindmap = mindmap;
|
this._mindmap = mindmap;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getId() {
|
getId() {
|
||||||
return this.getProperty('id');
|
return this.getProperty('id');
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
setId(id) {
|
setId(id) {
|
||||||
if (core.Function.$defined(id) && id > INodeModel._uuid) {
|
if ($defined(id) && id > INodeModel._uuid) {
|
||||||
INodeModel._uuid = id;
|
INodeModel._uuid = id;
|
||||||
}
|
}
|
||||||
if (!core.Function.$defined(id)) {
|
if (!$defined(id)) {
|
||||||
id = INodeModel._nextUUID();
|
id = INodeModel._nextUUID();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.putProperty('id', id);
|
this.putProperty('id', id);
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getType() {
|
getType() {
|
||||||
return this.getProperty('type');
|
return this.getProperty('type');
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
setType(type) {
|
setType(type) {
|
||||||
this.putProperty('type', type);
|
this.putProperty('type', type);
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
setText(text) {
|
setText(text) {
|
||||||
this.putProperty('text', text);
|
this.putProperty('text', text);
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getText() {
|
getText() {
|
||||||
return this.getProperty('text');
|
return this.getProperty('text');
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
setPosition(x, y) {
|
setPosition(x, y) {
|
||||||
core.Function.$assert(!isNaN(parseInt(x)), `x position is not valid:${x}`);
|
$assert(!Number.isNaN(parseInt(x, 10)), `x position is not valid:${x}`);
|
||||||
core.Function.$assert(!isNaN(parseInt(y)), `y position is not valid:${y}`);
|
$assert(!Number.isNaN(parseInt(y, 10)), `y position is not valid:${y}`);
|
||||||
this.putProperty('position', `{x:${parseInt(x)},y:${parseInt(y)}}`);
|
this.putProperty('position', `{x:${parseInt(x, 10)},y:${parseInt(y, 10)}}`);
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getPosition() {
|
getPosition() {
|
||||||
@ -91,12 +76,12 @@ const INodeModel = new Class(
|
|||||||
result = eval(`(${value})`);
|
result = eval(`(${value})`);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
setImageSize(width, height) {
|
setImageSize(width, height) {
|
||||||
this.putProperty('imageSize', `{width:${width},height:${height}}`);
|
this.putProperty('imageSize', `{width:${width},height:${height}}`);
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getImageSize() {
|
getImageSize() {
|
||||||
@ -106,32 +91,32 @@ const INodeModel = new Class(
|
|||||||
result = eval(`(${value})`);
|
result = eval(`(${value})`);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
setImageUrl(url) {
|
setImageUrl(url) {
|
||||||
this.putProperty('imageUrl', url);
|
this.putProperty('imageUrl', url);
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getMetadata() {
|
getMetadata() {
|
||||||
return this.getProperty('metadata');
|
return this.getProperty('metadata');
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
setMetadata(json) {
|
setMetadata(json) {
|
||||||
this.putProperty('metadata', json);
|
this.putProperty('metadata', json);
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getImageUrl() {
|
getImageUrl() {
|
||||||
return this.getProperty('imageUrl');
|
return this.getProperty('imageUrl');
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getMindmap() {
|
getMindmap() {
|
||||||
return this._mindmap;
|
return this._mindmap;
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* lets the mindmap handle the disconnect node operation
|
* lets the mindmap handle the disconnect node operation
|
||||||
@ -140,133 +125,133 @@ const INodeModel = new Class(
|
|||||||
disconnect() {
|
disconnect() {
|
||||||
const mindmap = this.getMindmap();
|
const mindmap = this.getMindmap();
|
||||||
mindmap.disconnect(this);
|
mindmap.disconnect(this);
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getShapeType() {
|
getShapeType() {
|
||||||
return this.getProperty('shapeType');
|
return this.getProperty('shapeType');
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
setShapeType(type) {
|
setShapeType(type) {
|
||||||
this.putProperty('shapeType', type);
|
this.putProperty('shapeType', type);
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
setOrder(value) {
|
setOrder(value) {
|
||||||
core.Function.$assert(
|
$assert(
|
||||||
(typeof value === 'number' && isFinite(value)) || value == null,
|
(typeof value === 'number' && isFinite(value)) || value == null,
|
||||||
'Order must be null or a number',
|
'Order must be null or a number',
|
||||||
);
|
);
|
||||||
this.putProperty('order', value);
|
this.putProperty('order', value);
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getOrder() {
|
getOrder() {
|
||||||
return this.getProperty('order');
|
return this.getProperty('order');
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
setFontFamily(fontFamily) {
|
setFontFamily(fontFamily) {
|
||||||
this.putProperty('fontFamily', fontFamily);
|
this.putProperty('fontFamily', fontFamily);
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getFontFamily() {
|
getFontFamily() {
|
||||||
return this.getProperty('fontFamily');
|
return this.getProperty('fontFamily');
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
setFontStyle(fontStyle) {
|
setFontStyle(fontStyle) {
|
||||||
this.putProperty('fontStyle', fontStyle);
|
this.putProperty('fontStyle', fontStyle);
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getFontStyle() {
|
getFontStyle() {
|
||||||
return this.getProperty('fontStyle');
|
return this.getProperty('fontStyle');
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
setFontWeight(weight) {
|
setFontWeight(weight) {
|
||||||
this.putProperty('fontWeight', weight);
|
this.putProperty('fontWeight', weight);
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getFontWeight() {
|
getFontWeight() {
|
||||||
return this.getProperty('fontWeight');
|
return this.getProperty('fontWeight');
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
setFontColor(color) {
|
setFontColor(color) {
|
||||||
this.putProperty('fontColor', color);
|
this.putProperty('fontColor', color);
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getFontColor() {
|
getFontColor() {
|
||||||
return this.getProperty('fontColor');
|
return this.getProperty('fontColor');
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
setFontSize(size) {
|
setFontSize(size) {
|
||||||
this.putProperty('fontSize', size);
|
this.putProperty('fontSize', size);
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getFontSize() {
|
getFontSize() {
|
||||||
return this.getProperty('fontSize');
|
return this.getProperty('fontSize');
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getBorderColor() {
|
getBorderColor() {
|
||||||
return this.getProperty('borderColor');
|
return this.getProperty('borderColor');
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
setBorderColor(color) {
|
setBorderColor(color) {
|
||||||
this.putProperty('borderColor', color);
|
this.putProperty('borderColor', color);
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getBackgroundColor() {
|
getBackgroundColor() {
|
||||||
return this.getProperty('backgroundColor');
|
return this.getProperty('backgroundColor');
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
setBackgroundColor(color) {
|
setBackgroundColor(color) {
|
||||||
this.putProperty('backgroundColor', color);
|
this.putProperty('backgroundColor', color);
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
areChildrenShrunken() {
|
areChildrenShrunken() {
|
||||||
const result = this.getProperty('shrunken');
|
const result = this.getProperty('shrunken');
|
||||||
return core.Function.$defined(result) ? result : false;
|
$defined(result) ? result : false;
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {Boolean} true if the children nodes are hidden by the shrink option
|
* @return {Boolean} true if the children nodes are hidden by the shrink option
|
||||||
*/
|
*/
|
||||||
setChildrenShrunken(value) {
|
setChildrenShrunken(value) {
|
||||||
this.putProperty('shrunken', value);
|
this.putProperty('shrunken', value);
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {Boolean} true
|
* @return {Boolean} true
|
||||||
*/
|
*/
|
||||||
isNodeModel() {
|
isNodeModel() {
|
||||||
return true;
|
return true;
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {Boolean} true if the node model has a parent assigned to it
|
* @return {Boolean} true if the node model has a parent assigned to it
|
||||||
*/
|
*/
|
||||||
isConnected() {
|
isConnected() {
|
||||||
return this.getParent() != null;
|
return this.getParent() != null;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** @abstract */
|
/** @abstract */
|
||||||
append(node) {
|
append(node) {
|
||||||
throw 'Unsupported operation';
|
throw 'Unsupported operation';
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* lets the mindmap handle the connect node operation
|
* lets the mindmap handle the connect node operation
|
||||||
@ -274,10 +259,10 @@ const INodeModel = new Class(
|
|||||||
* @see mindplot.model.IMindmap.connect
|
* @see mindplot.model.IMindmap.connect
|
||||||
*/
|
*/
|
||||||
connectTo(parent) {
|
connectTo(parent) {
|
||||||
core.Function.$assert(parent, 'parent can not be null');
|
$assert(parent, 'parent can not be null');
|
||||||
const mindmap = this.getMindmap();
|
const mindmap = this.getMindmap();
|
||||||
mindmap.connect(parent, this);
|
mindmap.connect(parent, this);
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param target
|
* @param target
|
||||||
@ -303,7 +288,7 @@ const INodeModel = new Class(
|
|||||||
});
|
});
|
||||||
|
|
||||||
return target;
|
return target;
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* lets parent handle the delete node operation, or, if none defined, calls the mindmap to
|
* lets parent handle the delete node operation, or, if none defined, calls the mindmap to
|
||||||
@ -314,7 +299,7 @@ const INodeModel = new Class(
|
|||||||
|
|
||||||
// console.log("Before:" + mindmap.inspect());
|
// console.log("Before:" + mindmap.inspect());
|
||||||
const parent = this.getParent();
|
const parent = this.getParent();
|
||||||
if (core.Function.$defined(parent)) {
|
if ($defined(parent)) {
|
||||||
parent.removeChild(this);
|
parent.removeChild(this);
|
||||||
} else {
|
} else {
|
||||||
// If it has not parent, it must be an isolate topic ...
|
// If it has not parent, it must be an isolate topic ...
|
||||||
@ -322,37 +307,37 @@ const INodeModel = new Class(
|
|||||||
}
|
}
|
||||||
// It's an isolated node. It must be a hole branch ...
|
// It's an isolated node. It must be a hole branch ...
|
||||||
// console.log("After:" + mindmap.inspect());
|
// console.log("After:" + mindmap.inspect());
|
||||||
},
|
}
|
||||||
|
|
||||||
/** @abstract */
|
/** @abstract */
|
||||||
getPropertiesKeys() {
|
getPropertiesKeys() {
|
||||||
throw 'Unsupported operation';
|
throw 'Unsupported operation';
|
||||||
},
|
}
|
||||||
|
|
||||||
/** @abstract */
|
/** @abstract */
|
||||||
putProperty(key, value) {
|
putProperty(key, value) {
|
||||||
throw 'Unsupported operation';
|
throw 'Unsupported operation';
|
||||||
},
|
}
|
||||||
|
|
||||||
/** @abstract */
|
/** @abstract */
|
||||||
setParent(parent) {
|
setParent(parent) {
|
||||||
throw 'Unsupported operation';
|
throw 'Unsupported operation';
|
||||||
},
|
}
|
||||||
|
|
||||||
/** @abstract */
|
/** @abstract */
|
||||||
getChildren() {
|
getChildren() {
|
||||||
throw 'Unsupported operation';
|
throw 'Unsupported operation';
|
||||||
},
|
}
|
||||||
|
|
||||||
/** @abstract */
|
/** @abstract */
|
||||||
getParent() {
|
getParent() {
|
||||||
throw 'Unsupported operation';
|
throw 'Unsupported operation';
|
||||||
},
|
}
|
||||||
|
|
||||||
/** @abstract */
|
/** @abstract */
|
||||||
clone() {
|
clone() {
|
||||||
throw 'Unsupported operation';
|
throw 'Unsupported operation';
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
inspect() {
|
inspect() {
|
||||||
@ -374,14 +359,13 @@ const INodeModel = new Class(
|
|||||||
|
|
||||||
result = `${result} }`;
|
result = `${result} }`;
|
||||||
return result;
|
return result;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** @abstract */
|
/** @abstract */
|
||||||
removeChild(child) {
|
removeChild(child) {
|
||||||
throw 'Unsupported operation';
|
throw 'Unsupported operation';
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {String}
|
* @enum {String}
|
||||||
@ -418,7 +402,7 @@ INodeModel.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE = 220;
|
|||||||
* @todo: This method must be implemented. (unascribed)
|
* @todo: This method must be implemented. (unascribed)
|
||||||
*/
|
*/
|
||||||
INodeModel._nextUUID = () => {
|
INodeModel._nextUUID = () => {
|
||||||
if (!core.Function.$defined(INodeModel._uuid)) {
|
if (!$defined(INodeModel._uuid)) {
|
||||||
INodeModel._uuid = 0;
|
INodeModel._uuid = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,29 +17,23 @@
|
|||||||
*/
|
*/
|
||||||
import FeatureModel from './FeatureModel';
|
import FeatureModel from './FeatureModel';
|
||||||
|
|
||||||
const IconModel = new Class(/** @lends IconModel */{
|
class IconModel extends FeatureModel {
|
||||||
Extends: FeatureModel,
|
constructor(attributes) {
|
||||||
/**
|
super(IconModel.FEATURE_TYPE);
|
||||||
* @constructs
|
|
||||||
* @param attributes
|
|
||||||
* @extends mindplot.model.FeatureModel
|
|
||||||
*/
|
|
||||||
initialize(attributes) {
|
|
||||||
this.parent(IconModel.FEATURE_TYPE);
|
|
||||||
this.setIconType(attributes.id);
|
this.setIconType(attributes.id);
|
||||||
},
|
}
|
||||||
|
|
||||||
/** @return the icon type id */
|
/** @return the icon type id */
|
||||||
getIconType() {
|
getIconType() {
|
||||||
return this.getAttribute('id');
|
return this.getAttribute('id');
|
||||||
},
|
}
|
||||||
|
|
||||||
/** @param {String} iconType the icon type id */
|
/** @param {String} iconType the icon type id */
|
||||||
setIconType(iconType) {
|
setIconType(iconType) {
|
||||||
$assert(iconType, 'iconType id can not be null');
|
$assert(iconType, 'iconType id can not be null');
|
||||||
this.setAttribute('id', iconType);
|
this.setAttribute('id', iconType);
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constant
|
* @constant
|
||||||
|
@ -17,22 +17,16 @@
|
|||||||
*/
|
*/
|
||||||
import FeatureModel from './FeatureModel';
|
import FeatureModel from './FeatureModel';
|
||||||
|
|
||||||
const LinkModel = new Class(/** @lends LinkModel */{
|
class LinkModel extends FeatureModel {
|
||||||
Extends: FeatureModel,
|
constructor(attributes) {
|
||||||
/**
|
super(LinkModel.FEATURE_TYPE);
|
||||||
* @constructs
|
|
||||||
* @param attributes
|
|
||||||
* @extends mindplot.model.FeatureModel
|
|
||||||
*/
|
|
||||||
initialize(attributes) {
|
|
||||||
this.parent(LinkModel.FEATURE_TYPE);
|
|
||||||
this.setUrl(attributes.url);
|
this.setUrl(attributes.url);
|
||||||
},
|
}
|
||||||
|
|
||||||
/** @return {String} the url attribute value */
|
/** @return {String} the url attribute value */
|
||||||
getUrl() {
|
getUrl() {
|
||||||
return this.getAttribute('url');
|
return this.getAttribute('url');
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {String} url a URL provided by the user to set the link to
|
* @param {String} url a URL provided by the user to set the link to
|
||||||
@ -46,7 +40,7 @@ const LinkModel = new Class(/** @lends LinkModel */{
|
|||||||
|
|
||||||
const type = fixedUrl.contains('mailto:') ? 'mail' : 'url';
|
const type = fixedUrl.contains('mailto:') ? 'mail' : 'url';
|
||||||
this.setAttribute('urlType', type);
|
this.setAttribute('urlType', type);
|
||||||
},
|
}
|
||||||
|
|
||||||
// url format is already checked in LinkEditor.checkUrl
|
// url format is already checked in LinkEditor.checkUrl
|
||||||
_fixUrl(url) {
|
_fixUrl(url) {
|
||||||
@ -55,7 +49,7 @@ const LinkModel = new Class(/** @lends LinkModel */{
|
|||||||
result = `http://${result}`;
|
result = `http://${result}`;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {String} urlType the url type, either 'mail' or 'url'
|
* @param {String} urlType the url type, either 'mail' or 'url'
|
||||||
@ -64,8 +58,8 @@ const LinkModel = new Class(/** @lends LinkModel */{
|
|||||||
setUrlType(urlType) {
|
setUrlType(urlType) {
|
||||||
$assert(urlType, 'urlType can not be null');
|
$assert(urlType, 'urlType can not be null');
|
||||||
this.setAttribute('urlType', urlType);
|
this.setAttribute('urlType', urlType);
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constant
|
* @constant
|
||||||
|
@ -21,52 +21,46 @@ import NodeModel from './NodeModel';
|
|||||||
import RelationshipModel from './RelationshipModel';
|
import RelationshipModel from './RelationshipModel';
|
||||||
import ModelCodeName from '../persistence/ModelCodeName';
|
import ModelCodeName from '../persistence/ModelCodeName';
|
||||||
|
|
||||||
const Mindmap = new Class(/** @lends Mindmap */{
|
class Mindmap extends IMindmap {
|
||||||
Extends: IMindmap,
|
constructor(id, version) {
|
||||||
/**
|
super();
|
||||||
* @constructs
|
|
||||||
* @param id
|
|
||||||
* @param version
|
|
||||||
* @extends mindplot.model.IMindmap
|
|
||||||
*/
|
|
||||||
initialize(id, version) {
|
|
||||||
$assert(id, 'Id can not be null');
|
$assert(id, 'Id can not be null');
|
||||||
this._branches = [];
|
this._branches = [];
|
||||||
this._description = null;
|
this._description = null;
|
||||||
this._relationships = [];
|
this._relationships = [];
|
||||||
this._version = $defined(version) ? version : ModelCodeName.TANGO;
|
this._version = $defined(version) ? version : ModelCodeName.TANGO;
|
||||||
this._id = id;
|
this._id = id;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getDescription() {
|
getDescription() {
|
||||||
return this._description;
|
return this._description;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
setDescription(value) {
|
setDescription(value) {
|
||||||
this._description = value;
|
this._description = value;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getId() {
|
getId() {
|
||||||
return this._id;
|
return this._id;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
setId(id) {
|
setId(id) {
|
||||||
this._id = id;
|
this._id = id;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getVersion() {
|
getVersion() {
|
||||||
return this._version;
|
return this._version;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
setVersion(version) {
|
setVersion(version) {
|
||||||
this._version = version;
|
this._version = version;
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {mindplot.model.NodeModel} nodeModel
|
* @param {mindplot.model.NodeModel} nodeModel
|
||||||
@ -76,7 +70,7 @@ const Mindmap = new Class(/** @lends Mindmap */{
|
|||||||
addBranch(nodeModel) {
|
addBranch(nodeModel) {
|
||||||
$assert(nodeModel && nodeModel.isNodeModel(), 'Add node must be invoked with model objects');
|
$assert(nodeModel && nodeModel.isNodeModel(), 'Add node must be invoked with model objects');
|
||||||
const branches = this.getBranches();
|
const branches = this.getBranches();
|
||||||
if (branches.length == 0) {
|
if (branches.length === 0) {
|
||||||
$assert(nodeModel.getType() == INodeModel.CENTRAL_TOPIC_TYPE, 'First element must be the central topic');
|
$assert(nodeModel.getType() == INodeModel.CENTRAL_TOPIC_TYPE, 'First element must be the central topic');
|
||||||
nodeModel.setPosition(0, 0);
|
nodeModel.setPosition(0, 0);
|
||||||
} else {
|
} else {
|
||||||
@ -84,7 +78,7 @@ const Mindmap = new Class(/** @lends Mindmap */{
|
|||||||
}
|
}
|
||||||
|
|
||||||
this._branches.push(nodeModel);
|
this._branches.push(nodeModel);
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param nodeModel
|
* @param nodeModel
|
||||||
@ -92,17 +86,17 @@ const Mindmap = new Class(/** @lends Mindmap */{
|
|||||||
removeBranch(nodeModel) {
|
removeBranch(nodeModel) {
|
||||||
$assert(nodeModel && nodeModel.isNodeModel(), 'Remove node must be invoked with model objects');
|
$assert(nodeModel && nodeModel.isNodeModel(), 'Remove node must be invoked with model objects');
|
||||||
return this._branches.erase(nodeModel);
|
return this._branches.erase(nodeModel);
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getBranches() {
|
getBranches() {
|
||||||
return this._branches;
|
return this._branches;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getRelationships() {
|
getRelationships() {
|
||||||
return this._relationships;
|
return this._relationships;
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param node
|
* @param node
|
||||||
@ -119,7 +113,7 @@ const Mindmap = new Class(/** @lends Mindmap */{
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param type
|
* @param type
|
||||||
@ -129,7 +123,7 @@ const Mindmap = new Class(/** @lends Mindmap */{
|
|||||||
createNode(type, id) {
|
createNode(type, id) {
|
||||||
type = !$defined(type) ? INodeModel.MAIN_TOPIC_TYPE : type;
|
type = !$defined(type) ? INodeModel.MAIN_TOPIC_TYPE : type;
|
||||||
return new NodeModel(type, this, id);
|
return new NodeModel(type, this, id);
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param sourceNodeId
|
* @param sourceNodeId
|
||||||
@ -143,21 +137,21 @@ const Mindmap = new Class(/** @lends Mindmap */{
|
|||||||
$assert($defined(targetNodeId), 'to node cannot be null');
|
$assert($defined(targetNodeId), 'to node cannot be null');
|
||||||
|
|
||||||
return new RelationshipModel(sourceNodeId, targetNodeId);
|
return new RelationshipModel(sourceNodeId, targetNodeId);
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param relationship
|
* @param relationship
|
||||||
*/
|
*/
|
||||||
addRelationship(relationship) {
|
addRelationship(relationship) {
|
||||||
this._relationships.push(relationship);
|
this._relationships.push(relationship);
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param relationship
|
* @param relationship
|
||||||
*/
|
*/
|
||||||
deleteRelationship(relationship) {
|
deleteRelationship(relationship) {
|
||||||
this._relationships.erase(relationship);
|
this._relationships.erase(relationship);
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param id
|
* @param id
|
||||||
@ -173,14 +167,14 @@ const Mindmap = new Class(/** @lends Mindmap */{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mapId
|
* @param mapId
|
||||||
* @return an empty mindmap with central topic only
|
* @return an empty mindmap with central topic only
|
||||||
*/
|
*/
|
||||||
Mindmap.buildEmpty = function (mapId) {
|
Mindmap.buildEmpty = (mapId) => {
|
||||||
const result = new Mindmap(mapId);
|
const result = new Mindmap(mapId);
|
||||||
const node = result.createNode(INodeModel.CENTRAL_TOPIC_TYPE, 0);
|
const node = result.createNode(INodeModel.CENTRAL_TOPIC_TYPE, 0);
|
||||||
result.addBranch(node);
|
result.addBranch(node);
|
||||||
|
@ -18,27 +18,19 @@
|
|||||||
import INodeModel from './INodeModel';
|
import INodeModel from './INodeModel';
|
||||||
import TopicFeature from '../TopicFeature';
|
import TopicFeature from '../TopicFeature';
|
||||||
|
|
||||||
const NodeModel = new Class(/** @lends NodeModel */{
|
class NodeModel extends INodeModel {
|
||||||
Extends: INodeModel,
|
constructor(type, mindmap, id) {
|
||||||
/**
|
|
||||||
* @constructs
|
|
||||||
* @param {String} type node type
|
|
||||||
* @param mindmap
|
|
||||||
* @param id
|
|
||||||
*/
|
|
||||||
initialize(type, mindmap, id) {
|
|
||||||
$assert(type, 'Node type can not be null');
|
$assert(type, 'Node type can not be null');
|
||||||
$assert(mindmap, 'mindmap can not be null');
|
$assert(mindmap, 'mindmap can not be null');
|
||||||
|
super(mindmap);
|
||||||
this._properties = {};
|
this._properties = {};
|
||||||
|
|
||||||
this.parent(mindmap);
|
|
||||||
this.setId(id);
|
this.setId(id);
|
||||||
this.setType(type);
|
this.setType(type);
|
||||||
this.areChildrenShrunken(false);
|
this.areChildrenShrunken(false);
|
||||||
|
|
||||||
this._children = [];
|
this._children = [];
|
||||||
this._feature = [];
|
this._feature = [];
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param type
|
* @param type
|
||||||
@ -47,7 +39,7 @@ const NodeModel = new Class(/** @lends NodeModel */{
|
|||||||
*/
|
*/
|
||||||
createFeature(type, attributes) {
|
createFeature(type, attributes) {
|
||||||
return TopicFeature.createModel(type, attributes);
|
return TopicFeature.createModel(type, attributes);
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param feature
|
* @param feature
|
||||||
@ -56,12 +48,12 @@ const NodeModel = new Class(/** @lends NodeModel */{
|
|||||||
addFeature(feature) {
|
addFeature(feature) {
|
||||||
$assert(feature, 'feature can not be null');
|
$assert(feature, 'feature can not be null');
|
||||||
this._feature.push(feature);
|
this._feature.push(feature);
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getFeatures() {
|
getFeatures() {
|
||||||
return this._feature;
|
return this._feature;
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param feature
|
* @param feature
|
||||||
@ -72,8 +64,8 @@ const NodeModel = new Class(/** @lends NodeModel */{
|
|||||||
$assert(feature, 'feature can not be null');
|
$assert(feature, 'feature can not be null');
|
||||||
const size = this._feature.length;
|
const size = this._feature.length;
|
||||||
this._feature = this._feature.filter((f) => feature.getId() != f.getId());
|
this._feature = this._feature.filter((f) => feature.getId() != f.getId());
|
||||||
$assert(size - 1 == this._feature.length, 'Could not be removed ...');
|
$assert(size - 1 === this._feature.length, 'Could not be removed ...');
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {String} type the feature type, e.g. icon or link
|
* @param {String} type the feature type, e.g. icon or link
|
||||||
@ -81,8 +73,8 @@ const NodeModel = new Class(/** @lends NodeModel */{
|
|||||||
*/
|
*/
|
||||||
findFeatureByType(type) {
|
findFeatureByType(type) {
|
||||||
$assert(type, 'type can not be null');
|
$assert(type, 'type can not be null');
|
||||||
return this._feature.filter((feature) => feature.getType() == type);
|
return this._feature.filter((feature) => feature.getType() === type);
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {String} id
|
* @param {String} id
|
||||||
@ -92,15 +84,15 @@ const NodeModel = new Class(/** @lends NodeModel */{
|
|||||||
*/
|
*/
|
||||||
findFeatureById(id) {
|
findFeatureById(id) {
|
||||||
$assert($defined(id), 'id can not be null');
|
$assert($defined(id), 'id can not be null');
|
||||||
const result = this._feature.filter((feature) => feature.getId() == id);
|
const result = this._feature.filter((feature) => feature.getId() === id);
|
||||||
$assert(result.length == 1, `Feature could not be found:${id}`);
|
$assert(result.length === 1, `Feature could not be found:${id}`);
|
||||||
return result[0];
|
return result[0];
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getPropertiesKeys() {
|
getPropertiesKeys() {
|
||||||
return Object.keys(this._properties);
|
return Object.keys(this._properties);
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param key
|
* @param key
|
||||||
@ -110,19 +102,19 @@ const NodeModel = new Class(/** @lends NodeModel */{
|
|||||||
putProperty(key, value) {
|
putProperty(key, value) {
|
||||||
$defined(key, 'key can not be null');
|
$defined(key, 'key can not be null');
|
||||||
this._properties[key] = value;
|
this._properties[key] = value;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getProperties() {
|
getProperties() {
|
||||||
return this._properties;
|
return this._properties;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getProperty(key) {
|
getProperty(key) {
|
||||||
$defined(key, 'key can not be null');
|
$defined(key, 'key can not be null');
|
||||||
const result = this._properties[key];
|
const result = this._properties[key];
|
||||||
return !$defined(result) ? null : result;
|
return !$defined(result) ? null : result;
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {mindplot.model.NodeModel} an identical clone of the NodeModel
|
* @return {mindplot.model.NodeModel} an identical clone of the NodeModel
|
||||||
@ -138,7 +130,7 @@ const NodeModel = new Class(/** @lends NodeModel */{
|
|||||||
result._properties = Object.clone(this._properties);
|
result._properties = Object.clone(this._properties);
|
||||||
result._feature = this._feature.clone();
|
result._feature = this._feature.clone();
|
||||||
return result;
|
return result;
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Similar to clone, assign new id to the elements ...
|
* Similar to clone, assign new id to the elements ...
|
||||||
@ -158,7 +150,7 @@ const NodeModel = new Class(/** @lends NodeModel */{
|
|||||||
|
|
||||||
result._feature = this._feature.clone();
|
result._feature = this._feature.clone();
|
||||||
return result;
|
return result;
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {mindplot.model.NodeModel} child
|
* @param {mindplot.model.NodeModel} child
|
||||||
@ -168,7 +160,7 @@ const NodeModel = new Class(/** @lends NodeModel */{
|
|||||||
$assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object');
|
$assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object');
|
||||||
this._children.push(child);
|
this._children.push(child);
|
||||||
child._parent = this;
|
child._parent = this;
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {mindplot.model.NodeModel} child
|
* @param {mindplot.model.NodeModel} child
|
||||||
@ -178,23 +170,23 @@ const NodeModel = new Class(/** @lends NodeModel */{
|
|||||||
$assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object.');
|
$assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object.');
|
||||||
this._children.erase(child);
|
this._children.erase(child);
|
||||||
child._parent = null;
|
child._parent = null;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getChildren() {
|
getChildren() {
|
||||||
return this._children;
|
return this._children;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getParent() {
|
getParent() {
|
||||||
return this._parent;
|
return this._parent;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
setParent(parent) {
|
setParent(parent) {
|
||||||
$assert(parent != this, 'The same node can not be parent and child if itself.');
|
$assert(parent !== this, 'The same node can not be parent and child if itself.');
|
||||||
this._parent = parent;
|
this._parent = parent;
|
||||||
},
|
}
|
||||||
|
|
||||||
_isChildNode(node) {
|
_isChildNode(node) {
|
||||||
let result = false;
|
let result = false;
|
||||||
@ -211,7 +203,7 @@ const NodeModel = new Class(/** @lends NodeModel */{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @id
|
* @id
|
||||||
@ -232,7 +224,7 @@ const NodeModel = new Class(/** @lends NodeModel */{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
export default NodeModel;
|
export default NodeModel;
|
||||||
|
@ -17,30 +17,24 @@
|
|||||||
*/
|
*/
|
||||||
import FeatureModel from './FeatureModel';
|
import FeatureModel from './FeatureModel';
|
||||||
|
|
||||||
const NoteModel = new Class(/** @lends NoteModel */{
|
class NoteModel extends FeatureModel {
|
||||||
Extends: FeatureModel,
|
constructor(attributes) {
|
||||||
/**
|
super(NoteModel.FEATURE_TYPE);
|
||||||
* @constructs
|
|
||||||
* @param attributes
|
|
||||||
* @extends mindplot.model.FeatureModel
|
|
||||||
*/
|
|
||||||
initialize(attributes) {
|
|
||||||
this.parent(NoteModel.FEATURE_TYPE);
|
|
||||||
const noteText = attributes.text ? attributes.text : ' ';
|
const noteText = attributes.text ? attributes.text : ' ';
|
||||||
this.setText(noteText);
|
this.setText(noteText);
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getText() {
|
getText() {
|
||||||
return this.getAttribute('text');
|
return this.getAttribute('text');
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
setText(text) {
|
setText(text) {
|
||||||
$assert(text, 'text can not be null');
|
$assert(text, 'text can not be null');
|
||||||
this.setAttribute('text', text);
|
this.setAttribute('text', text);
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constant
|
* @constant
|
||||||
|
@ -17,16 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
import ConnectionLine from '../ConnectionLine';
|
import ConnectionLine from '../ConnectionLine';
|
||||||
|
|
||||||
const RelationshipModel = new Class(
|
class RelationshipModel {
|
||||||
/** @lends RelationshipModel */ {
|
constructor(sourceTopicId, targetTopicId) {
|
||||||
/**
|
|
||||||
* @constructs
|
|
||||||
* @param sourceTopicId
|
|
||||||
* @param targetTopicId
|
|
||||||
* @throws will throw an error if sourceTopicId is null or undefined
|
|
||||||
* @throws will throw an error if targetTopicId is null or undefined
|
|
||||||
*/
|
|
||||||
initialize(sourceTopicId, targetTopicId) {
|
|
||||||
$assert($defined(sourceTopicId), 'from node type can not be null');
|
$assert($defined(sourceTopicId), 'from node type can not be null');
|
||||||
$assert($defined(targetTopicId), 'to node type can not be null');
|
$assert($defined(targetTopicId), 'to node type can not be null');
|
||||||
|
|
||||||
@ -38,73 +30,73 @@ const RelationshipModel = new Class(
|
|||||||
this._destCtrlPoint = null;
|
this._destCtrlPoint = null;
|
||||||
this._endArrow = true;
|
this._endArrow = true;
|
||||||
this._startArrow = false;
|
this._startArrow = false;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getFromNode() {
|
getFromNode() {
|
||||||
return this._sourceTargetId;
|
return this._sourceTargetId;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getToNode() {
|
getToNode() {
|
||||||
return this._targetTopicId;
|
return this._targetTopicId;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getId() {
|
getId() {
|
||||||
$assert(this._id, 'id is null');
|
$assert(this._id, 'id is null');
|
||||||
return this._id;
|
return this._id;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getLineType() {
|
getLineType() {
|
||||||
return this._lineType;
|
return this._lineType;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
setLineType(lineType) {
|
setLineType(lineType) {
|
||||||
this._lineType = lineType;
|
this._lineType = lineType;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getSrcCtrlPoint() {
|
getSrcCtrlPoint() {
|
||||||
return this._srcCtrlPoint;
|
return this._srcCtrlPoint;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
setSrcCtrlPoint(srcCtrlPoint) {
|
setSrcCtrlPoint(srcCtrlPoint) {
|
||||||
this._srcCtrlPoint = srcCtrlPoint;
|
this._srcCtrlPoint = srcCtrlPoint;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getDestCtrlPoint() {
|
getDestCtrlPoint() {
|
||||||
return this._destCtrlPoint;
|
return this._destCtrlPoint;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
setDestCtrlPoint(destCtrlPoint) {
|
setDestCtrlPoint(destCtrlPoint) {
|
||||||
this._destCtrlPoint = destCtrlPoint;
|
this._destCtrlPoint = destCtrlPoint;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getEndArrow() {
|
getEndArrow() {
|
||||||
return this._endArrow;
|
return this._endArrow;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
setEndArrow(endArrow) {
|
setEndArrow(endArrow) {
|
||||||
this._endArrow = endArrow;
|
this._endArrow = endArrow;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
getStartArrow() {
|
getStartArrow() {
|
||||||
return this._startArrow;
|
return this._startArrow;
|
||||||
},
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
setStartArrow(startArrow) {
|
setStartArrow(startArrow) {
|
||||||
this._startArrow = startArrow;
|
this._startArrow = startArrow;
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a clone of the relationship model
|
* @return a clone of the relationship model
|
||||||
@ -118,29 +110,28 @@ const RelationshipModel = new Class(
|
|||||||
result._endArrow = this._endArrow;
|
result._endArrow = this._endArrow;
|
||||||
result._startArrow = this._startArrow;
|
result._startArrow = this._startArrow;
|
||||||
return result;
|
return result;
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {String} textual information about the relationship's source and target node
|
* @return {String} textual information about the relationship's source and target node
|
||||||
*/
|
*/
|
||||||
inspect() {
|
inspect() {
|
||||||
return (
|
return (
|
||||||
`(fromNode:${
|
`(fromNode:${this.getFromNode().getId()
|
||||||
this.getFromNode().getId()
|
} , toNode: ${this.getToNode().getId()
|
||||||
} , toNode: ${
|
|
||||||
this.getToNode().getId()
|
|
||||||
})`
|
})`
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
);
|
|
||||||
|
|
||||||
RelationshipModel._nextUUID = function _nextUUID() {
|
function _nextUUID() {
|
||||||
if (!$defined(RelationshipModel._uuid)) {
|
if (!$defined(RelationshipModel._uuid)) {
|
||||||
RelationshipModel._uuid = 0;
|
RelationshipModel._uuid = 0;
|
||||||
}
|
}
|
||||||
RelationshipModel._uuid += 1;
|
RelationshipModel._uuid += 1;
|
||||||
return RelationshipModel._uuid;
|
return RelationshipModel._uuid;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
RelationshipModel._nextUUID = _nextUUID;
|
||||||
|
|
||||||
export default RelationshipModel;
|
export default RelationshipModel;
|
||||||
|
@ -14,19 +14,17 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import Core from '@wisemapping/core-js';
|
import { createDocument, innerXML } from '@wisemapping/core-js';
|
||||||
import ModelCodeName from './ModelCodeName';
|
import ModelCodeName from './ModelCodeName';
|
||||||
import Mindmap from '../model/Mindmap';
|
import Mindmap from '../model/Mindmap';
|
||||||
import INodeModel from '../model/INodeModel';
|
import INodeModel from '../model/INodeModel';
|
||||||
import TopicFeature from '../TopicFeature';
|
import TopicFeature from '../TopicFeature';
|
||||||
|
|
||||||
const core = Core();
|
|
||||||
|
|
||||||
const XMLSerializer_Beta = new Class({
|
const XMLSerializer_Beta = new Class({
|
||||||
toXML(mindmap) {
|
toXML(mindmap) {
|
||||||
$assert(mindmap, 'Can not save a null mindmap');
|
$assert(mindmap, 'Can not save a null mindmap');
|
||||||
|
|
||||||
const document = core.Utils.createDocument();
|
const document = createDocument();
|
||||||
|
|
||||||
// Store map attributes ...
|
// Store map attributes ...
|
||||||
const mapElem = document.createElement('map');
|
const mapElem = document.createElement('map');
|
||||||
@ -51,11 +49,11 @@ const XMLSerializer_Beta = new Class({
|
|||||||
const parentTopic = document.createElement('topic');
|
const parentTopic = document.createElement('topic');
|
||||||
|
|
||||||
// Set topic attributes...
|
// Set topic attributes...
|
||||||
if (topic.getType() == INodeModel.CENTRAL_TOPIC_TYPE) {
|
if (topic.getType() === INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||||
parentTopic.setAttribute('central', true);
|
parentTopic.setAttribute('central', true);
|
||||||
} else {
|
} else {
|
||||||
const parent = topic.getParent();
|
const parent = topic.getParent();
|
||||||
if (parent == null || parent.getType() == INodeModel.CENTRAL_TOPIC_TYPE) {
|
if (parent == null || parent.getType() === INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||||
const pos = topic.getPosition();
|
const pos = topic.getPosition();
|
||||||
parentTopic.setAttribute('position', `${pos.x},${pos.y}`);
|
parentTopic.setAttribute('position', `${pos.x},${pos.y}`);
|
||||||
} else {
|
} else {
|
||||||
@ -176,16 +174,15 @@ const XMLSerializer_Beta = new Class({
|
|||||||
// Is a valid object ?
|
// Is a valid object ?
|
||||||
const { documentElement } = dom;
|
const { documentElement } = dom;
|
||||||
$assert(
|
$assert(
|
||||||
documentElement.nodeName != 'parsererror',
|
documentElement.nodeName !== 'parsererror',
|
||||||
`Error while parsing: '${documentElement.childNodes[0].nodeValue}`,
|
`Error while parsing: '${documentElement.childNodes[0].nodeValue}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Is a wisemap?.
|
// Is a wisemap?.
|
||||||
$assert(
|
$assert(
|
||||||
documentElement.tagName == XMLSerializer_Beta.MAP_ROOT_NODE,
|
documentElement.tagName === XMLSerializer_Beta.MAP_ROOT_NODE,
|
||||||
`This seem not to be a map document. Root Tag: '${documentElement.tagName},',HTML:${
|
`This seem not to be a map document. Root Tag: '${documentElement.tagName},',HTML:${dom.innerHTML
|
||||||
dom.innerHTML
|
},XML:${innerXML(dom)}`,
|
||||||
},XML:${core.Utils.innerXML(dom)}`,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Start the loading process ...
|
// Start the loading process ...
|
||||||
@ -196,7 +193,7 @@ const XMLSerializer_Beta = new Class({
|
|||||||
const children = documentElement.childNodes;
|
const children = documentElement.childNodes;
|
||||||
for (let i = 0; i < children.length; i++) {
|
for (let i = 0; i < children.length; i++) {
|
||||||
const child = children[i];
|
const child = children[i];
|
||||||
if (child.nodeType == 1) {
|
if (child.nodeType === 1) {
|
||||||
const topic = this._deserializeNode(child, mindmap);
|
const topic = this._deserializeNode(child, mindmap);
|
||||||
mindmap.addBranch(topic);
|
mindmap.addBranch(topic);
|
||||||
}
|
}
|
||||||
@ -219,7 +216,7 @@ const XMLSerializer_Beta = new Class({
|
|||||||
|
|
||||||
const order = domElem.getAttribute('order');
|
const order = domElem.getAttribute('order');
|
||||||
if ($defined(order)) {
|
if ($defined(order)) {
|
||||||
topic.setOrder(parseInt(order));
|
topic.setOrder(parseInt(order, 10));
|
||||||
}
|
}
|
||||||
|
|
||||||
const shape = domElem.getAttribute('shape');
|
const shape = domElem.getAttribute('shape');
|
||||||
@ -277,24 +274,24 @@ const XMLSerializer_Beta = new Class({
|
|||||||
const children = domElem.childNodes;
|
const children = domElem.childNodes;
|
||||||
for (let i = 0; i < children.length; i++) {
|
for (let i = 0; i < children.length; i++) {
|
||||||
const child = children[i];
|
const child = children[i];
|
||||||
if (child.nodeType == 1) {
|
if (child.nodeType === 1) {
|
||||||
$assert(
|
$assert(
|
||||||
child.tagName == 'topic'
|
child.tagName === 'topic'
|
||||||
|| child.tagName == 'icon'
|
|| child.tagName === 'icon'
|
||||||
|| child.tagName == 'link'
|
|| child.tagName === 'link'
|
||||||
|| child.tagName == 'note',
|
|| child.tagName === 'note',
|
||||||
`Illegal node type:${child.tagName}`,
|
`Illegal node type:${child.tagName}`,
|
||||||
);
|
);
|
||||||
if (child.tagName == 'topic') {
|
if (child.tagName === 'topic') {
|
||||||
const childTopic = this._deserializeNode(child, mindmap);
|
const childTopic = this._deserializeNode(child, mindmap);
|
||||||
childTopic.connectTo(topic);
|
childTopic.connectTo(topic);
|
||||||
} else if (child.tagName == 'icon') {
|
} else if (child.tagName === 'icon') {
|
||||||
const icon = this._deserializeIcon(child, topic);
|
const icon = this._deserializeIcon(child, topic);
|
||||||
topic.addFeature(icon);
|
topic.addFeature(icon);
|
||||||
} else if (child.tagName == 'link') {
|
} else if (child.tagName === 'link') {
|
||||||
const link = this._deserializeLink(child, topic);
|
const link = this._deserializeLink(child, topic);
|
||||||
topic.addFeature(link);
|
topic.addFeature(link);
|
||||||
} else if (child.tagName == 'note') {
|
} else if (child.tagName === 'note') {
|
||||||
const note = this._deserializeNote(child, topic);
|
const note = this._deserializeNote(child, topic);
|
||||||
topic.addFeature(note);
|
topic.addFeature(note);
|
||||||
}
|
}
|
||||||
|
@ -15,18 +15,17 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import Core from '@wisemapping/core-js';
|
import { $assert, createDocument } from '@wisemapping/core-js';
|
||||||
import web2d from '@wisemapping/web2d';
|
import web2d from '@wisemapping/web2d';
|
||||||
import Mindmap from '../model/Mindmap';
|
import Mindmap from '../model/Mindmap';
|
||||||
import INodeModel, { TopicShape } from '../model/INodeModel';
|
import INodeModel, { TopicShape } from '../model/INodeModel';
|
||||||
import TopicFeature from '../TopicFeature';
|
import TopicFeature from '../TopicFeature';
|
||||||
import ConnectionLine from '../ConnectionLine';
|
import ConnectionLine from '../ConnectionLine';
|
||||||
|
|
||||||
const core = Core();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class
|
* @class
|
||||||
*/
|
*/
|
||||||
|
// eslint-disable-next-line camelcase
|
||||||
const XMLSerializer_Pela = new Class(
|
const XMLSerializer_Pela = new Class(
|
||||||
/** @lends XMLSerializer_Pela */ {
|
/** @lends XMLSerializer_Pela */ {
|
||||||
/**
|
/**
|
||||||
@ -37,7 +36,7 @@ const XMLSerializer_Pela = new Class(
|
|||||||
toXML(mindmap) {
|
toXML(mindmap) {
|
||||||
$assert(mindmap, 'Can not save a null mindmap');
|
$assert(mindmap, 'Can not save a null mindmap');
|
||||||
|
|
||||||
const document = core.Utils.createDocument();
|
const document = createDocument();
|
||||||
|
|
||||||
// Store map attributes ...
|
// Store map attributes ...
|
||||||
const mapElem = document.createElement('map');
|
const mapElem = document.createElement('map');
|
||||||
@ -83,14 +82,14 @@ const XMLSerializer_Pela = new Class(
|
|||||||
const parentTopic = document.createElement('topic');
|
const parentTopic = document.createElement('topic');
|
||||||
|
|
||||||
// Set topic attributes...
|
// Set topic attributes...
|
||||||
if (topic.getType() == INodeModel.CENTRAL_TOPIC_TYPE) {
|
if (topic.getType() === INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||||
parentTopic.setAttribute('central', 'true');
|
parentTopic.setAttribute('central', 'true');
|
||||||
} else {
|
} else {
|
||||||
const pos = topic.getPosition();
|
const pos = topic.getPosition();
|
||||||
parentTopic.setAttribute('position', `${pos.x},${pos.y}`);
|
parentTopic.setAttribute('position', `${pos.x},${pos.y}`);
|
||||||
|
|
||||||
const order = topic.getOrder();
|
const order = topic.getOrder();
|
||||||
if (typeof order === 'number' && isFinite(order)) { parentTopic.setAttribute('order', order); }
|
if (typeof order === 'number' && Number.isFinite(order)) { parentTopic.setAttribute('order', order); }
|
||||||
}
|
}
|
||||||
|
|
||||||
const text = topic.getText();
|
const text = topic.getText();
|
||||||
@ -102,17 +101,16 @@ const XMLSerializer_Pela = new Class(
|
|||||||
if ($defined(shape)) {
|
if ($defined(shape)) {
|
||||||
parentTopic.setAttribute('shape', shape);
|
parentTopic.setAttribute('shape', shape);
|
||||||
|
|
||||||
if (shape == TopicShape.IMAGE) {
|
if (shape === TopicShape.IMAGE) {
|
||||||
parentTopic.setAttribute(
|
parentTopic.setAttribute(
|
||||||
'image',
|
'image',
|
||||||
`${topic.getImageSize().width},${
|
`${topic.getImageSize().width},${topic.getImageSize().height
|
||||||
topic.getImageSize().height
|
|
||||||
}:${topic.getImageUrl()}`,
|
}:${topic.getImageUrl()}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (topic.areChildrenShrunken() && topic.getType() != INodeModel.CENTRAL_TOPIC_TYPE) {
|
if (topic.areChildrenShrunken() && topic.getType() !== INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||||
parentTopic.setAttribute('shrink', 'true');
|
parentTopic.setAttribute('shrink', 'true');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +171,7 @@ const XMLSerializer_Pela = new Class(
|
|||||||
|
|
||||||
for (const key in attributes) {
|
for (const key in attributes) {
|
||||||
const value = attributes[key];
|
const value = attributes[key];
|
||||||
if (key == 'text') {
|
if (key === 'text') {
|
||||||
const cdata = document.createCDATASection(this.rmXmlInv(value));
|
const cdata = document.createCDATASection(this.rmXmlInv(value));
|
||||||
featureDom.appendChild(cdata);
|
featureDom.appendChild(cdata);
|
||||||
} else {
|
} else {
|
||||||
@ -194,7 +192,7 @@ const XMLSerializer_Pela = new Class(
|
|||||||
},
|
},
|
||||||
|
|
||||||
_noteTextToXML(document, elem, text) {
|
_noteTextToXML(document, elem, text) {
|
||||||
if (text.indexOf('\n') == -1) {
|
if (text.indexOf('\n') === -1) {
|
||||||
elem.setAttribute('text', this.rmXmlInv(text));
|
elem.setAttribute('text', this.rmXmlInv(text));
|
||||||
} else {
|
} else {
|
||||||
const textDom = document.createElement('text');
|
const textDom = document.createElement('text');
|
||||||
@ -211,7 +209,7 @@ const XMLSerializer_Pela = new Class(
|
|||||||
|
|
||||||
const lineType = relationship.getLineType();
|
const lineType = relationship.getLineType();
|
||||||
result.setAttribute('lineType', lineType);
|
result.setAttribute('lineType', lineType);
|
||||||
if (lineType == ConnectionLine.CURVED || lineType == ConnectionLine.SIMPLE_CURVED) {
|
if (lineType === ConnectionLine.CURVED || lineType === ConnectionLine.SIMPLE_CURVED) {
|
||||||
if ($defined(relationship.getSrcCtrlPoint())) {
|
if ($defined(relationship.getSrcCtrlPoint())) {
|
||||||
const srcPoint = relationship.getSrcCtrlPoint();
|
const srcPoint = relationship.getSrcCtrlPoint();
|
||||||
result.setAttribute(
|
result.setAttribute(
|
||||||
@ -248,7 +246,7 @@ const XMLSerializer_Pela = new Class(
|
|||||||
|
|
||||||
// Is a wisemap?.
|
// Is a wisemap?.
|
||||||
$assert(
|
$assert(
|
||||||
rootElem.tagName == XMLSerializer_Pela.MAP_ROOT_NODE,
|
rootElem.tagName === XMLSerializer_Pela.MAP_ROOT_NODE,
|
||||||
'This seem not to be a map document.',
|
'This seem not to be a map document.',
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -260,15 +258,21 @@ const XMLSerializer_Pela = new Class(
|
|||||||
const children = rootElem.childNodes;
|
const children = rootElem.childNodes;
|
||||||
for (let i = 0; i < children.length; i++) {
|
for (let i = 0; i < children.length; i++) {
|
||||||
const child = children[i];
|
const child = children[i];
|
||||||
if (child.nodeType == 1) {
|
if (child.nodeType === 1) {
|
||||||
switch (child.tagName) {
|
switch (child.tagName) {
|
||||||
case 'topic':
|
case 'topic': {
|
||||||
var topic = this._deserializeNode(child, mindmap);
|
const topic = this._deserializeNode(child, mindmap);
|
||||||
mindmap.addBranch(topic);
|
mindmap.addBranch(topic);
|
||||||
break;
|
break;
|
||||||
case 'relationship':
|
}
|
||||||
var relationship = this._deserializeRelationship(child, mindmap);
|
case 'relationship': {
|
||||||
if (relationship != null) mindmap.addRelationship(relationship);
|
const relationship = this._deserializeRelationship(child, mindmap);
|
||||||
|
if (relationship != null) {
|
||||||
|
mindmap.addRelationship(relationship);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -286,7 +290,7 @@ const XMLSerializer_Pela = new Class(
|
|||||||
// Load attributes...
|
// Load attributes...
|
||||||
let id = domElem.getAttribute('id');
|
let id = domElem.getAttribute('id');
|
||||||
if ($defined(id)) {
|
if ($defined(id)) {
|
||||||
id = parseInt(id);
|
id = parseInt(id, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._idsMap[id]) {
|
if (this._idsMap[id]) {
|
||||||
@ -332,7 +336,7 @@ const XMLSerializer_Pela = new Class(
|
|||||||
if ($defined(shape)) {
|
if ($defined(shape)) {
|
||||||
topic.setShapeType(shape);
|
topic.setShapeType(shape);
|
||||||
|
|
||||||
if (shape == TopicShape.IMAGE) {
|
if (shape === TopicShape.IMAGE) {
|
||||||
const image = domElem.getAttribute('image');
|
const image = domElem.getAttribute('image');
|
||||||
const size = image.substring(0, image.indexOf(':'));
|
const size = image.substring(0, image.indexOf(':'));
|
||||||
const url = image.substring(image.indexOf(':') + 1, image.length);
|
const url = image.substring(image.indexOf(':') + 1, image.length);
|
||||||
@ -354,14 +358,14 @@ const XMLSerializer_Pela = new Class(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const order = domElem.getAttribute('order');
|
const order = domElem.getAttribute('order');
|
||||||
if ($defined(order) && order != 'NaN') {
|
if ($defined(order) && order !== 'NaN') {
|
||||||
// Hack for broken maps ...
|
// Hack for broken maps ...
|
||||||
topic.setOrder(parseInt(order));
|
topic.setOrder(parseInt(order, 10));
|
||||||
}
|
}
|
||||||
|
|
||||||
const isShrink = domElem.getAttribute('shrink');
|
const isShrink = domElem.getAttribute('shrink');
|
||||||
// Hack: Some production maps has been stored with the central topic collapsed. This is a bug.
|
// Hack: Some production maps has been stored with the central topic collapsed. This is a bug.
|
||||||
if ($defined(isShrink) && type != INodeModel.CENTRAL_TOPIC_TYPE) {
|
if ($defined(isShrink) && type !== INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||||
topic.setChildrenShrunken(isShrink);
|
topic.setChildrenShrunken(isShrink);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,8 +384,8 @@ const XMLSerializer_Pela = new Class(
|
|||||||
const children = domElem.childNodes;
|
const children = domElem.childNodes;
|
||||||
for (let i = 0; i < children.length; i++) {
|
for (let i = 0; i < children.length; i++) {
|
||||||
const child = children[i];
|
const child = children[i];
|
||||||
if (child.nodeType == Node.ELEMENT_NODE) {
|
if (child.nodeType === Node.ELEMENT_NODE) {
|
||||||
if (child.tagName == 'topic') {
|
if (child.tagName === 'topic') {
|
||||||
const childTopic = this._deserializeNode(child, mindmap);
|
const childTopic = this._deserializeNode(child, mindmap);
|
||||||
childTopic.connectTo(topic);
|
childTopic.connectTo(topic);
|
||||||
} else if (TopicFeature.isSupported(child.tagName)) {
|
} else if (TopicFeature.isSupported(child.tagName)) {
|
||||||
@ -403,7 +407,7 @@ const XMLSerializer_Pela = new Class(
|
|||||||
const featureType = child.tagName;
|
const featureType = child.tagName;
|
||||||
const feature = TopicFeature.createModel(featureType, attributes);
|
const feature = TopicFeature.createModel(featureType, attributes);
|
||||||
topic.addFeature(feature);
|
topic.addFeature(feature);
|
||||||
} else if (child.tagName == 'text') {
|
} else if (child.tagName === 'text') {
|
||||||
const nodeText = this._deserializeNodeText(child);
|
const nodeText = this._deserializeNodeText(child);
|
||||||
topic.setText(nodeText);
|
topic.setText(nodeText);
|
||||||
}
|
}
|
||||||
@ -418,7 +422,7 @@ const XMLSerializer_Pela = new Class(
|
|||||||
const children = domElem.childNodes;
|
const children = domElem.childNodes;
|
||||||
for (let i = 0; i < children.length; i++) {
|
for (let i = 0; i < children.length; i++) {
|
||||||
const child = children[i];
|
const child = children[i];
|
||||||
if (child.nodeType == Node.CDATA_SECTION_NODE) {
|
if (child.nodeType === Node.CDATA_SECTION_NODE) {
|
||||||
value = child.nodeValue;
|
value = child.nodeValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -427,7 +431,7 @@ const XMLSerializer_Pela = new Class(
|
|||||||
value = unescape(value);
|
value = unescape(value);
|
||||||
|
|
||||||
// Hack for empty nodes ...
|
// Hack for empty nodes ...
|
||||||
if (value == '') {
|
if (value === '') {
|
||||||
value = ' ';
|
value = ' ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -440,7 +444,7 @@ const XMLSerializer_Pela = new Class(
|
|||||||
let value = null;
|
let value = null;
|
||||||
for (let i = 0; i < children.length; i++) {
|
for (let i = 0; i < children.length; i++) {
|
||||||
const child = children[i];
|
const child = children[i];
|
||||||
if (child.nodeType == Node.CDATA_SECTION_NODE) {
|
if (child.nodeType === Node.CDATA_SECTION_NODE) {
|
||||||
value = child.nodeValue;
|
value = child.nodeValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -453,10 +457,9 @@ const XMLSerializer_Pela = new Class(
|
|||||||
const lineType = domElement.getAttribute('lineType');
|
const lineType = domElement.getAttribute('lineType');
|
||||||
const srcCtrlPoint = domElement.getAttribute('srcCtrlPoint');
|
const srcCtrlPoint = domElement.getAttribute('srcCtrlPoint');
|
||||||
const destCtrlPoint = domElement.getAttribute('destCtrlPoint');
|
const destCtrlPoint = domElement.getAttribute('destCtrlPoint');
|
||||||
const endArrow = domElement.getAttribute('endArrow');
|
|
||||||
const startArrow = domElement.getAttribute('startArrow');
|
|
||||||
// If for some reason a relationship lines has source and dest nodes the same, don't import it.
|
// If for some reason a relationship lines has source and dest nodes the same, don't import it.
|
||||||
if (srcId == destId) {
|
if (srcId === destId) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// Is the connections points valid ?. If it's not, do not load the relationship ...
|
// Is the connections points valid ?. If it's not, do not load the relationship ...
|
||||||
@ -466,10 +469,10 @@ const XMLSerializer_Pela = new Class(
|
|||||||
|
|
||||||
const model = mindmap.createRelationship(srcId, destId);
|
const model = mindmap.createRelationship(srcId, destId);
|
||||||
model.setLineType(lineType);
|
model.setLineType(lineType);
|
||||||
if ($defined(srcCtrlPoint) && srcCtrlPoint != '') {
|
if ($defined(srcCtrlPoint) && srcCtrlPoint !== '') {
|
||||||
model.setSrcCtrlPoint(web2d.Point.fromString(srcCtrlPoint));
|
model.setSrcCtrlPoint(web2d.Point.fromString(srcCtrlPoint));
|
||||||
}
|
}
|
||||||
if ($defined(destCtrlPoint) && destCtrlPoint != '') {
|
if ($defined(destCtrlPoint) && destCtrlPoint !== '') {
|
||||||
model.setDestCtrlPoint(web2d.Point.fromString(destCtrlPoint));
|
model.setDestCtrlPoint(web2d.Point.fromString(destCtrlPoint));
|
||||||
}
|
}
|
||||||
model.setEndArrow('false');
|
model.setEndArrow('false');
|
||||||
@ -489,15 +492,15 @@ const XMLSerializer_Pela = new Class(
|
|||||||
* @return The in String, stripped of non-valid characters.
|
* @return The in String, stripped of non-valid characters.
|
||||||
*/
|
*/
|
||||||
rmXmlInv(str) {
|
rmXmlInv(str) {
|
||||||
if (str == null || str == undefined) return null;
|
if (str == null || str === undefined) return null;
|
||||||
|
|
||||||
let result = '';
|
let result = '';
|
||||||
for (let i = 0; i < str.length; i++) {
|
for (let i = 0; i < str.length; i++) {
|
||||||
const c = str.charCodeAt(i);
|
const c = str.charCodeAt(i);
|
||||||
if (
|
if (
|
||||||
c == 0x9
|
c === 0x9
|
||||||
|| c == 0xa
|
|| c === 0xa
|
||||||
|| c == 0xd
|
|| c === 0xd
|
||||||
|| (c >= 0x20 && c <= 0xd7ff)
|
|| (c >= 0x20 && c <= 0xd7ff)
|
||||||
|| (c >= 0xe000 && c <= 0xfffd)
|
|| (c >= 0xe000 && c <= 0xfffd)
|
||||||
|| (c >= 0x10000 && c <= 0x10ffff)
|
|| (c >= 0x10000 && c <= 0x10ffff)
|
||||||
|
@ -16,23 +16,21 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import web2d from '@wisemapping/web2d';
|
import web2d from '@wisemapping/web2d';
|
||||||
import coreJs from '@wisemapping/core-js';
|
import { $assert, $defined } from '@wisemapping/core-js';
|
||||||
import { TopicShape } from '../model/INodeModel';
|
import { TopicShape } from '../model/INodeModel';
|
||||||
import TopicConfig from '../TopicConfig';
|
import TopicConfig from '../TopicConfig';
|
||||||
|
|
||||||
const core = coreJs();
|
|
||||||
|
|
||||||
const Shape = {
|
const Shape = {
|
||||||
isAtRight(sourcePoint, targetPoint) {
|
isAtRight(sourcePoint, targetPoint) {
|
||||||
core.Function.$assert(sourcePoint, 'Source can not be null');
|
$assert(sourcePoint, 'Source can not be null');
|
||||||
core.Function.$assert(targetPoint, 'Target can not be null');
|
$assert(targetPoint, 'Target can not be null');
|
||||||
return sourcePoint.x < targetPoint.x;
|
return sourcePoint.x < targetPoint.x;
|
||||||
},
|
},
|
||||||
|
|
||||||
calculateRectConnectionPoint(rectCenterPoint, rectSize, isAtRight) {
|
calculateRectConnectionPoint(rectCenterPoint, rectSize, isAtRight) {
|
||||||
core.Function.$assert(rectCenterPoint, 'rectCenterPoint can not be null');
|
$assert(rectCenterPoint, 'rectCenterPoint can not be null');
|
||||||
core.Function.$assert(rectSize, 'rectSize can not be null');
|
$assert(rectSize, 'rectSize can not be null');
|
||||||
core.Function.$assert(core.Function.$defined(isAtRight), 'isRight can not be null');
|
$assert($defined(isAtRight), 'isRight can not be null');
|
||||||
|
|
||||||
// Node is placed at the right ?
|
// Node is placed at the right ?
|
||||||
const result = new web2d.Point();
|
const result = new web2d.Point();
|
||||||
@ -115,7 +113,7 @@ const Shape = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
workoutIncomingConnectionPoint(targetNode, sourcePosition) {
|
workoutIncomingConnectionPoint(targetNode, sourcePosition) {
|
||||||
core.Function.$assert(sourcePosition, 'sourcePoint can not be null');
|
$assert(sourcePosition, 'sourcePoint can not be null');
|
||||||
const pos = targetNode.getPosition();
|
const pos = targetNode.getPosition();
|
||||||
const size = targetNode.getSize();
|
const size = targetNode.getSize();
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
import { $assert, $defined } from '@wisemapping/core-js';
|
||||||
import ToolbarPaneItem from './ToolbarPaneItem';
|
import ToolbarPaneItem from './ToolbarPaneItem';
|
||||||
|
|
||||||
const ColorPalettePanel = new Class({
|
const ColorPalettePanel = new Class({
|
||||||
@ -89,11 +90,11 @@ const ColorPalettePanel = new Class({
|
|||||||
let modelValue = model.getValue();
|
let modelValue = model.getValue();
|
||||||
_.each(colorCells, (elem) => {
|
_.each(colorCells, (elem) => {
|
||||||
const color = $(elem).css('background-color').rgbToHex();
|
const color = $(elem).css('background-color').rgbToHex();
|
||||||
if (modelValue != null && modelValue[0] == 'r') {
|
if (modelValue != null && modelValue[0] === 'r') {
|
||||||
modelValue = modelValue.rgbToHex();
|
modelValue = modelValue.rgbToHex();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modelValue != null && modelValue.toUpperCase() == color.toUpperCase()) {
|
if (modelValue != null && modelValue.toUpperCase() === color.toUpperCase()) {
|
||||||
$(elem).parent().attr('class', 'palette-cell palette-cell-selected');
|
$(elem).parent().attr('class', 'palette-cell palette-cell-selected');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
import { $assert } from "@wisemapping/core-js";
|
||||||
import PersistenceManager from '../PersistenceManager';
|
import PersistenceManager from '../PersistenceManager';
|
||||||
|
|
||||||
const IMenu = new Class({
|
const IMenu = new Class({
|
||||||
@ -90,7 +91,7 @@ const IMenu = new Class({
|
|||||||
if (saveHistory) {
|
if (saveHistory) {
|
||||||
saveElem.css('cursor', 'pointer');
|
saveElem.css('cursor', 'pointer');
|
||||||
|
|
||||||
if (error.severity != 'FATAL') {
|
if (error.severity !== 'FATAL') {
|
||||||
$notify(error.message);
|
$notify(error.message);
|
||||||
} else {
|
} else {
|
||||||
$notifyModal(error.message);
|
$notifyModal(error.message);
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
import { $assert } from '@wisemapping/core-js';
|
||||||
import FloatingTip from './FloatingTip';
|
import FloatingTip from './FloatingTip';
|
||||||
|
|
||||||
const KeyboardShortcutTooltip = new Class({
|
const KeyboardShortcutTooltip = new Class({
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
import { $defined } from '@wisemapping/core-js';
|
||||||
import BootstrapDialog from '../libraries/bootstrap/BootstrapDialog';
|
import BootstrapDialog from '../libraries/bootstrap/BootstrapDialog';
|
||||||
import IMenu from './IMenu';
|
import IMenu from './IMenu';
|
||||||
import FontFamilyPanel from './FontFamilyPanel';
|
import FontFamilyPanel from './FontFamilyPanel';
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
import { $assert } from '@wisemapping/core-js';
|
||||||
import Events from '../Events';
|
import Events from '../Events';
|
||||||
|
|
||||||
const ToolbarItem = new Class({
|
const ToolbarItem = new Class({
|
||||||
|
@ -16,16 +16,18 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const ToolbarNotifier = new Class({
|
import $ from '@libraries/jquery-2.1.0';
|
||||||
initialize() {
|
|
||||||
|
class ToolbarNotifier {
|
||||||
|
constructor() {
|
||||||
this.container = $('#headerNotifier');
|
this.container = $('#headerNotifier');
|
||||||
},
|
}
|
||||||
|
|
||||||
hide() {
|
hide() {
|
||||||
this.container.hide();
|
this.container.hide();
|
||||||
},
|
}
|
||||||
|
|
||||||
logMessage(msg, fade) {
|
logMessage(msg) {
|
||||||
$assert(msg, 'msg can not be null');
|
$assert(msg, 'msg can not be null');
|
||||||
// In case of print,embedded no message is displayed ....
|
// In case of print,embedded no message is displayed ....
|
||||||
if (this.container && !this.container.data('transitioning')) {
|
if (this.container && !this.container.data('transitioning')) {
|
||||||
@ -38,11 +40,11 @@ const ToolbarNotifier = new Class({
|
|||||||
this.container.show().fadeOut(5000);
|
this.container.show().fadeOut(5000);
|
||||||
}
|
}
|
||||||
this.container.data('transitioning', false);
|
this.container.data('transitioning', false);
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
const toolbarNotifier = new ToolbarNotifier();
|
const toolbarNotifier = new ToolbarNotifier();
|
||||||
const $notify = function (msg) {
|
const $notify = (msg) => {
|
||||||
toolbarNotifier.logMessage(msg);
|
toolbarNotifier.logMessage(msg);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
import { $assert } from '@wisemapping/core-js';
|
||||||
import ToolbarItem from './ToolbarItem';
|
import ToolbarItem from './ToolbarItem';
|
||||||
import FloatingTip from './FloatingTip';
|
import FloatingTip from './FloatingTip';
|
||||||
|
|
||||||
@ -25,10 +26,10 @@ const ToolbarPaneItem = new Class({
|
|||||||
$assert(model, 'model can not be null');
|
$assert(model, 'model can not be null');
|
||||||
this._model = model;
|
this._model = model;
|
||||||
const me = this;
|
const me = this;
|
||||||
const fn = function () {
|
const fn = () => {
|
||||||
// Is the panel being displayed ?
|
return me.isVisible() ? me.hide() : me.show();
|
||||||
me.isVisible() ? me.hide() : me.show();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.parent(buttonId, fn, { topicAction: true, relAction: false });
|
this.parent(buttonId, fn, { topicAction: true, relAction: false });
|
||||||
this._panelElem = this._init();
|
this._panelElem = this._init();
|
||||||
this._visible = false;
|
this._visible = false;
|
||||||
@ -118,7 +119,7 @@ const ToolbarPaneItem = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
buildPanel: function () {
|
buildPanel: function () {
|
||||||
throw 'Method must be implemented';
|
throw new Error('Method must be implemented');
|
||||||
}.protect(),
|
}.protect(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,26 +1,6 @@
|
|||||||
|
/* eslint-disable no-unused-vars */
|
||||||
import '@libraries/mootools-core-1.4.5';
|
import '@libraries/mootools-core-1.4.5';
|
||||||
import $ from '@libraries/jquery-2.1.0';
|
|
||||||
import _ from '@libraries/underscore-min';
|
import _ from '@libraries/underscore-min';
|
||||||
|
|
||||||
import coreJs from '@wisemapping/core-js';
|
import Mindmap from './components/model/Mindmap';
|
||||||
|
import PersistenceManager from './components/PersistenceManager';
|
||||||
import commands from '@commands';
|
|
||||||
import layout from '@layout';
|
|
||||||
import models from '@model';
|
|
||||||
import persistence from '@persistence';
|
|
||||||
import widget from '@widget';
|
|
||||||
import component from '@components';
|
|
||||||
|
|
||||||
global.$ = $;
|
|
||||||
global.JQuery = $;
|
|
||||||
global._ = _;
|
|
||||||
global.core = coreJs();
|
|
||||||
|
|
||||||
export default {
|
|
||||||
commands,
|
|
||||||
layout,
|
|
||||||
models,
|
|
||||||
persistence,
|
|
||||||
widget,
|
|
||||||
...component,
|
|
||||||
};
|
|
||||||
|
@ -15,8 +15,10 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
import { $assert } from '@wisemapping/core-js';
|
||||||
import mindplot from '../../../../src/mindplot';
|
import Mindmap from '../../../../src/components/model/Mindmap';
|
||||||
|
import PersistenceManager from '../../../../src/components/PersistenceManager';
|
||||||
|
import $ from '@libraries/jquery-2.1.0'
|
||||||
|
|
||||||
let designer = null;
|
let designer = null;
|
||||||
|
|
||||||
@ -191,7 +193,6 @@ global.editor.WaitDialog = new Class({
|
|||||||
|
|
||||||
// Show loading dialog ...
|
// Show loading dialog ...
|
||||||
$(() => {
|
$(() => {
|
||||||
global.jQuery = global.$;
|
|
||||||
import('./bootstrap').then(() => {
|
import('./bootstrap').then(() => {
|
||||||
global.waitDialog = new global.editor.WaitDialog();
|
global.waitDialog = new global.editor.WaitDialog();
|
||||||
global.waitDialog.show();
|
global.waitDialog.show();
|
||||||
@ -204,13 +205,13 @@ $(() => {
|
|||||||
var designer = buildDesigner(options);
|
var designer = buildDesigner(options);
|
||||||
|
|
||||||
// Load map from XML file persisted on disk...
|
// Load map from XML file persisted on disk...
|
||||||
var persistence = mindplot.PersistenceManager.getInstance();
|
var persistence = PersistenceManager.getInstance();
|
||||||
var mindmap;
|
var mindmap;
|
||||||
try {
|
try {
|
||||||
mindmap = persistence.load(mapId);
|
mindmap = persistence.load(mapId);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// If the map could not be loaded, create a new empty map...
|
// If the map could not be loaded, create a new empty map...
|
||||||
mindmap = mindplot.model.Mindmap.buildEmpty(mapId);
|
mindmap = Mindmap.buildEmpty(mapId);
|
||||||
}
|
}
|
||||||
designer.loadMap(mindmap);
|
designer.loadMap(mindmap);
|
||||||
// from viewmode.html ---------
|
// from viewmode.html ---------
|
||||||
|
Loading…
Reference in New Issue
Block a user