115 lines
4.0 KiB
Java
115 lines
4.0 KiB
Java
|
|
/*
|
||
|
|
* Copyright (c) 2006 Declarative Engineering LLC.
|
||
|
|
* All rights reserved. This program and the accompanying materials
|
||
|
|
* are made available under the terms of the Declarative Engineering LLC
|
||
|
|
* verson 1 which accompanies this distribution, and is available at
|
||
|
|
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||
|
|
*/
|
||
|
|
package com.foundation.view.swt;
|
||
|
|
|
||
|
|
import org.eclipse.swt.custom.ST;
|
||
|
|
|
||
|
|
import com.common.comparison.Comparator;
|
||
|
|
import com.foundation.metadata.Attribute;
|
||
|
|
import com.foundation.model.Model;
|
||
|
|
|
||
|
|
/*
|
||
|
|
* An external structure for specifying bullet metadata for a section of text in the styled text control.
|
||
|
|
* <p>If the text represented by this info instance contains a mix of style settings then only the common styles will be set in this info object. The attributes for which there is a mix of data will be assigned a null value.</p>
|
||
|
|
*/
|
||
|
|
public class StyleBulletInfo extends Model {
|
||
|
|
public static final Integer TYPE_DOT = new Integer(ST.BULLET_DOT);
|
||
|
|
public static final Integer TYPE_NUMBER = new Integer(ST.BULLET_NUMBER);
|
||
|
|
public static final Integer TYPE_LETTER_LOWER = new Integer(ST.BULLET_LETTER_LOWER);
|
||
|
|
public static final Integer TYPE_LETTER_UPPER = new Integer(ST.BULLET_LETTER_UPPER);
|
||
|
|
|
||
|
|
/** The type of bullet as an ST constant. */
|
||
|
|
public static final Attribute TYPE = registerAttribute(StyleBulletInfo.class, "type");
|
||
|
|
/** The text used only if one of the type constants is ST.TEXT. */
|
||
|
|
public static final Attribute TEXT = registerAttribute(StyleBulletInfo.class, "text");
|
||
|
|
public static final Attribute STYLE = registerAttribute(StyleBulletInfo.class, "style");
|
||
|
|
/**
|
||
|
|
* StyleBulletInfo constructor.
|
||
|
|
*/
|
||
|
|
public StyleBulletInfo() {
|
||
|
|
super();
|
||
|
|
setStyle(new StyleTextInfo());
|
||
|
|
setText("");
|
||
|
|
setType(new Integer(0));
|
||
|
|
}//StyleBulletInfo()//
|
||
|
|
/**
|
||
|
|
* Gets the bullet style type.
|
||
|
|
* <p>This can be one of the type constants defined by this class.</p>
|
||
|
|
* @return The type of bullet.
|
||
|
|
* @see #TYPE_DOT
|
||
|
|
* @see #TYPE_NUMBER
|
||
|
|
* @see #TYPE_LETTER_LOWER
|
||
|
|
* @see #TYPE_LETTER_UPPER
|
||
|
|
*/
|
||
|
|
public Integer getType() {
|
||
|
|
return (Integer) getAttributeValue(TYPE);
|
||
|
|
}//getType()//
|
||
|
|
/**
|
||
|
|
* Sets the bullet style type.
|
||
|
|
* <p>This can be one of the type constants defined by this class.</p>
|
||
|
|
* @param type The type of bullet.
|
||
|
|
* @see #TYPE_DOT
|
||
|
|
* @see #TYPE_NUMBER
|
||
|
|
* @see #TYPE_LETTER_LOWER
|
||
|
|
* @see #TYPE_LETTER_UPPER
|
||
|
|
*/
|
||
|
|
public void setType(Integer type) {
|
||
|
|
setAttributeValue(TYPE, type);
|
||
|
|
}//setType()//
|
||
|
|
/**
|
||
|
|
* Gets the bullet style text.
|
||
|
|
* <p>If text has greater than zero length then it will appear after the bullet type's graphic.</p>
|
||
|
|
* @return The text of bullet.
|
||
|
|
*/
|
||
|
|
public String getText() {
|
||
|
|
return (String) getAttributeValue(TEXT);
|
||
|
|
}//getText()//
|
||
|
|
/**
|
||
|
|
* Sets the bullet style text.
|
||
|
|
* <p>If text has greater than zero length then it will appear after the bullet type's graphic.</p>
|
||
|
|
* @param text The text of bullet.
|
||
|
|
*/
|
||
|
|
public void setText(String text) {
|
||
|
|
setAttributeValue(TEXT, text);
|
||
|
|
}//setText()//
|
||
|
|
/**
|
||
|
|
* Gets the bullet style.
|
||
|
|
* @return The style data for the bullet.
|
||
|
|
*/
|
||
|
|
public StyleTextInfo getStyle() {
|
||
|
|
return (StyleTextInfo) getAttributeValue(STYLE);
|
||
|
|
}//getStyle()//
|
||
|
|
/**
|
||
|
|
* Sets the bullet style
|
||
|
|
* @param style The style data for the bullet.
|
||
|
|
*/
|
||
|
|
private void setStyle(StyleTextInfo style) {
|
||
|
|
setAttributeValue(STYLE, style);
|
||
|
|
}//setStyle()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see java.lang.Object#toString()
|
||
|
|
*/
|
||
|
|
public String toString() {
|
||
|
|
return "Bullet Style";
|
||
|
|
}//toString()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see java.lang.Object#equals(java.lang.Object)
|
||
|
|
*/
|
||
|
|
public boolean equals(Object object) {
|
||
|
|
return (object instanceof StyleBulletInfo) &&
|
||
|
|
Comparator.equals(getStyle(), ((StyleBulletInfo) object).getStyle()) &&
|
||
|
|
Comparator.equals(getType(), ((StyleBulletInfo) object).getType()) &&
|
||
|
|
Comparator.equals(getText(), ((StyleBulletInfo) object).getText());
|
||
|
|
}//equals()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see java.lang.Object#hashCode()
|
||
|
|
*/
|
||
|
|
public int hashCode() {
|
||
|
|
return (getStyle() == null ? 0 : getStyle().hashCode()) ^ (getText() == null ? 0 : getText().hashCode()) ^ (getType() == null ? 0 : getType().hashCode());
|
||
|
|
}//hashCode()//
|
||
|
|
}//StyleBulletInfo//
|