Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Css with Forms
Css with Forms [message #742377] Thu, 20 October 2011 12:47 Go to next message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
Registered: July 2009
Senior Member
Hello,

can I style the Forms widget via css?

	FormToolkit toolkit = new FormToolkit(parent.getDisplay());

		Section section = toolkit.createSection(parent, Section.TITLE_BAR);
		section.setText("Forms Details CSS"); //$NON-NLS-1$
		final Composite client = toolkit.createComposite(section, SWT.WRAP);


Section{
    background-color: #e3efff #c1d5ef 60%;
}


Re: Css with Forms [message #747985 is a reply to message #742377] Mon, 24 October 2011 12:03 Go to previous messageGo to next message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
Registered: July 2009
Senior Member
Exist css-support for forms widget?
Re: Css with Forms [message #753607 is a reply to message #747985] Fri, 28 October 2011 02:26 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 242
Registered: July 2009
Senior Member
SirWayne wrote on Mon, 24 October 2011 08:03
Exist css-support for forms widget?


I don't think so. I've started putting some docs together on how to add CSS support for other objects at:

http://wiki.eclipse.org/Eclipse4/RCP/Modeled_UI/Rendering_the_Model#Adding_CSS_Support_for_a_New_Widget_Type

It's untested, but based on what I've derived from examining the code.
Re: Css with Forms [message #754765 is a reply to message #753607] Fri, 04 November 2011 09:03 Go to previous messageGo to next message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
Registered: July 2009
Senior Member
It doesn't work. I set a breakpoint in myCssProvider, but it has never called.


the plugin.xml
   <extension
         point="org.eclipse.e4.u.css.core.elementProvider">
      <provider
            class="css.MyCssProvider">
         <widget
               class="org.eclipse.ui.forms.widgets.Section">
         </widget>
      </provider>
   </extension>
   <extension
         point="org.eclipse.e4.ui.css.swt.property.handler">
      <handler
            adapter="css.SectionElement"
            composite="true"
            handler="org.eclipse.e4.ui.css.swt.properties.css2.CSSPropertyBackgroundSWTHandler">
         <property-name
               name="background-color">
         </property-name>
         <property-name
               name="background-image">
         </property-name>
         <property-name
               name="background">
         </property-name>
      </handler>
   </extension>


my css provider
public class MyCssProvider extends SWTElementProvider{

	@Override
	public Element getElement(Object element, CSSEngine engine) {
		return createElement(element, engine);
	}
	
	public CSSStylableElement createElement(Object element, CSSEngine engine) {
		CSSStylableElement elment = super.createElement(element, engine);
		if (element instanceof Section) {
			return new SectionElement((Section) element, engine);
		}
		return elment;
	}

}


public class SectionElement extends ControlElement {
	
	public SectionElement(Section section, CSSEngine engine) {
		super(section, engine);
	}

	public int getLength() {
		return getSection().getChildren().length;
	}

	public Node item(int index) {
		Widget w = getSection().getChildren()[index];
		return getElement(w);
	}

	protected Section getSection() {
		return (Section) getNativeWidget();
	}

}


my part
@Inject
	public void initUi(Composite parent, PersonService personService ){
		FormToolkit toolkit = new FormToolkit(parent.getDisplay());

		Section section = toolkit.createSection(parent, Section.TITLE_BAR);
		section.setText("Forms Details CSS"); //$NON-NLS-1$
		final Composite client = toolkit.createComposite(section, SWT.WRAP);
Re: Css with Forms [message #755164 is a reply to message #754765] Mon, 07 November 2011 15:23 Go to previous message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 242
Registered: July 2009
Senior Member
SirWayne, this looks like a bug in AbstractCSSEngine. Thanks for finding and reporting!

https://bugs.eclipse.org/bugs/show_bug.cgi?id=363053
Previous Topic:Eclipse 4.2 update site?
Next Topic:How get width and height of a part
Goto Forum:
  


Current Time: Thu Apr 25 08:34:04 GMT 2024

Powered by FUDForum. Page generated in 0.03565 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top