Author: dazarov
Date: 2008-09-26 08:50:49 -0400 (Fri, 26 Sep 2008)
New Revision: 10504
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ParamListEditPart.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/ParamFigure.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/ParamListFigure.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2254
fine tuning
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ParamListEditPart.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ParamListEditPart.java 2008-09-26
12:47:06 UTC (rev 10503)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ParamListEditPart.java 2008-09-26
12:50:49 UTC (rev 10504)
@@ -14,6 +14,7 @@
import java.util.List;
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;
@@ -29,7 +30,9 @@
import org.eclipse.gef.requests.DropRequest;
import org.eclipse.swt.accessibility.AccessibleControlEvent;
import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.jboss.tools.seam.ui.pages.editor.ecore.pages.Param;
import org.jboss.tools.seam.ui.pages.editor.figures.NodeFigure;
+import org.jboss.tools.seam.ui.pages.editor.figures.ParamFigure;
import org.jboss.tools.seam.ui.pages.editor.figures.ParamListFigure;
public class ParamListEditPart extends PagesEditPart implements PropertyChangeListener,
Adapter {
@@ -83,7 +86,41 @@
Dimension size;
-
+ private int calculateListWidth(){
+ int width = 0;
+ int nameWidth = 0;
+
+ for(int i = 0; i < getPageWrapperModel().getPage().getChildren().size(); i++){
+ Param param = (Param)getPageWrapperModel().getPage().getChildren().get(i);
+ String name;
+ if(param.getName() != null){
+ name = param.getName();
+ name += ":";
+ }else
+ name = "Param:";
+
+ String value;
+ if(param.getValue() != null){
+ value = param.getValue();
+ }else
+ value = "value";
+
+ int curName = FigureUtilities.getTextExtents(name, ParamFigure.nameParamFont).width;
+
+ if(curName > nameWidth)
+ nameWidth = curName;
+
+ int current = FigureUtilities.getTextExtents(name, ParamFigure.nameParamFont).width+
+ FigureUtilities.getTextExtents(value, ParamFigure.valueParamFont).width + 20;
+
+ if(current > width)
+ width = current;
+ }
+
+ ((ParamListFigure)getFigure()).setNameWidth(nameWidth);
+
+ return width;
+ }
protected void refreshVisuals() {
Point loc = getPageWrapperModel().getPage().getLocation().getCopy();
@@ -91,7 +128,7 @@
if(links == 0)
links = 1;
loc.y += 25+links*NodeFigure.LINK_HEIGHT;
- size = new Dimension(200, getPageWrapperModel().getPage().getChildren().size()*19+2);
+ size = new Dimension(calculateListWidth(),
getPageWrapperModel().getPage().getChildren().size()*19+2);
adjustForGrid(loc);
Rectangle r = new Rectangle(loc, size);
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/ParamFigure.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/ParamFigure.java 2008-09-26
12:47:06 UTC (rev 10503)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/ParamFigure.java 2008-09-26
12:50:49 UTC (rev 10504)
@@ -26,9 +26,9 @@
public class ParamFigure extends NodeFigure implements HandleBounds {
private static final Dimension SIZE = new Dimension(56, 100);
- private static final Font nameParamFont = new Font(null, "default", 8,
SWT.BOLD); // TODO: use preference font mechanism for this
+ public static final Font nameParamFont = new Font(null, "default", 8,
SWT.BOLD); // TODO: use preference font mechanism for this
- private static final Font valueParamFont = new Font(null, "default", 8,
SWT.NORMAL); // TODO: use preference font mechanism for this
+ public static final Font valueParamFont = new Font(null, "default", 8,
SWT.NORMAL); // TODO: use preference font mechanism for this
private static final Color selectionColor = new Color(null, 0x41, 0x77, 0xa0);
@@ -88,14 +88,14 @@
}
String name;
if(param.getName() != null){
- name = dottedString(param.getName(), getTextWidth()-getTextInset(), nameParamFont);
+ name = param.getName();
name += ":";
}else
name = "Param:";
String value;
if(param.getValue() != null){
- value = dottedString(param.getValue(), getTextWidth()-getTextInset(),
valueParamFont);
+ value = param.getValue();
}else
value = "value";
@@ -104,7 +104,7 @@
g.drawString(name, getTextInset(), 2);
g.setFont(valueParamFont);
- g.drawString(value, getTextWidth()+3*getTextInset(), 2);
+ g.drawString(value, ((ParamListFigure)getParent()).getNameWidth()+3*getTextInset(),
2);
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/ParamListFigure.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/ParamListFigure.java 2008-09-26
12:47:06 UTC (rev 10503)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/ParamListFigure.java 2008-09-26
12:50:49 UTC (rev 10504)
@@ -97,4 +97,14 @@
}
}
+
+ private int nameWidth = 0;
+
+ public void setNameWidth(int nameWidth){
+ this.nameWidth = nameWidth;
+ }
+
+ public int getNameWidth(){
+ return nameWidth;
+ }
}
\ No newline at end of file