topControl.setLayout(GridLayoutFactory.fillDefaults().spacing(0, 5).create());
}
@Override
protected void createContents(final Composite topControl) {
PixelConverter pc = new PixelConverter(topControl);
Link openPrefsLink = createOpenPreferencesDialogLink(topControl,
PreferencesMessages.DLTKEditorColoringConfigurationBlock_link);
openPrefsLink.setLayoutData(
gdFillDefaults().hint(pc.convertWidthInCharsToPixels(50), SWT.DEFAULT).create());
createHorizontalSpacer(topControl, 1, pc);
SWTFactoryUtil.createLabel(topControl, SWT.LEFT,
PreferencesMessages.DLTKEditorPreferencePage_coloring_element,
gdFillDefaults().create());
Composite editorComposite = createComposite(topControl);
editorComposite.setLayoutData(
gdFillDefaults().grab(true, false).create());
editorComposite.setLayout(GridLayoutFactory.swtDefaults().numColumns(2).margins(0, 0).create());
treeViewer = new TreeViewerExt(editorComposite, SWT.SINGLE | SWT.BORDER);
treeViewer.setContentProvider(new ElementContentProvider2());
treeViewer.setLabelProvider(new LabeledTreeElementLabelProvider());
treeViewer.getTree().setLayoutData(
gdFillDefaults().hint(pc.convertWidthInCharsToPixels(40), pc.convertHeightInCharsToPixels(10)).create());
treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
handleAppearanceColorListSelectionChanged();
}
});
treeViewer.setInput(coloringOptionsList);
treeViewer.setExpandedElements(getTreeElements());
Composite itemEditorComposite = new Composite(editorComposite, SWT.NONE);
itemEditorComposite.setLayoutData(
gdFillDefaults().create());
itemEditorComposite.setLayout(GridLayoutFactory.swtDefaults().extendedMargins(5, 20, 5, 5).create());
enableField = new CheckBoxField(PreferencesMessages.DLTKEditorPreferencePage_enable);
enableField.createComponent(itemEditorComposite, gdFillDefaults().create());
colorField = new ColorField(PreferencesMessages.DLTKEditorPreferencePage_color);
colorField.createComponent(itemEditorComposite, gdFillDefaults().indent(20, 0).create());
boldCheckboxField = new CheckBoxField(PreferencesMessages.DLTKEditorPreferencePage_bold);
boldCheckboxField.createComponent(itemEditorComposite, gdFillDefaults().indent(20, 0).create());
italicCheckboxField = new CheckBoxField(PreferencesMessages.DLTKEditorPreferencePage_italic);
italicCheckboxField.createComponent(itemEditorComposite, gdFillDefaults().indent(20, 0).create());
striketroughCheckboxField = new CheckBoxField(PreferencesMessages.DLTKEditorPreferencePage_strikethrough);
striketroughCheckboxField.createComponent(itemEditorComposite, gdFillDefaults().indent(20, 0).create());
underlineCheckboxField = new CheckBoxField(PreferencesMessages.DLTKEditorPreferencePage_underline);
underlineCheckboxField.createComponent(itemEditorComposite, gdFillDefaults().indent(20, 0).create());
enableField.addValueChangedListener(new IFieldValueListener() {
@Override
public void fieldValueChanged() {
SourceColoringElement item = getSelectedColoringItem();
boolean enabled = enableField.getBooleanFieldValue();
getOverlayPrefStore().setValue(item.getEnableKey(), enabled);
setColoringEditorControlsEnabled(enabled);
}
});
colorField.addValueChangedListener(new IFieldValueListener() {
@Override
public void fieldValueChanged() {
SourceColoringElement item = getSelectedColoringItem();
PreferenceConverter.setValue(getOverlayPrefStore(), item.getColorKey(), colorField.getFieldValue());
}
});
boldCheckboxField.addValueChangedListener(new IFieldValueListener() {
@Override
public void fieldValueChanged() {
SourceColoringElement item = getSelectedColoringItem();
getOverlayPrefStore().setValue(item.getBoldKey(), boldCheckboxField.getBooleanFieldValue());
}
});
italicCheckboxField.addValueChangedListener(new IFieldValueListener() {
@Override
public void fieldValueChanged() {
SourceColoringElement item = getSelectedColoringItem();
getOverlayPrefStore().setValue(item.getItalicKey(), italicCheckboxField.getBooleanFieldValue());
}
});
striketroughCheckboxField.addValueChangedListener(new IFieldValueListener() {
@Override
public void fieldValueChanged() {
SourceColoringElement item = getSelectedColoringItem();
getOverlayPrefStore().setValue(item.getStrikethroughKey(),
striketroughCheckboxField.getBooleanFieldValue());
}
});
underlineCheckboxField.addValueChangedListener(new IFieldValueListener() {
@Override
public void fieldValueChanged() {
SourceColoringElement item = getSelectedColoringItem();
getOverlayPrefStore().setValue(item.getUnderlineKey(), underlineCheckboxField.getBooleanFieldValue());
}
});
SWTFactoryUtil.createLabel(topControl, SWT.LEFT,
PreferencesMessages.DLTKEditorPreferencePage_preview,
gdFillDefaults().create());
Control previewViewerControl = createPreviewViewer(topControl);
previewViewerControl.setLayoutData(
gdFillDefaults().hint(pc.convertWidthInCharsToPixels(50), pc.convertHeightInCharsToPixels(15)).
grab(true, true).
create());
}