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", weight:"bold",
color:"#ffffff" color:"#ffffff"
}; };
},
getShrinkConnector : function() {
return null;
} }
}); });

View File

@ -131,6 +131,7 @@ mindplot.ConnectionLine = new Class({
y = y - offset; y = y - offset;
var connector = targetTopic.getShrinkConnector(); var connector = targetTopic.getShrinkConnector();
if ($defined(connector)) {
if (Math.sign(targetPosition.x) > 0) { if (Math.sign(targetPosition.x) > 0) {
var x = targetTopicSize.width; var x = targetTopicSize.width;
connector.setPosition(x, y); connector.setPosition(x, y);
@ -139,6 +140,7 @@ mindplot.ConnectionLine = new Class({
var x = -mindplot.Topic.CONNECTOR_WIDTH; var x = -mindplot.Topic.CONNECTOR_WIDTH;
connector.setPosition(x, y); connector.setPosition(x, y);
} }
}
}, },
setStroke : function(color, style, opacity) { setStroke : function(color, style, opacity) {

View File

@ -448,7 +448,7 @@ mindplot.Designer = new Class({
$assert(mindmapModel, "mindmapModel can not be null"); $assert(mindmapModel, "mindmapModel can not be null");
this._mindmap = mindmapModel; this._mindmap = mindmapModel;
try { // try {
// Init layout manager ... // Init layout manager ...
var size = {width:25,height:25}; var size = {width:25,height:25};
var layoutManager = new mindplot.layout.LayoutManager(mindmapModel.getCentralTopic().getId(), size); 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); mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.DoLayout);
this.fireEvent('loadSuccess'); this.fireEvent('loadSuccess');
} catch(e) { // } catch(e) {
this.fireEvent('loadError', e); // this.fireEvent('loadError', e);
} // }
}, },
getMindmap : function() { getMindmap : function() {

View File

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

View File

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

View File

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