Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Commit

Permalink
BZ1145522: fix for shape selection
Browse files Browse the repository at this point in the history
  • Loading branch information
Tihomir Surdilovic authored and Jeremy Lindop committed Feb 6, 2015
1 parent bdc8f49 commit c23a390
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1599,6 +1599,7 @@ ORYX.Plugins.ShapeMenuPlugin.CreateCommand = ORYX.Core.Command.extend({
var resume = false;

if (this.shape) {
this.shape.properties["oryx-invisid"] = Math.random();
if (this.shape instanceof ORYX.Core.Node) {
this.parent.add(this.shape);
if (this.edge) {
Expand All @@ -1620,6 +1621,7 @@ ORYX.Plugins.ShapeMenuPlugin.CreateCommand = ORYX.Core.Command.extend({
}
else {
this.shape = this.plugin.facade.createShape(this.option);
this.shape.properties["oryx-invisid"] = Math.random();
this.edge = (!(this.shape instanceof ORYX.Core.Edge)) ? this.shape.getIncomingShapes().first() : undefined;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2040,13 +2040,6 @@ ORYX.Plugins.View = {
if ( (Object.hasOwnProperty.call(window, "ActiveXObject") && !window.ActiveXObject) ||
(navigator.appVersion.indexOf("MSIE 10") !== -1) ) {

var currectSelection;
if(options && options.shape) {
currectSelection = [ options.shape ];
} else {
currectSelection = this.facade.getSelection();
}

var currentJSON = ORYX.EDITOR.getSerializedJSON();
this.facade.setSelection(this.facade.getCanvas().getChildShapes(true));
var selection = this.facade.getSelection();
Expand All @@ -2056,10 +2049,37 @@ ORYX.Plugins.View = {
this.facade.executeCommands([command]);
this.facade.importJSON(currentJSON);

this.facade.setSelection(currectSelection);
var foundShape = false;
foundShape = this.findSelectedShape(options.shape, options);
if(foundShape) {
this.facade.setSelection([foundShape]);
}

this.facade.getCanvas().update();
this.facade.updateSelection();

}
},

findSelectedShape: function(shape, options) {
var foundShape = false;
if(options && options.shape) {
ORYX.EDITOR._canvas.getChildren().each((function(child) {
if(child instanceof ORYX.Core.Node || child instanceof ORYX.Core.Edge) {
if(options.shape.properties["oryx-invisid"] == child.properties["oryx-invisid"]) {
foundShape = child;
}
}
if(child.getChildren().size() > 0) {
for (var i = 0; i < child.getChildren().size(); i++) {
if(child.getChildren()[i] instanceof ORYX.Core.Node || child.getChildren()[i] instanceof ORYX.Core.Edge) {
this.findSelectedShape(child.getChildren()[i], options);
}
}
}
}).bind(this));
}
return foundShape;
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,21 @@
"value":"false"
}
]
}
},
{
"id":"invisid",
"type":"Text",
"title":"invisid",
"value":"",
"description":"",
"description_ja":"",
"readonly":false,
"optional":true,
"length":"",
"wrapLines":true,
"hidden":true,
"visible":false
}
]
},
{
Expand Down

0 comments on commit c23a390

Please sign in to comment.