mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 14:17:57 +01:00
Introduce the convept of Feature to a topic.
This commit is contained in:
parent
9e44804314
commit
7ba0e36cb9
@ -68,7 +68,6 @@
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="DesignerKeyboard.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="NodeGraph.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="Topic.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="TextTopic.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="CentralTopic.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="MainTopic.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="DragTopic.js"/>
|
||||
@ -82,7 +81,8 @@
|
||||
<!--<filelist dir="${basedir}/src/main/javascript/" files="RichTextEditor.js"/>-->
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="TextEditorFactory.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="util/Shape.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="persistence/ModelCodeName.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
files="persistence/ModelCodeName.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
files="persistence/XMLSerializer_Pela.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
@ -91,7 +91,8 @@
|
||||
files="persistence/Pela2TangoMigrator.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
files="persistence/XMLSerializer_Beta.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="persistence/Beta2PelaMigrator.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
files="persistence/Beta2PelaMigrator.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
files="persistence/XMLSerializerFactory.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="PersistenceManager.js"/>
|
||||
@ -105,6 +106,7 @@
|
||||
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="ActionIcon.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="ImageIcon.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="model/FeatureModel.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="model/IconModel.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="model/LinkModel.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="model/NoteModel.js"/>
|
||||
@ -114,7 +116,7 @@
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="ControlPoint.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="EditorOptions.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="RelationshipPivot.js"/>
|
||||
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="TopicFeature.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/commands/"
|
||||
files="GenericFunctionCommand.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/commands/" files="DeleteCommand.js"/>
|
||||
@ -123,17 +125,11 @@
|
||||
<filelist dir="${basedir}/src/main/javascript/commands/"
|
||||
files="AddTopicCommand.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
files="commands/ChangeLinkToTopicCommand.js"/>
|
||||
files="commands/ChangeFeatureToTopicCommand.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
files="commands/RemoveLinkFromTopicCommand.js"/>
|
||||
files="commands/RemoveFeatureFromTopicCommand.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
files="commands/AddIconToTopicCommand.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
files="commands/RemoveIconFromTopicCommand.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
files="commands/ChangeNoteToTopicCommand.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
files="commands/RemoveNoteFromTopicCommand.js"/>
|
||||
files="commands/AddFeatureToTopicCommand.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
files="commands/AddRelationshipCommand.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
@ -167,6 +163,7 @@
|
||||
files="widget/IMenu.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
files="widget/Menu.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="TopicFeature.js"/>
|
||||
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
files="layout/EventBusDispatcher.js"/>
|
||||
|
@ -23,18 +23,6 @@ mindplot.ActionDispatcher = new Class({
|
||||
$assert(commandContext, "commandContext can not be null");
|
||||
},
|
||||
|
||||
addIconToTopic: function(topicId, iconType) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
changeLinkToTopic: function(topicId, url) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
changeNoteToTopic: function(topicId, text) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
connectByRelation: function(model, mindmap) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
@ -59,18 +47,6 @@ mindplot.ActionDispatcher = new Class({
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
removeIconFromTopic: function(topicId, iconModel) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
removeLinkFromTopic: function(topicId) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
removeNoteFromTopic: function(topicId) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
changeFontFamilyToTopic: function(topicIds, fontFamily) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
@ -109,9 +85,19 @@ mindplot.ActionDispatcher = new Class({
|
||||
|
||||
shrinkBranch : function(topicsIds, collapse) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
addFeatureToTopic : function(topicId, type, attributes) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
changeFeatureToTopic : function(topicId, featureId, attributes) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
removeFeatureFromTopic : function(topicId, featureId) {
|
||||
throw "method must be implemented.";
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
mindplot.ActionDispatcher.setInstance = function(dispatcher) {
|
||||
|
@ -22,14 +22,17 @@ mindplot.Command = new Class(
|
||||
{
|
||||
this._id = mindplot.Command._nextUUID();
|
||||
},
|
||||
|
||||
execute: function(commandContext)
|
||||
{
|
||||
throw "execute must be implemented.";
|
||||
},
|
||||
|
||||
undoExecute: function(commandContext)
|
||||
{
|
||||
throw "undo must be implemented.";
|
||||
},
|
||||
|
||||
getId:function()
|
||||
{
|
||||
return this._id;
|
||||
|
@ -422,7 +422,7 @@ mindplot.Designer = new Class({
|
||||
$assert(mindmapModel, "mindmapModel can not be null");
|
||||
this._mindmap = mindmapModel;
|
||||
|
||||
// try {
|
||||
try {
|
||||
// Init layout manager ...
|
||||
var size = {width:25,height:25};
|
||||
var layoutManager = new mindplot.layout.LayoutManager(mindmapModel.getCentralTopic().getId(), size);
|
||||
@ -446,7 +446,6 @@ mindplot.Designer = new Class({
|
||||
nodeGraph.setBranchVisibility(true);
|
||||
}
|
||||
|
||||
|
||||
var relationships = mindmapModel.getRelationships();
|
||||
for (var j = 0; j < relationships.length; j++) {
|
||||
this._relationshipModelToRelationship(relationships[j]);
|
||||
@ -460,9 +459,9 @@ mindplot.Designer = new Class({
|
||||
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.DoLayout);
|
||||
|
||||
this.fireEvent('loadSuccess');
|
||||
// } catch(e) {
|
||||
// this.fireEvent('loadError',e);
|
||||
// }
|
||||
} catch(e) {
|
||||
this.fireEvent('loadError', e);
|
||||
}
|
||||
},
|
||||
|
||||
getMindmap : function() {
|
||||
@ -707,7 +706,7 @@ mindplot.Designer = new Class({
|
||||
addIconType : function(iconType) {
|
||||
var topicsIds = this.getModel().filterTopicsIds();
|
||||
if (topicsIds.length > 0) {
|
||||
this._actionDispatcher.addIconToTopic(topicsIds[0], iconType);
|
||||
this._actionDispatcher.addFeatureToTopic(topicsIds[0], mindplot.TopicFeature.Icon.id, {id:iconType});
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -83,10 +83,10 @@ mindplot.IconGroup = new Class({
|
||||
|
||||
_findIconFromModel : function(iconModel) {
|
||||
var result = null;
|
||||
this._icons.each(function(el) {
|
||||
var elModel = el.getModel();
|
||||
if (result == null && $defined(elModel.isIconModel) && elModel.getId() == iconModel.getId()) {
|
||||
result = el;
|
||||
this._icons.each(function(icon) {
|
||||
var elModel = icon.getModel();
|
||||
if (elModel.getId() == iconModel.getId()) {
|
||||
result = icon;
|
||||
}
|
||||
}, this);
|
||||
|
||||
@ -110,6 +110,13 @@ mindplot.IconGroup = new Class({
|
||||
this._removeIcon(icon);
|
||||
},
|
||||
|
||||
removeIconByModel : function(featureModel) {
|
||||
$assert(featureModel, "featureModel can not be null");
|
||||
|
||||
var icon = this._findIconFromModel(featureModel);
|
||||
this._removeIcon(icon);
|
||||
},
|
||||
|
||||
_removeIcon : function(icon) {
|
||||
$assert(icon, "icon can not be null");
|
||||
|
||||
|
@ -23,7 +23,7 @@ mindplot.ImageIcon = new Class({
|
||||
$assert(topic, 'topic can not be null');
|
||||
|
||||
this._topicId = topic.getId();
|
||||
this._iconModel = iconModel;
|
||||
this._featureModel = iconModel;
|
||||
|
||||
// @Todo: Read only must be a property ...
|
||||
this._readOnly = designer._readOnly;
|
||||
@ -57,7 +57,7 @@ mindplot.ImageIcon = new Class({
|
||||
},
|
||||
|
||||
getModel : function() {
|
||||
return this._iconModel;
|
||||
return this._featureModel;
|
||||
},
|
||||
|
||||
_getNextFamilyIconId : function(iconId) {
|
||||
@ -98,21 +98,39 @@ mindplot.ImageIcon = new Class({
|
||||
return result;
|
||||
},
|
||||
|
||||
getId : function() {
|
||||
return this._iconType;
|
||||
},
|
||||
|
||||
getUiId : function() {
|
||||
return this._uiId;
|
||||
},
|
||||
|
||||
remove : function() {
|
||||
var actionDispatcher = mindplot.ActionDispatcher.getInstance();
|
||||
actionDispatcher.removeIconFromTopic(this._topicId, this._iconModel);
|
||||
var featureId = this._featureModel.getId();
|
||||
var topicId = this._topicId;
|
||||
actionDispatcher.removeFeatureFromTopic(topicId, featureId);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mindplot.ImageIcon.prototype.ICON_FAMILIES = [{"id": "face", "icons" : ["face_plain","face_sad","face_crying","face_smile","face_surprise","face_wink"]},{"id": "funy", "icons" : ["funy_angel","funy_devilish","funy_glasses","funy_grin","funy_kiss","funy_monkey"]},{"id": "conn", "icons" : ["conn_connect","conn_disconnect"]},{"id": "sport", "icons" : ["sport_basketball","sport_football","sport_golf","sport_raquet","sport_shuttlecock","sport_soccer","sport_tennis"]},{"id": "bulb", "icons" : ["bulb_light_on","bulb_light_off"]},{"id": "thumb", "icons" : ["thumb_thumb_up","thumb_thumb_down"]},{"id": "tick", "icons" : ["tick_tick","tick_cross"]},{"id": "onoff", "icons" : ["onoff_clock","onoff_clock_red","onoff_add","onoff_delete","onoff_status_offline","onoff_status_online"]},{"id": "money", "icons" : ["money_money","money_dollar","money_euro","money_pound","money_yen","money_coins","money_ruby"]},{"id": "time", "icons" : ["time_calendar","time_clock","time_hourglass"]},{"id": "chart", "icons" : ["chart_bar","chart_line","chart_curve","chart_pie","chart_organisation"]},{"id": "sign", "icons" : ["sign_warning","sign_info","sign_stop","sign_help","sign_cancel"]},{"id": "hard", "icons" : ["hard_cd","hard_computer","hard_controller","hard_driver_disk","hard_ipod","hard_keyboard","hard_mouse","hard_printer"]},{"id": "soft", "icons" : ["soft_bug","soft_cursor","soft_database_table","soft_database","soft_feed","soft_folder_explore","soft_rss","soft_penguin"]},{"id": "arrow", "icons" : ["arrow_up","arrow_down","arrow_left","arrow_right"]},{"id": "arrowc", "icons" : ["arrowc_rotate_anticlockwise","arrowc_rotate_clockwise","arrowc_turn_left","arrowc_turn_right"]},{"id": "people", "icons" : ["people_group","people_male1","people_male2","people_female1","people_female2"]},{"id": "mail", "icons" : ["mail_envelop","mail_mailbox","mail_edit","mail_list"]},{"id": "flag", "icons" : ["flag_blue","flag_green","flag_orange","flag_pink","flag_purple","flag_yellow"]},{"id": "bullet", "icons" : ["bullet_black","bullet_blue","bullet_green","bullet_orange","bullet_red","bullet_pink","bullet_purple"]},{"id": "tag", "icons" : ["tag_blue","tag_green","tag_orange","tag_red","tag_pink","tag_yellow"]},{"id": "object", "icons" : ["object_bell","object_clanbomber","object_key","object_pencil","object_phone","object_magnifier","object_clip","object_music","object_star","object_wizard","object_house","object_cake","object_camera","object_palette","object_rainbow"]},{"id": "weather", "icons" : ["weather_clear-night","weather_clear","weather_few-clouds-night","weather_few-clouds","weather_overcast","weather_severe-alert","weather_showers-scattered","weather_showers","weather_snow","weather_storm"]}];
|
||||
mindplot.ImageIcon.prototype.ICON_FAMILIES = [
|
||||
{"id": "face", "icons" : ["face_plain","face_sad","face_crying","face_smile","face_surprise","face_wink"]},
|
||||
{"id": "funy", "icons" : ["funy_angel","funy_devilish","funy_glasses","funy_grin","funy_kiss","funy_monkey"]},
|
||||
{"id": "conn", "icons" : ["conn_connect","conn_disconnect"]},
|
||||
{"id": "sport", "icons" : ["sport_basketball","sport_football","sport_golf","sport_raquet","sport_shuttlecock","sport_soccer","sport_tennis"]},
|
||||
{"id": "bulb", "icons" : ["bulb_light_on","bulb_light_off"]},
|
||||
{"id": "thumb", "icons" : ["thumb_thumb_up","thumb_thumb_down"]},
|
||||
{"id": "tick", "icons" : ["tick_tick","tick_cross"]},
|
||||
{"id": "onoff", "icons" : ["onoff_clock","onoff_clock_red","onoff_add","onoff_delete","onoff_status_offline","onoff_status_online"]},
|
||||
{"id": "money", "icons" : ["money_money","money_dollar","money_euro","money_pound","money_yen","money_coins","money_ruby"]},
|
||||
{"id": "time", "icons" : ["time_calendar","time_clock","time_hourglass"]},
|
||||
{"id": "chart", "icons" : ["chart_bar","chart_line","chart_curve","chart_pie","chart_organisation"]},
|
||||
{"id": "sign", "icons" : ["sign_warning","sign_info","sign_stop","sign_help","sign_cancel"]},
|
||||
{"id": "hard", "icons" : ["hard_cd","hard_computer","hard_controller","hard_driver_disk","hard_ipod","hard_keyboard","hard_mouse","hard_printer"]},
|
||||
{"id": "soft", "icons" : ["soft_bug","soft_cursor","soft_database_table","soft_database","soft_feed","soft_folder_explore","soft_rss","soft_penguin"]},
|
||||
{"id": "arrow", "icons" : ["arrow_up","arrow_down","arrow_left","arrow_right"]},
|
||||
{"id": "arrowc", "icons" : ["arrowc_rotate_anticlockwise","arrowc_rotate_clockwise","arrowc_turn_left","arrowc_turn_right"]},
|
||||
{"id": "people", "icons" : ["people_group","people_male1","people_male2","people_female1","people_female2"]},
|
||||
{"id": "mail", "icons" : ["mail_envelop","mail_mailbox","mail_edit","mail_list"]},
|
||||
{"id": "flag", "icons" : ["flag_blue","flag_green","flag_orange","flag_pink","flag_purple","flag_yellow"]},
|
||||
{"id": "bullet", "icons" : ["bullet_black","bullet_blue","bullet_green","bullet_orange","bullet_red","bullet_pink","bullet_purple"]},
|
||||
{"id": "tag", "icons" : ["tag_blue","tag_green","tag_orange","tag_red","tag_pink","tag_yellow"]},
|
||||
{"id": "object", "icons" : ["object_bell","object_clanbomber","object_key","object_pencil","object_phone","object_magnifier","object_clip","object_music","object_star","object_wizard","object_house","object_cake","object_camera","object_palette","object_rainbow"]},
|
||||
{"id": "weather", "icons" : ["weather_clear-night","weather_clear","weather_few-clouds-night","weather_few-clouds","weather_overcast","weather_severe-alert","weather_showers-scattered","weather_showers","weather_snow","weather_storm"]}
|
||||
];
|
||||
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
mindplot.ShirinkConnector = new Class({
|
||||
initialize: function(topic) {
|
||||
|
||||
var ellipse = new web2d.Elipse(mindplot.TextTopic.prototype.INNER_RECT_ATTRIBUTES);
|
||||
var ellipse = new web2d.Elipse(mindplot.Topic.prototype.INNER_RECT_ATTRIBUTES);
|
||||
this._ellipse = ellipse;
|
||||
ellipse.setFill('rgb(62,118,179)');
|
||||
|
||||
|
@ -28,26 +28,12 @@ mindplot.StandaloneActionDispatcher = new Class({
|
||||
this._actionRunner.hasBeenChanged();
|
||||
},
|
||||
|
||||
addIconToTopic: function(topicId, iconType) {
|
||||
var command = new mindplot.commands.AddIconToTopicCommand(topicId, iconType);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
changeLinkToTopic: function(topicId, url) {
|
||||
var command = new mindplot.commands.ChangeLinkToTopicCommand(topicId, url);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
addTopic:function(nodeModel, parentTopicId, animated) {
|
||||
var command = new mindplot.commands.AddTopicCommand(nodeModel, parentTopicId, animated);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
changeNoteToTopic: function(topicId, text) {
|
||||
var command = new mindplot.commands.ChangeNoteToTopicCommand(topicId, text);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
connectByRelation: function(model) {
|
||||
var command = new mindplot.commands.AddRelationshipCommand(model);
|
||||
this.execute(command);
|
||||
@ -82,20 +68,6 @@ mindplot.StandaloneActionDispatcher = new Class({
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
removeIconFromTopic: function(topicId, iconModel) {
|
||||
var command = new mindplot.commands.RemoveIconFromTopicCommand(topicId, iconModel);
|
||||
this.execute(command);
|
||||
},
|
||||
removeLinkFromTopic: function(topicId) {
|
||||
var command = new mindplot.commands.RemoveLinkFromTopicCommand(topicId);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
removeNoteFromTopic: function(topicId) {
|
||||
var command = new mindplot.commands.RemoveNoteFromTopicCommand(topicId);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
changeFontStyleToTopic: function(topicsIds) {
|
||||
|
||||
var commandFunc = function(topic) {
|
||||
@ -242,6 +214,21 @@ mindplot.StandaloneActionDispatcher = new Class({
|
||||
this.execute(command, false);
|
||||
},
|
||||
|
||||
addFeatureToTopic : function(topicId, featureType, attributes) {
|
||||
var command = new mindplot.commands.AddFeatureToTopicCommand(topicId, featureType, attributes);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
changeFeatureToTopic : function(topicId, featureId, attributes) {
|
||||
var command = new mindplot.commands.ChangeFeatureToTopicCommand(topicId, featureId, attributes);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
removeFeatureFromTopic : function(topicId, featureId) {
|
||||
var command = new mindplot.commands.RemoveFeatureFromTopicCommand(topicId, featureId);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
execute:function(command) {
|
||||
this._actionRunner.execute(command);
|
||||
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.DoLayout);
|
||||
|
@ -1,590 +0,0 @@
|
||||
/*
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
mindplot.TextTopic = new Class({
|
||||
Extends:mindplot.Topic,
|
||||
initialize : function(model, options) {
|
||||
this._textEditor = new mindplot.MultilineTextEditor(this);
|
||||
this.parent(model, options);
|
||||
},
|
||||
|
||||
_registerEvents : function() {
|
||||
|
||||
this.parent();
|
||||
this.addEvent('dblclick', function (event) {
|
||||
this._textEditor.show();
|
||||
event.stopPropagation(true);
|
||||
}.bind(this));
|
||||
|
||||
this._textEditor.addEvent('input', function(event, text) {
|
||||
var textShape = this.getTextShape();
|
||||
// var oldText = textShape.getText();
|
||||
|
||||
// this._setText(text, false);
|
||||
// @Todo: I must resize, no change the position ...
|
||||
// textShape.setText(oldText);
|
||||
}.bind(this));
|
||||
|
||||
},
|
||||
|
||||
setShapeType : function(type) {
|
||||
this._setShapeType(type, true);
|
||||
|
||||
},
|
||||
|
||||
_setShapeType : function(type, updateModel) {
|
||||
// Remove inner shape figure ...
|
||||
var model = this.getModel();
|
||||
if ($defined(updateModel) && updateModel) {
|
||||
model.setShapeType(type);
|
||||
}
|
||||
|
||||
var oldInnerShape = this.getInnerShape();
|
||||
if (oldInnerShape != null) {
|
||||
|
||||
this._removeInnerShape();
|
||||
|
||||
// Create a new one ...
|
||||
var innerShape = this.getInnerShape();
|
||||
|
||||
// Update figure size ...
|
||||
var size = model.getSize();
|
||||
this.setSize(size, true);
|
||||
|
||||
var group = this.get2DElement();
|
||||
group.appendChild(innerShape);
|
||||
|
||||
// Move text to the front ...
|
||||
var text = this.getTextShape();
|
||||
text.moveToFront();
|
||||
|
||||
//Move iconGroup to front ...
|
||||
var iconGroup = this.getIconGroup();
|
||||
if ($defined(iconGroup)) {
|
||||
iconGroup.moveToFront();
|
||||
}
|
||||
//Move connector to front
|
||||
var connector = this.getShrinkConnector();
|
||||
if ($defined(connector)) {
|
||||
connector.moveToFront();
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
getShapeType : function() {
|
||||
var model = this.getModel();
|
||||
var result = model.getShapeType();
|
||||
if (!$defined(result)) {
|
||||
result = this._defaultShapeType();
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
getInnerShape : function() {
|
||||
if (!$defined(this._innerShape)) {
|
||||
// Create inner box.
|
||||
this._innerShape = this.buildShape(mindplot.TextTopic.INNER_RECT_ATTRIBUTES);
|
||||
|
||||
// Update bgcolor ...
|
||||
var bgColor = this.getBackgroundColor();
|
||||
this._setBackgroundColor(bgColor, false);
|
||||
|
||||
// Update border color ...
|
||||
var brColor = this.getBorderColor();
|
||||
this._setBorderColor(brColor, false);
|
||||
|
||||
// Define the pointer ...
|
||||
if (this.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
this._innerShape.setCursor('move');
|
||||
} else {
|
||||
this._innerShape.setCursor('default');
|
||||
}
|
||||
|
||||
}
|
||||
return this._innerShape;
|
||||
},
|
||||
|
||||
buildShape : function(attributes, type) {
|
||||
var result;
|
||||
if (!$defined(type)) {
|
||||
type = this.getShapeType();
|
||||
}
|
||||
|
||||
if (type == mindplot.model.INodeModel.SHAPE_TYPE_RECT) {
|
||||
result = new web2d.Rect(0, attributes);
|
||||
}
|
||||
else if (type == mindplot.model.INodeModel.SHAPE_TYPE_ELIPSE) {
|
||||
result = new web2d.Rect(0.9, attributes);
|
||||
}
|
||||
else if (type == mindplot.model.INodeModel.SHAPE_TYPE_ROUNDED_RECT) {
|
||||
result = new web2d.Rect(0.3, attributes);
|
||||
}
|
||||
else if (type == mindplot.model.INodeModel.SHAPE_TYPE_LINE) {
|
||||
result = new web2d.Line({strokeColor:"#495879",strokeWidth:1});
|
||||
result.setSize = function(width, height) {
|
||||
this.size = {width:width, height:height};
|
||||
result.setFrom(0, height);
|
||||
result.setTo(width, height);
|
||||
|
||||
// Lines will have the same color of the default connection lines...
|
||||
var stokeColor = mindplot.ConnectionLine.getStrokeColor();
|
||||
result.setStroke(1, 'solid', stokeColor);
|
||||
};
|
||||
|
||||
result.getSize = function() {
|
||||
return this.size;
|
||||
};
|
||||
|
||||
result.setPosition = function() {
|
||||
};
|
||||
|
||||
var setStrokeFunction = result.setStroke;
|
||||
result.setFill = function() {
|
||||
|
||||
};
|
||||
|
||||
result.setStroke = function() {
|
||||
|
||||
};
|
||||
}
|
||||
else {
|
||||
$assert(false, "Unsupported figure type:" + type);
|
||||
}
|
||||
result.setPosition(0, 0);
|
||||
return result;
|
||||
},
|
||||
|
||||
|
||||
getOuterShape : function() {
|
||||
if (!$defined(this._outerShape)) {
|
||||
var rect = this.buildShape(mindplot.Topic.OUTER_SHAPE_ATTRIBUTES, mindplot.model.INodeModel.SHAPE_TYPE_ROUNDED_RECT);
|
||||
rect.setPosition(-2, -3);
|
||||
rect.setOpacity(0);
|
||||
this._outerShape = rect;
|
||||
}
|
||||
|
||||
return this._outerShape;
|
||||
},
|
||||
|
||||
getTextShape : function() {
|
||||
if (!$defined(this._text)) {
|
||||
this._text = this._buildTextShape(false);
|
||||
|
||||
// Set Text ...
|
||||
var text = this.getText();
|
||||
this._setText(text, false);
|
||||
}
|
||||
return this._text;
|
||||
},
|
||||
|
||||
|
||||
_buildTextShape : function(readOnly) {
|
||||
var result = new web2d.Text();
|
||||
var family = this.getFontFamily();
|
||||
var size = this.getFontSize();
|
||||
var weight = this.getFontWeight();
|
||||
var style = this.getFontStyle();
|
||||
result.setFont(family, size, style, weight);
|
||||
|
||||
var color = this.getFontColor();
|
||||
result.setColor(color);
|
||||
|
||||
if (!readOnly) {
|
||||
// Propagate mouse events ...
|
||||
if (this.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
result.setCursor('move');
|
||||
} else {
|
||||
result.setCursor('default');
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
_getInnerPadding : function() {
|
||||
throw "this must be implemented";
|
||||
},
|
||||
|
||||
setFontFamily : function(value, updateModel) {
|
||||
var textShape = this.getTextShape();
|
||||
textShape.setFontFamily(value);
|
||||
if ($defined(updateModel) && updateModel) {
|
||||
var model = this.getModel();
|
||||
model.setFontFamily(value);
|
||||
}
|
||||
this._adjustShapes(updateModel);
|
||||
},
|
||||
|
||||
setFontSize : function(value, updateModel) {
|
||||
|
||||
var textShape = this.getTextShape();
|
||||
textShape.setSize(value);
|
||||
|
||||
if ($defined(updateModel) && updateModel) {
|
||||
var model = this.getModel();
|
||||
model.setFontSize(value);
|
||||
}
|
||||
this._adjustShapes(updateModel);
|
||||
|
||||
},
|
||||
|
||||
setFontStyle : function(value, updateModel) {
|
||||
var textShape = this.getTextShape();
|
||||
textShape.setStyle(value);
|
||||
if ($defined(updateModel) && updateModel) {
|
||||
var model = this.getModel();
|
||||
model.setFontStyle(value);
|
||||
}
|
||||
this._adjustShapes(updateModel);
|
||||
},
|
||||
|
||||
setFontWeight : function(value, updateModel) {
|
||||
var textShape = this.getTextShape();
|
||||
textShape.setWeight(value);
|
||||
if ($defined(updateModel) && updateModel) {
|
||||
var model = this.getModel();
|
||||
model.setFontWeight(value);
|
||||
}
|
||||
this._adjustShapes();
|
||||
},
|
||||
|
||||
getFontWeight : function() {
|
||||
var model = this.getModel();
|
||||
var result = model.getFontWeight();
|
||||
if (!$defined(result)) {
|
||||
var font = this._defaultFontStyle();
|
||||
result = font.weight;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
getFontFamily : function() {
|
||||
var model = this.getModel();
|
||||
var result = model.getFontFamily();
|
||||
if (!$defined(result)) {
|
||||
var font = this._defaultFontStyle();
|
||||
result = font.font;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
getFontColor : function() {
|
||||
var model = this.getModel();
|
||||
var result = model.getFontColor();
|
||||
if (!$defined(result)) {
|
||||
var font = this._defaultFontStyle();
|
||||
result = font.color;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
getFontStyle : function() {
|
||||
var model = this.getModel();
|
||||
var result = model.getFontStyle();
|
||||
if (!$defined(result)) {
|
||||
var font = this._defaultFontStyle();
|
||||
result = font.style;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
getFontSize : function() {
|
||||
var model = this.getModel();
|
||||
var result = model.getFontSize();
|
||||
if (!$defined(result)) {
|
||||
var font = this._defaultFontStyle();
|
||||
result = font.size;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
setFontColor : function(value, updateModel) {
|
||||
var textShape = this.getTextShape();
|
||||
textShape.setColor(value);
|
||||
if ($defined(updateModel) && updateModel) {
|
||||
var model = this.getModel();
|
||||
model.setFontColor(value);
|
||||
}
|
||||
},
|
||||
|
||||
_setText : function(text, updateModel) {
|
||||
var textShape = this.getTextShape();
|
||||
textShape.setText(text == null ? this._defaultText() : text);
|
||||
|
||||
if ($defined(updateModel) && updateModel) {
|
||||
var model = this.getModel();
|
||||
model.setText(text);
|
||||
}
|
||||
},
|
||||
|
||||
setText : function(text) {
|
||||
// Avoid empty nodes ...
|
||||
if (text.trim().length == 0) {
|
||||
text = null;
|
||||
}
|
||||
|
||||
this._setText(text, true);
|
||||
this._adjustShapes();
|
||||
},
|
||||
|
||||
getText : function() {
|
||||
var model = this.getModel();
|
||||
var result = model.getText();
|
||||
if (!$defined(result)) {
|
||||
result = this._defaultText();
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
setBackgroundColor : function(color) {
|
||||
this._setBackgroundColor(color, true);
|
||||
},
|
||||
|
||||
_setBackgroundColor : function(color, updateModel) {
|
||||
var innerShape = this.getInnerShape();
|
||||
innerShape.setFill(color);
|
||||
|
||||
var connector = this.getShrinkConnector();
|
||||
connector.setFill(color);
|
||||
|
||||
if ($defined(updateModel) && updateModel) {
|
||||
var model = this.getModel();
|
||||
model.setBackgroundColor(color);
|
||||
}
|
||||
},
|
||||
|
||||
getBackgroundColor : function() {
|
||||
var model = this.getModel();
|
||||
var result = model.getBackgroundColor();
|
||||
if (!$defined(result)) {
|
||||
result = this._defaultBackgroundColor();
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
setBorderColor : function(color) {
|
||||
this._setBorderColor(color, true);
|
||||
},
|
||||
|
||||
_setBorderColor : function(color, updateModel) {
|
||||
var innerShape = this.getInnerShape();
|
||||
innerShape.setAttribute('strokeColor', color);
|
||||
|
||||
var connector = this.getShrinkConnector();
|
||||
connector.setAttribute('strokeColor', color);
|
||||
|
||||
|
||||
if ($defined(updateModel) && updateModel) {
|
||||
var model = this.getModel();
|
||||
model.setBorderColor(color);
|
||||
}
|
||||
},
|
||||
|
||||
getBorderColor : function() {
|
||||
var model = this.getModel();
|
||||
var result = model.getBorderColor();
|
||||
if (!$defined(result)) {
|
||||
result = this._defaultBorderColor();
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
_buildShape : function() {
|
||||
var groupAttributes = {width: 100, height:100,coordSizeWidth:100,coordSizeHeight:100};
|
||||
var group = new web2d.Group(groupAttributes);
|
||||
this._set2DElement(group);
|
||||
|
||||
// Shape must be build based on the model width ...
|
||||
var outerShape = this.getOuterShape();
|
||||
var innerShape = this.getInnerShape();
|
||||
var textShape = this.getTextShape();
|
||||
var shrinkConnector = this.getShrinkConnector();
|
||||
|
||||
// Add to the group ...
|
||||
group.appendChild(outerShape);
|
||||
group.appendChild(innerShape);
|
||||
group.appendChild(textShape);
|
||||
|
||||
// Update figure size ...
|
||||
var model = this.getModel();
|
||||
if (model.getLinks().length != 0 || model.getNotes().length != 0 || model.getIcons().length != 0) {
|
||||
this.getOrBuildIconGroup();
|
||||
}
|
||||
|
||||
if (this.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
shrinkConnector.addToWorkspace(group);
|
||||
}
|
||||
|
||||
// Register listeners ...
|
||||
this._registerDefaultListenersToElement(group, this);
|
||||
},
|
||||
|
||||
|
||||
showTextEditor : function(text) {
|
||||
this._textEditor.show(text);
|
||||
},
|
||||
|
||||
showLinkEditor : function() {
|
||||
|
||||
var topicId = this.getId();
|
||||
var model = this.getModel();
|
||||
var editorModel = {
|
||||
getValue : function() {
|
||||
var links = model.getLinks();
|
||||
var result;
|
||||
if (links.length > 0)
|
||||
result = links[0].getUrl();
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
setValue : function(value) {
|
||||
var dispatcher = mindplot.ActionDispatcher.getInstance();
|
||||
if (!$defined(value)) {
|
||||
dispatcher.removeLinkFromTopic(topicId);
|
||||
}
|
||||
else {
|
||||
dispatcher.changeLinkToTopic(topicId, value);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.closeEditors();
|
||||
var editor = new mindplot.widget.LinkEditor(editorModel);
|
||||
editor.show();
|
||||
},
|
||||
|
||||
|
||||
closeEditors : function() {
|
||||
this._textEditor.close(true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Point: references the center of the rect shape.!!!
|
||||
*/
|
||||
setPosition : function(point) {
|
||||
$assert(point, "position can not be null");
|
||||
point.x = Math.ceil(point.x);
|
||||
point.y = Math.ceil(point.y);
|
||||
|
||||
// Update model's position ...
|
||||
var model = this.getModel();
|
||||
model.setPosition(point.x, point.y);
|
||||
|
||||
// Elements are positioned in the center.
|
||||
// All topic element must be positioned based on the innerShape.
|
||||
var size = this.getSize();
|
||||
|
||||
var cx = point.x - (size.width / 2);
|
||||
var cy = point.y - (size.height / 2);
|
||||
|
||||
// Update visual position.
|
||||
this._elem2d.setPosition(cx, cy);
|
||||
|
||||
// Update connection lines ...
|
||||
this._updateConnectionLines();
|
||||
|
||||
// Check object state.
|
||||
this.invariant();
|
||||
},
|
||||
|
||||
getOutgoingConnectedTopic : function() {
|
||||
var result = null;
|
||||
var line = this.getOutgoingLine();
|
||||
if ($defined(line)) {
|
||||
result = line.getTargetTopic();
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
_setTopicVisibility : function(value) {
|
||||
this.parent(value);
|
||||
|
||||
var textShape = this.getTextShape();
|
||||
textShape.setVisibility(value);
|
||||
|
||||
},
|
||||
|
||||
setOpacity : function(opacity) {
|
||||
this.parent();
|
||||
|
||||
var textShape = this.getTextShape();
|
||||
textShape.setOpacity(opacity);
|
||||
},
|
||||
|
||||
_updatePositionOnChangeSize : function(oldSize, newSize) {
|
||||
$assert(false, "this method must be overwrited.");
|
||||
},
|
||||
|
||||
createDragNode : function(layoutManager) {
|
||||
var result = this.parent(layoutManager);
|
||||
|
||||
// Is the node already connected ?
|
||||
var targetTopic = this.getOutgoingConnectedTopic();
|
||||
if ($defined(targetTopic)) {
|
||||
result.connectTo(targetTopic);
|
||||
result.setVisibility(false);
|
||||
}
|
||||
|
||||
// If a drag node is create for it, let's hide the editor.
|
||||
this._textEditor.close();
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
_adjustShapes : function() {
|
||||
if (this._isInWorkspace) {
|
||||
var textShape = this.getTextShape();
|
||||
var textWidth = textShape.getWidth();
|
||||
|
||||
var textHeight = textShape.getHeight();
|
||||
textHeight = textHeight != 0 ? textHeight : 20;
|
||||
|
||||
var topicPadding = this._getInnerPadding();
|
||||
|
||||
// Adjust the icon size to the size of the text ...
|
||||
var iconGroup = this.getOrBuildIconGroup();
|
||||
var fontHeight = this.getTextShape().getFontHeight();
|
||||
iconGroup.setPosition(topicPadding, topicPadding);
|
||||
iconGroup.seIconSize(fontHeight, fontHeight);
|
||||
|
||||
// Add a extra padding between the text and the icons
|
||||
var iconsWidth = iconGroup.getSize().width;
|
||||
if (iconsWidth != 0) {
|
||||
|
||||
iconsWidth = iconsWidth + (textHeight / 4);
|
||||
}
|
||||
|
||||
var height = textHeight + (topicPadding * 2);
|
||||
var width = textWidth + iconsWidth + (topicPadding * 2);
|
||||
|
||||
this.setSize({width:width,height:height});
|
||||
|
||||
// Position node ...
|
||||
textShape.setPosition(topicPadding + iconsWidth, topicPadding);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
mindplot.TextTopic.INNER_RECT_ATTRIBUTES = {stroke:'2 solid'};
|
||||
|
||||
|
||||
|
@ -260,129 +260,55 @@ mindplot.Topic = new Class({
|
||||
var padding = this._getInnerPadding();
|
||||
result.setPosition(padding, padding);
|
||||
|
||||
// Load topic features ...
|
||||
var model = this.getModel();
|
||||
|
||||
//Icons
|
||||
var icons = model.getIcons();
|
||||
for (var i = 0; i < icons.length; i++) {
|
||||
// Update model identifier ...
|
||||
var iconModel = icons[i];
|
||||
var icon = new mindplot.ImageIcon(this, iconModel);
|
||||
result.addIcon(icon, true);
|
||||
}
|
||||
|
||||
//Links
|
||||
var links = model.getLinks();
|
||||
for (var i = 0; i < links.length; i++) {
|
||||
this._link = new mindplot.LinkIcon(this, links[i]);
|
||||
result.addIcon(this._link);
|
||||
}
|
||||
|
||||
//Notes
|
||||
var notes = model.getNotes();
|
||||
for (var j = 0; j < notes.length; j++) {
|
||||
this._note = new mindplot.NoteIcon(this, notes[j]);
|
||||
result.addIcon(this._note);
|
||||
var featuresModel = model.getFeatures();
|
||||
for (var i = 0; i < featuresModel.length; i++) {
|
||||
var featureModel = featuresModel[i];
|
||||
var icon = mindplot.TopicFeature.createIcon(this, featureModel);
|
||||
result.addIcon(icon, featureModel.getType() == "icon"); // @Todo: Remove hack ...
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
addLink : function(url) {
|
||||
var iconGroup = this.getOrBuildIconGroup();
|
||||
var model = this.getModel();
|
||||
var linkModel = model.createLink(url);
|
||||
model.addLink(linkModel);
|
||||
|
||||
this._link = new mindplot.LinkIcon(this, linkModel);
|
||||
iconGroup.addIcon(this._link);
|
||||
|
||||
this._adjustShapes();
|
||||
},
|
||||
|
||||
addNote : function(text) {
|
||||
var iconGroup = this.getOrBuildIconGroup();
|
||||
var model = this.getModel();
|
||||
|
||||
var noteModel = model.createNote(text);
|
||||
model.addNote(noteModel);
|
||||
|
||||
this._note = new mindplot.NoteIcon(this, noteModel);
|
||||
iconGroup.addIcon(this._note);
|
||||
|
||||
this._adjustShapes();
|
||||
},
|
||||
|
||||
addIcon : function(iconType) {
|
||||
addFeature : function(type, attributes) {
|
||||
var iconGroup = this.getOrBuildIconGroup();
|
||||
this.closeEditors();
|
||||
|
||||
var model = this.getModel();
|
||||
|
||||
// Update model ...
|
||||
var iconModel = model.createIcon(iconType);
|
||||
model.addIcon(iconModel);
|
||||
var feature = model.createFeature(type, attributes);
|
||||
model.addFeature(feature);
|
||||
|
||||
var result = mindplot.TopicFeature.createIcon(this, feature);
|
||||
iconGroup.addIcon(result, type == "icon"); // @Todo: Remove hack ...
|
||||
|
||||
var imageIcon = new mindplot.ImageIcon(this, iconModel);
|
||||
iconGroup.addIcon(imageIcon, true);
|
||||
this._adjustShapes();
|
||||
return imageIcon;
|
||||
return result;
|
||||
},
|
||||
|
||||
removeIcon : function(iconModel) {
|
||||
findFeatureById : function(id) {
|
||||
var model = this.getModel();
|
||||
return model.findFeatureById(id);
|
||||
},
|
||||
|
||||
removeFeature : function(featureModel) {
|
||||
$assert(featureModel, "featureModel could not be null");
|
||||
|
||||
//Removing the icon from MODEL
|
||||
var model = this.getModel();
|
||||
model.removeIcon(iconModel);
|
||||
model.removeFeature(featureModel);
|
||||
|
||||
//Removing the icon from UI
|
||||
var iconGroup = this.getIconGroup();
|
||||
if ($defined(iconGroup)) {
|
||||
iconGroup.removeIcon(iconModel);
|
||||
iconGroup.removeIconByModel(featureModel);
|
||||
}
|
||||
this._adjustShapes();
|
||||
},
|
||||
|
||||
removeLink : function() {
|
||||
// Update model ...
|
||||
var model = this.getModel();
|
||||
var links = model.getLinks();
|
||||
model._removeLink(links[0]);
|
||||
|
||||
// Remove UI ...
|
||||
var iconGroup = this.getIconGroup();
|
||||
if ($defined(iconGroup)) {
|
||||
iconGroup.removeIconByUrl(mindplot.LinkIcon.IMAGE_URL);
|
||||
}
|
||||
|
||||
this._link = null;
|
||||
this._adjustShapes();
|
||||
},
|
||||
|
||||
removeNote : function() {
|
||||
// Update model ...
|
||||
var model = this.getModel();
|
||||
var notes = model.getNotes();
|
||||
model.removeNote(notes[0]);
|
||||
|
||||
// Remove UI ...
|
||||
var iconGroup = this.getIconGroup();
|
||||
if ($defined(iconGroup)) {
|
||||
iconGroup.removeIconByUrl(mindplot.NoteIcon.IMAGE_URL);
|
||||
}
|
||||
|
||||
this._note = null;
|
||||
this._adjustShapes();
|
||||
},
|
||||
|
||||
hasNote : function() {
|
||||
return this.getModel().getNotes().length != 0;
|
||||
},
|
||||
|
||||
hasLink : function() {
|
||||
return this.getModel().getLinks().length != 0;
|
||||
},
|
||||
|
||||
connectByRelation : function(relationship) {
|
||||
this._relationships.push(relationship);
|
||||
},
|
||||
@ -624,7 +550,7 @@ mindplot.Topic = new Class({
|
||||
|
||||
// Update figure size ...
|
||||
var model = this.getModel();
|
||||
if (model.getLinks().length != 0 || model.getNotes().length != 0 || model.getIcons().length != 0) {
|
||||
if (model.getFeatures().length != 0) {
|
||||
this.getOrBuildIconGroup();
|
||||
}
|
||||
|
||||
@ -728,7 +654,7 @@ mindplot.Topic = new Class({
|
||||
var model = this.getModel();
|
||||
var editorModel = {
|
||||
getValue : function() {
|
||||
var notes = model.getNotes();
|
||||
var notes = model.findFeatureByType(mindplot.TopicFeature.Note.id);
|
||||
var result;
|
||||
if (notes.length > 0)
|
||||
result = notes[0].getText();
|
||||
@ -738,11 +664,18 @@ mindplot.Topic = new Class({
|
||||
|
||||
setValue : function(value) {
|
||||
var dispatcher = mindplot.ActionDispatcher.getInstance();
|
||||
var notes = model.findFeatureByType(mindplot.TopicFeature.Note.id);
|
||||
if (!$defined(value)) {
|
||||
dispatcher.removeNoteFromTopic(topicId);
|
||||
var featureId = notes[0].getId();
|
||||
dispatcher.removeFeatureFromTopic(topicId, featureId);
|
||||
}
|
||||
else {
|
||||
dispatcher.changeNoteToTopic(topicId, value);
|
||||
if (notes.length > 0) {
|
||||
dispatcher.changeFeatureToTopic(topicId, notes[0].getId(), {text:value});
|
||||
}
|
||||
else {
|
||||
dispatcher.addFeatureToTopic(topicId, mindplot.TopicFeature.Note.id, {text:value});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -757,7 +690,7 @@ mindplot.Topic = new Class({
|
||||
var model = this.getModel();
|
||||
var editorModel = {
|
||||
getValue : function() {
|
||||
var links = model.getLinks();
|
||||
var links = model.findFeatureByType(mindplot.TopicFeature.Link.id);
|
||||
var result;
|
||||
if (links.length > 0)
|
||||
result = links[0].getUrl();
|
||||
@ -767,11 +700,18 @@ mindplot.Topic = new Class({
|
||||
|
||||
setValue : function(value) {
|
||||
var dispatcher = mindplot.ActionDispatcher.getInstance();
|
||||
var links = model.findFeatureByType(mindplot.TopicFeature.Link.id);
|
||||
if (!$defined(value)) {
|
||||
dispatcher.removeLinkFromTopic(topicId);
|
||||
var featureId = links[0].getId();
|
||||
dispatcher.removeFeatureFromTopic(topicId, featureId);
|
||||
}
|
||||
else {
|
||||
dispatcher.changeLinkToTopic(topicId, value);
|
||||
if (links.length > 0) {
|
||||
dispatcher.changeFeatureToTopic(topicId, links[0].getId(), {url:value});
|
||||
}
|
||||
else {
|
||||
dispatcher.addFeatureToTopic(topicId, mindplot.TopicFeature.Link.id, {url:value});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -841,7 +781,6 @@ mindplot.Topic = new Class({
|
||||
return result;
|
||||
},
|
||||
|
||||
|
||||
_updateConnectionLines : function() {
|
||||
// Update this to parent line ...
|
||||
var outgoingLine = this.getOutgoingLine();
|
||||
|
68
mindplot/src/main/javascript/TopicFeature.js
Normal file
68
mindplot/src/main/javascript/TopicFeature.js
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.TopicFeature = {
|
||||
Icon: {
|
||||
id:mindplot.model.IconModel.FEATURE_TYPE,
|
||||
model: mindplot.model.IconModel,
|
||||
icon : mindplot.ImageIcon
|
||||
},
|
||||
|
||||
Link: {
|
||||
id: mindplot.model.LinkModel.FEATURE_TYPE,
|
||||
model: mindplot.model.LinkModel,
|
||||
icon : mindplot.LinkIcon
|
||||
},
|
||||
|
||||
Note: {
|
||||
id: mindplot.model.NoteModel.FEATURE_TYPE,
|
||||
model: mindplot.model.NoteModel,
|
||||
icon : mindplot.NoteIcon
|
||||
},
|
||||
|
||||
isSupported : function(id) {
|
||||
return mindplot.TopicFeature._featuresMetadataById.some(function(elem) {
|
||||
return elem.id == id;
|
||||
});
|
||||
},
|
||||
|
||||
createModel : function(id, topic, attributes) {
|
||||
$assert(id, 'type can not be null');
|
||||
$assert(topic, 'topic can not be null');
|
||||
$assert(attributes, 'attributes can not be null');
|
||||
|
||||
var model = mindplot.TopicFeature._featuresMetadataById.filter(function(elem) {
|
||||
return elem.id == id;
|
||||
})[0].model;
|
||||
return new model(topic, attributes);
|
||||
},
|
||||
|
||||
createIcon : function(topic, model) {
|
||||
$assert(topic, 'topic can not be null');
|
||||
$assert(model, 'model can not be null');
|
||||
|
||||
var icon = mindplot.TopicFeature._featuresMetadataById.filter(function(elem) {
|
||||
return elem.id == model.getType();
|
||||
})[0].icon;
|
||||
return new icon(topic, model);
|
||||
}
|
||||
};
|
||||
|
||||
mindplot.TopicFeature._featuresMetadataById = [mindplot.TopicFeature.Icon,mindplot.TopicFeature.Link,mindplot.TopicFeature.Note]
|
||||
|
||||
|
@ -16,23 +16,27 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.commands.AddIconToTopicCommand = new Class({
|
||||
mindplot.commands.AddFeatureToTopicCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize: function(topicId, iconType) {
|
||||
initialize: function(topicId, featureType, attributes) {
|
||||
|
||||
$assert($defined(topicId), 'topicId can not be null');
|
||||
$assert(iconType, 'iconType can not be null');
|
||||
this._topicsIds = topicId;
|
||||
this._iconType = iconType;
|
||||
$assert(featureType, 'featureType can not be null');
|
||||
$assert(attributes, 'attributes can not be null');
|
||||
|
||||
this._topicId = topicId;
|
||||
this._featureType = featureType;
|
||||
this._attributes = attributes;
|
||||
},
|
||||
|
||||
execute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._topicsIds)[0];
|
||||
var iconImg = topic.addIcon(this._iconType, commandContext._designer);
|
||||
this._iconModel = iconImg.getModel();
|
||||
var topic = commandContext.findTopics(this._topicId)[0];
|
||||
var icon = topic.addFeature(this._featureType, this._attributes);
|
||||
this._featureModel = icon.getModel();
|
||||
},
|
||||
|
||||
undoExecute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._topicsIds)[0];
|
||||
topic.removeIcon(this._iconModel);
|
||||
var topic = commandContext.findTopics(this._topicId)[0];
|
||||
topic.removeFeature(this._featureModel);
|
||||
}
|
||||
});
|
@ -16,23 +16,28 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.commands.RemoveLinkFromTopicCommand = new Class({
|
||||
mindplot.commands.ChangeFeatureToTopicCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize: function(topicId) {
|
||||
initialize: function(topicId, featureId, attributes) {
|
||||
$assert($defined(topicId), 'topicId can not be null');
|
||||
this._topicsIds = topicId;
|
||||
$assert($defined(featureId), 'featureId can not be null');
|
||||
$assert($defined(attributes), 'attributes can not be null');
|
||||
|
||||
this._topicId = topicId;
|
||||
this._featureId = featureId;
|
||||
this._attributes = attributes;
|
||||
},
|
||||
|
||||
execute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._topicsIds)[0];
|
||||
var model = topic.getModel();
|
||||
var links = model.getLinks()[0];
|
||||
this._text = links.getUrl();
|
||||
topic.removeLink();
|
||||
var topic = commandContext.findTopics(this._topicId)[0];
|
||||
var feature = topic.findFeatureById(this._featureId);
|
||||
|
||||
var oldAttributes = feature.getAttributes();
|
||||
feature.setAttributes(this._attributes);
|
||||
this._attributes = oldAttributes;
|
||||
},
|
||||
|
||||
undoExecute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._topicsIds)[0];
|
||||
topic.addLink(this._url, commandContext._designer);
|
||||
this.execute(commandContext);
|
||||
}
|
||||
});
|
@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.commands.ChangeLinkToTopicCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize: function(topicId, url) {
|
||||
$assert($defined(topicId), 'topicId can not be null');
|
||||
this._topicsIds = topicId;
|
||||
this._url = url;
|
||||
this._id = mindplot.Command._nextUUID();
|
||||
},
|
||||
|
||||
execute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._topicsIds)[0];
|
||||
if (topic.hasLink()) {
|
||||
var model = topic.getModel();
|
||||
var link = model.getLinks()[0];
|
||||
this._oldUrl = link.getUrl();
|
||||
topic.removeLink();
|
||||
}
|
||||
topic.addLink(this._url);
|
||||
},
|
||||
|
||||
undoExecute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._topicsIds)[0];
|
||||
if (this._oldtext) {
|
||||
topic.removeLink();
|
||||
topic.addLink(this._oldUrl);
|
||||
} else {
|
||||
topic.removeLink();
|
||||
}
|
||||
}
|
||||
});
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.commands.ChangeNoteToTopicCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize: function(topicId, text) {
|
||||
$assert($defined(topicId), 'topicId can not be null');
|
||||
this._topicsIds = topicId;
|
||||
this._text = text;
|
||||
this._oldtext = null;
|
||||
this._id = mindplot.Command._nextUUID();
|
||||
},
|
||||
|
||||
execute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._topicsIds)[0];
|
||||
if (topic.hasNote()) {
|
||||
var model = topic.getModel();
|
||||
var notes = model.getNotes()[0];
|
||||
this._oldtext = notes.getText();
|
||||
topic.removeNote();
|
||||
}
|
||||
topic.addNote(this._text);
|
||||
},
|
||||
|
||||
undoExecute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._topicsIds)[0];
|
||||
if (this._oldtext) {
|
||||
topic.removeNote();
|
||||
topic.addNote(this._oldtext);
|
||||
} else {
|
||||
topic.removeNote();
|
||||
}
|
||||
}
|
||||
});
|
@ -16,21 +16,30 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.commands.RemoveNoteFromTopicCommand = new Class({
|
||||
mindplot.commands.RemoveFeatureFromTopicCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize: function(topicId) {
|
||||
initialize: function(topicId, featureId) {
|
||||
$assert($defined(topicId), 'topicId can not be null');
|
||||
this._topicsIds = topicId;
|
||||
$assert(featureId, 'iconModel can not be null');
|
||||
|
||||
this._topicId = topicId;
|
||||
this._featureId = featureId;
|
||||
this._oldFeature = null;
|
||||
},
|
||||
|
||||
execute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._topicsIds)[0];
|
||||
var model = topic.getModel();
|
||||
var notes = model.getNotes()[0];
|
||||
this._text = notes.getText();
|
||||
topic.removeNote();
|
||||
var topic = commandContext.findTopics(this._topicId)[0];
|
||||
|
||||
var feature = topic.findFeatureById(this._featureId);
|
||||
topic.removeFeature(feature);
|
||||
this._oldFeature = feature;
|
||||
},
|
||||
|
||||
undoExecute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._topicsIds)[0];
|
||||
topic.addNote(this._text, commandContext._designer);
|
||||
var topic = commandContext.findTopics(this._topicId)[0];
|
||||
|
||||
var feature = this._oldFeature;
|
||||
topic.addFeature(feature.getType(), feature.getAttributes());
|
||||
this._oldFeature = null;
|
||||
}
|
||||
});
|
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.commands.RemoveIconFromTopicCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize: function(topicIds, iconModel) {
|
||||
$assert($defined(topicIds), 'topicIds can not be null');
|
||||
$assert(iconModel, 'iconModel can not be null');
|
||||
this._topicsIds = topicIds;
|
||||
this._iconModel = iconModel;
|
||||
},
|
||||
|
||||
execute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._topicsIds)[0];
|
||||
topic.removeIcon(this._iconModel);
|
||||
},
|
||||
|
||||
undoExecute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._topicsIds)[0];
|
||||
var iconType = this._iconModel.getIconType();
|
||||
var iconImg = topic.addIcon(iconType, commandContext._designer);
|
||||
this._iconModel = iconImg.getModel();
|
||||
}
|
||||
});
|
76
mindplot/src/main/javascript/model/FeatureModel.js
Normal file
76
mindplot/src/main/javascript/model/FeatureModel.js
Normal file
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.model.FeatureModel = new Class({
|
||||
initialize:function(type, topic) {
|
||||
$assert(type, 'type can not be null');
|
||||
$assert(topic, 'topic can not be null');
|
||||
|
||||
this._id = mindplot.model.FeatureModel._nextUUID();
|
||||
this._type = type;
|
||||
this._topic = topic;
|
||||
this._attributes = {};
|
||||
|
||||
// Create type method ...
|
||||
this['is' + type.camelCase() + 'Model'] = function() {
|
||||
return true;
|
||||
};
|
||||
},
|
||||
|
||||
getAttributes : function() {
|
||||
return Object.clone(this._attributes);
|
||||
},
|
||||
|
||||
setAttributes : function(attributes) {
|
||||
for (key in attributes) {
|
||||
this["set" + key.capitalize()](attributes[key]);
|
||||
}
|
||||
},
|
||||
|
||||
setAttribute : function(key, value) {
|
||||
$assert(key, 'key id can not be null');
|
||||
this._attributes[key] = value;
|
||||
},
|
||||
|
||||
getAttribute : function(key) {
|
||||
$assert(key, 'key id can not be null');
|
||||
|
||||
return this._attributes[key];
|
||||
},
|
||||
|
||||
getTopic : function() {
|
||||
return this._topic;
|
||||
},
|
||||
|
||||
getId : function() {
|
||||
return this._id;
|
||||
},
|
||||
|
||||
getType:function() {
|
||||
return this._type;
|
||||
}
|
||||
});
|
||||
|
||||
mindplot.model.FeatureModel._nextUUID = function() {
|
||||
if (!$defined(this._uuid)) {
|
||||
this._uuid = 0;
|
||||
}
|
||||
|
||||
this._uuid = this._uuid + 1;
|
||||
return this._uuid;
|
||||
};
|
@ -248,58 +248,10 @@ mindplot.model.INodeModel = new Class({
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
createLink : function(url) {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
addLink : function(link) {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
createNote : function(text) {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
addNote : function(note) {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
removeNote : function(note) {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
createIcon : function(iconType) {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
addIcon : function(icon) {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
removeIcon : function(icon) {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
removeLastIcon : function() {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
getChildren : function() {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
getIcons : function() {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
getLinks : function() {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
getNotes : function() {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
getParent : function() {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
@ -17,46 +17,19 @@
|
||||
*/
|
||||
|
||||
mindplot.model.IconModel = new Class({
|
||||
initialize:function(iconType, topic) {
|
||||
$assert(iconType, 'Icon id can not be null');
|
||||
$assert(topic, 'topic can not be null');
|
||||
|
||||
this._iconType = iconType;
|
||||
this._id = mindplot.model.IconModel._nextUUID();
|
||||
this._topic = topic;
|
||||
},
|
||||
|
||||
getId : function() {
|
||||
return this._id;
|
||||
Extends: mindplot.model.FeatureModel,
|
||||
initialize:function(topic, attributes) {
|
||||
this.parent(mindplot.model.IconModel.FEATURE_TYPE, topic);
|
||||
this.setIconType(attributes.id);
|
||||
},
|
||||
|
||||
getIconType : function() {
|
||||
return this._iconType;
|
||||
return this.getAttribute('id');
|
||||
},
|
||||
|
||||
|
||||
setIconType : function(iconType) {
|
||||
this._iconType = iconType;
|
||||
},
|
||||
|
||||
getTopic : function() {
|
||||
return this._topic;
|
||||
},
|
||||
|
||||
isIconModel : function() {
|
||||
return true;
|
||||
}});
|
||||
|
||||
|
||||
/**
|
||||
* @todo: This method must be implemented.
|
||||
*/
|
||||
mindplot.model.IconModel._nextUUID = function() {
|
||||
if (!$defined(this._uuid)) {
|
||||
this._uuid = 0;
|
||||
$assert(iconType, 'iconType id can not be null');
|
||||
this.setAttribute('id', iconType);
|
||||
}
|
||||
|
||||
this._uuid = this._uuid + 1;
|
||||
return this._uuid;
|
||||
};
|
||||
|
||||
});
|
||||
mindplot.model.IconModel.FEATURE_TYPE = "icon";
|
||||
|
@ -17,31 +17,27 @@
|
||||
*/
|
||||
|
||||
mindplot.model.LinkModel = new Class({
|
||||
initialize : function(url, topic) {
|
||||
$assert(url, 'url can not be null');
|
||||
$assert(topic, 'mindmap can not be null');
|
||||
this._topic = topic;
|
||||
this.setUrl(url);
|
||||
Extends: mindplot.model.FeatureModel,
|
||||
initialize : function(topic, attributes) {
|
||||
this.parent(mindplot.model.LinkModel.FEATURE_TYPE, topic);
|
||||
this.setUrl(attributes.url);
|
||||
},
|
||||
|
||||
getUrl : function() {
|
||||
return this._url;
|
||||
return this.getAttribute('url');
|
||||
},
|
||||
|
||||
setUrl : function(url) {
|
||||
$assert(url, 'url can not be null');
|
||||
this._url = this._fixUrl(url);
|
||||
this._type = this._url.contains('mailto:') ? 'mail' : 'url';
|
||||
|
||||
var fixedUrl = this._fixUrl(url);
|
||||
this.setAttribute('url', fixedUrl);
|
||||
|
||||
var type = fixedUrl.contains('mailto:') ? 'mail' : 'url';
|
||||
this.setAttribute('type', type);
|
||||
|
||||
},
|
||||
|
||||
getTopic : function() {
|
||||
return this._topic;
|
||||
},
|
||||
|
||||
isLinkModel : function() {
|
||||
return true;
|
||||
}
|
||||
,
|
||||
_fixUrl : function(url) {
|
||||
var result = url;
|
||||
if (!result.contains('http://') && !result.contains('https://') && !result.contains('mailto://')) {
|
||||
@ -49,4 +45,6 @@ mindplot.model.LinkModel = new Class({
|
||||
}
|
||||
return result;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
mindplot.model.LinkModel.FEATURE_TYPE = 'link';
|
@ -30,9 +30,39 @@ mindplot.model.NodeModel = new Class({
|
||||
this.setSize(50, 20);
|
||||
|
||||
this._children = [];
|
||||
this._icons = [];
|
||||
this._links = [];
|
||||
this._notes = [];
|
||||
this._feature = [];
|
||||
},
|
||||
|
||||
createFeature: function(type, attributes) {
|
||||
return mindplot.TopicFeature.createModel(type, this, attributes);
|
||||
},
|
||||
|
||||
addFeature: function(feature) {
|
||||
$assert(feature, 'feature can not be null');
|
||||
this._feature.push(feature);
|
||||
},
|
||||
|
||||
getFeatures: function() {
|
||||
return this._feature;
|
||||
},
|
||||
|
||||
removeFeature: function(feature) {
|
||||
$assert(feature, 'feature can not be null');
|
||||
this._feature.erase(feature);
|
||||
},
|
||||
|
||||
findFeatureByType : function(type) {
|
||||
$assert(type, 'type can not be null');
|
||||
return this._feature.filter(function(feature) {
|
||||
return feature.getType() == type;
|
||||
});
|
||||
},
|
||||
|
||||
findFeatureById : function(id) {
|
||||
$assert($defined(id), 'id can not be null');
|
||||
return this._feature.filter(function(feature) {
|
||||
return feature.getId() == id;
|
||||
})[0];
|
||||
},
|
||||
|
||||
getPropertiesKeys : function() {
|
||||
@ -64,67 +94,10 @@ mindplot.model.NodeModel = new Class({
|
||||
});
|
||||
|
||||
result._properties = Object.clone(this._properties);
|
||||
result._icons = this._icons.clone();
|
||||
result._links = this._links.clone();
|
||||
result._notes = this._notes.clone();
|
||||
result._feature = this._feature.clone();
|
||||
return result;
|
||||
},
|
||||
|
||||
addChildren : function() {
|
||||
$assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object');
|
||||
this._children.push(child);
|
||||
child._parent = this;
|
||||
},
|
||||
|
||||
createLink : function(url) {
|
||||
$assert(url, 'Link URL must be specified.');
|
||||
return new mindplot.model.LinkModel(url, this);
|
||||
},
|
||||
|
||||
addLink : function(link) {
|
||||
$assert(link && link.isLinkModel(), 'Only LinkModel can be appended to Mindmap object as links');
|
||||
this._links.push(link);
|
||||
},
|
||||
|
||||
_removeLink : function(link) {
|
||||
$assert(link && link.isLinkModel(), 'Only LinkModel can be appended to Mindmap object as links');
|
||||
this._links.erase(link);
|
||||
},
|
||||
|
||||
createNote : function(text) {
|
||||
$assert(text != null, 'note text must be specified.');
|
||||
return new mindplot.model.NoteModel(text, this);
|
||||
},
|
||||
|
||||
addNote : function(note) {
|
||||
$assert(note && note.isNoteModel(), 'Only NoteModel can be appended to Mindmap object as links');
|
||||
this._notes.push(note);
|
||||
},
|
||||
|
||||
removeNote : function(note) {
|
||||
$assert(note && note.isNoteModel(), 'Only NoteModel can be appended to Mindmap object as links');
|
||||
this._notes.erase(note);
|
||||
},
|
||||
|
||||
createIcon : function(iconType) {
|
||||
$assert(iconType, 'IconType must be specified.');
|
||||
return new mindplot.model.IconModel(iconType, this);
|
||||
},
|
||||
|
||||
addIcon : function(icon) {
|
||||
$assert(icon && icon.isIconModel(), 'Only IconModel can be appended to Mindmap object as icons');
|
||||
this._icons.push(icon);
|
||||
},
|
||||
|
||||
removeIcon : function(icon) {
|
||||
$assert(icon && icon.isIconModel(), 'Only IconModel can be appended to Mindmap object as icons');
|
||||
this._icons.erase(icon);
|
||||
},
|
||||
|
||||
removeLastIcon : function() {
|
||||
this._icons.pop();
|
||||
},
|
||||
|
||||
appendChild : function(child) {
|
||||
$assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object');
|
||||
this._children.push(child);
|
||||
@ -141,18 +114,6 @@ mindplot.model.NodeModel = new Class({
|
||||
return this._children;
|
||||
},
|
||||
|
||||
getIcons : function() {
|
||||
return this._icons;
|
||||
},
|
||||
|
||||
getLinks : function() {
|
||||
return this._links;
|
||||
},
|
||||
|
||||
getNotes : function() {
|
||||
return this._notes;
|
||||
},
|
||||
|
||||
getParent : function() {
|
||||
return this._parent;
|
||||
},
|
||||
|
@ -17,26 +17,20 @@
|
||||
*/
|
||||
|
||||
mindplot.model.NoteModel = new Class({
|
||||
initialize : function(text, topic) {
|
||||
$assert(text, 'text text can not be null');
|
||||
$assert(topic, 'topic can not be null');
|
||||
this._text = text;
|
||||
this._topic = topic;
|
||||
Extends: mindplot.model.FeatureModel,
|
||||
initialize : function(topic, attributes) {
|
||||
this.parent(mindplot.model.NoteModel.FEATURE_TYPE, topic);
|
||||
this.setText(attributes.text);
|
||||
},
|
||||
|
||||
getText:function() {
|
||||
return this._text;
|
||||
return this.getAttribute('text');
|
||||
},
|
||||
|
||||
setText : function(text) {
|
||||
this._text = text;
|
||||
},
|
||||
|
||||
getTopic : function() {
|
||||
return this._topic;
|
||||
},
|
||||
|
||||
isNoteModel : function() {
|
||||
return true;
|
||||
$assert(text, 'text can not be null');
|
||||
this.setAttribute('text', text);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
mindplot.model.NoteModel.FEATURE_TYPE = "note";
|
||||
|
@ -260,13 +260,13 @@ mindplot.persistence.XMLSerializer_Beta = new Class({
|
||||
childTopic.connectTo(topic);
|
||||
} else if (child.tagName == "icon") {
|
||||
var icon = this._deserializeIcon(child, topic);
|
||||
topic.addIcon(icon);
|
||||
topic.addFeature(icon);
|
||||
} else if (child.tagName == "link") {
|
||||
var link = this._deserializeLink(child, topic);
|
||||
topic.addLink(link);
|
||||
topic.addFeature(link);
|
||||
} else if (child.tagName == "note") {
|
||||
var note = this._deserializeNote(child, topic);
|
||||
topic.addNote(note);
|
||||
topic.addFeature(note);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -277,15 +277,15 @@ mindplot.persistence.XMLSerializer_Beta = new Class({
|
||||
_deserializeIcon : function(domElem, topic) {
|
||||
var icon = domElem.getAttribute("id");
|
||||
icon = icon.replace("images/", "icons/legacy/");
|
||||
return topic.createIcon(icon);
|
||||
return mindplot.TopicFeature.createModel(mindplot.TopicFeature.Icon.id, topic, {id:icon});
|
||||
},
|
||||
|
||||
_deserializeLink : function(domElem, topic) {
|
||||
return topic.createLink(domElem.getAttribute("url"));
|
||||
return mindplot.TopicFeature.createModel(mindplot.TopicFeature.Link.id, topic, {url:domElem.getAttribute("url")});
|
||||
},
|
||||
|
||||
_deserializeNote : function(domElem, topic) {
|
||||
return topic.createNote(domElem.getAttribute("text"));
|
||||
return mindplot.TopicFeature.createModel(mindplot.TopicFeature.Note.id, topic, {text:domElem.getAttribute("url")});
|
||||
}});
|
||||
|
||||
mindplot.persistence.XMLSerializer_Beta.MAP_ROOT_NODE = 'map';
|
@ -47,8 +47,6 @@ mindplot.persistence.XMLSerializer_Pela = new Class({
|
||||
// Create Relationships
|
||||
var relationships = mindmap.getRelationships();
|
||||
if (relationships.length > 0) {
|
||||
// var relationshipDom=document.createElement("relationships");
|
||||
// mapElem.appendChild(relationshipDom);
|
||||
for (var j = 0; j < relationships.length; j++) {
|
||||
var relationDom = this._relationshipToXML(document, relationships[j]);
|
||||
mapElem.appendChild(relationDom);
|
||||
@ -124,60 +122,38 @@ mindplot.persistence.XMLSerializer_Pela = new Class({
|
||||
parentTopic.setAttribute('brColor', brColor);
|
||||
}
|
||||
|
||||
//ICONS
|
||||
var icons = topic.getIcons();
|
||||
for (var i = 0; i < icons.length; i++) {
|
||||
var icon = icons[i];
|
||||
var iconDom = this._iconToXML(document, icon);
|
||||
parentTopic.appendChild(iconDom);
|
||||
}
|
||||
// Serialize features ...
|
||||
var features = topic.getFeatures();
|
||||
for (var i = 0; i < features.length; i++) {
|
||||
var feature = features[i];
|
||||
|
||||
//LINKS
|
||||
var links = topic.getLinks();
|
||||
for (var i = 0; i < links.length; i++) {
|
||||
var link = links[i];
|
||||
var linkDom = this._linkToXML(document, link);
|
||||
parentTopic.appendChild(linkDom);
|
||||
}
|
||||
var featureType = feature.getType();
|
||||
var featureDom = document.createElement(featureType);
|
||||
var attributes = feature.getAttributes();
|
||||
|
||||
var notes = topic.getNotes();
|
||||
for (var i = 0; i < notes.length; i++) {
|
||||
var note = notes[i];
|
||||
var noteDom = this._noteToXML(document, note);
|
||||
parentTopic.appendChild(noteDom);
|
||||
for (var key in attributes) {
|
||||
var value = attributes[key];
|
||||
if (key == 'text') {
|
||||
var cdata = document.createCDATASection(value);
|
||||
featureDom.appendChild(cdata);
|
||||
} else {
|
||||
featureDom.setAttribute(key, value);
|
||||
}
|
||||
}
|
||||
parentTopic.appendChild(featureDom);
|
||||
}
|
||||
|
||||
//CHILDREN TOPICS
|
||||
var childTopics = topic.getChildren();
|
||||
for (var i = 0; i < childTopics.length; i++) {
|
||||
var childTopic = childTopics[i];
|
||||
for (var j = 0; j < childTopics.length; j++) {
|
||||
var childTopic = childTopics[j];
|
||||
var childDom = this._topicToXML(document, childTopic);
|
||||
parentTopic.appendChild(childDom);
|
||||
|
||||
}
|
||||
|
||||
return parentTopic;
|
||||
},
|
||||
|
||||
_iconToXML : function(document, icon) {
|
||||
var iconDom = document.createElement("icon");
|
||||
iconDom.setAttribute('id', icon.getIconType());
|
||||
return iconDom;
|
||||
},
|
||||
|
||||
_linkToXML : function(document, link) {
|
||||
var linkDom = document.createElement("link");
|
||||
linkDom.setAttribute('url', link.getUrl());
|
||||
return linkDom;
|
||||
},
|
||||
|
||||
_noteToXML : function(document, note) {
|
||||
var noteDom = document.createElement("note");
|
||||
var cdata = document.createCDATASection(note.getText());
|
||||
noteDom.appendChild(cdata);
|
||||
return noteDom;
|
||||
},
|
||||
|
||||
_noteTextToXML : function(document, elem, text) {
|
||||
if (text.indexOf('\n') == -1) {
|
||||
elem.setAttribute('text', text);
|
||||
@ -305,17 +281,6 @@ mindplot.persistence.XMLSerializer_Pela = new Class({
|
||||
if ($defined(borderColor)) {
|
||||
topic.setBorderColor(borderColor);
|
||||
}
|
||||
//
|
||||
// } else {
|
||||
// var sizeStr = domElem.getAttribute('size');
|
||||
// $assert(sizeStr, "size can not be null");
|
||||
// var size = sizeStr.split(',');
|
||||
// topic.setSize(size[0], size[1]);
|
||||
//
|
||||
// var url = domElem.getAttribute('image');
|
||||
// $assert(url, "url can not be null");
|
||||
// topic.setImageUrl(url);
|
||||
// }
|
||||
|
||||
var order = domElem.getAttribute('order');
|
||||
if ($defined(order)) {
|
||||
@ -338,40 +303,40 @@ mindplot.persistence.XMLSerializer_Pela = new Class({
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
var child = children[i];
|
||||
if (child.nodeType == Node.ELEMENT_NODE) {
|
||||
$assert(child.tagName == "topic" || child.tagName == "icon" || child.tagName == "link" || child.tagName == "note" || child.tagName == "text", 'Illegal node type:' + child.tagName);
|
||||
if (child.tagName == "topic") {
|
||||
var childTopic = this._deserializeNode(child, mindmap);
|
||||
childTopic.connectTo(topic);
|
||||
} else if (child.tagName == "icon") {
|
||||
var icon = this._deserializeIcon(child, topic);
|
||||
topic.addIcon(icon);
|
||||
} else if (child.tagName == "link") {
|
||||
var link = this._deserializeLink(child, topic);
|
||||
topic.addLink(link);
|
||||
} else if (child.tagName == "note") {
|
||||
var note = this._deserializeNote(child, topic);
|
||||
topic.addNote(note);
|
||||
} else if (mindplot.TopicFeature.isSupported(child.tagName)) {
|
||||
|
||||
// Load attributes ...
|
||||
var namedNodeMap = child.attributes;
|
||||
var attributes = {};
|
||||
for (var j = 0; j < namedNodeMap.length; j++) {
|
||||
var attribute = namedNodeMap.item(j);
|
||||
attributes[attribute.name] = attribute.value;
|
||||
}
|
||||
|
||||
// Has text node ?.
|
||||
var textAttr = this._deserializeTextAttr(child);
|
||||
if (textAttr) {
|
||||
attributes['text'] = textAttr;
|
||||
}
|
||||
|
||||
// Create a new element ....
|
||||
var featureType = child.tagName;
|
||||
var feature = mindplot.TopicFeature.createModel(featureType, topic, attributes);
|
||||
topic.addFeature(feature);
|
||||
|
||||
} else if (child.tagName == "text") {
|
||||
var nodeText = this._deserializeNodeText(child);
|
||||
topic.setText(nodeText);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return topic;
|
||||
},
|
||||
|
||||
_deserializeIcon : function(domElem, topic) {
|
||||
var icon = domElem.getAttribute("id");
|
||||
icon = icon.replace("images/", "icons/legacy/");
|
||||
return topic.createIcon(icon);
|
||||
},
|
||||
|
||||
_deserializeLink : function(domElem, topic) {
|
||||
return topic.createLink(domElem.getAttribute("url"));
|
||||
},
|
||||
|
||||
_deserializeNote : function(domElem, topic) {
|
||||
_deserializeTextAttr : function(domElem) {
|
||||
var value = domElem.getAttribute("text");
|
||||
if (!$defined(value)) {
|
||||
var children = domElem.childNodes;
|
||||
@ -382,11 +347,10 @@ mindplot.persistence.XMLSerializer_Pela = new Class({
|
||||
}
|
||||
}
|
||||
}
|
||||
return topic.createNote(value);
|
||||
return value;
|
||||
},
|
||||
|
||||
_deserializeNodeText: function(domElem) {
|
||||
|
||||
var children = domElem.childNodes;
|
||||
var value = null;
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
|
@ -1,20 +1,49 @@
|
||||
Actual :<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<map version="pela" name="basic">
|
||||
<topic id="0" central="true" position="0,0" shape="rounded rectagle" text="Fonts">
|
||||
<topic id="1" position="200,-50" order="1" shape="line" text="Styles">
|
||||
<topic id="2" position="400,-25" order="0" fontStyle="Arial;12;;bold;;" shape="line" text="Bold"/>
|
||||
<topic id="3" position="400,-50" order="1" fontStyle="Arial;12;;;italic;" shape="line" text="Italic"/>
|
||||
<map name="welcome" version="tango">
|
||||
<topic central="true" text="Welcome To WiseMapping" id="1" fontStyle=";;#dfcfe6;;;" bgColor="#0a0a08">
|
||||
<topic position="178,-130" order="0" text="Try it Now!" id="11" fontStyle=";;#ffffff;;;" bgColor="#250be3"
|
||||
brColor="#080559">
|
||||
<topic position="272,-156" order="0" text="Double Click" id="12" fontStyle=";;#001be6;;italic;"/>
|
||||
<topic position="274,-130" order="1" text=" INS to insert" id="13" fontStyle=";;#001be6;;italic;"/>
|
||||
<topic position="285,-104" order="2" text="Drag map to move" id="14" fontStyle=";;#001be6;;italic;"/>
|
||||
</topic>
|
||||
<topic id="4" position="-200,-50" order="1" shape="line" text="Sizes">
|
||||
<topic id="5" position="-400,50" order="0" fontStyle="Arial;8;;;;" shape="line" text="Normal----"/>
|
||||
<topic id="6" position="-400,25" order="1" fontStyle="Arial;9;;;;" shape="line" text="Normal---"/>
|
||||
<topic id="7" position="-400,0" order="2" fontStyle="Arial;10;;;;" shape="line" text="Normal--"/>
|
||||
<topic id="8" position="-400,-25" order="3" fontStyle="Arial;11;;;;" shape="line" text="Normal-"/>
|
||||
<topic id="9" position="-400,-50" order="4" shape="line" text="Normal"/>
|
||||
<topic id="10" position="-400,-75" order="5" fontStyle="Arial;13;;;;" shape="line" text="Nomal+"/>
|
||||
<topic id="11" position="-400,-100" order="6" fontStyle="Arial;14;;;;" shape="line" text="Normal++"/>
|
||||
<topic id="12" position="-400,-125" order="7" fontStyle="Arial;15;;;;" shape="line" text="Normal+++"/>
|
||||
<topic id="13" position="-400,-150" order="8" fontStyle="Arial;16;;;;" shape="line" text="Normal++++"/>
|
||||
<topic position="-197,-68" order="1" id="2" fontStyle=";;#104f11;;;" bgColor="#d9b518">
|
||||
<text><![CDATA[Productivity sss sss]]></text>
|
||||
<icon id="chart_pie"/>
|
||||
<note><![CDATA[hola]]></note>
|
||||
<topic position="-325,-94" order="0" text="Share your ideas" id="3">
|
||||
<icon id="bulb_light_on"/>
|
||||
</topic>
|
||||
<topic position="-314,-68" order="1" text="Brainstorming" id="4"/>
|
||||
<topic position="-298,-42" order="2" text="Visual " id="5"/>
|
||||
</topic>
|
||||
<topic position="185,-39" order="2" text="Mind Mapping" id="6" fontStyle=";;#602378;;;" bgColor="#edabff">
|
||||
<topic position="303,-78" order="0" text="Share with Collegues" id="7"/>
|
||||
<topic position="275,-52" order="1" text="Online" id="8"/>
|
||||
<topic position="299,-26" order="2" text="Anyplace, Anytime" id="9"/>
|
||||
<topic position="277,0" order="3" text="Free!!!" id="10"/>
|
||||
</topic>
|
||||
<topic position="-183,23" order="3" text="Web 2.0 Tool" id="22" fontStyle=";;#0c1d6b;;;" bgColor="#add1f7">
|
||||
<topic position="-281,-16" order="0" text="Collaborate" id="23"/>
|
||||
<topic position="-302,10" order="1" text="No plugin required" id="24">
|
||||
<icon id="conn_disconnect"/>
|
||||
</topic>
|
||||
<topic position="-271,36" order="2" text="Share" id="25"/>
|
||||
<topic position="-282,62" order="3" text="Easy to use" id="26"/>
|
||||
</topic>
|
||||
<topic position="171,91" order="4" text="Features" id="15">
|
||||
<topic position="266,26" order="0" text="Links to Sites" id="16" fontStyle=";6;;;;">
|
||||
<link url="http://www.digg.com" type="url"/>
|
||||
</topic>
|
||||
<topic position="245,52" order="1" text="Fonts" id="17"/>
|
||||
<topic position="255,78" order="2" text="Topic Color" id="18"/>
|
||||
<topic position="260,104" order="3" text="Topic Shapes" shape="line" id="19"/>
|
||||
<topic position="252,130" order="4" text="Icons" id="20">
|
||||
<icon id="object_rainbow"/>
|
||||
</topic>
|
||||
<topic position="272,156" order="5" text="History Changes" id="21">
|
||||
<icon id="arrowc_turn_left"/>
|
||||
</topic>
|
||||
</topic>
|
||||
<topic position="-176,91" order="5" id="27"/>
|
||||
</topic>
|
||||
</map>
|
||||
|
Loading…
Reference in New Issue
Block a user