Skip to content

Commit

Permalink
#963 Fixes for metaDecorator
Browse files Browse the repository at this point in the history
- now MetaDecorator uses FQN
- the library elements are 'read-only' but can be put onto any sheet
- when removing library elements, they will be removed without question as they cannot loose their meta information
- constraints now cannot be added/changed for library nodes #955
  • Loading branch information
kecso committed May 4, 2016
1 parent 2818a50 commit a86ec36
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ define([
var MetaDecoratorDiagramDesignerWidget,
DECORATOR_ID = 'MetaDecorator',
ABSTRACT_CLASS = 'abstract',
TEXT_META_EDIT_BTN_BASE = $('<i class="glyphicon glyphicon-cog text-meta"/>');
TEXT_META_EDIT_BTN_BASE = $('<i class="glyphicon glyphicon-cog text-meta"/>'),
TEXT_META_LOCKED_BASE = $('<i class="glyphicon glyphicon-lock meta-lock"/>');

MetaDecoratorDiagramDesignerWidget = function (options) {

Expand Down Expand Up @@ -76,23 +77,34 @@ define([

//jshint camelcase: false
MetaDecoratorDiagramDesignerWidget.prototype.on_addTo = function () {
var self = this;
var self = this,
node = self._control._client.getNode(self._metaInfo[CONSTANTS.GME_ID]),
belongsToLibrary = false;

if (node && (node.isLibraryElement() || node.isLibraryRoot())) {
belongsToLibrary = true;
self._inLibrary = true;
}

this._renderContent();

// set title editable on double-click
this._skinParts.$name.on('dblclick.editOnDblClick', null, function (event) {
if (self.hostDesignerItem.canvas.getIsReadOnlyMode() !== true) {
$(this).editInPlace({
class: '',
onChange: function (oldValue, newValue) {
self._onNodeTitleChanged(oldValue, newValue);
}
});
}
event.stopPropagation();
event.preventDefault();
});
if (belongsToLibrary) {
this.readOnlyMode(true);
} else {
// set title editable on double-click
this._skinParts.$name.on('dblclick.editOnDblClick', null, function (event) {
if (self.hostDesignerItem.canvas.getIsReadOnlyMode() !== true) {
$(this).editInPlace({
class: '',
onChange: function (oldValue, newValue) {
self._onNodeTitleChanged(oldValue, newValue);
}
});
}
event.stopPropagation();
event.preventDefault();
});
}

//set the 'Add new...' clickhandler
this._skinParts.$addAttributeContainer.on('click', null, function (event) {
Expand Down Expand Up @@ -177,6 +189,8 @@ define([

//render text-editor based META editing UI piece
this._skinParts.$textMetaEditorBtn = TEXT_META_EDIT_BTN_BASE.clone();
this._skinParts.$textMetaLock = TEXT_META_LOCKED_BASE.clone();

this.$el.append(this._skinParts.$textMetaEditorBtn);
this._skinParts.$textMetaEditorBtn.on('click', function (event) {
if (self.hostDesignerItem.canvas.getIsReadOnlyMode() !== true) {
Expand All @@ -186,6 +200,9 @@ define([
event.preventDefault();
});

this.$el.append(this._skinParts.$textMetaLock);
this._skinParts.$textMetaLock.hide();

if (this.hostDesignerItem.canvas.getIsReadOnlyMode() === true) {
this._skinParts.$addAttributeContainer.detach();
this._skinParts.$addConstraintContainer.detach();
Expand All @@ -201,7 +218,8 @@ define([
newName = '';

if (nodeObj) {
newName = nodeObj.getAttribute(nodePropertyNames.Attributes.name) || '';
// newName = nodeObj.getAttribute(nodePropertyNames.Attributes.name) || '';
newName = nodeObj.getFullyQualifiedName();

if (this.name !== newName) {
this.name = newName;
Expand Down Expand Up @@ -489,15 +507,17 @@ define([
};

MetaDecoratorDiagramDesignerWidget.prototype._setReadOnlyMode = function (readOnly) {
if (readOnly === true) {
if (readOnly === true || this._inLibrary === true) {
this._skinParts.$addAttributeContainer.detach();
this._skinParts.$addConstraintContainer.detach();
this._skinParts.$addAspectContainer.detach();
this.$el.find('input.new-attr').val('').blur();
this._skinParts.$textMetaLock.show();
} else {
this._skinParts.$attributesTitle.append(this._skinParts.$addAttributeContainer);
this._skinParts.$constraintsTitle.append(this._skinParts.$addConstraintContainer);
this._skinParts.$aspectsTitle.append(this._skinParts.$addAspectContainer);
this._skinParts.$textMetaLock.hide();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@
width: 15px;
margin-top: 2px;
border-radius: 5px; }
.meta-decorator .meta-lock {
position: absolute;
top: 0;
left: 1px;
height: 15px;
width: 15px;
margin-top: 2px;
border-radius: 5px; }
.meta-decorator.abstract .name {
font-style: italic;
color: #aaaaaa; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,16 @@ $abstract-class-name-color: #AAAAAA;
border-radius: 5px;
}

.meta-lock {
position: absolute;
top: 0;
left: 1px;
height: 15px;
width: 15px;
margin-top: 2px;
border-radius: 5px;
}

&.abstract {
.name {
font-style: italic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,13 @@ define(['js/logger',

//if the items is not present anywhere else, remove it from the META's global sheet too
if (self._metaAspectSheetsPerMember[gmeID].length === 1) {
_client.removeMember(aspectNodeID, gmeID, MetaEditorConstants.META_ASPECT_SET_NAME);
_client.setMeta(gmeID, {});
nodeObj = _client.getNode(gmeID);
if (nodeObj && (nodeObj.isLibraryElement() || nodeObj.isLibraryRoot())) {
//library elements will not be lost at all
} else {
_client.removeMember(aspectNodeID, gmeID, MetaEditorConstants.META_ASPECT_SET_NAME);
_client.setMeta(gmeID, {});
}
}
} else if (self._connectionListByID.hasOwnProperty(itemsToDelete[len])) {
//entity is a connection, just simply delete it
Expand All @@ -540,7 +545,12 @@ define(['js/logger',
//entity is a box
//check to see if this gmeID is present on any other sheet at all
if (this._metaAspectSheetsPerMember[gmeID].length === 1) {
metaInfoToBeLost.push(gmeID);
nodeObj = _client.getNode(gmeID);
if (nodeObj && (nodeObj.isLibraryElement() || nodeObj.isLibraryRoot())) {
//library elements will not be lost at all
} else {
metaInfoToBeLost.push(gmeID);
}
}
}
}
Expand Down Expand Up @@ -833,7 +843,12 @@ define(['js/logger',
//entity is a box
//check to see if this gmeID is present on any other sheet at all
if (this._metaAspectSheetsPerMember[gmeID].length === 1) {
metaAspectMemberToBeLost.push(gmeID);
nodeObj = _client.getNode(gmeID);
if (nodeObj && (nodeObj.isLibraryElement() || nodeObj.isLibraryRoot())) {
//library elements will not be lost
} else {
metaAspectMemberToBeLost.push(gmeID);
}
}
}
}
Expand Down

0 comments on commit a86ec36

Please sign in to comment.