Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 463662

Summary: Prohibit a size of 0 pixel for a label
Product: [Modeling] Sirius Reporter: Laurent Redor <laurent.redor>
Component: CoreAssignee: Steve Monnier <steve.monnier>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: florian.barbin, maxime.porhel, steve.monnier
Version: 0.9Keywords: triaged
Target Milestone: 3.1.0   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/45001
https://git.eclipse.org/r/52347
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=2a946ad66da34123bdcd0f49ce540d03316240fc
Whiteboard:

Description Laurent Redor CLA 2015-04-01 06:34:26 EDT
A label size of 0 pixel should be forbidden. Indeed, SWT does not handle a Font with 0 pixel.

Currently, if the specifier uses 0 for a label size, this provides the below error:

java.lang.IllegalArgumentException: Argument not valid
	at org.eclipse.swt.SWT.error(SWT.java:4462)
	at org.eclipse.swt.SWT.error(SWT.java:4396)
	at org.eclipse.swt.SWT.error(SWT.java:4367)
	at org.eclipse.swt.graphics.FontData.setHeight(FontData.java:340)
	at org.eclipse.swt.graphics.FontData.<init>(FontData.java:200)
	at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.refreshFont(GraphicalEditPart.java:890)
	at org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramContainerEditPart.refreshFont(AbstractDiagramContainerEditPart.java:125)

There are 2 concerned fields:
* BasicLabelStyleDescription.labelSize (for diagram and tree)
* ForegroundStyleDescription.labelSize (for table)

The corresponding property sections, BasicLabelStyleDescriptionLabelSizePropertySection and ForegroundStyleDescriptionLabelSizePropertySection, should forbid that.
And perhaps a validation rule should be added.
Comment 1 Eclipse Genie CLA 2015-04-01 09:28:12 EDT
New Gerrit change created: https://git.eclipse.org/r/45001
Comment 2 Maxime Porhel CLA 2015-04-08 04:52:43 EDT
DTreeElementSynchronizerSpec, StyleHelper and DtableElementSynchronizer should also avoid to set 0 value for the font size. 
They might set 1 as minimum value.
Comment 3 Maxime Porhel CLA 2015-04-08 04:57:13 EDT
Steps to reproduce (User): 
 Open a diagram
 Select an element
 Change the label size in the style tab of the properties views
 The error is logged in the error log


Step to reproduce (Specifier)
 Open a VSM 
 Select or create any label (style) description
 Descrese the label size in the label tab: 1 should the minimum possible value.
Comment 4 Maxime Porhel CLA 2015-04-08 04:59:28 EDT
DTreeElementSynchronizerSpec, StyleHelper and DtableElementSynchronizer modification will prevent the error also in case of a style custmization forcing a 0 value. 

Note: the hide label and hide label per defualt capabilities should soon arrive on container and lists. This should cover the cases for which a specifier might want to set a 0 size.
Comment 5 Eclipse Genie CLA 2015-07-22 09:03:12 EDT
New Gerrit change created: https://git.eclipse.org/r/52347
Comment 7 Steve Monnier CLA 2015-07-29 11:00:03 EDT
Pushed on the master branch
Comment 8 Florian Barbin CLA 2015-09-23 09:01:14 EDT
Verified with 3.1.0.201509211006
Comment 9 Pierre-Charles David CLA 2015-10-16 09:11:58 EDT
Available in Sirius 3.1.0.