Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "E4/CSS/Add Selector"

< E4‎ | CSS
(New page: This wiki is a "how-to" that will explain the steps needed to add a CSS Selector in E4.)
 
Line 1: Line 1:
 
This wiki is a "how-to" that will explain the steps needed to add a CSS Selector in E4.
 
This wiki is a "how-to" that will explain the steps needed to add a CSS Selector in E4.
 +
 +
 +
- Create a class in org.eclipse.e4.ui.css.swt.selectors, and name it "DynamicPseudoClassesSWTxxxxHandler" where "xxxx" is the name of the selector
 +
 +
 +
- Make this new class extend "AbstractDynamicPseudoClassesControlHandler"
 +
      public class DynamicPseudoClassesSWTActiveHandler extends AbstractDynamicPseudoClassesControlHandler
 +
 +
 +
- Add the following two methods:
 +
      protected void intialize(final Control control, final CSSEngine engine) {}
 +
      protected void dispose(Control control, CSSEngine engine) {}
 +
 +
      Note: method name is intilize is not initialize
 +
 +
 +
- In the intialize method, add the code needed (most likely listeners to look for change of state). For an example, see org.eclipse.e4.ui.css.swt.selectors.DynamicPseudoClassesSWTActiveHandler
 +
 +
 +
- Make use of the setData() method on the widget (to get information about the widget in another class), as well as applying the styles to the engine. For example, in a listener's method, you can do the following:
 +
      try {
 +
          control.setData("Some Qualified String", Boolean.TRUE);
 +
          engine.applyStyles(control, false, true);
 +
      } catch (Exception ex) {
 +
          engine.handleExceptions(ex);
 +
      }
 +
 +
   
 +
- It is preferable to use a qualified string, and to keep it in org.eclipse.e4.ui.css.swt.CSSSWTConstants
 +
 +
 +
- In the dispose method, get rid of all listeners that were created in the above intialize method
 +
 +
 +
-

Revision as of 10:26, 21 April 2009

This wiki is a "how-to" that will explain the steps needed to add a CSS Selector in E4.


- Create a class in org.eclipse.e4.ui.css.swt.selectors, and name it "DynamicPseudoClassesSWTxxxxHandler" where "xxxx" is the name of the selector


- Make this new class extend "AbstractDynamicPseudoClassesControlHandler"

     public class DynamicPseudoClassesSWTActiveHandler extends AbstractDynamicPseudoClassesControlHandler


- Add the following two methods:

     protected void intialize(final Control control, final CSSEngine engine) {}
     protected void dispose(Control control, CSSEngine engine) {}
     Note: method name is intilize is not initialize


- In the intialize method, add the code needed (most likely listeners to look for change of state). For an example, see org.eclipse.e4.ui.css.swt.selectors.DynamicPseudoClassesSWTActiveHandler


- Make use of the setData() method on the widget (to get information about the widget in another class), as well as applying the styles to the engine. For example, in a listener's method, you can do the following:

     try {
          control.setData("Some Qualified String", Boolean.TRUE);
          engine.applyStyles(control, false, true);
     } catch (Exception ex) {
          engine.handleExceptions(ex);
     }

    

- It is preferable to use a qualified string, and to keep it in org.eclipse.e4.ui.css.swt.CSSSWTConstants


- In the dispose method, get rid of all listeners that were created in the above intialize method


-

Back to the top