.getSelection()).getFirstElement();
String namedStyle = o.toString();
if (SemanticHighlightingManager.getInstance()
.getSemanticHighlightings().containsKey(namedStyle)) {
AbstractSemanticHighlighting semanticHighlighting = SemanticHighlightingManager
.getInstance().getSemanticHighlightings()
.get(namedStyle);
String oldValue = getOverlayStore().getString(
semanticHighlighting.getColorPreferenceKey());
String newValue = ColorHelper
.toRGBString(fForegroundColorEditor
.getColorValue());
if (!newValue.equals(oldValue)) {
getOverlayStore().setValue(
semanticHighlighting
.getColorPreferenceKey(), newValue);
applyStyles();
fText.redraw();
}
return;
}
String prefString = getOverlayStore().getString(namedStyle);
String[] stylePrefs = ColorHelper
.unpackStylePreferences(prefString);
if (stylePrefs != null) {
String oldValue = stylePrefs[0];
// open color dialog to get new color
String newValue = ColorHelper
.toRGBString(fForegroundColorEditor
.getColorValue());
if (!newValue.equals(oldValue)) {
stylePrefs[0] = newValue;
String newPrefString = ColorHelper
.packStylePreferences(stylePrefs);
getOverlayStore().setValue(namedStyle,
newPrefString);
applyStyles();
fText.redraw();
}
}
}
}
});
fBackgroundColorEditor.addListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(ColorSelector.PROP_COLORCHANGE)) {
Object o = ((IStructuredSelection) fStylesViewer
.getSelection()).getFirstElement();
String namedStyle = o.toString();
if (SemanticHighlightingManager.getInstance()
.getSemanticHighlightings().containsKey(namedStyle)) {
AbstractSemanticHighlighting semanticHighlighting = SemanticHighlightingManager
.getInstance().getSemanticHighlightings()
.get(namedStyle);
String oldValue = getOverlayStore().getString(
semanticHighlighting
.getBackgroundColorPreferenceKey());
String newValue = ColorHelper
.toRGBString(fBackgroundColorEditor
.getColorValue());
if (!newValue.equals(oldValue)) {
getOverlayStore().setValue(
semanticHighlighting
.getBackgroundColorPreferenceKey(),
newValue);
applyStyles();
fText.redraw();
}
return;
}
String prefString = getOverlayStore().getString(namedStyle);
String[] stylePrefs = ColorHelper
.unpackStylePreferences(prefString);
if (stylePrefs != null) {
String oldValue = stylePrefs[1];
// open color dialog to get new color
String newValue = ColorHelper
.toRGBString(fBackgroundColorEditor
.getColorValue());
if (!newValue.equals(oldValue)) {
stylePrefs[1] = newValue;
String newPrefString = ColorHelper
.packStylePreferences(stylePrefs);
getOverlayStore().setValue(namedStyle,
newPrefString);
applyStyles();
fText.redraw();
activate(namedStyle);
}
}
}
}
});
fBold.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
// get current (newly old) style
Object o = ((IStructuredSelection) fStylesViewer.getSelection())
.getFirstElement();
String namedStyle = o.toString();
if (SemanticHighlightingManager.getInstance()
.getSemanticHighlightings().containsKey(namedStyle)) {
AbstractSemanticHighlighting semanticHighlighting = SemanticHighlightingManager
.getInstance().getSemanticHighlightings()
.get(namedStyle);
String oldValue = getOverlayStore().getString(
semanticHighlighting.getBoldPreferenceKey());
String newValue = String.valueOf(fBold.getSelection());
if (!newValue.equals(oldValue)) {
getOverlayStore().setValue(
semanticHighlighting.getBoldPreferenceKey(),
newValue);
applyStyles();
fText.redraw();
}
return;
}
String prefString = getOverlayStore().getString(namedStyle);
String[] stylePrefs = ColorHelper
.unpackStylePreferences(prefString);
if (stylePrefs != null) {
String oldValue = stylePrefs[2];
String newValue = String.valueOf(fBold.getSelection());
if (!newValue.equals(oldValue)) {
stylePrefs[2] = newValue;
String newPrefString = ColorHelper
.packStylePreferences(stylePrefs);
getOverlayStore().setValue(namedStyle, newPrefString);
applyStyles();
fText.redraw();
}
}
}
});
fItalic.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
// get current (newly old) style
Object o = ((IStructuredSelection) fStylesViewer.getSelection())
.getFirstElement();
String namedStyle = o.toString();
if (SemanticHighlightingManager.getInstance()
.getSemanticHighlightings().containsKey(namedStyle)) {
AbstractSemanticHighlighting semanticHighlightingType = SemanticHighlightingManager
.getInstance().getSemanticHighlightings()
.get(namedStyle);
String oldValue = getOverlayStore().getString(
semanticHighlightingType.getItalicPreferenceKey());
String newValue = String.valueOf(fItalic.getSelection());
if (!newValue.equals(oldValue)) {
getOverlayStore().setValue(
semanticHighlightingType
.getItalicPreferenceKey(), newValue);
applyStyles();
fText.redraw();
}
return;
}
String prefString = getOverlayStore().getString(namedStyle);
String[] stylePrefs = ColorHelper
.unpackStylePreferences(prefString);
if (stylePrefs != null) {
String oldValue = stylePrefs[3];
String newValue = String.valueOf(fItalic.getSelection());
if (!newValue.equals(oldValue)) {
stylePrefs[3] = newValue;
String newPrefString = ColorHelper
.packStylePreferences(stylePrefs);
getOverlayStore().setValue(namedStyle, newPrefString);
applyStyles();
fText.redraw();
}
}
}
});
fStrike.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
// get current (newly old) style
Object o = ((IStructuredSelection) fStylesViewer.getSelection())
.getFirstElement();
String namedStyle = o.toString();
if (SemanticHighlightingManager.getInstance()
.getSemanticHighlightings().containsKey(namedStyle)) {
AbstractSemanticHighlighting semanticHighlighting = SemanticHighlightingManager
.getInstance().getSemanticHighlightings()
.get(namedStyle);
String oldValue = getOverlayStore().getString(
semanticHighlighting
.getStrikethroughPreferenceKey());
String newValue = String.valueOf(fStrike.getSelection());
if (!newValue.equals(oldValue)) {
getOverlayStore().setValue(
semanticHighlighting
.getStrikethroughPreferenceKey(),
newValue);
applyStyles();
fText.redraw();
}
return;
}
String prefString = getOverlayStore().getString(namedStyle);
String[] stylePrefs = ColorHelper
.unpackStylePreferences(prefString);
if (stylePrefs != null) {
String oldValue = stylePrefs[4];
String newValue = String.valueOf(fStrike.getSelection());
if (!newValue.equals(oldValue)) {
stylePrefs[4] = newValue;
String newPrefString = ColorHelper
.packStylePreferences(stylePrefs);
getOverlayStore().setValue(namedStyle, newPrefString);
applyStyles();
fText.redraw();
}
}
}
});
fUnderline.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
// get current (newly old) style
Object o = ((IStructuredSelection) fStylesViewer.getSelection())
.getFirstElement();
String namedStyle = o.toString();
if (SemanticHighlightingManager.getInstance()
.getSemanticHighlightings().containsKey(namedStyle)) {
AbstractSemanticHighlighting semanticHighlighting = SemanticHighlightingManager
.getInstance().getSemanticHighlightings()
.get(namedStyle);
String oldValue = getOverlayStore().getString(
semanticHighlighting.getUnderlinePreferenceKey());
String newValue = String.valueOf(fUnderline.getSelection());
if (!newValue.equals(oldValue)) {
getOverlayStore().setValue(
semanticHighlighting
.getUnderlinePreferenceKey(), newValue);
applyStyles();
fText.redraw();
}
return;
}
String prefString = getOverlayStore().getString(namedStyle);
String[] stylePrefs = ColorHelper
.unpackStylePreferences(prefString);
if (stylePrefs != null) {
String oldValue = stylePrefs[5];
String newValue = String.valueOf(fUnderline.getSelection());
if (!newValue.equals(oldValue)) {
stylePrefs[5] = newValue;
String newPrefString = ColorHelper
.packStylePreferences(stylePrefs);
getOverlayStore().setValue(namedStyle, newPrefString);
applyStyles();
fText.redraw();
}
}
}
});
fClearStyle.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (fStylesViewer.getSelection().isEmpty())
return;
String namedStyle = ((IStructuredSelection) fStylesViewer
.getSelection()).getFirstElement().toString();
if (SemanticHighlightingManager.getInstance()
.getSemanticHighlightings().containsKey(namedStyle)) {
AbstractSemanticHighlighting semanticHighlighting = SemanticHighlightingManager
.getInstance().getSemanticHighlightings()
.get(namedStyle);
getOverlayStore().setToDefault(
semanticHighlighting.getBoldPreferenceKey());
getOverlayStore().setToDefault(
semanticHighlighting.getColorPreferenceKey());
getOverlayStore().setToDefault(
semanticHighlighting
.getBackgroundColorPreferenceKey());
getOverlayStore().setToDefault(
semanticHighlighting.getEnabledPreferenceKey());
getOverlayStore().setToDefault(
semanticHighlighting.getItalicPreferenceKey());
getOverlayStore().setToDefault(
semanticHighlighting
.getStrikethroughPreferenceKey());
getOverlayStore().setToDefault(
semanticHighlighting.getUnderlinePreferenceKey());
boolean enablement = getOverlayStore().getDefaultBoolean(
semanticHighlighting.getEnabledPreferenceKey());
switchEnablement(enablement);
} else {
getOverlayStore().setToDefault(namedStyle);
}
applyStyles();
fText.redraw();
activate(namedStyle);
}
});
fEnabler.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
// get current (newly old) style
Object o = ((IStructuredSelection) fStylesViewer.getSelection())
.getFirstElement();
String namedStyle = o.toString();
Map<String, AbstractSemanticHighlighting> highlightingMap = SemanticHighlightingManager
.getInstance().getSemanticHighlightings();
if (highlightingMap.containsKey(namedStyle)) {
AbstractSemanticHighlighting semantic = highlightingMap
.get(namedStyle);
boolean enablement = fEnabler.getSelection();
semantic.getStyle().setEnabledByDefault(enablement);
switchEnablement(enablement);
getOverlayStore().setValue(
semantic.getEnabledPreferenceKey(), enablement);
applyStyles();
fText.redraw();
} else if (getStylePreferenceKeys().contains(namedStyle)) {
boolean enablement = fEnabler.getSelection();