mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 14:17:57 +01:00
Add remove node support.
This commit is contained in:
parent
c1e0d52ff5
commit
5a08728686
@ -52,12 +52,12 @@
|
||||
<concat destfile="${basedir}/target/tmp/mindplot.js" append="false">
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="header.js"/>
|
||||
|
||||
<filelist dir="${basedir}/src/main/javascript/libraries/"
|
||||
<filelist dir="${basedir}/src/main/javascript/libraries/moodialog/"
|
||||
files="Overlay.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/libraries/"
|
||||
files="MooDialog.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/libraries/"
|
||||
files="MooDialog.Fx.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/libraries/moodialog/"
|
||||
files="MooDialog.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/libraries/moodialog/"
|
||||
files="MooDialog.Fx.js"/>
|
||||
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="EventBus.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="model/IMindmap.js"/>
|
||||
|
@ -26,6 +26,7 @@ mindplot.MindmapDesigner = new Class({
|
||||
// Dispatcher manager ...
|
||||
var commandContext = new mindplot.CommandContext(this);
|
||||
this._actionDispatcher = new mindplot.BrixActionDispatcher(commandContext);
|
||||
// this._actionDispatcher = new mindplot.LocalActionDispatcher(commandContext);
|
||||
// this._actionDispatcher = new mindplot.LocalActionDispatcher(commandContext);
|
||||
this._actionDispatcher.addEvent("modelUpdate", function(event) {
|
||||
this.fireEvent("modelUpdate", event);
|
||||
|
@ -71,7 +71,12 @@ mindplot.collaboration.framework.brix.model.Mindmap = new Class({
|
||||
addBranch : function(nodeModel) {
|
||||
$assert(nodeModel, "nodeModel can not be null");
|
||||
var branches = this._brixModel.get("branches");
|
||||
branches.add(nodeModel.getBrixModel());
|
||||
|
||||
// @Todo: Hack ?
|
||||
var newModel = mindplot.collaboration.framework.brix.model.NodeModel.create(this._brixFramework, this, nodeModel.getType(), nodeModel.getId());
|
||||
nodeModel.copyTo(newModel);
|
||||
|
||||
branches.add(newModel);
|
||||
},
|
||||
|
||||
removeBranch : function(nodeModel) {
|
||||
|
@ -63,17 +63,19 @@ mindplot.collaboration.framework.brix.model.NodeModel = new Class({
|
||||
}.bind(this));
|
||||
|
||||
children.addListener("valuesRemoved", function(event) {
|
||||
console.log("remove node:" + funName);
|
||||
|
||||
var brixChildren = event.getValues();
|
||||
for (var i = 0; i < brixChildren.size(); i++) {
|
||||
var brixNodeModel = brixChildren.get(i);
|
||||
var cmodel = new mindplot.collaboration.framework.brix.model.NodeModel(this._brixFramework, brixNodeModel, this.getMindmap());
|
||||
actionDispatcher.deleteTopics(cmodel.getId());
|
||||
try {
|
||||
var brixChildren = event.getValues();
|
||||
for (var i = 0; i < brixChildren.size(); i++) {
|
||||
var brixNodeModel = brixChildren.get(i);
|
||||
var cmodel = new mindplot.collaboration.framework.brix.model.NodeModel(this._brixFramework, brixNodeModel, this.getMindmap());
|
||||
actionDispatcher.deleteTopics([cmodel.getId()]);
|
||||
}
|
||||
} catch(e) {
|
||||
console.trace();
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
}.bind(this));
|
||||
|
||||
this._brixModel.__registered = true;
|
||||
}
|
||||
},
|
||||
@ -106,7 +108,7 @@ mindplot.collaboration.framework.brix.model.NodeModel = new Class({
|
||||
},
|
||||
|
||||
getPropertiesKeys : function() {
|
||||
return this._brixModel.getKeys();
|
||||
return this._brixModel.getKeys().erase('children');
|
||||
},
|
||||
|
||||
getParent : function() {
|
||||
|
@ -225,23 +225,16 @@ mindplot.model.INodeModel = new Class({
|
||||
deleteNode : function() {
|
||||
var mindmap = this.getMindmap();
|
||||
|
||||
// if it has children nodes, Their must be disconnected.
|
||||
var children = this.getChildren();
|
||||
var length = children.length;
|
||||
|
||||
for (var i = 0; i < length; i++) {
|
||||
var child = children[i];
|
||||
mindmap.disconnect(child);
|
||||
}
|
||||
|
||||
// if it is connected, I must remove it from the parent..
|
||||
console.log(mindmap.inspect());
|
||||
var parent = this.getParent();
|
||||
if ($defined(parent)) {
|
||||
mindmap.disconnect(this);
|
||||
parent.removeChild(this);
|
||||
} else {
|
||||
// If it has not parent, it must be an isolate topic ...
|
||||
mindmap.removeBranch(this);
|
||||
}
|
||||
|
||||
// It's an isolated node. It must be a hole branch ...
|
||||
mindmap.removeBranch(this);
|
||||
console.log(mindmap.inspect());
|
||||
},
|
||||
|
||||
getPropertiesKeys : function() {
|
||||
@ -325,7 +318,13 @@ mindplot.model.INodeModel = new Class({
|
||||
if (children.length > 0) {
|
||||
result = result + ", children: {(size:" + children.length;
|
||||
children.forEach(function(node) {
|
||||
result = result + "=> (" + node.getPropertiesKeys() + ")";
|
||||
result = result + "=> (";
|
||||
var keys = node.getPropertiesKeys();
|
||||
keys.forEach(function(key) {
|
||||
var value = node.getProperty(key);
|
||||
result = result + key + ":" + value + ",";
|
||||
});
|
||||
result = result + "}"
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ mindplot.model.NodeModel = new Class({
|
||||
return cnode;
|
||||
});
|
||||
|
||||
result._properties = this._properties.clone();
|
||||
result._properties = Object.clone(this._properties);
|
||||
result._icons = this._icons.clone();
|
||||
result._links = this._links.clone();
|
||||
result._notes = this._notes.clone();
|
||||
|
@ -8,40 +8,41 @@
|
||||
|
||||
app.addListener('modelLoad', function(model) {
|
||||
var root = app.getModel().getRoot();
|
||||
if (!root.get("mindmap7")) {
|
||||
|
||||
console.log("Creating empty map ...");
|
||||
|
||||
// var topics = app.getModel().create("List");
|
||||
root.put("mindmap7", "start_");
|
||||
var myList = root.get("myList");
|
||||
if (!myList) {
|
||||
myList = app.getModel().create("List");
|
||||
root.put("myList", myList);
|
||||
}
|
||||
|
||||
root.addListener('valueChanged', function(e) {
|
||||
console.log("New item added ...:");
|
||||
console.log(app.getModel().getRoot().get("mindmap7"));
|
||||
myList.addListener('valuesAdded', function(event) {
|
||||
console.log("value added:" + myList.size());
|
||||
});
|
||||
|
||||
myList.addListener('valuesRemoved', function(event) {
|
||||
console.log("value removed:" + myList.size());
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
removedAction = function() {
|
||||
var root = app.getModel().getRoot();
|
||||
var myList = root.get("myList");
|
||||
myList.remove(myList.size() - 1);
|
||||
};
|
||||
|
||||
addAction = function() {
|
||||
var root = app.getModel().getRoot();
|
||||
var myList = root.get("myList");
|
||||
myList.add("Some elem " + myList.size());
|
||||
console.log("Click on adding...");
|
||||
};
|
||||
};
|
||||
|
||||
function addTopic() {
|
||||
|
||||
console.log("Adding new item ver:2 ...");
|
||||
|
||||
var root = app.getModel().getRoot();
|
||||
var topics = root.get("mindmap7");
|
||||
|
||||
// var topic = app.getModel().create("Map");
|
||||
// topic.put("id", "topic_x");
|
||||
// topic.put("text", "topic X text");
|
||||
// topics.add(topic);
|
||||
|
||||
// root.put("mindmap7", topics);
|
||||
root.put("mindmap7", app.getModel().getRoot().get("mindmap7") + "_algo");
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
Este es este no ?
|
||||
<input style="font-size:20px;width:50px;height:50px;" type="button" value=" " id="a2" onclick="addTopic(this)"/>
|
||||
Funca?
|
||||
|
||||
<input style="font-size:20px;width:50px;height:50px;" type="button" value="Add" id="a2" onclick="addAction(this)"/>
|
||||
<input style="font-size:20px;width:50px;height:50px;" type="button" value="Remove" id="a2"
|
||||
onclick="removedAction(this)"/>
|
||||
</body>
|
||||
</html>
|
@ -11,18 +11,12 @@
|
||||
<title>WiseMapping - Editor </title>
|
||||
<link rel="stylesheet" type="text/css" href="../css/editor.css"/>
|
||||
<link rel="stylesheet" type="text/css" href='/mindplot/src/main/javascript/libraries/moodialog/css/MooDialog.css'/>
|
||||
|
||||
<!--<script type='text/javascript' src='../js/wiseLibrary.js'></script>-->
|
||||
|
||||
<script type='text/javascript'
|
||||
src='https://ajax.googleapis.com/ajax/libs/mootools/1.3.2/mootools-yui-compressed.js'></script>
|
||||
<script type='text/javascript' src='../js/mootools-more-1.3.2.1-yui.js'></script>
|
||||
|
||||
<!--<script type='text/javascript' src='../js/common.js'></script>-->
|
||||
|
||||
<!--<script type='text/javascript' src='../js/wiseEditorLibrary.js'></script>-->
|
||||
|
||||
<script type='text/javascript' src='/core-js/target/classes/core.js'></script>
|
||||
<!--<script type='text/javascript' src='js/core-min.js'></script>-->
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
<!DOCTYPE HTML>
|
||||
!DOCTYPE HTML>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
@ -22,8 +22,6 @@
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
$("someId").addEvent("click", function(event) {
|
||||
$("someId").fireEvent("wiseNodeAdded",null)
|
||||
});
|
||||
|
@ -1,80 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
<script type="text/javascript" src="http://docs.google.com/brix/static/api/js/jsapi.nocache.js"></script>
|
||||
<script type="text/javascript">
|
||||
var app;
|
||||
|
||||
collabOnLoad = function() {
|
||||
app = new goog.collab.CollaborativeApp();
|
||||
app.start();
|
||||
app.addListener('modelLoad', function(model) {
|
||||
var root = app.getModel().getRoot();
|
||||
if (root.isEmpty()) {
|
||||
root.put("a1", ' ');
|
||||
root.put("a2", " ");
|
||||
root.put("a3", " ");
|
||||
root.put("b1", " ");
|
||||
root.put("b2", " ");
|
||||
root.put("b3", " ");
|
||||
root.put("c1", " ");
|
||||
root.put("c2", " ");
|
||||
root.put("c3", " ");
|
||||
root.put("turn", "X");
|
||||
}
|
||||
var list1 = app.getModel().create("List");
|
||||
root.put("list",list1);
|
||||
|
||||
document.getElementById("a1").value = root.get("a1");
|
||||
document.getElementById("a2").value = root.get("a2");
|
||||
document.getElementById("a3").value = root.get("a3");
|
||||
document.getElementById("b1").value = root.get("b1");
|
||||
document.getElementById("b2").value = root.get("b2");
|
||||
document.getElementById("b3").value = root.get("b3");
|
||||
document.getElementById("c1").value = root.get("c1");
|
||||
document.getElementById("c2").value = root.get("c2");
|
||||
document.getElementById("c3").value = root.get("c3");
|
||||
relabelTurn(root.get("turn"));
|
||||
|
||||
root.addListener('valueChanged', function(e) {
|
||||
document.getElementById(e.getProperty()).value = e.getNewValue();
|
||||
relabelTurn(root.get("turn"));
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function move(square) {
|
||||
app.getModel().getRoot().put(square.id, app.getModel().getRoot().get("turn"));
|
||||
var turn = app.getModel().getRoot().get("turn") == "X" ? "O" : "X";
|
||||
app.getModel().getRoot().put("turn", turn);
|
||||
relabelTurn(app.getModel().getRoot().get("turn"));
|
||||
app.getModel().getRoot().get("list").add(turn);
|
||||
}
|
||||
|
||||
function relabelTurn(turn) {
|
||||
document.getElementById("turn").innerHTML = "Next move is: " + turn;
|
||||
}
|
||||
|
||||
</script>
|
||||
<p>
|
||||
TIC TAC TOE!
|
||||
<p>
|
||||
<span id=turn></span>
|
||||
<table>
|
||||
<tr>
|
||||
<td><input style="font-size:20px;width:50px;height:50px;" type="button" value=" " id="a1" onclick="move(this)"></td>
|
||||
<td><input style="font-size:20px;width:50px;height:50px;" type="button" value=" " id="b1" onclick="move(this)"></td>
|
||||
<td><input style="font-size:20px;width:50px;height:50px;" type="button" value=" " id="c1" onclick="move(this)"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input style="font-size:20px;width:50px;height:50px;" type="button" value=" " id="a2" onclick="move(this)"></td>
|
||||
<td><input style="font-size:20px;width:50px;height:50px;" type="button" value=" " id="b2" onclick="move(this)"></td>
|
||||
<td><input style="font-size:20px;width:50px;height:50px;" type="button" value=" " id="c2" onclick="move(this)"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input style="font-size:20px;width:50px;height:50px;" type="button" value=" " id="a3" onclick="move(this)"></td>
|
||||
<td><input style="font-size:20px;width:50px;height:50px;" type="button" value=" " id="b3" onclick="move(this)"></td>
|
||||
<td><input style="font-size:20px;width:50px;height:50px;" type="button" value=" " id="c3" onclick="move(this)"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
@ -237,7 +237,7 @@ if (localEnv) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Asset.javascript("../js/mindplot.svg.js", {
|
||||
Asset.javascript("../js/mindplot-min.js", {
|
||||
onLoad:function() {
|
||||
$(document).fireEvent('loadcomplete', 'mind')
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user