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

Commit

Permalink
BZ1145522: After adding a node via the shape menu in IE, select it so…
Browse files Browse the repository at this point in the history
… that its buttons are active.
  • Loading branch information
Tihomir Surdilovic committed Feb 5, 2015
1 parent 2bd6b15 commit 0680f96
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -824,9 +824,10 @@ ORYX.Plugins.ShapeMenuPlugin = {
}

var command = new ORYX.Plugins.ShapeMenuPlugin.CreateCommand(Object.clone(option), this._currentReference, pos, this);
this.facade.executeCommands([command]);
var newShape = this.facade.executeCommands([command]);
this.facade.raiseEvent({
type: ORYX.CONFIG.EVENT_SHAPE_ADDED
type: ORYX.CONFIG.EVENT_SHAPE_ADDED,
shape: newShape
});

// Inform about completed Drag
Expand Down Expand Up @@ -867,10 +868,10 @@ ORYX.Plugins.ShapeMenuPlugin = {

var command = new ORYX.Plugins.ShapeMenuPlugin.CreateCommand(option, undefined, undefined, this);

this.facade.executeCommands([command]);

var newShape = this.facade.executeCommands([command]);
this.facade.raiseEvent({
type: ORYX.CONFIG.EVENT_SHAPE_ADDED
type: ORYX.CONFIG.EVENT_SHAPE_ADDED,
shape: newShape
});
}
},
Expand Down Expand Up @@ -1711,6 +1712,8 @@ ORYX.Plugins.ShapeMenuPlugin.CreateCommand = ORYX.Core.Command.extend({
}
}

return this.shape;

},
rollback: function(){
this.plugin.facade.deleteShape(this.shape);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ ORYX.Plugins.View = {
this.facade.registerOnEvent(ORYX.CONFIG.VOICE_COMMAND_VIEW_SOURCE, this.showProcessBPMN.bind(this));

this.facade.registerOnEvent(ORYX.CONFIG.EVENT_DRAGDROP_END, this.refreshCanvasForIE.bind(this));
this.facade.registerOnEvent(ORYX.CONFIG.EVENT_SHAPE_ADDED, this.refreshCanvasAfterShapeAddedForIE.bind(this));
this.facade.registerOnEvent(ORYX.CONFIG.EVENT_SHAPE_ADDED, this.refreshCanvasForIE.bind(this));

//Standard Values
this.zoomLevel = 1.0;
Expand Down Expand Up @@ -2036,10 +2036,17 @@ ORYX.Plugins.View = {
}
},

refreshCanvasForIE : function() {
refreshCanvasForIE : function( options ) {
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 @@ -2049,36 +2056,11 @@ ORYX.Plugins.View = {
this.facade.executeCommands([command]);
this.facade.importJSON(currentJSON);

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

}
},

refreshCanvasAfterShapeAddedForIE: function() {
this.refreshCanvasForIE();
this.selectShapeAdded();
},

selectShapeAdded: function() {
var lastShape = this.getLastShapeAdded(this.facade.getCanvas().getChildShapes(true));
if (lastShape) {
this.facade.setSelection([lastShape]);
this.facade.setSelection(currectSelection);
this.facade.getCanvas().update();
this.facade.updateSelection();
}
},

getLastShapeAdded: function(shapes)
{
// Returns the last shape that was added to the canvas
var matchingShapes = shapes.findAll(function(n){ return n instanceof ORYX.Core.Shape });
if (matchingShapes && matchingShapes.length && matchingShapes.length > 1) {
return matchingShapes[matchingShapes.length - 2];
}
}

};

ORYX.Plugins.View = Clazz.extend(ORYX.Plugins.View);

0 comments on commit 0680f96

Please sign in to comment.