X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/JavaElementLabelProvider.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/JavaElementLabelProvider.java index 4067228..44eb464 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/JavaElementLabelProvider.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/JavaElementLabelProvider.java @@ -18,124 +18,130 @@ import org.eclipse.core.resources.IStorage; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.graphics.Image; - - /** - * Standard label provider for Java elements. - * Use this class when you want to present the Java elements in a viewer. + * Standard label provider for Java elements. Use this class when you want to + * present the Java elements in a viewer. *

- * The implementation also handles non-Java elements by forwarding the requests to the - * IWorkbenchAdapter of the element. + * The implementation also handles non-Java elements by forwarding the requests + * to the IWorkbenchAdapter of the element. *

*

* This class may be instantiated; it is not intended to be subclassed. *

*/ public class JavaElementLabelProvider extends LabelProvider { - + /** - * Flag (bit mask) indicating that methods labels include the method return type. (appended) + * Flag (bit mask) indicating that methods labels include the method return + * type. (appended) */ - public final static int SHOW_RETURN_TYPE= 0x001; - + public final static int SHOW_RETURN_TYPE = 0x001; + /** - * Flag (bit mask) indicating that method label include method parameter types. + * Flag (bit mask) indicating that method label include method parameter + * types. */ - public final static int SHOW_PARAMETERS= 0x002; - + public final static int SHOW_PARAMETERS = 0x002; + /** - * Flag (bit mask) indicating that the label of a member should include the container. - * For example, include the name of the type enclosing a field. + * Flag (bit mask) indicating that the label of a member should include the + * container. For example, include the name of the type enclosing a field. + * * @deprecated Use SHOW_QUALIFIED or SHOW_ROOT instead */ - public final static int SHOW_CONTAINER= 0x004; + public final static int SHOW_CONTAINER = 0x004; /** - * Flag (bit mask) indicating that the label of a type should be fully qualified. - * For example, include the fully qualified name of the type enclosing a type. + * Flag (bit mask) indicating that the label of a type should be fully + * qualified. For example, include the fully qualified name of the type + * enclosing a type. + * * @deprecated Use SHOW_QUALIFIED instead */ - public final static int SHOW_CONTAINER_QUALIFICATION= 0x008; + public final static int SHOW_CONTAINER_QUALIFICATION = 0x008; /** * Flag (bit mask) indicating that the label should include overlay icons * for element type and modifiers. */ - public final static int SHOW_OVERLAY_ICONS= 0x010; + public final static int SHOW_OVERLAY_ICONS = 0x010; /** - * Flag (bit mask) indicating thata field label should include the declared type. + * Flag (bit mask) indicating thata field label should include the declared + * type. */ - public final static int SHOW_TYPE= 0x020; + public final static int SHOW_TYPE = 0x020; /** * Flag (bit mask) indicating that the label should include the name of the * package fragment root (appended). */ - public final static int SHOW_ROOT= 0x040; - + public final static int SHOW_ROOT = 0x040; + /** * Flag (bit mask) indicating that the label qualification of a type should * be shown after the name. + * * @deprecated SHOW_POST_QUALIFIED instead */ - public final static int SHOW_POSTIFIX_QUALIFICATION= 0x080; + public final static int SHOW_POSTIFIX_QUALIFICATION = 0x080; /** - * Flag (bit mask) indicating that the label should show the icons with no space - * reserved for overlays. + * Flag (bit mask) indicating that the label should show the icons with no + * space reserved for overlays. */ - public final static int SHOW_SMALL_ICONS= 0x100; - + public final static int SHOW_SMALL_ICONS = 0x100; + /** - * Flag (bit mask) indicating that the packagefragment roots from variables should - * be rendered with the variable in the name + * Flag (bit mask) indicating that the packagefragment roots from variables + * should be rendered with the variable in the name */ - public final static int SHOW_VARIABLE= 0x200; - + public final static int SHOW_VARIABLE = 0x200; + /** - * Flag (bit mask) indicating that Complation Units, Class Files, Types, Declarations and Members - * should be rendered qualified. - * Examples: java.lang.String, java.util.Vector.size() + * Flag (bit mask) indicating that Complation Units, Class Files, Types, + * Declarations and Members should be rendered qualified. Examples: + * java.lang.String, java.util.Vector.size() * * @since 2.0 */ - public final static int SHOW_QUALIFIED= 0x400; + public final static int SHOW_QUALIFIED = 0x400; /** - * Flag (bit mask) indicating that Complation Units, Class Files, Types, Declarations and Members - * should be rendered qualified. The qualifcation is appended - * Examples: String - java.lang, size() - java.util.Vector + * Flag (bit mask) indicating that Complation Units, Class Files, Types, + * Declarations and Members should be rendered qualified. The qualifcation + * is appended Examples: String - java.lang, size() - java.util.Vector * * @since 2.0 */ - public final static int SHOW_POST_QUALIFIED= 0x800; - - + public final static int SHOW_POST_QUALIFIED = 0x800; + /** - * Constant (value 0) indicating that the label should show + * Constant (value 0) indicating that the label should show * the basic images only. */ - public final static int SHOW_BASICS= 0x000; - - + public final static int SHOW_BASICS = 0x000; + /** - * Constant indicating the default label rendering. - * Currently the default is equivalent to - * SHOW_PARAMETERS | SHOW_OVERLAY_ICONS. + * Constant indicating the default label rendering. Currently the default is + * equivalent to SHOW_PARAMETERS | SHOW_OVERLAY_ICONS. */ - public final static int SHOW_DEFAULT= new Integer(SHOW_PARAMETERS | SHOW_OVERLAY_ICONS).intValue(); + public final static int SHOW_DEFAULT = new Integer(SHOW_PARAMETERS + | SHOW_OVERLAY_ICONS).intValue(); private JavaElementImageProvider fImageLabelProvider; - + private StorageLabelProvider fStorageLabelProvider; + private int fFlags; + private int fImageFlags; + private int fTextFlags; - + /** * Creates a new label provider with SHOW_DEFAULT flag. - * + * * @see #SHOW_DEFAULT * @since 2.0 */ @@ -145,108 +151,132 @@ public class JavaElementLabelProvider extends LabelProvider { /** * Creates a new label provider. - * - * @param flags the initial options; a bitwise OR of SHOW_* constants + * + * @param flags + * the initial options; a bitwise OR of SHOW_* + * constants */ public JavaElementLabelProvider(int flags) { - fImageLabelProvider= new JavaElementImageProvider(); - fStorageLabelProvider= new StorageLabelProvider(); - fFlags= flags; + fImageLabelProvider = new JavaElementImageProvider(); + fStorageLabelProvider = new StorageLabelProvider(); + fFlags = flags; updateImageProviderFlags(); - updateTextProviderFlags(); + updateTextProviderFlags(); } - - private boolean getFlag( int flag) { + + private boolean getFlag(int flag) { return (fFlags & flag) != 0; } - + /** * Turns on the rendering options specified in the given flags. - * - * @param flags the options; a bitwise OR of SHOW_* constants + * + * @param flags + * the options; a bitwise OR of SHOW_* constants */ public void turnOn(int flags) { fFlags |= flags; updateImageProviderFlags(); updateTextProviderFlags(); } - + /** * Turns off the rendering options specified in the given flags. - * - * @param flags the initial options; a bitwise OR of SHOW_* constants + * + * @param flags + * the initial options; a bitwise OR of SHOW_* + * constants */ public void turnOff(int flags) { fFlags &= (~flags); updateImageProviderFlags(); updateTextProviderFlags(); } - + private void updateImageProviderFlags() { - fImageFlags= 0; + fImageFlags = 0; if (getFlag(SHOW_OVERLAY_ICONS)) { fImageFlags |= JavaElementImageProvider.OVERLAY_ICONS; } if (getFlag(SHOW_SMALL_ICONS)) { fImageFlags |= JavaElementImageProvider.SMALL_ICONS; } - } - + } + private void updateTextProviderFlags() { - fTextFlags= 0; + fTextFlags = 0; if (getFlag(SHOW_RETURN_TYPE)) { fTextFlags |= JavaElementLabels.M_APP_RETURNTYPE; } if (getFlag(SHOW_PARAMETERS)) { fTextFlags |= JavaElementLabels.M_PARAMETER_TYPES; - } + } if (getFlag(SHOW_CONTAINER)) { - fTextFlags |= JavaElementLabels.P_POST_QUALIFIED | JavaElementLabels.T_POST_QUALIFIED | JavaElementLabels.CF_POST_QUALIFIED | JavaElementLabels.CU_POST_QUALIFIED | JavaElementLabels.M_POST_QUALIFIED | JavaElementLabels.F_POST_QUALIFIED; + fTextFlags |= JavaElementLabels.P_POST_QUALIFIED + | JavaElementLabels.T_POST_QUALIFIED + | JavaElementLabels.CF_POST_QUALIFIED + | JavaElementLabels.CU_POST_QUALIFIED + | JavaElementLabels.M_POST_QUALIFIED + | JavaElementLabels.F_POST_QUALIFIED; } if (getFlag(SHOW_POSTIFIX_QUALIFICATION)) { - fTextFlags |= (JavaElementLabels.T_POST_QUALIFIED | JavaElementLabels.CF_POST_QUALIFIED | JavaElementLabels.CU_POST_QUALIFIED); + fTextFlags |= (JavaElementLabels.T_POST_QUALIFIED + | JavaElementLabels.CF_POST_QUALIFIED | JavaElementLabels.CU_POST_QUALIFIED); } else if (getFlag(SHOW_CONTAINER_QUALIFICATION)) { - fTextFlags |=(JavaElementLabels.T_FULLY_QUALIFIED | JavaElementLabels.CF_QUALIFIED | JavaElementLabels.CU_QUALIFIED); + fTextFlags |= (JavaElementLabels.T_FULLY_QUALIFIED + | JavaElementLabels.CF_QUALIFIED | JavaElementLabels.CU_QUALIFIED); } if (getFlag(SHOW_TYPE)) { fTextFlags |= JavaElementLabels.F_APP_TYPE_SIGNATURE; } if (getFlag(SHOW_ROOT)) { fTextFlags |= JavaElementLabels.APPEND_ROOT_PATH; - } + } if (getFlag(SHOW_VARIABLE)) { fTextFlags |= JavaElementLabels.ROOT_VARIABLE; } if (getFlag(SHOW_QUALIFIED)) { - fTextFlags |= (JavaElementLabels.F_FULLY_QUALIFIED | JavaElementLabels.M_FULLY_QUALIFIED | JavaElementLabels.I_FULLY_QUALIFIED - | JavaElementLabels.T_FULLY_QUALIFIED | JavaElementLabels.D_QUALIFIED | JavaElementLabels.CF_QUALIFIED | JavaElementLabels.CU_QUALIFIED); + fTextFlags |= (JavaElementLabels.F_FULLY_QUALIFIED + | JavaElementLabels.M_FULLY_QUALIFIED + | JavaElementLabels.I_FULLY_QUALIFIED + | JavaElementLabels.T_FULLY_QUALIFIED + | JavaElementLabels.D_QUALIFIED + | JavaElementLabels.CF_QUALIFIED | JavaElementLabels.CU_QUALIFIED); } if (getFlag(SHOW_POST_QUALIFIED)) { - fTextFlags |= (JavaElementLabels.F_POST_QUALIFIED | JavaElementLabels.M_POST_QUALIFIED | JavaElementLabels.I_POST_QUALIFIED - | JavaElementLabels.T_POST_QUALIFIED | JavaElementLabels.D_POST_QUALIFIED | JavaElementLabels.CF_POST_QUALIFIED | JavaElementLabels.CU_POST_QUALIFIED); - } + fTextFlags |= (JavaElementLabels.F_POST_QUALIFIED + | JavaElementLabels.M_POST_QUALIFIED + | JavaElementLabels.I_POST_QUALIFIED + | JavaElementLabels.T_POST_QUALIFIED + | JavaElementLabels.D_POST_QUALIFIED + | JavaElementLabels.CF_POST_QUALIFIED | JavaElementLabels.CU_POST_QUALIFIED); + } } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see ILabelProvider#getImage */ public Image getImage(Object element) { - Image result= fImageLabelProvider.getImageLabel(element, fImageFlags); + Image result = fImageLabelProvider.getImageLabel(element, fImageFlags); if (result != null) { return result; } - if (element instanceof IStorage) + if (element instanceof IStorage) return fStorageLabelProvider.getImage(element); return result; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see ILabelProvider#getText */ public String getText(Object element) { - String text= JavaElementLabels.getTextLabel(element, fTextFlags); + String text = JavaElementLabels.getTextLabel(element, fTextFlags); if (text.length() > 0) { return text; } @@ -257,7 +287,8 @@ public class JavaElementLabelProvider extends LabelProvider { return text; } - /* (non-Javadoc) + /* + * (non-Javadoc) * * @see IBaseLabelProvider#dispose */