Fix exception on changing central topic shape.

This commit is contained in:
Paulo Gustavo Veiga 2012-03-08 00:30:27 -03:00
parent 0f2af2cb74
commit 0660c7e8c3
6 changed files with 45 additions and 30 deletions

View File

@ -90,5 +90,9 @@ mindplot.CentralTopic = new Class({
weight:"bold",
color:"#ffffff"
};
},
getShrinkConnector : function() {
return null;
}
});

View File

@ -131,13 +131,15 @@ mindplot.ConnectionLine = new Class({
y = y - offset;
var connector = targetTopic.getShrinkConnector();
if (Math.sign(targetPosition.x) > 0) {
var x = targetTopicSize.width;
connector.setPosition(x, y);
}
else {
var x = -mindplot.Topic.CONNECTOR_WIDTH;
connector.setPosition(x, y);
if ($defined(connector)) {
if (Math.sign(targetPosition.x) > 0) {
var x = targetTopicSize.width;
connector.setPosition(x, y);
}
else {
var x = -mindplot.Topic.CONNECTOR_WIDTH;
connector.setPosition(x, y);
}
}
},

View File

@ -448,7 +448,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);
@ -485,9 +485,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() {

View File

@ -93,6 +93,7 @@ mindplot.Topic = new Class({
if ($defined(iconGroup)) {
iconGroup.moveToFront();
}
//Move connector to front
var connector = this.getShrinkConnector();
if ($defined(connector)) {
@ -489,7 +490,9 @@ mindplot.Topic = new Class({
innerShape.setFill(color);
var connector = this.getShrinkConnector();
connector.setFill(color);
if (connector) {
connector.setFill(color);
}
if ($defined(updateModel) && updateModel) {
var model = this.getModel();
@ -515,8 +518,9 @@ mindplot.Topic = new Class({
innerShape.setAttribute('strokeColor', color);
var connector = this.getShrinkConnector();
connector.setAttribute('strokeColor', color);
if (connector) {
connector.setAttribute('strokeColor', color);
}
if ($defined(updateModel) && updateModel) {
var model = this.getModel();
@ -542,7 +546,6 @@ mindplot.Topic = new Class({
var outerShape = this.getOuterShape();
var innerShape = this.getInnerShape();
var textShape = this.getTextShape();
var shrinkConnector = this.getShrinkConnector();
// Add to the group ...
group.appendChild(outerShape);
@ -555,7 +558,8 @@ mindplot.Topic = new Class({
this.getOrBuildIconGroup();
}
if (this.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
var shrinkConnector = this.getShrinkConnector();
if ($defined(shrinkConnector)) {
shrinkConnector.addToWorkspace(group);
}
@ -615,7 +619,9 @@ mindplot.Topic = new Class({
// Change render base on the state.
var shrinkConnector = this.getShrinkConnector();
shrinkConnector.changeRender(value);
if ($defined(shrinkConnector)) {
shrinkConnector.changeRender(value);
}
// Do some fancy animation ....
var elements = this._flatten2DElements(this);
@ -874,7 +880,9 @@ mindplot.Topic = new Class({
if (this.getIncomingLines().length > 0) {
var connector = this.getShrinkConnector();
connector.setVisibility(value);
if ($defined(connector)) {
connector.setVisibility(value);
}
}
var textShape = this.getTextShape();
@ -885,8 +893,10 @@ mindplot.Topic = new Class({
var elem = this.get2DElement();
elem.setOpacity(opacity);
this.getShrinkConnector().setOpacity(opacity);
var connector = this.getShrinkConnector();
if ($defined(connector)) {
connector.setOpacity(opacity);
}
var textShape = this.getTextShape();
textShape.setOpacity(opacity);
},
@ -986,7 +996,9 @@ mindplot.Topic = new Class({
// Hide connection line?.
if (targetTopic.getChildren().length == 0) {
var connector = targetTopic.getShrinkConnector();
connector.setVisibility(false);
if ($defined(connector)) {
connector.setVisibility(false);
}
}
}
},
@ -1041,7 +1053,9 @@ mindplot.Topic = new Class({
// Display connection node...
var connector = targetTopic.getShrinkConnector();
connector.setVisibility(true);
if ($defined(connector)) {
connector.setVisibility(true);
}
// Redraw line ...
outgoingLine.redraw();

View File

@ -22,7 +22,7 @@
<script type="text/javascript">
var mapId = 'welcome-reloaded';
var mapId = 'welcome';
$(document).addEvent('loadcomplete', function(resource) {
var options = loadDesignerOptions();
var designer = buildDesigner(options);

View File

@ -30,17 +30,12 @@ function buildDesigner(options) {
window.waitDialog.destroy();
});
// Register error handlers ...
designer.addEvent('loadError', function(e) {
window.onerror = function()
{
window.waitDialog.close();
window.waitDialog.destroy();
errorDialog.show();
console.log(e);
});
window.onerror = function()
{
errorDialog.show();
};
// Configure default persistence manager ...