use of org.eclipse.jface.preference.ColorSelector in project webtools.sourceediting by eclipse.
the class CSSSyntaxColoringPage method createContents.
protected Control createContents(final Composite parent) {
initializeDialogUnits(parent);
fDefaultForeground = parent.getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND);
fDefaultBackground = parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
Composite pageComponent = createComposite(parent, 2);
PlatformUI.getWorkbench().getHelpSystem().setHelp(pageComponent, IHelpContextIds.CSS_PREFWEBX_STYLES_HELPID);
Link link = new Link(pageComponent, SWT.WRAP);
link.setText(SSEUIMessages.SyntaxColoring_Link);
link.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
PreferencesUtil.createPreferenceDialogOn(parent.getShell(), e.text, null, null);
}
});
GridData linkData = new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1);
// only expand further if anyone else requires it
linkData.widthHint = 150;
link.setLayoutData(linkData);
new Label(pageComponent, SWT.NONE).setLayoutData(new GridData());
new Label(pageComponent, SWT.NONE).setLayoutData(new GridData());
SashForm editor = new SashForm(pageComponent, SWT.VERTICAL);
GridData gridData2 = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData2.horizontalSpan = 2;
editor.setLayoutData(gridData2);
SashForm top = new SashForm(editor, SWT.HORIZONTAL);
Composite styleEditor = createComposite(top, 1);
((GridLayout) styleEditor.getLayout()).marginRight = 5;
((GridLayout) styleEditor.getLayout()).marginLeft = 0;
createLabel(styleEditor, CSSUIMessages.SyntaxColoringPage_0);
fStylesViewer = createStylesViewer(styleEditor);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData.horizontalIndent = 0;
Iterator iterator = fStyleToDescriptionMap.values().iterator();
while (iterator.hasNext()) {
gridData.widthHint = Math.max(gridData.widthHint, convertWidthInCharsToPixels(iterator.next().toString().length()));
}
gridData.heightHint = convertHeightInCharsToPixels(5);
fStylesViewer.getControl().setLayoutData(gridData);
Composite editingComposite = createComposite(top, 1);
((GridLayout) styleEditor.getLayout()).marginLeft = 5;
createLabel(editingComposite, "");
Button enabler = createCheckbox(editingComposite, CSSUIMessages.SyntaxColoringPage_2);
enabler.setEnabled(false);
enabler.setSelection(true);
Composite editControls = createComposite(editingComposite, 2);
((GridLayout) editControls.getLayout()).marginLeft = 20;
fForegroundLabel = createLabel(editControls, SSEUIMessages.Foreground_UI_);
((GridData) fForegroundLabel.getLayoutData()).verticalAlignment = SWT.CENTER;
fForegroundLabel.setEnabled(false);
fForegroundColorEditor = new ColorSelector(editControls);
Button fForegroundColor = fForegroundColorEditor.getButton();
GridData gd = new GridData(SWT.BEGINNING, SWT.FILL, false, false);
fForegroundColor.setLayoutData(gd);
fForegroundColorEditor.setEnabled(false);
fForegroundColorEditor.getButton().getAccessible().addAccessibleListener(new AccessibleAdapter() {
public void getName(final AccessibleEvent e) {
e.result = SSEUIMessages.Foreground_Color_Selector_Button;
}
});
fBackgroundLabel = createLabel(editControls, SSEUIMessages.Background_UI_);
((GridData) fBackgroundLabel.getLayoutData()).verticalAlignment = SWT.CENTER;
fBackgroundLabel.setEnabled(false);
fBackgroundColorEditor = new ColorSelector(editControls);
Button fBackgroundColor = fBackgroundColorEditor.getButton();
gd = new GridData(SWT.BEGINNING, SWT.FILL, false, false);
fBackgroundColor.setLayoutData(gd);
fBackgroundColorEditor.setEnabled(false);
fBackgroundColorEditor.getButton().getAccessible().addAccessibleListener(new AccessibleAdapter() {
public void getName(final AccessibleEvent e) {
e.result = SSEUIMessages.Background_Color_Selector_Button;
}
});
fBold = createCheckbox(editControls, CSSUIMessages.SyntaxColoringPage_3);
fBold.setEnabled(false);
((GridData) fBold.getLayoutData()).horizontalSpan = 2;
fItalic = createCheckbox(editControls, CSSUIMessages.SyntaxColoringPage_4);
fItalic.setEnabled(false);
((GridData) fItalic.getLayoutData()).horizontalSpan = 2;
fStrike = createCheckbox(editControls, CSSUIMessages.SyntaxColoringPage_5);
fStrike.setEnabled(false);
((GridData) fStrike.getLayoutData()).horizontalSpan = 2;
fUnderline = createCheckbox(editControls, CSSUIMessages.SyntaxColoringPage_6);
fUnderline.setEnabled(false);
((GridData) fUnderline.getLayoutData()).horizontalSpan = 2;
fClearStyle = new Button(editingComposite, SWT.PUSH);
// $NON-NLS-1$ = "Restore Default"
fClearStyle.setText(SSEUIMessages.Restore_Default_UI_);
fClearStyle.setLayoutData(new GridData(SWT.BEGINNING));
((GridData) fClearStyle.getLayoutData()).horizontalIndent = 20;
fClearStyle.setEnabled(false);
Composite sampleArea = createComposite(editor, 1);
((GridLayout) sampleArea.getLayout()).marginLeft = 5;
((GridLayout) sampleArea.getLayout()).marginTop = 5;
// $NON-NLS-1$ = "&Sample text:"
createLabel(sampleArea, SSEUIMessages.Sample_text__UI_);
fPreviewViewer = new SourceViewer(sampleArea, null, SWT.BORDER | SWT.LEFT_TO_RIGHT | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY);
fText = fPreviewViewer.getTextWidget();
GridData gridData3 = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData3.widthHint = convertWidthInCharsToPixels(20);
gridData3.heightHint = convertHeightInCharsToPixels(5);
gridData3.horizontalSpan = 2;
fText.setLayoutData(gridData3);
fText.setEditable(false);
fText.setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont"));
fText.addKeyListener(getTextKeyListener());
fText.addSelectionListener(getTextSelectionListener());
fText.addMouseListener(getTextMouseListener());
fText.addTraverseListener(getTraverseListener());
setAccessible(fText, SSEUIMessages.Sample_text__UI_);
fDocument = StructuredModelManager.getModelManager().createStructuredDocumentFor(ContentTypeIdForCSS.ContentTypeID_CSS);
fDocument.set(getExampleText());
initializeSourcePreviewColors(fPreviewViewer);
fPreviewViewer.setDocument(fDocument);
top.setWeights(new int[] { 1, 1 });
editor.setWeights(new int[] { 1, 1 });
PlatformUI.getWorkbench().getHelpSystem().setHelp(pageComponent, IHelpContextIds.CSS_PREFWEBX_STYLES_HELPID);
fStylesViewer.setInput(getStylePreferenceKeys());
applyStyles();
fStylesViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
if (!event.getSelection().isEmpty()) {
Object o = ((IStructuredSelection) event.getSelection()).getFirstElement();
String namedStyle = o.toString();
activate(namedStyle);
if (namedStyle == null)
return;
}
}
});
fForegroundColorEditor.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();
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();
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() {
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
// get current (newly old) style
Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
String namedStyle = o.toString();
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() {
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
// get current (newly old) style
Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
String namedStyle = o.toString();
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() {
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
// get current (newly old) style
Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
String namedStyle = o.toString();
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() {
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
// get current (newly old) style
Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
String namedStyle = o.toString();
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() {
public void widgetSelected(SelectionEvent e) {
if (fStylesViewer.getSelection().isEmpty())
return;
String namedStyle = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement().toString();
getOverlayStore().setToDefault(namedStyle);
applyStyles();
fText.redraw();
activate(namedStyle);
}
});
return pageComponent;
}
use of org.eclipse.jface.preference.ColorSelector in project webtools.sourceediting by eclipse.
the class JSPSyntaxColoringPage method createContents.
protected Control createContents(final Composite parent) {
initializeDialogUnits(parent);
fDefaultForeground = parent.getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND);
fDefaultBackground = parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
Composite pageComponent = createComposite(parent, 2);
PlatformUI.getWorkbench().getHelpSystem().setHelp(pageComponent, IHelpContextIds.JSP_PREFWEBX_STYLES_HELPID);
Link link = new Link(pageComponent, SWT.WRAP);
link.setText(SSEUIMessages.SyntaxColoring_Link);
link.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
PreferencesUtil.createPreferenceDialogOn(parent.getShell(), e.text, null, null);
}
});
GridData linkData = new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1);
// only expand further if anyone else requires it
linkData.widthHint = 150;
link.setLayoutData(linkData);
new Label(pageComponent, SWT.NONE).setLayoutData(new GridData());
new Label(pageComponent, SWT.NONE).setLayoutData(new GridData());
SashForm editor = new SashForm(pageComponent, SWT.VERTICAL);
GridData gridData2 = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData2.horizontalSpan = 2;
editor.setLayoutData(gridData2);
SashForm top = new SashForm(editor, SWT.HORIZONTAL);
Composite styleEditor = createComposite(top, 1);
((GridLayout) styleEditor.getLayout()).marginRight = 5;
((GridLayout) styleEditor.getLayout()).marginLeft = 0;
createLabel(styleEditor, JSPUIMessages.SyntaxColoringPage_0);
fStylesViewer = createStylesViewer(styleEditor);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData.horizontalIndent = 0;
Iterator iterator = fStyleToDescriptionMap.values().iterator();
while (iterator.hasNext()) {
gridData.widthHint = Math.max(gridData.widthHint, convertWidthInCharsToPixels(iterator.next().toString().length()));
}
gridData.heightHint = convertHeightInCharsToPixels(5);
fStylesViewer.getControl().setLayoutData(gridData);
Composite editingComposite = createComposite(top, 1);
((GridLayout) styleEditor.getLayout()).marginLeft = 5;
// $NON-NLS-1$
createLabel(editingComposite, "");
Button enabler = createCheckbox(editingComposite, JSPUIMessages.SyntaxColoringPage_2);
enabler.setEnabled(false);
enabler.setSelection(true);
Composite editControls = createComposite(editingComposite, 2);
((GridLayout) editControls.getLayout()).marginLeft = 20;
fForegroundLabel = createLabel(editControls, SSEUIMessages.Foreground_UI_);
((GridData) fForegroundLabel.getLayoutData()).verticalAlignment = SWT.CENTER;
fForegroundLabel.setEnabled(false);
fForegroundColorEditor = new ColorSelector(editControls);
Button fForegroundColor = fForegroundColorEditor.getButton();
GridData gd = new GridData(SWT.BEGINNING, SWT.FILL, false, false);
fForegroundColor.setLayoutData(gd);
fForegroundColorEditor.setEnabled(false);
fForegroundColorEditor.getButton().getAccessible().addAccessibleListener(new AccessibleAdapter() {
public void getName(final AccessibleEvent e) {
e.result = SSEUIMessages.Foreground_Color_Selector_Button;
}
});
fBackgroundLabel = createLabel(editControls, SSEUIMessages.Background_UI_);
((GridData) fBackgroundLabel.getLayoutData()).verticalAlignment = SWT.CENTER;
fBackgroundLabel.setEnabled(false);
fBackgroundColorEditor = new ColorSelector(editControls);
Button fBackgroundColor = fBackgroundColorEditor.getButton();
gd = new GridData(SWT.BEGINNING, SWT.FILL, false, false);
fBackgroundColor.setLayoutData(gd);
fBackgroundColorEditor.setEnabled(false);
fBackgroundColorEditor.getButton().getAccessible().addAccessibleListener(new AccessibleAdapter() {
public void getName(final AccessibleEvent e) {
e.result = SSEUIMessages.Background_Color_Selector_Button;
}
});
fBold = createCheckbox(editControls, JSPUIMessages.SyntaxColoringPage_3);
fBold.setEnabled(false);
((GridData) fBold.getLayoutData()).horizontalSpan = 2;
fItalic = createCheckbox(editControls, JSPUIMessages.SyntaxColoringPage_4);
fItalic.setEnabled(false);
((GridData) fItalic.getLayoutData()).horizontalSpan = 2;
fStrike = createCheckbox(editControls, JSPUIMessages.SyntaxColoringPage_5);
fStrike.setEnabled(false);
((GridData) fStrike.getLayoutData()).horizontalSpan = 2;
fUnderline = createCheckbox(editControls, JSPUIMessages.SyntaxColoringPage_6);
fUnderline.setEnabled(false);
((GridData) fUnderline.getLayoutData()).horizontalSpan = 2;
fClearStyle = new Button(editingComposite, SWT.PUSH);
// $NON-NLS-1$ = "Restore Default"
fClearStyle.setText(SSEUIMessages.Restore_Default_UI_);
fClearStyle.setLayoutData(new GridData(SWT.BEGINNING));
((GridData) fClearStyle.getLayoutData()).horizontalIndent = 20;
fClearStyle.setEnabled(false);
Composite sampleArea = createComposite(editor, 1);
((GridLayout) sampleArea.getLayout()).marginLeft = 5;
((GridLayout) sampleArea.getLayout()).marginTop = 5;
// $NON-NLS-1$ = "&Sample text:"
createLabel(sampleArea, SSEUIMessages.Sample_text__UI_);
fPreviewViewer = new SourceViewer(sampleArea, null, SWT.BORDER | SWT.LEFT_TO_RIGHT | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY);
fText = fPreviewViewer.getTextWidget();
GridData gridData3 = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData3.widthHint = convertWidthInCharsToPixels(20);
gridData3.heightHint = convertHeightInCharsToPixels(5);
gridData3.horizontalSpan = 2;
fText.setLayoutData(gridData3);
fText.setEditable(false);
// $NON-NLS-1$
fText.setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont"));
fText.addKeyListener(getTextKeyListener());
fText.addSelectionListener(getTextSelectionListener());
fText.addMouseListener(getTextMouseListener());
fText.addTraverseListener(getTraverseListener());
setAccessible(fText, SSEUIMessages.Sample_text__UI_);
fDocument = StructuredModelManager.getModelManager().createStructuredDocumentFor(ContentTypeIdForJSP.ContentTypeID_JSP);
fDocument.set(getExampleText());
initializeSourcePreviewColors(fPreviewViewer);
fPreviewViewer.setDocument(fDocument);
top.setWeights(new int[] { 1, 1 });
editor.setWeights(new int[] { 1, 1 });
PlatformUI.getWorkbench().getHelpSystem().setHelp(pageComponent, IHelpContextIds.JSP_PREFWEBX_STYLES_HELPID);
fStylesViewer.setInput(getStylePreferenceKeys());
applyStyles();
fStylesViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
if (!event.getSelection().isEmpty()) {
Object o = ((IStructuredSelection) event.getSelection()).getFirstElement();
String namedStyle = o.toString();
activate(namedStyle);
if (namedStyle == null)
return;
}
}
});
fForegroundColorEditor.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();
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();
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() {
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
// get current (newly old) style
Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
String namedStyle = o.toString();
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() {
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
// get current (newly old) style
Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
String namedStyle = o.toString();
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() {
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
// get current (newly old) style
Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
String namedStyle = o.toString();
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() {
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
// get current (newly old) style
Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
String namedStyle = o.toString();
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() {
public void widgetSelected(SelectionEvent e) {
if (fStylesViewer.getSelection().isEmpty())
return;
String namedStyle = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement().toString();
getOverlayStore().setToDefault(namedStyle);
applyStyles();
fText.redraw();
activate(namedStyle);
}
});
return pageComponent;
}
use of org.eclipse.jface.preference.ColorSelector in project webtools.sourceediting by eclipse.
the class StyledTextColorPicker method createControls.
protected void createControls(Composite parent) {
Composite styleRow = createComposite(parent, 3);
// row 1 - content type label, combo box, restore defaults
// $NON-NLS-1$ = "Content type:"
createLabel(styleRow, SSEUIMessages.Content_type__UI_);
// Contexts combo box
fStyleCombo = createCombo(styleRow, new String[0], -1);
// $NON-NLS-1$ = "Restore Default"
fClearStyle = createPushButton(styleRow, SSEUIMessages.Restore_Default_UI_);
Composite styleRow2;
if (showItalic)
styleRow2 = createComposite(parent, 7);
else
styleRow2 = createComposite(parent, 6);
// row 2 - foreground label, button, background label, button, bold,
// italics?
// $NON-NLS-1$ = "Foreground"
fForegroundLabel = createLabel(styleRow2, SSEUIMessages.Foreground_UI_);
fForeground = new ColorSelector(styleRow2);
fForeground.getButton().setLayoutData(new GridData());
setAccessible(fForeground.getButton(), fForegroundLabel.getText());
// defect
fForeground.getButton().getAccessible().addAccessibleControlListener(foregroundAccListener);
// 200764
// -
// ACC:display
// values
// for
// color
// buttons
((GridData) fForeground.getButton().getLayoutData()).minimumWidth = 20;
// $NON-NLS-1$ = "Background"
fBackgroundLabel = createLabel(styleRow2, SSEUIMessages.Background_UI_);
fBackground = new ColorSelector(styleRow2);
fBackground.getButton().setLayoutData(new GridData());
setAccessible(fBackground.getButton(), fBackgroundLabel.getText());
// defect
fBackground.getButton().getAccessible().addAccessibleControlListener(backgroundAccListener);
// 200764
// -
// ACC:display
// values
// for
// color
// buttons
((GridData) fBackground.getButton().getLayoutData()).minimumWidth = 20;
// $NON-NLS-1$
createLabel(styleRow2, "");
fBold = createCheckBox(styleRow2, SSEUIMessages.Bold_UI_);
if (showItalic)
fItalic = createCheckBox(styleRow2, SSEUIMessages.Italics_UI);
// // Defaults checkbox
fForeground.setEnabled(false);
fBackground.setEnabled(false);
fClearStyle.setEnabled(false);
fBold.setEnabled(false);
if (showItalic)
fItalic.setEnabled(false);
fForegroundLabel.setEnabled(false);
fBackgroundLabel.setEnabled(false);
Composite sample = createComposite(parent, 1);
// $NON-NLS-1$ = "&Sample text:"
createLabel(sample, SSEUIMessages.Sample_text__UI_);
// BUG141089 - make sure text is left-aligned
fText = new StyledText(sample, SWT.LEFT_TO_RIGHT | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.READ_ONLY);
GridData data = new GridData(GridData.FILL_BOTH);
fText.setLayoutData(data);
fText.setEditable(false);
fText.setBackground(fDefaultBackground);
fText.setFont(JFaceResources.getTextFont());
fText.addKeyListener(getTextKeyListener());
fText.addSelectionListener(getTextSelectionListener());
fText.addMouseListener(getTextMouseListener());
// defect 220377 -
fText.addTraverseListener(getTraverseListener());
// Provide tab
// traversal for
// fText widget
// $NON-NLS-1$ = "&Sample text:"
setAccessible(fText, SSEUIMessages.Sample_text__UI_);
fForeground.addListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(ColorSelector.PROP_COLORCHANGE)) {
// get current (newly old) style
String namedStyle = getStyleName(fStyleCombo.getItem(fStyleCombo.getSelectionIndex()));
String prefString = getPreferenceStore().getString(namedStyle);
String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
if (stylePrefs != null) {
String oldValue = stylePrefs[0];
// $NON-NLS-1$
String newValue = "null";
Object newValueObject = event.getNewValue();
if (newValueObject instanceof RGB) {
newValue = ColorHelper.toRGBString((RGB) newValueObject);
}
if (!newValue.equals(oldValue)) {
stylePrefs[0] = newValue;
String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
getPreferenceStore().setValue(namedStyle, newPrefString);
refresh();
}
}
}
}
});
fBackground.addListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(ColorSelector.PROP_COLORCHANGE)) {
// get current (newly old) style
String namedStyle = getStyleName(fStyleCombo.getItem(fStyleCombo.getSelectionIndex()));
String prefString = getPreferenceStore().getString(namedStyle);
String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
if (stylePrefs != null) {
String oldValue = stylePrefs[1];
// $NON-NLS-1$
String newValue = "null";
Object newValueObject = event.getNewValue();
if (newValueObject instanceof RGB) {
newValue = ColorHelper.toRGBString((RGB) newValueObject);
}
if (!newValue.equals(oldValue)) {
stylePrefs[1] = newValue;
String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
getPreferenceStore().setValue(namedStyle, newPrefString);
refresh();
}
}
}
}
});
fClearStyle.addSelectionListener(buttonListener);
fBold.addSelectionListener(buttonListener);
if (showItalic)
fItalic.addSelectionListener(buttonListener);
fStyleCombo.addSelectionListener(comboListener);
}
use of org.eclipse.jface.preference.ColorSelector in project webtools.sourceediting by eclipse.
the class XSLSyntaxColoringPage method createContents.
@Override
protected Control createContents(final Composite parent) {
initializeDialogUnits(parent);
defaultForeground = parent.getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND);
defaultBackground = parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
Composite pageComponent = createComposite(parent, 2);
PlatformUI.getWorkbench().getHelpSystem().setHelp(pageComponent, IHelpContextIds.XML_PREFWEBX_STYLES_HELPID);
Link link = new Link(pageComponent, SWT.WRAP);
link.setText(Messages.XSLSyntaxColoringPage);
link.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
PreferencesUtil.createPreferenceDialogOn(parent.getShell(), e.text, null, null);
}
});
GridData linkData = new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1);
// only expand further if anyone else requires
linkData.widthHint = 150;
// it
link.setLayoutData(linkData);
new Label(pageComponent, SWT.NONE).setLayoutData(new GridData());
new Label(pageComponent, SWT.NONE).setLayoutData(new GridData());
SashForm editor = new SashForm(pageComponent, SWT.VERTICAL);
GridData gridData2 = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData2.horizontalSpan = 2;
editor.setLayoutData(gridData2);
SashForm top = new SashForm(editor, SWT.HORIZONTAL);
Composite styleEditor = createComposite(top, 1);
((GridLayout) styleEditor.getLayout()).marginRight = 5;
((GridLayout) styleEditor.getLayout()).marginLeft = 0;
createLabel(styleEditor, XMLUIMessages.SyntaxColoringPage_0);
stylesViewer = createStylesViewer(styleEditor);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData.horizontalIndent = 0;
Iterator iterator = styleToDescriptionMap.values().iterator();
while (iterator.hasNext()) {
gridData.widthHint = Math.max(gridData.widthHint, convertWidthInCharsToPixels(iterator.next().toString().length()));
}
gridData.heightHint = convertHeightInCharsToPixels(5);
stylesViewer.getControl().setLayoutData(gridData);
Composite editingComposite = createComposite(top, 1);
((GridLayout) styleEditor.getLayout()).marginLeft = 5;
// $NON-NLS-1$
createLabel(editingComposite, "");
Button enabler = createCheckbox(editingComposite, XMLUIMessages.SyntaxColoringPage_2);
enabler.setEnabled(false);
enabler.setSelection(true);
Composite editControls = createComposite(editingComposite, 2);
((GridLayout) editControls.getLayout()).marginLeft = 20;
foregroundLabel = createLabel(editControls, SSEUIMessages.Foreground_UI_);
((GridData) foregroundLabel.getLayoutData()).verticalAlignment = SWT.CENTER;
foregroundLabel.setEnabled(false);
foregroundColorEditor = new ColorSelector(editControls);
Button fForegroundColor = foregroundColorEditor.getButton();
GridData gd = new GridData(SWT.BEGINNING, SWT.FILL, false, false);
fForegroundColor.setLayoutData(gd);
foregroundColorEditor.setEnabled(false);
backgroundLabel = createLabel(editControls, SSEUIMessages.Background_UI_);
((GridData) backgroundLabel.getLayoutData()).verticalAlignment = SWT.CENTER;
backgroundLabel.setEnabled(false);
backgroundColorEditor = new ColorSelector(editControls);
Button fBackgroundColor = backgroundColorEditor.getButton();
gd = new GridData(SWT.BEGINNING, SWT.FILL, false, false);
fBackgroundColor.setLayoutData(gd);
backgroundColorEditor.setEnabled(false);
bold = createCheckbox(editControls, XMLUIMessages.SyntaxColoringPage_3);
bold.setEnabled(false);
((GridData) bold.getLayoutData()).horizontalSpan = 2;
italic = createCheckbox(editControls, XMLUIMessages.SyntaxColoringPage_4);
italic.setEnabled(false);
((GridData) italic.getLayoutData()).horizontalSpan = 2;
strike = createCheckbox(editControls, XMLUIMessages.SyntaxColoringPage_5);
strike.setEnabled(false);
((GridData) strike.getLayoutData()).horizontalSpan = 2;
underline = createCheckbox(editControls, XMLUIMessages.SyntaxColoringPage_6);
underline.setEnabled(false);
((GridData) underline.getLayoutData()).horizontalSpan = 2;
clearStyle = new Button(editingComposite, SWT.PUSH);
// = "Restore Default"
clearStyle.setText(SSEUIMessages.Restore_Default_UI_);
clearStyle.setLayoutData(new GridData(SWT.BEGINNING));
((GridData) clearStyle.getLayoutData()).horizontalIndent = 20;
clearStyle.setEnabled(false);
Composite sampleArea = createComposite(editor, 1);
((GridLayout) sampleArea.getLayout()).marginLeft = 5;
((GridLayout) sampleArea.getLayout()).marginTop = 5;
// = "&Sample text:"
createLabel(sampleArea, SSEUIMessages.Sample_text__UI_);
SourceViewer viewer = new SourceViewer(sampleArea, null, SWT.BORDER | SWT.LEFT_TO_RIGHT | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY);
styledText = viewer.getTextWidget();
GridData gridData3 = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData3.widthHint = convertWidthInCharsToPixels(20);
gridData3.heightHint = convertHeightInCharsToPixels(5);
gridData3.horizontalSpan = 2;
styledText.setLayoutData(gridData3);
styledText.setEditable(false);
styledText.setFont(JFaceResources.getFont(// $NON-NLS-1$
"org.eclipse.wst.sse.ui.textfont"));
styledText.addKeyListener(getTextKeyListener());
styledText.addSelectionListener(getTextSelectionListener());
styledText.addMouseListener(getTextMouseListener());
styledText.addTraverseListener(getTraverseListener());
setAccessible(styledText, SSEUIMessages.Sample_text__UI_);
try {
File file = XSLUIPlugin.makeFileFor(XSLSyntaxColoringPage.XSLFILES_DIR, XSLSyntaxColoringPage.SYNTAXCOLORING_XSL);
document = StructuredModelManager.getModelManager().createStructuredDocumentFor(file.getAbsolutePath(), new FileInputStream(file), null);
} catch (Exception ex) {
XSLUIPlugin.log(ex);
}
viewer.setDocument(document);
top.setWeights(new int[] { 1, 1 });
editor.setWeights(new int[] { 1, 1 });
PlatformUI.getWorkbench().getHelpSystem().setHelp(pageComponent, IHelpContextIds.XML_PREFWEBX_STYLES_HELPID);
stylesViewer.setInput(getStylePreferenceKeys());
applyStyles();
stylesViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
if (!event.getSelection().isEmpty()) {
Object o = ((IStructuredSelection) event.getSelection()).getFirstElement();
String namedStyle = o.toString();
activate(namedStyle);
if (namedStyle == null)
return;
}
}
});
foregroundColorEditor.addListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(ColorSelector.PROP_COLORCHANGE)) {
Object o = ((IStructuredSelection) stylesViewer.getSelection()).getFirstElement();
String namedStyle = o.toString();
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(foregroundColorEditor.getColorValue());
if (!newValue.equals(oldValue)) {
stylePrefs[0] = newValue;
String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
getOverlayStore().setValue(namedStyle, newPrefString);
applyStyles();
styledText.redraw();
}
}
}
}
});
backgroundColorEditor.addListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(ColorSelector.PROP_COLORCHANGE)) {
Object o = ((IStructuredSelection) stylesViewer.getSelection()).getFirstElement();
String namedStyle = o.toString();
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(backgroundColorEditor.getColorValue());
if (!newValue.equals(oldValue)) {
stylePrefs[1] = newValue;
String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
getOverlayStore().setValue(namedStyle, newPrefString);
applyStyles();
styledText.redraw();
activate(namedStyle);
}
}
}
}
});
bold.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
// get current (newly old) style
Object o = ((IStructuredSelection) stylesViewer.getSelection()).getFirstElement();
String namedStyle = o.toString();
String prefString = getOverlayStore().getString(namedStyle);
String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
if (stylePrefs != null) {
String oldValue = stylePrefs[2];
String newValue = String.valueOf(bold.getSelection());
if (!newValue.equals(oldValue)) {
stylePrefs[2] = newValue;
String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
getOverlayStore().setValue(namedStyle, newPrefString);
applyStyles();
styledText.redraw();
}
}
}
});
italic.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
// get current (newly old) style
Object o = ((IStructuredSelection) stylesViewer.getSelection()).getFirstElement();
String namedStyle = o.toString();
String prefString = getOverlayStore().getString(namedStyle);
String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
if (stylePrefs != null) {
String oldValue = stylePrefs[3];
String newValue = String.valueOf(italic.getSelection());
if (!newValue.equals(oldValue)) {
stylePrefs[3] = newValue;
String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
getOverlayStore().setValue(namedStyle, newPrefString);
applyStyles();
styledText.redraw();
}
}
}
});
strike.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
// get current (newly old) style
Object o = ((IStructuredSelection) stylesViewer.getSelection()).getFirstElement();
String namedStyle = o.toString();
String prefString = getOverlayStore().getString(namedStyle);
String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
if (stylePrefs != null) {
String oldValue = stylePrefs[4];
String newValue = String.valueOf(strike.getSelection());
if (!newValue.equals(oldValue)) {
stylePrefs[4] = newValue;
String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
getOverlayStore().setValue(namedStyle, newPrefString);
applyStyles();
styledText.redraw();
}
}
}
});
underline.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
// get current (newly old) style
Object o = ((IStructuredSelection) stylesViewer.getSelection()).getFirstElement();
String namedStyle = o.toString();
String prefString = getOverlayStore().getString(namedStyle);
String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
if (stylePrefs != null) {
String oldValue = stylePrefs[5];
String newValue = String.valueOf(underline.getSelection());
if (!newValue.equals(oldValue)) {
stylePrefs[5] = newValue;
String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
getOverlayStore().setValue(namedStyle, newPrefString);
applyStyles();
styledText.redraw();
}
}
}
});
clearStyle.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (stylesViewer.getSelection().isEmpty())
return;
String namedStyle = ((IStructuredSelection) stylesViewer.getSelection()).getFirstElement().toString();
getOverlayStore().setToDefault(namedStyle);
applyStyles();
styledText.redraw();
activate(namedStyle);
}
});
return pageComponent;
}
use of org.eclipse.jface.preference.ColorSelector in project netxms by netxms.
the class ServiceComponents method createContents.
@Override
protected Control createContents(Composite parent) {
config = (ServiceComponentsConfig) getElement().getAdapter(ServiceComponentsConfig.class);
Composite dialogArea = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
dialogArea.setLayout(layout);
objectSelector = new ObjectSelector(dialogArea, SWT.NONE, false);
objectSelector.setLabel("Container");
objectSelector.setClassFilter(ObjectSelectionDialog.createContainerSelectionFilter());
objectSelector.setObjectClass(AbstractObject.class);
objectSelector.setObjectId(config.getObjectId());
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 2;
objectSelector.setLayoutData(gd);
title = new LabeledText(dialogArea, SWT.NONE);
title.setLabel("Title");
title.setText(config.getTitle());
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 2;
title.setLayoutData(gd);
Label label = new Label(dialogArea, SWT.NONE);
label.setText("Zoom level (%)");
gd = new GridData();
gd.horizontalSpan = 2;
label.setLayoutData(gd);
zoomLevelScale = new Scale(dialogArea, SWT.HORIZONTAL);
zoomLevelScale.setMinimum(10);
zoomLevelScale.setMaximum(400);
zoomLevelScale.setSelection(config.getZoomLevel());
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
zoomLevelScale.setLayoutData(gd);
zoomLevelScale.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
zoomLevelSpinner.setSelection(zoomLevelScale.getSelection());
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
zoomLevelSpinner = new Spinner(dialogArea, SWT.BORDER);
zoomLevelSpinner.setMinimum(10);
zoomLevelSpinner.setMaximum(400);
zoomLevelSpinner.setSelection(config.getZoomLevel());
zoomLevelSpinner.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
zoomLevelScale.setSelection(zoomLevelSpinner.getSelection());
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
enableObjectDoubleClick = new Button(dialogArea, SWT.CHECK);
enableObjectDoubleClick.setText("Enable double click action on objects");
enableObjectDoubleClick.setSelection(config.isObjectDoubleClickEnabled());
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 2;
enableObjectDoubleClick.setLayoutData(gd);
gd = new GridData();
gd.horizontalAlignment = SWT.LEFT;
gd.horizontalSpan = 2;
layoutAlgorithm = WidgetHelper.createLabeledCombo(dialogArea, SWT.READ_ONLY, "Layout algorithm", gd);
layoutAlgorithm.add("Spring");
layoutAlgorithm.add("Radial");
layoutAlgorithm.add("Horizontal tree");
layoutAlgorithm.add("Vertical tree");
layoutAlgorithm.add("Sparse vertical tree");
layoutAlgorithm.select(config.getDefaultLayoutAlgorithm().getValue());
/**
** object display ***
*/
Group objectDisplayGroup = new Group(dialogArea, SWT.NONE);
objectDisplayGroup.setText("Default display options");
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
objectDisplayGroup.setLayoutData(gd);
layout = new GridLayout();
objectDisplayGroup.setLayout(layout);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
objectDisplayMode = WidgetHelper.createLabeledCombo(objectDisplayGroup, SWT.READ_ONLY, "Display object as", gd);
objectDisplayMode.add("Icons");
objectDisplayMode.add("Small labels");
objectDisplayMode.add("Large labels");
objectDisplayMode.add("Status icons");
objectDisplayMode.select(config.getObjectDisplayMode().getValue());
checkShowStatusIcon = new Button(objectDisplayGroup, SWT.CHECK);
checkShowStatusIcon.setText("Show status icon");
checkShowStatusIcon.setSelection((config.getFlags() & NetworkMap.MF_SHOW_STATUS_ICON) != 0);
checkShowStatusFrame = new Button(objectDisplayGroup, SWT.CHECK);
checkShowStatusFrame.setText("Show status frame");
checkShowStatusFrame.setSelection((config.getFlags() & NetworkMap.MF_SHOW_STATUS_FRAME) != 0);
checkShowStatusBkgnd = new Button(objectDisplayGroup, SWT.CHECK);
checkShowStatusBkgnd.setText("Show status background");
checkShowStatusBkgnd.setSelection((config.getFlags() & NetworkMap.MF_SHOW_STATUS_BKGND) != 0);
/**
** default link appearance ***
*/
Group linkGroup = new Group(dialogArea, SWT.NONE);
linkGroup.setText("Default connection options");
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
linkGroup.setLayoutData(gd);
layout = new GridLayout();
linkGroup.setLayout(layout);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
routingAlgorithm = WidgetHelper.createLabeledCombo(linkGroup, SWT.READ_ONLY, "Routing algorithm", gd);
routingAlgorithm.add("Direct");
routingAlgorithm.add("Manhattan");
routingAlgorithm.select(config.getDefaultLinkRouting() - 1);
final SelectionListener listener = new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
linkColor.setEnabled(radioColorCustom.getSelection());
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
};
radioColorDefault = new Button(linkGroup, SWT.RADIO);
radioColorDefault.setText("Default color");
radioColorDefault.setSelection(config.getDefaultLinkColor() < 0);
radioColorDefault.addSelectionListener(listener);
gd = new GridData();
gd.verticalIndent = WidgetHelper.OUTER_SPACING * 2;
radioColorDefault.setLayoutData(gd);
radioColorCustom = new Button(linkGroup, SWT.RADIO);
radioColorCustom.setText("Custom color");
radioColorCustom.setSelection(config.getDefaultLinkColor() >= 0);
radioColorCustom.addSelectionListener(listener);
linkColor = new ColorSelector(linkGroup);
linkColor.setColorValue(ColorConverter.rgbFromInt(config.getDefaultLinkColor()));
linkColor.setEnabled(config.getDefaultLinkColor() >= 0);
gd = new GridData();
gd.horizontalIndent = 20;
linkColor.getButton().setLayoutData(gd);
return dialogArea;
}
Aggregations