Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 281131
Collapse All | Expand All

(-)src/org/eclipse/rwt/internal/theme/ThemeCssElement.java (-19 / +9 lines)
Lines 18-25 Link Here
18
18
19
  private final String name;
19
  private final String name;
20
20
21
  private String description;
22
23
  private Collection properties;
21
  private Collection properties;
24
22
25
  private Collection styles;
23
  private Collection styles;
Lines 37-77 Link Here
37
    return name;
35
    return name;
38
  }
36
  }
39
37
40
  public String getDescription() {
38
  public String[] getProperties() {
41
    return description;
39
    String[] result = new String[ properties.size() ];
42
  }
43
44
  public IThemeCssProperty[] getProperties() {
45
    IThemeCssProperty[] result = new IThemeCssProperty[ properties.size() ];
46
    properties.toArray( result );
40
    properties.toArray( result );
47
    return result;
41
    return result;
48
  }
42
  }
49
43
50
  public IThemeCssAttribute[] getStyles() {
44
  public String[] getStyles() {
51
    IThemeCssAttribute[] result = new IThemeCssAttribute[ styles.size() ];
45
    String[] result = new String[ styles.size() ];
52
    styles.toArray( result );
46
    styles.toArray( result );
53
    return result;
47
    return result;
54
  }
48
  }
55
  
49
  
56
  public IThemeCssAttribute[] getStates() {
50
  public String[] getStates() {
57
    IThemeCssAttribute[] result = new IThemeCssAttribute[ states.size() ];
51
    String[] result = new String[ states.size() ];
58
    states.toArray( result );
52
    states.toArray( result );
59
    return result;
53
    return result;
60
  }
54
  }
61
55
62
  public void setDescription( final String description ) {
56
  public void addProperty( final String property ) {
63
    this.description = description;
64
  }
65
66
  public void addProperty( final IThemeCssProperty property ) {
67
    properties.add( property );
57
    properties.add( property );
68
  }
58
  }
69
59
70
  public void addStyle( final IThemeCssAttribute style ) {
60
  public void addStyle( final String style ) {
71
    styles.add( style );
61
    styles.add( style );
72
  }
62
  }
73
63
74
  public void addState( final IThemeCssAttribute state ) {
64
  public void addState( final String state ) {
75
    states.add( state );
65
    states.add( state );
76
  }
66
  }
77
}
67
}
(-)src/org/eclipse/rwt/internal/theme/ThemeCssValuesMap.java (-8 / +5 lines)
Lines 33-42 Link Here
33
                           final StyleSheet styleSheet )
33
                           final StyleSheet styleSheet )
34
  {
34
  {
35
    String elementName = element.getName();
35
    String elementName = element.getName();
36
    IThemeCssProperty[] properties = element.getProperties();
36
    String[] properties = element.getProperties();
37
    for( int i = 0; i < properties.length; i++ ) {
37
    for( int i = 0; i < properties.length; i++ ) {
38
      IThemeCssProperty property = properties[ i ];
38
      String propertyName = properties[ i ];
39
      String propertyName = property.getName();
40
      ConditionalValue[] values = styleSheet.getValues( elementName,
39
      ConditionalValue[] values = styleSheet.getValues( elementName,
41
                                                        propertyName );
40
                                                        propertyName );
42
      ConditionalValue[] filteredValues = filterValues( values, element );
41
      ConditionalValue[] filteredValues = filterValues( values, element );
Lines 100-112 Link Here
100
    return passed;
99
    return passed;
101
  }
100
  }
102
101
103
  private static boolean contains( final IThemeCssAttribute[] attributes,
102
  private static boolean contains( final String[] elements, final String string )
104
                                   final String name )
105
  {
103
  {
106
    boolean result = false;
104
    boolean result = false;
107
    for( int i = 0; i < attributes.length && !result; i++ ) {
105
    for( int i = 0; i < elements.length && !result; i++ ) {
108
      IThemeCssAttribute themeCssAttribute = attributes[ i ];
106
      if( string.equals( elements[ i ] ) ) {
109
      if( name.equals( themeCssAttribute.getName() ) ) {
110
        result = true;
107
        result = true;
111
      }
108
      }
112
    }
109
    }
(-)src/org/eclipse/rwt/internal/theme/ThemeCssProperty.java (-46 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.theme;
12
13
14
/**
15
 * A property in a theme definition file (*.theme.xml).
16
 */
17
public class ThemeCssProperty implements IThemeCssProperty {
18
19
  private final String name;
20
  private final String type;
21
  private String description;
22
23
  public ThemeCssProperty( final String name, final String type ) {
24
    if( name == null || type == null ) {
25
      throw new NullPointerException( "null argument" );
26
    }
27
    this.name = name;
28
    this.type = type;
29
  }
30
31
  public String getName() {
32
    return name;
33
  }
34
35
  public String getType() {
36
    return type;
37
  }
38
39
  public String getDescription() {
40
    return description;
41
  }
42
43
  public void setDescription( final String description ) {
44
    this.description = description;
45
  }
46
}
(-)src/org/eclipse/rwt/internal/theme/IThemeCssAttribute.java (-23 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
12
package org.eclipse.rwt.internal.theme;
13
14
15
/**
16
 * A state or a style that can be applied to an {@link IThemeCssElement}.
17
 */
18
public interface IThemeCssAttribute {
19
20
  public abstract String getName();
21
22
  public abstract String getDescription();
23
}
(-)src/org/eclipse/rwt/internal/theme/IThemeCssElement.java (-5 / +3 lines)
Lines 20-30 Link Here
20
20
21
  public abstract String getName();
21
  public abstract String getName();
22
22
23
  public abstract String getDescription();
23
  public abstract String[] getProperties();
24
24
25
  public abstract IThemeCssProperty[] getProperties();
25
  public abstract String[] getStyles();
26
26
27
  public abstract IThemeCssAttribute[] getStyles();
27
  public abstract String[] getStates();
28
29
  public abstract IThemeCssAttribute[] getStates();
30
}
28
}
(-)src/org/eclipse/rwt/internal/theme/IThemeCssProperty.java (-25 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
12
package org.eclipse.rwt.internal.theme;
13
14
15
/**
16
 * A themeable property of an {@link IThemeCssElement}.
17
 */
18
public interface IThemeCssProperty {
19
20
  public abstract String getName();
21
22
  public abstract String getType();
23
24
  public abstract String getDescription();
25
}
(-)src/org/eclipse/rwt/internal/theme/ThemeDefinitionReader.java (-69 / +3 lines)
Lines 42-51 Link Here
42
  
42
  
43
  private static final String ATTR_NAME = "name";
43
  private static final String ATTR_NAME = "name";
44
44
45
  private static final String ATTR_TYPE = "type";
46
47
  private static final String ATTR_DESCRIPTION = "description";
48
49
  public static final String TYPE_BOOLEAN = "boolean";
45
  public static final String TYPE_BOOLEAN = "boolean";
50
46
51
  public static final String TYPE_BORDER = "border";
47
  public static final String TYPE_BORDER = "border";
Lines 128-135 Link Here
128
    String name = getAttributeValue( node, ATTR_NAME );
124
    String name = getAttributeValue( node, ATTR_NAME );
129
    ThemeCssElement themeElement = new ThemeCssElement( name );
125
    ThemeCssElement themeElement = new ThemeCssElement( name );
130
    cssElements.add( themeElement );
126
    cssElements.add( themeElement );
131
    String description = getElementOrAttributeValue( node, ATTR_DESCRIPTION );
132
    themeElement.setDescription( description );
133
    NodeList childNodes = node.getChildNodes();
127
    NodeList childNodes = node.getChildNodes();
134
    for( int i = 0; i < childNodes.getLength(); i++ ) {
128
    for( int i = 0; i < childNodes.getLength(); i++ ) {
135
      Node childNode = childNodes.item( i );
129
      Node childNode = childNodes.item( i );
Lines 137-193 Link Here
137
        if( ELEM_ELEMENT.equals( childNode.getNodeName() ) ) {
131
        if( ELEM_ELEMENT.equals( childNode.getNodeName() ) ) {
138
          readElement( childNode );
132
          readElement( childNode );
139
        } else if( ELEM_PROPERTY.equals( childNode.getNodeName() ) ) {
133
        } else if( ELEM_PROPERTY.equals( childNode.getNodeName() ) ) {
140
          themeElement.addProperty( readProperty( childNode ) );
134
          themeElement.addProperty( getAttributeValue( childNode, ATTR_NAME ) );
141
        } else if( ELEM_STYLE.equals( childNode.getNodeName() ) ) {
135
        } else if( ELEM_STYLE.equals( childNode.getNodeName() ) ) {
142
          themeElement.addStyle( readStateOrStyle( childNode ) );
136
          themeElement.addStyle( getAttributeValue( childNode, ATTR_NAME ) );
143
        } else if( ELEM_STATE.equals( childNode.getNodeName() ) ) {
137
        } else if( ELEM_STATE.equals( childNode.getNodeName() ) ) {
144
          themeElement.addState( readStateOrStyle( childNode ) );
138
          themeElement.addState( getAttributeValue( childNode, ATTR_NAME ) );
145
        }
139
        }
146
      }
140
      }
147
    }
141
    }
148
  }
142
  }
149
143
150
  private IThemeCssProperty readProperty( final Node node ) {
151
    String name = getAttributeValue( node, ATTR_NAME );
152
    String type = getAttributeValue( node, ATTR_TYPE );
153
    if( type == null ) {
154
      if( "padding".equals( name ) || "margin".equals( name ) ) {
155
        type = TYPE_BOXDIMENSIONS;
156
      } else if( "color".equals( name ) || "background-color".equals( name ) ) {
157
        type = TYPE_COLOR;
158
      } else if( "font".equals( name ) ) {
159
        type = TYPE_FONT;
160
      } else if( "border".equals( name ) ) {
161
        type = TYPE_BORDER;
162
      } else if( "spacing".equals( name )
163
                 || "width".equals( name )
164
                 || "height".equals( name ) )
165
      {
166
        type = TYPE_DIMENSION;
167
      } else if( "background-image".equals( name ) ) {
168
        type = TYPE_IMAGE;
169
      } else {
170
        throw new IllegalArgumentException( "type unknown for property " + name );
171
      }
172
    }
173
    ThemeCssProperty result = new ThemeCssProperty( name, type );
174
    String description = getElementOrAttributeValue( node, ATTR_DESCRIPTION );
175
    if( description != null ) {
176
      result.setDescription( description );
177
    }
178
    return result;
179
  }
180
181
  private IThemeCssAttribute readStateOrStyle( final Node node ) {
182
    String name = getAttributeValue( node, ATTR_NAME );
183
    ThemeCssAttribute result = new ThemeCssAttribute( name );
184
    String description = getElementOrAttributeValue( node, ATTR_DESCRIPTION );
185
    if( description != null ) {
186
      result.setDescription( description );
187
    }
188
    return result;
189
  }
190
191
  private Document parseThemeDefinition( final InputStream is )
144
  private Document parseThemeDefinition( final InputStream is )
192
    throws SAXException, IOException
145
    throws SAXException, IOException
193
  {
146
  {
Lines 227-251 Link Here
227
    builder.setErrorHandler( new ThemeDefinitionErrorHandler() );
180
    builder.setErrorHandler( new ThemeDefinitionErrorHandler() );
228
    return builder.parse( is );
181
    return builder.parse( is );
229
  }
182
  }
230
  
231
  private static String getElementOrAttributeValue( final Node node,
232
                                                    final String name )
233
  {
234
    String result = null;
235
    NodeList childNodes = node.getChildNodes();
236
    int length = childNodes.getLength();
237
    for( int i = 0; i < length && result == null; i++ ) {
238
      Node child = childNodes.item( i );
239
      if( name.equals( child.getNodeName() ) ) {
240
        Node text = child.getFirstChild();
241
        result = text.toString().trim();
242
      }
243
    }
244
    if( result == null ) {
245
      result = getAttributeValue( node, name );
246
    }
247
    return result;
248
  }
249
183
250
  private static String getAttributeValue( final Node node, final String name )
184
  private static String getAttributeValue( final Node node, final String name )
251
  {
185
  {
(-)src/org/eclipse/rwt/internal/theme/ThemeStoreWriter.java (-4 / +3 lines)
Lines 116-126 Link Here
116
      IThemeCssElement element = elements[ i ];
116
      IThemeCssElement element = elements[ i ];
117
      String elementName = element.getName();
117
      String elementName = element.getName();
118
      JsonObject elementObj = new JsonObject();
118
      JsonObject elementObj = new JsonObject();
119
      IThemeCssProperty[] properties = element.getProperties();
119
      String[] properties = element.getProperties();
120
      for( int j = 0; j < properties.length; j++ ) {
120
      for( int j = 0; j < properties.length; j++ ) {
121
        IThemeCssProperty property = properties[ j ];
121
        String propertyName = properties[ j ];
122
        JsonArray valuesArray = new JsonArray();
122
        JsonArray valuesArray = new JsonArray();
123
        String propertyName = property.getName();
124
        ConditionalValue[] values
123
        ConditionalValue[] values
125
          = valuesMap.getValues( elementName, propertyName );
124
          = valuesMap.getValues( elementName, propertyName );
126
        for( int k = 0; k < values.length; k++ ) {
125
        for( int k = 0; k < values.length; k++ ) {
Lines 130-136 Link Here
130
          array.append( Theme.createCssKey( conditionalValue.value ) );
129
          array.append( Theme.createCssKey( conditionalValue.value ) );
131
          valuesArray.append( array );
130
          valuesArray.append( array );
132
        }
131
        }
133
        elementObj.append( property.getName(), valuesArray );
132
        elementObj.append( propertyName, valuesArray );
134
      }
133
      }
135
      mainObject.append( elementName, elementObj );
134
      mainObject.append( elementName, elementObj );
136
    }
135
    }
(-)src/org/eclipse/rwt/internal/theme/ThemeCssAttribute.java (-34 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.theme;
12
13
14
public class ThemeCssAttribute implements IThemeCssAttribute {
15
16
  private final String name;
17
  private String description;
18
19
  public ThemeCssAttribute( final String name ) {
20
    this.name = name;
21
  }
22
23
  public String getName() {
24
    return name;
25
  }
26
27
  public String getDescription() {
28
    return description;
29
  }
30
31
  public void setDescription( final String description ) {
32
    this.description = description;
33
  }
34
}
(-)src/org/eclipse/rwt/internal/theme/WidgetMatcher.java (-1 lines)
Lines 16-22 Link Here
16
16
17
import org.eclipse.rwt.internal.theme.css.ConditionalValue;
17
import org.eclipse.rwt.internal.theme.css.ConditionalValue;
18
import org.eclipse.rwt.lifecycle.WidgetUtil;
18
import org.eclipse.rwt.lifecycle.WidgetUtil;
19
import org.eclipse.swt.widgets.Control;
20
import org.eclipse.swt.widgets.Widget;
19
import org.eclipse.swt.widgets.Widget;
21
20
22
21
(-)src/org/eclipse/rwt/internal/theme/ThemeDefinitionReader_Test.java (-7 / +6 lines)
Lines 39-57 Link Here
39
    assertNotNull( elements );
39
    assertNotNull( elements );
40
    assertTrue( elements.length > 0 );
40
    assertTrue( elements.length > 0 );
41
    assertEquals( "Button", elements[ 0 ].getName() );
41
    assertEquals( "Button", elements[ 0 ].getName() );
42
    assertNotNull( elements[ 0 ].getDescription() );
42
    String[] properties = elements[ 0 ].getProperties();
43
    IThemeCssProperty[] properties = elements[ 0 ].getProperties();
44
    assertNotNull( properties );
43
    assertNotNull( properties );
45
    assertTrue( properties.length > 0 );
44
    assertTrue( properties.length > 0 );
46
    IThemeCssAttribute[] styles = elements[ 0 ].getStyles();
45
    assertEquals( "color", properties[ 0 ] );
46
    String[] styles = elements[ 0 ].getStyles();
47
    assertNotNull( styles );
47
    assertNotNull( styles );
48
    assertTrue( styles.length > 0 );
48
    assertTrue( styles.length > 0 );
49
    IThemeCssAttribute[] states = elements[ 0 ].getStates();
49
    assertEquals( "PUSH", styles[ 0 ] );
50
    String[] states = elements[ 0 ].getStates();
50
    assertNotNull( states );
51
    assertNotNull( states );
51
    assertTrue( states.length > 0 );
52
    assertTrue( states.length > 0 );
52
    assertTrue( properties.length > 0 );
53
    assertEquals( "hover", states[ 0 ] );
53
    assertEquals( "color", properties[ 0 ].getName() );
54
    assertNotNull( properties[ 0 ].getDescription() );
55
  }
54
  }
56
55
57
  public void testNestedElements() throws Exception {
56
  public void testNestedElements() throws Exception {

Return to bug 281131