Author: dazarov
Date: 2008-05-29 06:47:06 -0400 (Thu, 29 May 2008)
New Revision: 8419
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ExceptionEditPart.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/NodeFigure.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1189
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ExceptionEditPart.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ExceptionEditPart.java 2008-05-29
09:44:04 UTC (rev 8418)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ExceptionEditPart.java 2008-05-29
10:47:06 UTC (rev 8419)
@@ -15,6 +15,7 @@
import java.util.*;
import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.FigureUtilities;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
@@ -35,6 +36,7 @@
import org.jboss.tools.seam.ui.pages.editor.ecore.pages.Page;
import org.jboss.tools.seam.ui.pages.editor.ecore.pages.PgException;
import org.jboss.tools.seam.ui.pages.editor.figures.ExceptionFigure;
+import org.jboss.tools.seam.ui.pages.editor.figures.NodeFigure;
import org.jboss.tools.seam.ui.pages.editor.figures.PageFigure;
public class ExceptionEditPart extends PagesEditPart implements PropertyChangeListener,
EditPartListener, Adapter {
@@ -150,7 +152,10 @@
protected void refreshVisuals() {
Point loc = getExceptionModel().getLocation();
- size = new Dimension(150, 21);
+ String text = getExceptionModel().getName();
+ if(text == null) text="Exception";
+ int width = 30+FigureUtilities.getTextExtents(text, NodeFigure.exceptionFont).width;
+ size = new Dimension(width, 21);
loc.x -= loc.x % 8;
loc.y -= loc.y % 8;
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/NodeFigure.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/NodeFigure.java 2008-05-29
09:44:04 UTC (rev 8418)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/NodeFigure.java 2008-05-29
10:47:06 UTC (rev 8419)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.seam.ui.pages.editor.figures;
+import org.eclipse.draw2d.FigureUtilities;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
@@ -63,4 +64,26 @@
.getImage("error_co.gif");
public static final int LINK_HEIGHT = 16;
+
+ public String dottedString(String str, int availTextWidth, Font font){
+ if(str == null) str = "";
+ String text = new String(str);
+
+ int tWidth = FigureUtilities.getTextExtents(text, font).width;
+
+ if (tWidth > availTextWidth) {
+ String clipString = "...";
+ int totalWidth;
+ int clipWidth = FigureUtilities.getTextExtents(clipString, font).width;;
+ int nChars;
+ for(nChars = 1; nChars < text.length(); nChars++) {
+ totalWidth = FigureUtilities.getTextExtents(text.substring(0,nChars),
font).width+clipWidth;
+ if (totalWidth > availTextWidth) {
+ break;
+ }
+ }
+ text = text.substring(0, nChars) + clipString;
+ }
+ return text;
+ }
}
\ No newline at end of file