- Remove getTopicType flag.

This commit is contained in:
Paulo Gustavo Veiga 2012-09-20 09:23:48 -03:00
parent 8a8922f2a6
commit a0ee153ca0
5 changed files with 291 additions and 265 deletions

View File

@ -40,20 +40,11 @@ mindplot.CentralTopic = new Class({
return 11; return 11;
}, },
getTopicType:function () {
return mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE;
},
setCursor:function (type) { setCursor:function (type) {
type = (type == 'move') ? 'default' : type; type = (type == 'move') ? 'default' : type;
this.parent(type); this.parent(type);
}, },
isConnectedToCentralTopic:function () {
return false;
},
_defaultShapeType:function () { _defaultShapeType:function () {
return mindplot.model.TopicShape.ROUNDED_RECT; return mindplot.model.TopicShape.ROUNDED_RECT;
}, },

View File

@ -116,7 +116,6 @@ mindplot.Designer = new Class({
}, },
addEvent:function (type, listener) { addEvent:function (type, listener) {
if (type == mindplot.TopicEvent.EDIT || type == mindplot.TopicEvent.CLICK) { if (type == mindplot.TopicEvent.EDIT || type == mindplot.TopicEvent.CLICK) {
var editor = mindplot.TopicEventDispatcher.getInstance(); var editor = mindplot.TopicEventDispatcher.getInstance();
@ -161,6 +160,48 @@ mindplot.Designer = new Class({
} }
}.bind(this)); }.bind(this));
// Register mouse drag and drop event ...
function noopHandler(evt) {
evt.stopPropagation();
evt.preventDefault();
}
// Enable drag events ...
Element.NativeEvents.dragenter = 2;
Element.NativeEvents.dragexit = 2;
Element.NativeEvents.dragover = 2;
Element.NativeEvents.drop = 2;
screenManager.addEvent('dragenter', noopHandler);
screenManager.addEvent('dragexit', noopHandler);
screenManager.addEvent('dragover', noopHandler);
screenManager.addEvent('drop', function (evt) {
evt.stopPropagation();
evt.preventDefault();
//
var files = evt.event.dataTransfer.files;
console.log(event);
var count = files.length;
// Only call the handler if 1 or more files was dropped.
if (count > 0) {
var model = this.getMindmap().createNode();
model.setImageSize(80, 43);
model.setMetadata("{'media':'video,'url':'http://www.youtube.com/watch?v=P3FrXftyuzw&feature=g-vrec&context=G2b4ab69RVAAAAAAAAAA'}");
model.setImageUrl("images/logo-small.png");
model.setShapeType(mindplot.model.TopicShape.IMAGE);
var position = screenManager.getWorkspaceMousePosition(evt);
model.setPosition(position.x, position.y);
model.setPosition(100, 100);
this._actionDispatcher.addTopics([model]);
}
}.bind(this));
}, },
_buildDragManager:function (workspace) { _buildDragManager:function (workspace) {
@ -362,7 +403,7 @@ mindplot.Designer = new Class({
// Exclude central topic .. // Exclude central topic ..
topics = topics.filter(function (topic) { topics = topics.filter(function (topic) {
return topic.getTopicType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE return !topic.isCentralTopic();
}); });
this._clipboard = topics.map(function (topic) { this._clipboard = topics.map(function (topic) {
@ -692,7 +733,7 @@ mindplot.Designer = new Class({
}, },
_removeTopic:function (node) { _removeTopic:function (node) {
if (node.getTopicType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) { if (!node.isCentralTopic()) {
var parent = node._parent; var parent = node._parent;
node.disconnect(this._workspace); node.disconnect(this._workspace);
@ -722,14 +763,14 @@ mindplot.Designer = new Class({
// If there are more than one node selected, // If there are more than one node selected,
$notify($msg('ENTITIES_COULD_NOT_BE_DELETED')); $notify($msg('ENTITIES_COULD_NOT_BE_DELETED'));
return; return;
} else if (topics.length == 1 && topics[0].getTopicType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) { } else 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;
} }
// If the central topic has been selected, I must filter ir // If the central topic has been selected, I must filter ir
var topicIds = topics.filter(function (topic) { var topicIds = topics.filter(function (topic) {
return topic.getTopicType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE return !topic.isCentralTopic();
}).map(function (topic) { }).map(function (topic) {
return topic.getId() return topic.getId()
}); });

View File

@ -228,7 +228,7 @@ mindplot.DesignerKeyboard = new Class({
'right':function () { 'right':function () {
var node = model.selectedTopic(); var node = model.selectedTopic();
if (node) { if (node) {
if (node.getTopicType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) { if (node.isCentralTopic()) {
this._goToSideChild(designer, node, 'RIGHT'); this._goToSideChild(designer, node, 'RIGHT');
} }
else { else {
@ -248,7 +248,7 @@ mindplot.DesignerKeyboard = new Class({
'left':function () { 'left':function () {
var node = model.selectedTopic(); var node = model.selectedTopic();
if (node) { if (node) {
if (node.getTopicType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) { if (node.isCentralTopic()) {
this._goToSideChild(designer, node, 'LEFT'); this._goToSideChild(designer, node, 'LEFT');
} }
else { else {
@ -268,7 +268,7 @@ mindplot.DesignerKeyboard = new Class({
'up':function () { 'up':function () {
var node = model.selectedTopic(); var node = model.selectedTopic();
if (node) { if (node) {
if (node.getTopicType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) { if (!node.isCentralTopic()) {
this._goToBrother(designer, node, 'UP'); this._goToBrother(designer, node, 'UP');
} }
} else { } else {
@ -280,7 +280,7 @@ mindplot.DesignerKeyboard = new Class({
'down':function () { 'down':function () {
var node = model.selectedTopic(); var node = model.selectedTopic();
if (node) { if (node) {
if (node.getTopicType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) { if (!node.isCentralTopic()) {
this._goToBrother(designer, node, 'DOWN'); this._goToBrother(designer, node, 'DOWN');
} }
} else { } else {

View File

@ -88,10 +88,6 @@ mindplot.MainTopic = new Class({
innerShape.setVisibility(true); innerShape.setVisibility(true);
}, },
getTopicType:function () {
return "MainTopic";
},
_updatePositionOnChangeSize:function (oldSize, newSize) { _updatePositionOnChangeSize:function (oldSize, newSize) {
var xOffset = Math.round((newSize.width - oldSize.width) / 2); var xOffset = Math.round((newSize.width - oldSize.width) / 2);
@ -181,13 +177,6 @@ mindplot.MainTopic = new Class({
return result; return result;
}, },
isConnectedToCentralTopic:function () {
var model = this.getModel();
var parent = model.getParent();
return parent && parent.getType() === mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE;
},
_defaultText:function () { _defaultText:function () {
var targetTopic = this.getOutgoingConnectedTopic(); var targetTopic = this.getOutgoingConnectedTopic();
var result = ""; var result = "";
@ -199,7 +188,6 @@ mindplot.MainTopic = new Class({
} }
} else { } else {
result = $msg('ISOLATED_TOPIC'); result = $msg('ISOLATED_TOPIC');
;
} }
return result; return result;
}, },

View File

@ -1216,7 +1216,13 @@ mindplot.Topic = new Class({
} }
} }
return result; return result;
},
isCentralTopic:function () {
return this.getModel().getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE;
} }
}); });