2011-01-23 20:34:05 -03:00
|
|
|
/*
|
2012-10-04 20:48:01 -03:00
|
|
|
* Copyright [2012] [wisemapping]
|
2011-07-30 18:55:32 -03:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2015-03-23 09:25:54 +01:00
|
|
|
|
|
|
|
mindplot.commands.AddRelationshipCommand = new Class(/** @lends AddRelationshipCommand */{
|
2011-07-26 15:07:53 -03:00
|
|
|
Extends:mindplot.Command,
|
2015-03-23 09:25:54 +01:00
|
|
|
/**
|
|
|
|
* @classdesc This command class handles do/undo of adding a relationship to a topic.
|
|
|
|
* @constructs
|
|
|
|
* @param {XMLDOM} model
|
|
|
|
* @extends mindplot.Command
|
|
|
|
*/
|
2012-07-07 01:33:34 -03:00
|
|
|
initialize:function (model) {
|
2011-07-27 14:33:02 -03:00
|
|
|
$assert(model, 'Relationship model can not be null');
|
2012-02-27 19:25:14 -03:00
|
|
|
|
|
|
|
this.parent();
|
2010-12-13 11:07:20 -03:00
|
|
|
this._model = model;
|
|
|
|
},
|
2015-03-23 09:25:54 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Overrides abstract parent method
|
|
|
|
*/
|
2012-07-07 01:33:34 -03:00
|
|
|
execute:function (commandContext) {
|
|
|
|
var relationship = commandContext.addRelationship(this._model);
|
2011-04-16 14:18:33 +01:00
|
|
|
relationship.setOnFocus(true);
|
2010-12-13 11:07:20 -03:00
|
|
|
},
|
2011-10-09 17:59:16 -03:00
|
|
|
|
2015-03-23 09:25:54 +01:00
|
|
|
/**
|
|
|
|
* Overrides abstract parent method
|
|
|
|
* @see {@link mindplot.Command.undoExecute}
|
|
|
|
*/
|
2012-07-07 01:33:34 -03:00
|
|
|
undoExecute:function (commandContext) {
|
|
|
|
var rel = commandContext.findRelationships(this._model.getId());
|
|
|
|
commandContext.deleteRelationship(rel[0]);
|
2010-12-13 11:07:20 -03:00
|
|
|
}
|
|
|
|
});
|