Java Code Examples for org.w3c.dom.css.CSSValue#getCssValueType()

The following examples show how to use org.w3c.dom.css.CSSValue#getCssValueType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GridPropertyHandler.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private boolean applyCSSPropertyStyle(final Object element, final Grid grid, final CSSValue value, String target) throws Exception {
	if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
		final FontData fd = CSSEngineHelper.getFontData(grid);
		boolean modified = false;
		if ("italic".equals(value.getCssText()) || "oblique".equals(value.getCssText())) {
			modified = (fd.getStyle() & SWT.ITALIC) != SWT.ITALIC;
			if (modified) {
				fd.setStyle(fd.getStyle() | SWT.ITALIC);
			}
		} else {
			modified = (fd.getStyle() & SWT.ITALIC) == SWT.ITALIC;
			if (modified) {
				fd.setStyle(fd.getStyle() | ~SWT.ITALIC);
			}
		}
		if (modified) {
			applyFont(grid, fd, target);
		}

	}
	return true;
}
 
Example 2
Source File: CDateTimePropertyHandler.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private void applyCSSPropertyWeight(final Control widget, final CSSValue value, final boolean picker) throws Exception {
	if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
		final FontData fd = CSSEngineHelper.getFontData(widget);
		boolean modified = false;
		if ("bold".equals(value.getCssText()) || "bolder".equals(value.getCssText())) {
			modified = (fd.getStyle() & SWT.BOLD) != SWT.BOLD;
			if (modified) {
				fd.setStyle(fd.getStyle() | SWT.BOLD);
			}
		} else {
			modified = (fd.getStyle() & SWT.BOLD) == SWT.BOLD;
			if (modified) {
				fd.setStyle(fd.getStyle() | ~SWT.BOLD);
			}
		}
		if (modified) {
			if (picker) {
				applyFontForPicker((CDateTime) widget, fd);
			} else {
				applyFont(widget, fd);
			}
		}

	}
}
 
Example 3
Source File: CDateTimePropertyHandler.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private void applyCSSPropertySize(final Control widget, final CSSValue value, final boolean picker) throws Exception {
	if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
		final FontData fd = CSSEngineHelper.getFontData(widget);
		final Measure m = (Measure) value;

		final int newSize = Math.round(m.getFloatValue((short) 0));
		final boolean modified = fd.getHeight() != newSize;
		if (modified) {
			fd.setHeight(newSize);
			if (picker) {
				applyFontForPicker((CDateTime) widget, fd);
			} else {
				applyFont(widget, fd);
			}
		}
	}
}
 
Example 4
Source File: CDateTimePropertyHandler.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private void applyCSSPropertyStyle(final Control widget, final CSSValue value, final boolean picker) throws Exception {
	if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
		final FontData fd = CSSEngineHelper.getFontData(widget);
		boolean modified = false;
		if ("italic".equals(value.getCssText()) || "oblique".equals(value.getCssText())) {
			modified = (fd.getStyle() & SWT.ITALIC) != SWT.ITALIC;
			if (modified) {
				fd.setStyle(fd.getStyle() | SWT.ITALIC);
			}
		} else {
			modified = (fd.getStyle() & SWT.ITALIC) == SWT.ITALIC;
			if (modified) {
				fd.setStyle(fd.getStyle() | ~SWT.ITALIC);
			}
		}
		if (modified) {
			if (picker) {
				applyFontForPicker((CDateTime) widget, fd);
			} else {
				applyFont(widget, fd);
			}
		}

	}
}
 
Example 5
Source File: CDateTimePropertyHandler.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private void applyCSSPropertyFont(final Control widget, final CSSValue value, final boolean picker) throws Exception {
	if (value.getCssValueType() == CSSValue.CSS_VALUE_LIST) {
		final CSSValueList valueList = (CSSValueList) value;
		final int length = valueList.getLength();
		for (int i = 0; i < length; i++) {
			final CSSValue value2 = valueList.item(i);
			if (value2.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
				final String cssProp = CSS2FontHelper.getCSSFontPropertyName((CSSPrimitiveValue) value2);
				if (cssProp.equals("font-family")) {
					applyCSSPropertyFamily(widget, value2, picker);
				} else if (cssProp.equals("font-size")) {
					applyCSSPropertySize(widget, value2, picker);
				} else if (cssProp.equals("font-weight") && ("bold".equals(value2.getCssText()) || "bolder".equals(value2.getCssText()))) {
					applyCSSPropertyWeight(widget, value2, picker);
				} else if (cssProp.equals("font-style") && ("italic".equals(value2.getCssText()) || "oblique".equals(value2.getCssText()))) {
					applyCSSPropertyStyle(widget, value2, picker);
				}
			}
		}
	}
}
 
Example 6
Source File: TableComboPropertyHandler.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private boolean applyCSSPropertyWeight(final Object element, final Control widget, final CSSValue value) throws Exception {
	if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
		final FontData fd = CSSEngineHelper.getFontData(widget);
		boolean modified = false;
		if ("bold".equals(value.getCssText()) || "bolder".equals(value.getCssText())) {
			modified = (fd.getStyle() & SWT.BOLD) != SWT.BOLD;
			if (modified) {
				fd.setStyle(fd.getStyle() | SWT.BOLD);
			}
		} else {
			modified = (fd.getStyle() & SWT.BOLD) == SWT.BOLD;
			if (modified) {
				fd.setStyle(fd.getStyle() | ~SWT.BOLD);
			}
		}
		if (modified) {
			applyFont(widget, fd);
		}

	}
	return true;
}
 
Example 7
Source File: TableComboPropertyHandler.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private boolean applyCSSPropertyStyle(final Object element, final Control widget, final CSSValue value) throws Exception {
	if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
		final FontData fd = CSSEngineHelper.getFontData(widget);
		boolean modified = false;
		if ("italic".equals(value.getCssText()) || "oblique".equals(value.getCssText())) {
			modified = (fd.getStyle() & SWT.ITALIC) != SWT.ITALIC;
			if (modified) {
				fd.setStyle(fd.getStyle() | SWT.ITALIC);
			}
		} else {
			modified = (fd.getStyle() & SWT.ITALIC) == SWT.ITALIC;
			if (modified) {
				fd.setStyle(fd.getStyle() | ~SWT.ITALIC);
			}
		}
		if (modified) {
			applyFont(widget, fd);
		}

	}
	return true;
}
 
Example 8
Source File: TableComboPropertyHandler.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private void applyCSSPropertyFont(final Object element, final Control widget, final CSSValue value) throws Exception {
	if (value.getCssValueType() == CSSValue.CSS_VALUE_LIST) {
		final CSSValueList valueList = (CSSValueList) value;
		final int length = valueList.getLength();
		for (int i = 0; i < length; i++) {
			final CSSValue value2 = valueList.item(i);
			if (value2.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
				final String cssProp = CSS2FontHelper.getCSSFontPropertyName((CSSPrimitiveValue) value2);
				if (cssProp.equals("font-family")) {
					applyCSSPropertyFamily(element, widget, value2);
				} else if (cssProp.equals("font-size")) {
					applyCSSPropertySize(element, widget, value2);
				} else if (cssProp.equals("font-weight") && ("bold".equals(value2.getCssText()) || "bolder".equals(value2.getCssText()))) {
					applyCSSPropertyWeight(element, widget, value2);
				} else if (cssProp.equals("font-style") && ("italic".equals(value2.getCssText()) || "oblique".equals(value2.getCssText()))) {
					applyCSSPropertyStyle(element, widget, value2);
				}
			}
		}
	}
}
 
Example 9
Source File: GridPropertyHandler.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private boolean applyCSSPropertyWeight(final Object element, final Grid grid, final CSSValue value, String target) throws Exception {
	if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
		final FontData fd = CSSEngineHelper.getFontData(grid);
		boolean modified = false;
		if ("bold".equals(value.getCssText()) || "bolder".equals(value.getCssText())) {
			modified = (fd.getStyle() & SWT.BOLD) != SWT.BOLD;
			if (modified) {
				fd.setStyle(fd.getStyle() | SWT.BOLD);
			}
		} else {
			modified = (fd.getStyle() & SWT.BOLD) == SWT.BOLD;
			if (modified) {
				fd.setStyle(fd.getStyle() | ~SWT.BOLD);
			}
		}
		if (modified) {
			applyFont(grid, fd, target);
		}

	}
	return true;
}
 
Example 10
Source File: GridPropertyHandler.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private void applyCSSPropertyFont(final Object element, final Grid grid, final CSSValue value, String target) throws Exception {
	if (value.getCssValueType() == CSSValue.CSS_VALUE_LIST) {
		final CSSValueList valueList = (CSSValueList) value;
		final int length = valueList.getLength();
		for (int i = 0; i < length; i++) {
			final CSSValue value2 = valueList.item(i);
			if (value2.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
				final String cssProp = CSS2FontHelper.getCSSFontPropertyName((CSSPrimitiveValue) value2);
				if (cssProp.equals("font-family")) {
					applyCSSPropertyFamily(element, grid, value2, target);
				} else if (cssProp.equals("font-size")) {
					applyCSSPropertySize(element, grid, value2, target);
				} else if (cssProp.equals("font-weight") && ("bold".equals(value2.getCssText()) || "bolder".equals(value2.getCssText()))) {
					applyCSSPropertyWeight(element, grid, value2, target);
				} else if (cssProp.equals("font-style") && ("italic".equals(value2.getCssText()) || "oblique".equals(value2.getCssText()))) {
					applyCSSPropertyStyle(element, grid, value2, target);
				}
			}
		}
	}
}
 
Example 11
Source File: TableComboPropertyHandler.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private boolean applyCSSPropertySize(final Object element, final Control widget, final CSSValue value) throws Exception {
	if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
		final FontData fd = CSSEngineHelper.getFontData(widget);
		final Measure m = (Measure) value;

		final int newSize = Math.round(m.getFloatValue((short) 0));
		final boolean modified = fd.getHeight() != newSize;
		if (modified) {
			fd.setHeight(newSize);
			applyFont(widget, fd);
		}
	}

	return true;
}
 
Example 12
Source File: TableComboPropertyHandler.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private boolean applyCSSPropertyFamily(final Object element, final Control widget, final CSSValue value) throws Exception {
	if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
		final FontData fd = CSSEngineHelper.getFontData(widget);
		final boolean modified = !fd.getName().equals(value.getCssText());
		if (modified) {
			fd.setName(value.getCssText());
			applyFont(widget, fd);
		}
	}
	return true;
}
 
Example 13
Source File: GridPropertyHandler.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private boolean applyCSSPropertyFamily(final Object element, final Grid grid, final CSSValue value, String target) throws Exception {
	if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
		final FontData fd = CSSEngineHelper.getFontData(grid);
		final boolean modified = !fd.getName().equals(value.getCssText());
		if (modified) {
			fd.setName(value.getCssText());
			applyFont(grid, fd, target);
		}
	}
	return true;
}
 
Example 14
Source File: GridPropertyHandler.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private boolean applyCSSPropertySize(final Object element, final Grid grid, final CSSValue value, String target) throws Exception {
	if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
		final FontData fd = CSSEngineHelper.getFontData(grid);
		final Measure m = (Measure) value;

		final int newSize = Math.round(m.getFloatValue((short) 0));
		final boolean modified = fd.getHeight() != newSize;
		if (modified) {
			fd.setHeight(newSize);
			applyFont(grid, fd, target);
		}
	}

	return true;
}
 
Example 15
Source File: CDateTimePropertyHandler.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private void applyCSSPropertyFamily(final Control widget, final CSSValue value, final boolean picker) throws Exception {
	if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
		final FontData fd = CSSEngineHelper.getFontData(widget);
		final boolean modified = !fd.getName().equals(value.getCssText());
		if (modified) {
			fd.setName(value.getCssText());
			if (picker) {
				applyFontForPicker((CDateTime) widget, fd);
			} else {
				applyFont(widget, fd);
			}
		}
	}
}
 
Example 16
Source File: TabbedPropertyTitleCssPropertyHandler.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void applyCSSProperty(Control control, String property, CSSValue value, String pseudo, CSSEngine engine)
		throws Exception {
	if (!(control instanceof TabbedPropertyTitle) || value.getCssValueType() != CSSValue.CSS_PRIMITIVE_VALUE
			|| property == null || !cssPropertyToSWTProperty.containsKey(property)) {
		return;
	}

	TabbedPropertyTitle title = (TabbedPropertyTitle) control;
	title.setColor(cssPropertyToSWTProperty.get(property), CSSSWTColorHelper.getRGBA(value));
}
 
Example 17
Source File: AbstractStyle.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public String getCssText( )
{
	StringBuffer sb = new StringBuffer( );

	for ( int i = 0; i < NUMBER_OF_STYLE; i++ )
	{
		//we don't return the format in css as the format
		//is a complex object which can't be represented as
		//css string.
		if (i == IStyle.STYLE_DATA_FORMAT)
			continue;
		CSSValue value = getProperty( i );
		if ( value != null )
		{
			sb.append( engine.getPropertyName( i ) );
			sb.append( ": " );
			short type = value.getCssValueType( );
			switch ( type )
			{
				case CSSValue.CSS_PRIMITIVE_VALUE :
				{
					CSSPrimitiveValue pv = (CSSPrimitiveValue) value;
					short unitType = pv.getPrimitiveType( );
					switch ( unitType )
					{
						case CSSPrimitiveValue.CSS_STRING :
							sb.append( "'" );
							sb.append( pv.getStringValue( ) );
							sb.append( "'" );
							break;
						case CSSPrimitiveValue.CSS_URI :
							sb.append( "url('" );
							sb.append( pv.getStringValue( ) );
							sb.append( "')" );
							break;
						default :
							sb.append( value.getCssText( ) );
					}
				}
					break;
				default :
					sb.append( value.getCssText( ) );
			}
			sb.append( "; " );
		}
	}
	if ( sb.length( ) > 2 )
	{
		sb.setLength( sb.length( ) - 2 );
	}
	return sb.toString( );
}