Bug 437186 - [CSS] CSS Stylesheet customization of labels is broken
Summary: [CSS] CSS Stylesheet customization of labels is broken
Status: NEW
Alias: None
Product: Papyrus
Classification: Modeling
Component: Diagram (show other bugs)
Version: 1.0.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: SR1   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard: nwadsl, Confirmed
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-11 10:39 EDT by Toni Siljamäki CLA
Modified: 2019-02-04 04:10 EST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Toni Siljamäki CLA 2014-06-11 10:39:30 EDT
Some refactoring of the properties view took place a short while ago,
cannot say exactly when, but it affected how and when elements and
their labels is displayed under the appearance tab.

Anyway... The following CSS rule for customizing port labels no longer works:

/* Rule for displaying only the name of the port in its label */
Port > Label {
   maskLabel: name;
   /* maskLabel: name type; */ /* This one displays both the name and the type */
}

This CSS rule is working in Papyrus version 1.0.0.v201405150454
This CSS rule STOPPED working in the version 1.0.0.v201405271626
...and is not working in version 1.0.0.v201406041426

ALSO: If the port has a stereotype applied some annoying <<stereotype>> noise
pops up for the port in the diagram, and it cannot be removed/hidden in
the diagram, and therefore we cannot create a CSS rule for removing it, right?

The strange thing is that in the properties view it has been set to NOT
display the stereotype for the port, but the <<stereotype>> pops up anyway,
right next to the port, and as a separate label.

Some time ago we got the stylesheet support for removing the
<<component>> noise in component names. There should be the same
kind of support for port labels.
Comment 1 Camille Letavernier CLA 2014-06-11 11:39:49 EDT
The rule has been simplified to:

Port {
	maskLabel: name;
}

although the initial intention was to allow both rules ('Port' and 'Port > Label'), to ensure "backwards" compatibility... Looks like we missed something.

This is more consistent with how it is done for Properties.
Comment 2 Toni Siljamäki CLA 2014-06-12 12:05:15 EDT
Yes, the simplified rule works for masking out e.g. type and multiplicity,
but it doesn't mask out the additional <<stereotypename>> label that
pops up when a stereotype is applied on the port.
Comment 3 Camille Letavernier CLA 2014-06-13 05:30:58 EDT
For the <<Stereotype>> tag, the RobotML diagrams use this rule to hide it:

Port>Label:stereotype{visible: false;}

However, there seems to be some refresh issues (i.e. the rule doesn't seem to work until you reopen the diagram)

Is this a regression? I don't think we changed anything related to this specific rule.
Comment 4 Toni Siljamäki CLA 2014-06-17 10:53:21 EDT
In Comment 1 you say that the rule has been simplified.
The change is that the >Label is not used.

I have tested both variants below, neither works.

Port>Label:stereotype{visible: false;}
Port:stereotype{visible: false;}

I don't understand the semantics of the first colon in the rule.
Port>Label:

There is no info nor or example in Help about : before {.
Comment 5 Camille Letavernier CLA 2014-06-17 11:33:31 EDT
The colon is partially documented in the "CSS / Syntax elements" chapter, and some examples are available under the "CSS / MaskLabel" chapter. It is currently used in two cases:

- Handling events (Which is not supported in standard Papyrus yet)
- Identifying specific labels (For elements which can have more than one label, including Associations and Ports)

In this case, Label:Stereotype is more specific than Label: it matches only the Label used to display the stereotypes applied on the current element.

However, as explained in Comment 3, there is a refresh issue with this rule: diagrams are not properly refreshed, and the rule is verified only once, when the diagram is first opened. So, these steps are expected to work:

- Use this rule in a stylesshet:

Port > Label:stereotype {
    visible: false;
}

- Create a stereotyped Port. The <<Stereotype>> label is displayed (While it shouldn't: refresh bug)
- Restart the editor: the <<Stereotype>> label is now hidden

Also note that, as soon as you show/hide a label manually, the CSS rule will be ignored: user actions always take precedence over CSS-defined rules
Comment 6 Toni Siljamäki CLA 2014-06-18 05:14:09 EDT
Port > Label:stereotype {
    visible: false;
}

works for stereotyped ports on a class in a structure diagram
after closing and reopening the model, wrt the refresh issue.

It does not work for stereotyped ports on components in component diagrams.

Also, the <<stereotype>> label itself behaves a bit strange for
ports on components. It cannot be positioned where I like it.

When dragging the label, it jumps away to one of ~4 fixed positions
close to the port.
Comment 7 Toni Siljamäki CLA 2014-06-18 05:38:49 EDT
Also, this functionality to "show/hide a label manually" to override the
CSS rule seem to be broken.

I tested this on the stereotyped class-port.

I use this port rule in a stylesheet added to the default theme.
I manually decide to display the stereotype on the port, and it gets visible.
Next time I open the model (wrt to the refresh issue), the CSS rule has
removed the stereotype label, but according to the Appearance properties
the <<stereotype>> label should be visible on the port.

I have also seen this for other CSS rules, that is, the CSS rules
cannot be overridden manually.

This is perhaps be covered as a separate bugzilla on broken CSS functionality?
Comment 8 Toni Siljamäki CLA 2014-06-18 05:50:44 EDT
Another example of "show/hide a manually" to override the CSS rule,
which seem to be broken, is shapeVisibility for Lifelines.

There is a CSS rule setting shapeVisibility to true for Lifelines.
When selecting the Lifeline and setting shape visibility to false nothing happens.

Next time the Lifeline is selected the shape visibility has been
automatically set back to true.
Comment 9 Johan Van Noten CLA 2016-02-19 07:08:56 EST
Mars.1 with SysML1.4 0.8.1 today's nightly

Customizing a label through CSS is still an issue to me.

e.g.

Class[appliedStereotypes~="Block"] Port > Label {
	maskLabel: name;
}

doesn't seem to do anything.
Example built on information from
https://wiki.eclipse.org/MDT/Papyrus/UserGuide/CSS
Comment 10 Johan Van Noten CLA 2016-02-20 17:09:31 EST
Ignore my own comment #9:
I didn't read the initial comments correctly.
The entry 
Class[appliedStereotypes~="Block"] Port {
	maskLabel: name;
}
works as expected as explained in comment #1.