Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
#662 support clipping of long labels and preserving the full value on…
… the tooltip
  • Loading branch information
jstrachan committed Nov 19, 2013
1 parent d836b26 commit a005055
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 4 deletions.
1 change: 1 addition & 0 deletions hawtio-web/src/main/webapp/app/camel/js/camel.ts
Expand Up @@ -5,6 +5,7 @@ module Camel {
$scope.routeNodes = {};

$scope.camelIgnoreIdForLabel = Camel.ignoreIdForLabel(localStorage);
$scope.camelMaximumLabelWidth = Camel.maximumLabelWidth(localStorage);

$scope.$on("$routeChangeSuccess", function (event, current, previous) {
// lets do this asynchronously to avoid Error: $digest already in progress
Expand Down
26 changes: 25 additions & 1 deletion hawtio-web/src/main/webapp/app/camel/js/helpers.ts
Expand Up @@ -2,6 +2,8 @@ module Camel {

export var log:Logging.Logger = Logger.get("Camel");

export var defaultMaximumLabelWidth = 34;

/**
* Looks up the route XML for the given context and selected route and
* processes the selected route's XML with the given function
Expand Down Expand Up @@ -848,11 +850,19 @@ module Camel {
if (elementID) {
var customId = route.getAttribute("customId");
if ($scope.camelIgnoreIdForLabel || (!customId || customId === "false")) {
labelSummary = elementID;
labelSummary = "id: " + elementID;
} else {
label = elementID;
}
}
// lets check if we need to trim the label
var labelLimit = $scope.camelMaximumLabelWidth || Camel.defaultMaximumLabelWidth;
var length = label.length;
if (length > labelLimit) {
labelSummary = label + "\n\n" + labelSummary;
label = label.substring(0, labelLimit) + "..";
}

var imageUrl = getRouteNodeIcon(nodeSettings);
if ((nodeId === "from" || nodeId === "to") && uri) {
var idx = uri.indexOf(":");
Expand Down Expand Up @@ -1090,4 +1100,18 @@ module Camel {
var value = localStorage["camelIgnoreIdForLabel"];
return value && (value === "true" || value === true);
}

/**
* Returns the maximum width of a label before we start to truncate
*/
export function maximumLabelWidth(localStorage) {
var value = localStorage["camelMaximumLabelWidth"];
if (angular.isString(value)) {
value = parseInt(value);
}
if (!value) {
value = Camel.defaultMaximumLabelWidth;
}
return value;
}
}
7 changes: 7 additions & 0 deletions hawtio-web/src/main/webapp/app/core/html/preferences.html
Expand Up @@ -143,6 +143,13 @@

<strong>Camel</strong>
<form class="form-horizontal">
<label class="control-label">Maximum label length</label>
<div class="control-group">
<div class="controls">
<input type="number" ng-model="camelMaximumLabelWidth">
<span class="help-block">The maximum length of a label in Camel diagrams before it is clipped</span>
</div>
</div>
<label class="control-label">Do not use ID for label</label>
<div class="control-group">
<div class="controls">
Expand Down
8 changes: 5 additions & 3 deletions hawtio-web/src/main/webapp/app/core/js/preferences.ts
Expand Up @@ -96,13 +96,15 @@ module Core {
var defaults = {
logCacheSize: 1000,
fabricEnableMaps: true,
camelIgnoreIdForLabel: false
camelIgnoreIdForLabel: false,
camelMaximumLabelWidth: Camel.defaultMaximumLabelWidth
};

var converters = {
logCacheSize: parseInt,
fabricEnableMaps: parseBooleanValue,
camelIgnoreIdForLabel: parseBooleanValue
camelIgnoreIdForLabel: parseBooleanValue,
camelMaximumLabelWidth: parseInt
};

$scope.$watch('updateRate', () => {
Expand All @@ -118,7 +120,7 @@ module Core {
});

var names = ["gitUserName", "gitUserEmail", "activemqUserName", "activemqPassword",
"logCacheSize", "fabricEnableMaps", "camelIgnoreIdForLabel"];
"logCacheSize", "fabricEnableMaps", "camelIgnoreIdForLabel", "camelMaximumLabelWidth"];

angular.forEach(names, (name) => {
if (angular.isDefined(localStorage[name])) {
Expand Down
1 change: 1 addition & 0 deletions hawtio-web/src/main/webapp/app/wiki/js/camelCanvas.ts
Expand Up @@ -4,6 +4,7 @@ module Wiki {
$scope.propertiesDialog = new Core.Dialog();
$scope.modified = false;
$scope.camelIgnoreIdForLabel = Camel.ignoreIdForLabel(localStorage);
$scope.camelMaximumLabelWidth = Camel.maximumLabelWidth(localStorage);

$scope.$watch("camelContextTree", () => {
var tree = $scope.camelContextTree;
Expand Down
1 change: 1 addition & 0 deletions hawtio-web/src/test/resources/applicationContext.xml
Expand Up @@ -87,6 +87,7 @@
<route>
<from id="inputFiles" uri="file:src/test/data?noop=true"/>
<to id="firstStep" uri="activemq:personnel.records"/>
<to id="firstStep" uri="activemq:very.long.queue.name.goes.here.wow.this.really.is.quite.a.long.queue.name.isnt.it.eh"/>
<bean ref="myBean" method="cheese"/>
<to id="coolBeans" uri="activemq:browse.me"/>
</route>
Expand Down

0 comments on commit a005055

Please sign in to comment.