use of org.eclipse.wst.sse.ui.ISemanticHighlighting in project webtools.sourceediting by eclipse.
the class SemanticHighlightingManager method handleHighlightingPropertyChange.
/**
* Handles property change events for individual semantic highlightings.
* @param event
*/
private void handleHighlightingPropertyChange(PropertyChangeEvent event) {
String property = event.getProperty();
if (property == null)
return;
boolean refreshRequired = false;
for (int i = 0; i < fHighlightings.length; i++) {
ISemanticHighlighting highlighting = fHighlightings[i];
if (fHighlightingStyleStringKeys[i] != null) {
if (property.equals(fHighlightingStyleStringKeys[i])) {
adaptToStyleChange(fHighlightingStyles[i], event);
fPresenter.highlightingStyleChanged(fHighlightingStyles[i]);
refreshRequired = true;
continue;
}
}
if (property.equals(highlighting.getBoldPreferenceKey())) {
adaptToTextStyleChange(fHighlightingStyles[i], event, SWT.BOLD);
fPresenter.highlightingStyleChanged(fHighlightingStyles[i]);
refreshRequired = true;
continue;
}
if (property.equals(highlighting.getColorPreferenceKey())) {
adaptToTextForegroundChange(fHighlightingStyles[i], event);
fPresenter.highlightingStyleChanged(fHighlightingStyles[i]);
refreshRequired = true;
continue;
}
if (property.equals(highlighting.getEnabledPreferenceKey())) {
adaptToEnablementChange(fHighlightingStyles[i], event);
fPresenter.highlightingStyleChanged(fHighlightingStyles[i]);
refreshRequired = true;
continue;
}
if (property.equals(highlighting.getItalicPreferenceKey())) {
adaptToTextStyleChange(fHighlightingStyles[i], event, SWT.ITALIC);
fPresenter.highlightingStyleChanged(fHighlightingStyles[i]);
refreshRequired = true;
continue;
}
if (property.equals(highlighting.getStrikethroughPreferenceKey())) {
adaptToTextStyleChange(fHighlightingStyles[i], event, TextAttribute.STRIKETHROUGH);
fPresenter.highlightingStyleChanged(fHighlightingStyles[i]);
refreshRequired = true;
continue;
}
if (property.equals(highlighting.getUnderlinePreferenceKey())) {
adaptToTextStyleChange(fHighlightingStyles[i], event, TextAttribute.UNDERLINE);
fPresenter.highlightingStyleChanged(fHighlightingStyles[i]);
refreshRequired = true;
continue;
}
if (highlighting instanceof ISemanticHighlightingExtension2 && property.equals(((ISemanticHighlightingExtension2) highlighting).getBackgroundColorPreferenceKey())) {
adaptToTextBackgroundChange(fHighlightingStyles[i], event);
fPresenter.highlightingStyleChanged(fHighlightingStyles[i]);
refreshRequired = true;
continue;
}
}
if (refreshRequired && fReconciler != null)
fReconciler.refresh();
}
use of org.eclipse.wst.sse.ui.ISemanticHighlighting in project webtools.sourceediting by eclipse.
the class SemanticHighlightingManager method loadSemanticHighlightings.
/**
* Load the semantic highlightings defined for this content type.
*/
private void loadSemanticHighlightings() {
List semantics = new ArrayList(0);
ISemanticHighlighting highlighting = null;
String styleKey = null;
String id = null;
String after = null;
IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(SSEUIPlugin.ID, SEMANTIC_HIGHLIGHTING_EXTENSION_POINT);
IContentType contentType = Platform.getContentTypeManager().getContentType(fContentTypeId);
for (int i = 0; i < elements.length; i++) {
String[] targets = StringUtils.unpack(elements[i].getAttribute(TARGET_ATTR));
for (int j = 0; j < targets.length; j++) {
IContentType targetContentType = Platform.getContentTypeManager().getContentType(targets[j]);
/* Apply semantic highlighting to kinds of targetContentType */
if (contentType.isKindOf(targetContentType)) {
try {
highlighting = (ISemanticHighlighting) elements[i].createExecutableExtension(CLASS_ATTR);
styleKey = elements[i].getAttribute(STYLE_KEY_ATTR);
id = elements[i].getAttribute(ID_ATTR);
after = elements[i].getAttribute(AFTER_ATTR);
} catch (CoreException e) {
Logger.logException(e);
}
if (highlighting != null) {
// The highlighting was not inserted through priority; insert at the beginning of the list
semantics.add(new SemanticContent(targetContentType, highlighting, styleKey, id, after));
}
break;
}
}
}
/* Sort the semantics, so that styles will be applied from general to specific */
Collections.sort(semantics);
fHighlightings = new ISemanticHighlighting[semantics.size()];
fHighlightingStyles = new HighlightingStyle[semantics.size()];
fHighlightingStyleStringKeys = new String[semantics.size()];
for (int i = 0; i < semantics.size(); i++) {
fHighlightings[i] = ((SemanticContent) semantics.get(i)).getHighlighting();
styleKey = ((SemanticContent) semantics.get(i)).getStyleKey();
fHighlightingStyles[i] = createHighlightingStyle(((SemanticContent) semantics.get(i)).getHighlighting(), styleKey);
fHighlightingStyleStringKeys[i] = styleKey;
}
}
Aggregations