View | Details | Raw Unified | Return to bug 22118 | Differences between
and this patch

Collapse All | Expand All

(-)DecoratorManager.java (-57 / +51 lines)
Lines 101-177 Link Here
101
	 * Return null if there are none defined for this type.
101
	 * Return null if there are none defined for this type.
102
	 */
102
	 */
103
	public String decorateText(String text, Object element) {
103
	public String decorateText(String text, Object element) {
104
		return decorateText(text, element, true);
105
	}
106
107
104
108
	/**
105
        DecoratorDefinition[] decorators = getDecoratorsFor(element);
109
	 * Decorate the text provided for the element type.
106
        String result = text;
110
	 * Check for an adapted resource if checkAdapted is true.
107
        for (int i = 0; i < decorators.length; i++) {
111
	 * Return null if there are none defined for this type.
108
            String newResult = decorators[i].decorateText(result, element);
112
	 */
109
            if (newResult != null)
113
	private String decorateText(
110
                result = newResult;
114
		String text,
111
        }
115
		Object element,
112
116
		boolean checkAdapted) {
113
        //Get any adaptions to IResource
117
114
        Object adapted = getResourceAdapter(element);
118
		DecoratorDefinition[] decorators = getDecoratorsFor(element);
115
        if (adapted != null) 
119
		String result = text;
116
        {
120
		for (int i = 0; i < decorators.length; i++) {
117
          DecoratorDefinition[] resourceDecorators = getDecoratorsFor(adapted);
121
			String newResult = decorators[i].decorateText(result, element);
118
          for (int i = 0; i < resourceDecorators.length; i++) 
122
			if (newResult != null)
119
          {
123
				result = newResult;
120
            if( resourceDecorators[i].isAdaptable() )
124
		}
121
            {
125
122
              String newResult = resourceDecorators[i].decorateText(result, element);
126
		if (checkAdapted) {
123
              if (newResult != null)
127
			//Get any adaptions to IResource
124
                result = newResult;
128
			Object adapted = getResourceAdapter(element);
125
            }
129
			if (adapted != null)
126
          }
130
				result = decorateText(result, adapted, false);
127
        }
131
		}
128
        
129
        return result;
132
130
133
		return result;
134
	}
131
	}
135
132
136
	/**
137
	 * Decorate the image provided for the element type.
138
	 * Return null if there are none defined for this type.
139
	 */
140
	public Image decorateImage(Image image, Object element) {
141
		return decorateImage(image, element, true);
142
	}
143
133
144
	/**
134
	/**
145
	 * Decorate the image provided for the element type.
135
	 * Decorate the image provided for the element type.
146
	 * Check for an adapted resource if checkAdapted is true.
147
	 * Return null if there are none defined for this type.
136
	 * Return null if there are none defined for this type.
148
	 */
137
	 */
149
	private Image decorateImage(
138
	public Image decorateImage(Image image, Object element) {
150
		Image image,
139
        DecoratorDefinition[] decorators = getDecoratorsFor(element);
151
		Object element,
140
        Image result = image;
152
		boolean checkAdapted) {
141
        for (int i = 0; i < decorators.length; i++) {
153
142
            Image newResult = decorators[i].decorateImage(result, element);
154
		DecoratorDefinition[] decorators = getDecoratorsFor(element);
143
            if (newResult != null)
155
		Image result = image;
144
                result = newResult;
156
		for (int i = 0; i < decorators.length; i++) {
145
        }
157
			Image newResult = decorators[i].decorateImage(result, element);
146
158
			if (newResult != null)
147
        //Get any adaptions to IResource
159
				result = newResult;
148
        Object adapted = getResourceAdapter(element);
160
		}
149
        if (adapted != null) 
161
150
        {
162
		if (checkAdapted) {
151
          DecoratorDefinition[] resourceDecorators = getDecoratorsFor(adapted);
163
			//Get any adaptions to IResource
152
          for (int i = 0; i < resourceDecorators.length; i++) 
164
			Object adapted = getResourceAdapter(element);
153
          {
165
			if (adapted != null)
154
            if( resourceDecorators[i].isAdaptable() )
166
				result = decorateImage(result, adapted, false);
155
            {
167
		}
156
              Image newResult = resourceDecorators[i].decorateImage(result, element);
157
              if (newResult != null)
158
                result = newResult;
159
            }
160
          }
161
        }
168
162
169
		return result;
163
        return result;
170
	}
164
	}
171
165
172
	/**
166
	/**
173
	 * Get the resource adapted object for the supplied
167
	 * Get the resource adapted object for the supplied
174
	 * element. Return null if there isn't one.
168
	 * element. Return null if there isn't one or if adapted == element.
175
	 */
169
	 */
176
	private Object getResourceAdapter(Object element) {
170
	private Object getResourceAdapter(Object element) {
177
171

Return to bug 22118