use of org.eclipse.jface.util.IPropertyChangeListener in project webtools.sourceediting by eclipse.
the class JSONSyntaxColoringPage 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.JSON_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
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, JSONUIMessages.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, JSONUIMessages.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, JSONUIMessages.SyntaxColoringPage_3);
fBold.setEnabled(false);
((GridData) fBold.getLayoutData()).horizontalSpan = 2;
fItalic = createCheckbox(editControls, JSONUIMessages.SyntaxColoringPage_4);
fItalic.setEnabled(false);
((GridData) fItalic.getLayoutData()).horizontalSpan = 2;
fStrike = createCheckbox(editControls, JSONUIMessages.SyntaxColoringPage_5);
fStrike.setEnabled(false);
((GridData) fStrike.getLayoutData()).horizontalSpan = 2;
fUnderline = createCheckbox(editControls, JSONUIMessages.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(ContentTypeIdForJSON.ContentTypeID_JSON);
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.JSON_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.util.IPropertyChangeListener in project webtools.sourceediting by eclipse.
the class DTDSyntaxColoringPage 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.DTD_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, DTDUIMessages.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, DTDUIMessages.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, DTDUIMessages.SyntaxColoringPage_3);
fBold.setEnabled(false);
((GridData) fBold.getLayoutData()).horizontalSpan = 2;
fItalic = createCheckbox(editControls, DTDUIMessages.SyntaxColoringPage_4);
fItalic.setEnabled(false);
((GridData) fItalic.getLayoutData()).horizontalSpan = 2;
fStrike = createCheckbox(editControls, DTDUIMessages.SyntaxColoringPage_5);
fStrike.setEnabled(false);
((GridData) fStrike.getLayoutData()).horizontalSpan = 2;
fUnderline = createCheckbox(editControls, DTDUIMessages.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(ContentTypeIdForDTD.ContentTypeID_DTD);
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.DTD_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.util.IPropertyChangeListener in project dbeaver by serge-rider.
the class PropertyTreeViewer method handlePropertyChange.
private void handlePropertyChange(TreeNode prop) {
super.update(prop, null);
List<IPropertyChangeListener> listenersCopy;
synchronized (propertyListeners) {
listenersCopy = new ArrayList<>(propertyListeners);
}
if (!listenersCopy.isEmpty()) {
PropertyChangeEvent event = new PropertyChangeEvent(this, CommonUtils.toString(prop.property.getId()), null, getPropertyValue(prop));
for (IPropertyChangeListener listener : listenersCopy) {
listener.propertyChange(event);
}
}
// Send modify event
Event event = new Event();
event.data = prop.property;
getTree().notifyListeners(SWT.Modify, event);
}
use of org.eclipse.jface.util.IPropertyChangeListener in project hale by halestudio.
the class DefaultSchemaTypePage method createContent.
/**
* @see HaleWizardPage#createContent(org.eclipse.swt.widgets.Composite)
*/
@Override
protected void createContent(Composite parent) {
Composite holder = new Composite(parent, SWT.NONE);
holder.setLayout(GridLayoutFactory.fillDefaults().create());
sc = new DynamicScrolledComposite(holder, SWT.V_SCROLL);
sc.setExpandHorizontal(true);
sc.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 200).create());
Composite page = new Composite(sc, SWT.NONE);
page.setLayout(new GridLayout(2, false));
sfe = new TypeNameField("typename", "Typename", page);
sfe.setEmptyStringAllowed(false);
// sfe.setErrorMessage("Please enter a valid Type Name");
sfe.setPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(StringFieldEditor.IS_VALID)) {
setPageComplete(isValid());
}
}
});
sfe.setStringValue(defaultString);
// sfe.setPage(this);
group = new Group(page, SWT.NONE);
group.setText("Properties");
group.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create());
group.setLayout(GridLayoutFactory.swtDefaults().numColumns(3).equalWidth(false).margins(5, 5).create());
sc.setContent(page);
sc.layout();
// setPageComplete(sfe.isValid());
}
use of org.eclipse.jface.util.IPropertyChangeListener in project hale by halestudio.
the class AbstractProjectDetailsPage method createContent.
/**
* @see HaleWizardPage#createContent(Composite)
*/
@Override
protected void createContent(Composite page) {
page.setLayout(new GridLayout(2, false));
// name
name = new StringFieldEditor("name", "Project name:", page);
name.setEmptyStringAllowed(false);
name.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE);
name.setErrorMessage("The project name must be specified.");
name.setPage(this);
// author
author = new StringFieldEditor("author", "Project author:", page);
author.setEmptyStringAllowed(false);
author.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE);
author.setPage(this);
// description
Label descLabel = new Label(page, SWT.NONE);
descLabel.setText("Description:");
descLabel.setLayoutData(GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.BEGINNING).create());
description = new Text(page, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.BORDER);
description.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(500, SWT.DEFAULT).create());
// listen for state changes on field editors
IPropertyChangeListener stateListener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(StringFieldEditor.IS_VALID)) {
updateState();
}
}
};
name.setPropertyChangeListener(stateListener);
author.setPropertyChangeListener(stateListener);
// listen for provider changes
getWizard().addIOWizardListener(new IOWizardListener<P, E>() {
@Override
public void providerDescriptorChanged(IOProviderDescriptor providerFactory) {
// update fields as the provider will have changed
updateFields();
}
@Override
public void contentTypeChanged(IContentType contentType) {
// ignore
}
});
updateState();
updateFields();
}
Aggregations