use of org.eclipse.ui.texteditor.AnnotationPreference in project eclipse.platform.text by eclipse.
the class TextSourceViewerConfiguration method isShowInOverviewRuler.
/*
* @see DefaultAnnotationHover#isIncluded(Annotation)
* @since 3.2
*/
protected boolean isShowInOverviewRuler(Annotation annotation) {
AnnotationPreference preference = getAnnotationPreference(annotation);
if (preference == null)
return true;
String key = preference.getOverviewRulerPreferenceKey();
if (key == null || !fPreferenceStore.getBoolean(key))
return false;
return true;
}
use of org.eclipse.ui.texteditor.AnnotationPreference in project eclipse.platform.text by eclipse.
the class TextSourceViewerConfiguration method isShownInText.
/*
* @see DefaultTextHover#isIncluded(Annotation)
* @since 3.2
*/
protected boolean isShownInText(Annotation annotation) {
AnnotationPreference preference = getAnnotationPreference(annotation);
if (preference == null)
return false;
String key = preference.getTextPreferenceKey();
if (key != null) {
if (!fPreferenceStore.getBoolean(key))
return false;
} else {
key = preference.getHighlightPreferenceKey();
if (key == null || !fPreferenceStore.getBoolean(key))
return false;
}
return true;
}
use of org.eclipse.ui.texteditor.AnnotationPreference in project eclipse.platform.text by eclipse.
the class AnnotationsConfigurationBlock method createAnnotationTypeListModel.
private ListItem[] createAnnotationTypeListModel(MarkerAnnotationPreferences preferences) {
ArrayList<ListItem> listModelItems = new ArrayList<>();
Iterator<AnnotationPreference> e = preferences.getAnnotationPreferences().iterator();
while (e.hasNext()) {
AnnotationPreference info = e.next();
if (info.isIncludeOnPreferencePage()) {
String label = info.getPreferenceLabel();
if (containsMoreThanOne(preferences.getAnnotationPreferences().iterator(), label))
// $NON-NLS-1$//$NON-NLS-2$
label += " (" + info.getAnnotationType() + ")";
Image image = getImage(info);
listModelItems.add(new ListItem(label, image, info.getColorPreferenceKey(), info.getTextPreferenceKey(), info.getOverviewRulerPreferenceKey(), info.getHighlightPreferenceKey(), info.getVerticalRulerPreferenceKey(), info.getTextStylePreferenceKey(), info.getIsGoToNextNavigationTargetKey()));
}
}
Comparator<ListItem> comparator = new Comparator<ListItem>() {
@Override
public int compare(ListItem o1, ListItem o2) {
String label1 = o1.label;
String label2 = o2.label;
return Collator.getInstance().compare(label1, label2);
}
};
Collections.sort(listModelItems, comparator);
ListItem[] items = new ListItem[listModelItems.size()];
listModelItems.toArray(items);
return items;
}
use of org.eclipse.ui.texteditor.AnnotationPreference in project eclipse.platform.text by eclipse.
the class AnnotationsConfigurationBlock method getImage.
/**
* Returns the image for the given annotation and the given annotation preferences or
* <code>null</code> if there is no such image.
*
* @param preference the annotation preference
* @return the image or <code>null</code>
* @since 3.1
*/
private Image getImage(AnnotationPreference preference) {
ImageRegistry registry = EditorsPlugin.getDefault().getImageRegistry();
String annotationType = (String) preference.getAnnotationType();
if (annotationType == null)
return null;
// $NON-NLS-1$
String customImage = annotationType + "__AnnotationsConfigurationBlock_Image";
Image image;
image = registry.get(customImage);
if (image != null)
return image;
image = registry.get(annotationType);
if (image == null) {
AnnotationPreference delegatingPreference = EditorsPlugin.getDefault().getAnnotationPreferenceLookup().getAnnotationPreference(annotationType);
ImageDescriptor descriptor = delegatingPreference.getImageDescriptor();
if (descriptor != null) {
registry.put(annotationType, descriptor);
image = registry.get(annotationType);
} else {
String symbolicImageName = preference.getSymbolicImageName();
if (symbolicImageName != null) {
String key = DefaultMarkerAnnotationAccess.getSharedImageName(symbolicImageName);
if (key != null) {
ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages();
image = sharedImages.getImage(key);
}
}
}
}
if (image == null)
return null;
// create custom image
// square images
final int SIZE = 16;
ImageData data = image.getImageData();
Image copy;
if (data.height > SIZE || data.width > SIZE) {
// scale down to icon size
copy = new Image(Display.getCurrent(), data.scaledTo(SIZE, SIZE));
} else if (data.height == SIZE && data.width == SIZE) {
// nothing to scale, return the image
return image;
} else {
// don't scale up, but rather copy into the middle and mark everything else transparent
ImageData mask = data.getTransparencyMask();
ImageData resized = new ImageData(SIZE, SIZE, data.depth, data.palette);
ImageData resizedMask = new ImageData(SIZE, SIZE, mask.depth, mask.palette);
int xo = Math.max(0, (SIZE - data.width) / 2);
int yo = Math.max(0, (SIZE - data.height) / 2);
for (int y = 0; y < SIZE; y++) {
for (int x = 0; x < SIZE; x++) {
if (y >= yo && x >= xo && y < yo + data.height && x < xo + data.width) {
resized.setPixel(x, y, data.getPixel(x - xo, y - yo));
resizedMask.setPixel(x, y, mask.getPixel(x - xo, y - yo));
}
}
}
copy = new Image(Display.getCurrent(), resized, resizedMask);
}
fImageKeys.add(customImage);
registry.put(customImage, copy);
return copy;
}
use of org.eclipse.ui.texteditor.AnnotationPreference in project eclipse.platform.text by eclipse.
the class QuickDiffConfigurationBlock method createOverlayStoreKeys.
private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys(MarkerAnnotationPreferences preferences) {
ArrayList<OverlayKey> overlayKeys = new ArrayList<>();
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_DEFAULT_PROVIDER));
Iterator<AnnotationPreference> e = preferences.getAnnotationPreferences().iterator();
while (e.hasNext()) {
AnnotationPreference info = e.next();
if (// $NON-NLS-1$
info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffChange") || // $NON-NLS-1$
(info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffAddition")) || // $NON-NLS-1$
(info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffDeletion"))) {
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getColorPreferenceKey()));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getOverviewRulerPreferenceKey()));
}
}
OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
overlayKeys.toArray(keys);
return keys;
}
Aggregations