use of org.eclipse.jface.util.IPropertyChangeListener 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.util.IPropertyChangeListener in project epp.mpc by eclipse.
the class MarketplaceViewer method doCreateHeaderControls.
@Override
protected void doCreateHeaderControls(Composite parent) {
header = parent;
final int originalChildCount = parent.getChildren().length;
for (CatalogFilter filter : getConfiguration().getFilters()) {
if (filter instanceof MarketplaceFilter) {
MarketplaceFilter marketplaceFilter = (MarketplaceFilter) filter;
marketplaceFilter.createControl(parent);
marketplaceFilter.addPropertyChangeListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
if (AbstractTagFilter.PROP_SELECTED.equals(event.getProperty())) {
doQuery();
}
}
});
}
}
Control[] children = parent.getChildren();
for (int x = originalChildCount; x < children.length; ++x) {
Control child = children[x];
GridDataFactory.swtDefaults().hint(135, SWT.DEFAULT).applyTo(child);
}
Button goButton = new Button(parent, SWT.PUSH);
goButton.setText(Messages.MarketplaceViewer_go);
goButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doQuery();
}
});
}
use of org.eclipse.jface.util.IPropertyChangeListener in project janrufmonitor by tbrandt77.
the class InitFritzBoxVariantPage method createControl.
public void createControl(Composite parent) {
setTitle(this.m_i18n.getString("ui.jface.configuration.pages.FritzBoxVoip", "title", "label", this.m_language));
setDescription(this.m_i18n.getString("ui.jface.configuration.pages.FritzBoxVoip", "description", "label", this.m_language));
final Composite c = new Composite(parent, SWT.NONE);
c.setLayout(new GridLayout(1, false));
c.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
BooleanFieldEditor bfe = new BooleanFieldEditor("activemonitor", this.m_i18n.getString("ui.jface.configuration.pages.FritzBoxVoip", "activemonitor2", "label", this.m_language), c);
bfe.setPropertyChangeListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent e) {
if (e != null && e.getNewValue() != null && e.getNewValue() instanceof Boolean)
m_active = ((Boolean) e.getNewValue()).booleanValue();
setPageComplete(isComplete());
}
});
new Label(c, SWT.LEFT);
StringFieldEditor sfe = new StringFieldEditor("boxip", this.m_i18n.getString("ui.jface.configuration.pages.FritzBoxVoip", "boxip", "label", this.m_language), c);
sfe.setStringValue("fritz.box");
this.m_boxip = "fritz.box";
sfe.setPropertyChangeListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent e) {
if (e != null && e.getNewValue() != null && e.getNewValue() instanceof String)
m_boxip = (String) e.getNewValue();
setPageComplete(isComplete());
}
});
ComboFieldEditor mode = new ComboFieldEditor("boxloginmode", this.m_i18n.getString("ui.jface.configuration.pages.FritzBoxVoip", "boxloginmode", "label", this.m_language), new String[][] { { this.m_i18n.getString("ui.jface.configuration.pages.FritzBoxVoip", "userpassword", "label", this.m_language), "0" }, { this.m_i18n.getString("ui.jface.configuration.pages.FritzBoxVoip", "password_only", "label", this.m_language), "1" } }, c);
final StringFieldEditor sfe1 = new StringFieldEditor("boxuser", this.m_i18n.getString("ui.jface.configuration.pages.FritzBoxVoip", "boxuser", "label", this.m_language), c);
sfe1.setStringValue("");
this.m_boxuser = "";
mode.setPropertyChangeListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent e) {
if (e != null && e.getNewValue() != null && e.getNewValue() instanceof String) {
String state = (String) e.getNewValue();
if (state.equalsIgnoreCase("1")) {
sfe1.setEnabled(false, c);
sfe1.setStringValue("");
sfe1.getTextControl(c).setBackground(new Color(DisplayManager.getDefaultDisplay(), 190, 190, 190));
m_boxuser = "";
} else {
sfe1.setEnabled(true, c);
sfe1.getTextControl(c).setBackground(new Color(DisplayManager.getDefaultDisplay(), 255, 255, 255));
}
}
}
});
sfe1.setPropertyChangeListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent e) {
if (e != null && e.getNewValue() != null && e.getNewValue() instanceof String)
m_boxuser = (String) e.getNewValue();
setPageComplete(isComplete());
}
});
sfe = new StringFieldEditor("boxpassword", this.m_i18n.getString("ui.jface.configuration.pages.FritzBoxVoip", "boxpassword", "label", this.m_language), c);
sfe.getTextControl(c).setEchoChar('*');
sfe.setStringValue("");
this.m_boxpassword = "";
sfe.setPropertyChangeListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent e) {
if (e != null && e.getNewValue() != null && e.getNewValue() instanceof String)
m_boxpassword = (String) e.getNewValue();
setPageComplete(isComplete());
}
});
new Label(c, SWT.LEFT);
bfe = new BooleanFieldEditor("usemsns", this.m_i18n.getString("ui.jface.configuration.pages.FritzBoxVoip", "usemsns", "label", this.m_language), c);
bfe.setPropertyChangeListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent e) {
if (e != null && e.getNewValue() != null && e.getNewValue() instanceof Boolean)
m_usemsns = ((Boolean) e.getNewValue()).booleanValue();
setPageComplete(isComplete());
}
});
new Label(c, SWT.LEFT);
Text l = new Text(c, SWT.LEFT | SWT.WRAP);
l.setText(this.m_i18n.getString("ui.jface.configuration.pages.FritzBoxVoip", "openfb", "label", this.m_language));
l.setEditable(false);
l.setBackground(parent.getBackground());
new Label(c, SWT.LEFT);
HyperLink hl = new HyperLink(c, SWT.LEFT | SWT.WRAP);
hl.setText(this.m_i18n.getString("ui.jface.configuration.pages.FritzBoxVoip", "openfb2", "label", this.m_language));
hl.addMouseListener(new MouseAdapter() {
public void mouseDown(MouseEvent e) {
if (e.button == 1)
Program.launch("http://www.janrufmonitor.de/fritzbox-freischalten");
}
});
setPageComplete(isComplete());
setControl(c);
}
use of org.eclipse.jface.util.IPropertyChangeListener in project janrufmonitor by tbrandt77.
the class InitAreaCodePage method createControl.
public void createControl(Composite parent) {
setTitle(this.m_i18n.getString(getNamespace(), "title", "label", this.m_language));
setDescription(this.m_i18n.getString(getNamespace(), "description", "label", this.m_language));
Composite c = new Composite(parent, SWT.NONE);
c.setLayout(new GridLayout(1, false));
c.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
StringFieldEditor sfe = new StringFieldEditor("intarea", this.m_i18n.getString(getNamespace(), "intarea", "label", this.m_language), 5, c);
sfe.setStringValue("49");
this.m_newIntArea = "49";
sfe.setPropertyChangeListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent e) {
if (e != null && e.getNewValue() != null)
m_newIntArea = (String) e.getNewValue();
setPageComplete(isComplete());
}
});
sfe = new StringFieldEditor("area", this.m_i18n.getString(getNamespace(), "area", "label", this.m_language), 10, c);
sfe.setStringValue("030");
this.m_newArea = "030";
sfe.setPropertyChangeListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent e) {
if (e != null && e.getNewValue() != null)
m_newArea = (String) e.getNewValue();
identify();
setPageComplete(isComplete());
}
});
new Label(c, SWT.LEFT);
m_city = new Label(c, SWT.LEFT);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 300;
m_city.setText("Berlin");
m_city.setLayoutData(gd);
setPageComplete(isComplete());
setControl(c);
}
use of org.eclipse.jface.util.IPropertyChangeListener in project janrufmonitor by tbrandt77.
the class InitNumberFormatPage method createControl.
public void createControl(Composite parent) {
setTitle(this.m_i18n.getString(getNamespace(), "title", "label", this.m_language));
setDescription(this.m_i18n.getString(getNamespace(), "description", "label", this.m_language));
Composite c = new Composite(parent, SWT.NONE);
c.setLayout(new GridLayout(1, false));
c.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
ComboFieldEditor cfe = new ComboFieldEditor(this.m_i18n.getString(getNamespace(), "name", "label", this.m_language), this.m_i18n.getString(getNamespace(), "label", "label", this.m_language), new String[][] { { this.m_i18n.getString(getNamespace(), "format1", "label", this.m_language), "+%intareacode% (%areacode%) %callnumber%" }, { this.m_i18n.getString(getNamespace(), "format2", "label", this.m_language), "00%intareacode% (%areacode%) %callnumber%" }, { this.m_i18n.getString(getNamespace(), "format3", "label", this.m_language), "(0%areacode%) %callnumber%" }, { this.m_i18n.getString(getNamespace(), "format4", "label", this.m_language), "0%areacode%-%callnumber%" } }, c);
cfe.setPropertyChangeListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent e) {
if (e != null && e.getNewValue() != null)
m_newFormat = (String) e.getNewValue();
setPageComplete(isComplete());
}
});
setPageComplete(isComplete());
setControl(c);
}
Aggregations