Bug 486738 - [CSS] Can't have multiple rules with the same name in css
Summary: [CSS] Can't have multiple rules with the same name in css
Status: UNCONFIRMED
Alias: None
Product: Papyrus
Classification: Modeling
Component: Diagram (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-28 11:01 EST by Ulf Olsson CLA
Modified: 2017-08-03 09:51 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ulf Olsson CLA 2016-01-28 11:01:16 EST
Named styles in CSS are convenient when controlling the rendering of a component accordng to a specific DSL in cases where the component should look different in different diagrams (of the same type). 
However in order to create rules affecting several properties it seems to be necessary to create several rules with different names; this rapidly becomes very inconvenient for the user.
Solutions: either allow one name to be applied to several rules (dot notation), or create a way of naming rule groups.
Comment 1 Camille Letavernier CLA 2016-01-29 04:30:34 EST
Hi Ulf,

I don't understand the issue

These rules are perfectly valid:

.myNamedRule {
	fillColor: red;
	bold: true;
}

.myNamedRule {
	lineColor: blue;
}

Result: all elements with myNamedRule will have a blue line and red background, and their label will be bold

And they can be combined as well:

.myNamedRule {
	fillColor: red;
}

Class.myNamedRule {
	fillColor: blue;
}

Property.myNamedRule {
	textColor: blue;
}

Result: all elements with myNamedRule will be filled in red, except classes and properties which will be blue

Do you have an example of what you are doing and what result you expect?
Comment 2 Camille Letavernier CLA 2016-01-29 04:43:50 EST
Typo in my previous comment: 'textColor' should actually be 'fontColor'
Comment 3 Ulf Olsson CLA 2016-01-29 08:01:45 EST
Thanks for the quick response. This is what Remi and I were trying to do: 

.Container[appliedStereotypes~="NWAComponent"]  {
	gradient: white vertical;	/* Transparency trick. Apparently, transparency only works when gradient is set. */
	elementIcon: false;			/* To override the Papyrus Theme, if enabled */
	shapeVisibility: true;
    displayBorder: true;
    transparency:0;
	displayTags: false;			/* For removing the <<component>> noise in the name label */
 	displayStereotypes: false;	/* For removing the <<component>> noise in the name label */
 	maxNumberOfSymbol: 1;
 	/* svgCSSFile: url('platform:/plugin/com.ericsson.papyrus.nwa.modeling/nwa_style/nwa_svg.css');	/* Select the stylesheet for the svg figure */
}
.Container2[appliedStereotypes~="NWAComponent"] > Compartment[type="compartment_shape_display"]{
	visible: false;
	showTitle: false;
}
.Container3[appliedStereotypes~="NWAComponent"] > Compartment[stereotype="NWAProfile::NWAComponent"]{
	visible: false;
	showTitle: false;
}
.Container4[appliedStereotypes~="NWAComponent"] > Compartment{
    visible: true;
	showTitle: false;
}

If we gave all rules the same name it seemed like we couldn't get all of them to fire: could it be that the evaluation of filtering rules stops once one has triggered? 
If, instead, we gev them separate names (as shown above) and applied all of them to the same component we could get the correct behavior, but that rapidly becomes untractable.
Comment 4 Camille Letavernier CLA 2016-01-29 09:25:53 EST
These rules seem valid to me, so maybe there's another issue (Or an actual bug)

I will try to reproduce a small example with something similar and see if I find something
Comment 5 Camille Letavernier CLA 2016-01-29 10:12:07 EST
Hi,

I've applied your stylesheet, with these additional extra-steps:

- use a single named style (.Container) instead of .Container1, ...
- Create a profile named NWAProfile with a single Stereotype NWAComponent to match your rules

The rules are properly applied to my elements (Tested on both the Component Diagram and Class Diagram), i.e. all compartments are visible, except the Symbol and Stereotype compartments, the tags/stereotypes disappear and the UML element icon is hidden. The shapeVisibility property is properly set to true (Although I don't have a shape in my example to verify that the image is properly displayed, but that's not relevant for the CSS rules)

I've also changed a few style properties to highlight that the 4 rules behave as expected

So this "works for me". A few other leads:

- There are some conflicting rules in this stylesheet (Unlikely, as changing the name of each rule works as you expect... and changing the name of a rule shouldn't change its priority)
--- Conflicts can be difficult to detect, so don't disregard this possibility. Ultimately, the priority is determined by the order of the rules (When all complexity criterias are equal), so try moving your rules at the end of the file and see if something changes
- The rules do not specify what you think they specify (Unlikely, for the same reason as above)
- Your actual model is more complex than my test model and so my test model is not sufficient to highlight the issue
Comment 6 Ulf Olsson CLA 2016-02-12 10:40:13 EST
Confirmed that multiple rules with the same style name works. Problem was that there were other rules that were more specific, and they apparently take precedence.
Thanks for the help! Still can't get the right things to show, though (not sure I have the proper documentation), but that is out of scope for this bugzilla.
Comment 7 Remi Schnekenburger CLA 2016-02-12 10:53:26 EST
Can we close the bug in this case Ulf?
Comment 8 Ulf Olsson CLA 2016-02-12 11:52:50 EST
OK with me to close (but I would really appreciate pointers to documentation...)