summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSidharth Singh2012-10-05 09:09:59 (EDT)
committerManik Kishore2012-10-05 09:09:59 (EDT)
commita4282420cc41bc9dc74498de0cf01fdff564e425 (patch)
treed28992579513fbe4680211e1b952c24604905949
parent323c81da3525c110fea085d9d8555e87dc6f79d3 (diff)
downloadorg.eclipse.stardust.ui.web-a4282420cc41bc9dc74498de0cf01fdff564e425.zip
org.eclipse.stardust.ui.web-a4282420cc41bc9dc74498de0cf01fdff564e425.tar.gz
org.eclipse.stardust.ui.web-a4282420cc41bc9dc74498de0cf01fdff564e425.tar.bz2
CRNT-26180
Added method textWrap in m_utils.js to trim the textNode text. Added method adjustPrimitivesOnShrink in m_activitySymbol.js which checks textNode and icon width with symbol width. git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/ui.web@59778 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--web-modeler/src/main/resources/META-INF/xhtml/js/m_activitySymbol.js19
-rw-r--r--web-modeler/src/main/resources/META-INF/xhtml/js/m_diagram.js4
-rw-r--r--web-modeler/src/main/resources/META-INF/xhtml/js/m_utils.js84
3 files changed, 82 insertions, 25 deletions
diff --git a/web-modeler/src/main/resources/META-INF/xhtml/js/m_activitySymbol.js b/web-modeler/src/main/resources/META-INF/xhtml/js/m_activitySymbol.js
index 95496f7..2ec265a 100644
--- a/web-modeler/src/main/resources/META-INF/xhtml/js/m_activitySymbol.js
+++ b/web-modeler/src/main/resources/META-INF/xhtml/js/m_activitySymbol.js
@@ -321,7 +321,6 @@ define(
*/
ActivitySymbol.prototype.adjustPrimitives = function() {
this.hideGlow();
-
this.rectangle.animate({
"x" : this.x,
"y" : this.y,
@@ -372,6 +371,7 @@ define(
}, this.diagram.animationDelay,
this.diagram.animationEasing);
+ this.adjustPrimitivesOnShrink();
// this.rectangle.attr({
// "x" : this.x,
// "y" : this.y,
@@ -413,9 +413,26 @@ define(
// "x" : this.x + 0.5 * this.width - 4,
// "y" : this.y + this.height - 16
// });
+
};
/**
+ * Hides the icon and shrinks the activity label when activity
+ * size decreases
+ */
+ ActivitySymbol.prototype.adjustPrimitivesOnShrink = function() {
+ if (this.text.getBBox().width > this.width) {
+ var words = this.text.attr("text");
+ m_utils.textWrap(this.text, this.width);
+ }
+
+ if (this.icon.getBBox().width > this.width) {
+ this.icon.hide();
+ } else
+ this.icon.show();
+ }
+
+ /**
*
*/
ActivitySymbol.prototype.createFlyOutMenu = function() {
diff --git a/web-modeler/src/main/resources/META-INF/xhtml/js/m_diagram.js b/web-modeler/src/main/resources/META-INF/xhtml/js/m_diagram.js
index 12b3d25..80b0c43 100644
--- a/web-modeler/src/main/resources/META-INF/xhtml/js/m_diagram.js
+++ b/web-modeler/src/main/resources/META-INF/xhtml/js/m_diagram.js
@@ -1675,7 +1675,7 @@ define(
.valueOf()));
this.editableText
.css("visibility", "visible")
- .html(textPrimitive.attr("text"))
+ .html(textPrimitive.auxiliaryProperties.callbackScope.modelElement.name)
.moveDiv(
{
"x" : textPrimitive.auxiliaryProperties.callbackScope.x
@@ -1711,6 +1711,8 @@ define(
this.currentTextPrimitive.auxiliaryProperties.callbackScope.oid,
changes));
this.currentTextPrimitive.show();
+ this.currentTextPrimitive.auxiliaryProperties.callbackScope
+ .adjustPrimitivesOnShrink();
this.symbolEditMode = false;
m_utils.debug("text primitive shown");
}
diff --git a/web-modeler/src/main/resources/META-INF/xhtml/js/m_utils.js b/web-modeler/src/main/resources/META-INF/xhtml/js/m_utils.js
index ba87fca..b2132f6 100644
--- a/web-modeler/src/main/resources/META-INF/xhtml/js/m_utils.js
+++ b/web-modeler/src/main/resources/META-INF/xhtml/js/m_utils.js
@@ -1,6 +1,6 @@
/**
* Helper functions for object inspection and object initialization.
- *
+ *
* @author Marc.Gille
*/
define(
@@ -50,7 +50,9 @@ define(
prettyDateTime : prettyDateTime,
- formatDate : formatDate
+ formatDate : formatDate,
+
+ textWrap : textWrap
};
function getLastIndexOf(str, searchStr) {
@@ -66,7 +68,7 @@ define(
return index;
}
/**
- *
+ *
* @param from
* @param to
* @returns
@@ -79,7 +81,7 @@ define(
;
/**
- *
+ *
* @param item
*/
function removeItemFromArray(array, item) {
@@ -95,10 +97,46 @@ define(
}
}
;
-
-
+
/**
- *
+ * Trim the text for TextNode element when symbol size is less than
+ * textNode size
+ *
+ * @param t :
+ * textNode element for Symbol
+ * @param width :
+ * actual width of Symbol
+ */
+ function textWrap(t, width) {
+ var content = t.attr("text");
+ var abc = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ t.attr({
+ "text" : abc
+ });
+ var letterWidth = t.getBBox().width / abc.length;
+ t.attr({
+ "text" : content
+ });
+
+ var x = 0;
+ var str = "";
+ for ( var i = 0; i < content.length; i++) {
+ // If textNode text width reaches symbol width append ".."
+ // and break
+ if (x + letterWidth > (width - letterWidth)) {
+ str += "..";
+ break;
+ }
+ x += letterWidth;
+ str += content.charAt(i);
+ }
+ t.attr({
+ "text" : str
+ });
+ }
+
+ /**
+ *
* @param array
* @param item
*/
@@ -122,11 +160,11 @@ define(
* Copies all data members of and object into another object
* recursively. Members existing in the childObject and not existing
* in the parentObject will not be overwritten.
- *
+ *
* Arrays however will be overwritten.
- *
+ *
* The function will not check for cyclic dependencies.
- *
+ *
* Functions in parentObject will not be copied.
*/
function inheritFields(childObject, parentObject) {
@@ -159,7 +197,7 @@ define(
}
/**
- *
+ *
*/
function typeObject(object, prototype) {
inheritMethods(object, prototype);
@@ -245,7 +283,7 @@ define(
}
// TODO I18N
-
+
var nameOfMonths = [ 'January', 'February', 'March', 'April',
'May', 'June', 'July', 'August', 'September', 'October',
'November', 'December' ];
@@ -253,11 +291,11 @@ define(
'Friday', 'Saturday', 'Sunday' ];
/**
- *
+ *
*/
function formatDate(date, s, utc) {
s = s.split('');
-
+
var l = s.length;
var r = '';
var n = m = null;
@@ -310,10 +348,10 @@ define(
m = utc ? date.getUTCMonth() : date.getMonth();
for ( var i = 0; i < m; i++)
n += Date.daysInMonth[i]
-
+
if (isLeapYear(date))
n++;
-
+
n += utc ? date.getUTCDate() : date.getDate();
n--;
r += n;
@@ -512,7 +550,7 @@ define(
}
/**
- *
+ *
*/
function getDaySuffix(date, utc) {
var n = utc ? date.getUTCDate() : date.getDate();
@@ -543,7 +581,7 @@ define(
}
/**
- *
+ *
*/
function getISOWeek(date, utc) {
var y = utc ? date.getUTCFullYear() : date.getFullYear();
@@ -591,7 +629,7 @@ define(
}
/**
- *
+ *
* @param date
* @param utc
* @returns
@@ -603,19 +641,19 @@ define(
}
/**
- *
+ *
* @param date
* @param utc
* @returns
*/
function getNameOfMonth(date, utc) {
var m = utc ? date.getUTCMonth() : date.getMonth();
-
+
return nameOfMonths[m];
}
/**
- *
+ *
*/
function getTimezoneOffset(date) {
return date.getTimezoneOffset() * -1;
@@ -626,7 +664,7 @@ define(
*/
function isLeapYear(date, utc) {
var y = utc ? date.getUTCFullYear() : date.getFullYear();
-
+
return !(y % 4) && (y % 100) || !(y % 400) ? true : false;
}
});