use of net.sourceforge.pmd.eclipse.ui.preferences.br.ValueChangeListener in project pmd-eclipse-plugin by pmd.
the class AbstractMultiValueEditorFactory method addNewValueRow.
private void addNewValueRow(final Composite parent, final PropertyDescriptor<List<T>> desc, final PropertySource source, final Text parentWidget, final ValueChangeListener changeListener, final SizeChangeListener sizeListener, final List<Control> newControls, int i) {
if (!canAddNewRowFor(desc, source)) {
return;
}
final Label number = new Label(parent, SWT.NONE);
number.setText(Integer.toString(i + 1));
newControls.add(number);
final Control widget = addWidget(parent, null, desc, source);
widget.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
newControls.add(widget);
final Button butt = new Button(parent, SWT.PUSH);
// TODO use icon for consistent width
butt.setText("+");
newControls.add(butt);
Listener addListener = new Listener() {
public void handleEvent(Event event) {
// add new value handler
// add the new value to the property set
// set the value in the widget to the cleaned up one, disable it
// remove old listener from button, add new (delete) one, update text/icon
// add new row widgets: label, value widget, button
// add listener for new button
T newValue = addValueIn(widget, desc, source);
if (newValue == null) {
return;
}
addNewValueRow(parent, desc, source, parentWidget, changeListener, sizeListener, newControls, -1);
convertToDelete(butt, newValue, parent, newControls, desc, source, parentWidget, number, widget, changeListener, sizeListener);
widget.setEnabled(false);
setValue(widget, newValue);
renumberLabelsIn(newControls);
fillWidget(parentWidget, desc, source);
adjustRendering(source, desc, parentWidget);
sizeListener.addedRows(1);
changeListener.changed(source, desc, newValue);
parent.getParent().layout();
}
};
butt.addListener(SWT.Selection, addListener);
// allow for CR on entry widgets themselves, no need to click the '+' button
widget.addListener(SWT.DefaultSelection, addListener);
widget.setFocus();
}
use of net.sourceforge.pmd.eclipse.ui.preferences.br.ValueChangeListener in project pmd-eclipse-plugin by pmd.
the class CharacterEditorFactory method newEditorOn.
public Control newEditorOn(Composite parent, final PropertyDescriptor<Character> desc, final PropertySource source, final ValueChangeListener listener, SizeChangeListener sizeListener) {
final Text text = new Text(parent, SWT.SINGLE | SWT.BORDER);
fillWidget(text, desc, source);
text.addListener(SWT.FocusOut, new Listener() {
public void handleEvent(Event event) {
Character newValue = charValueIn(text);
Character existingValue = valueFor(source, desc);
if (existingValue.equals(newValue)) {
return;
}
source.setProperty(desc, newValue);
listener.changed(source, desc, newValue);
adjustRendering(source, desc, text);
}
});
return text;
}
use of net.sourceforge.pmd.eclipse.ui.preferences.br.ValueChangeListener in project pmd-eclipse-plugin by pmd.
the class MultiStringEditorFactory method configure.
protected void configure(final Text textWidget, final PropertyDescriptor<List<String>> desc, final PropertySource source, final ValueChangeListener listener) {
Listener widgetListener = new Listener() {
public void handleEvent(Event event) {
List<String> newValues = textWidgetValues(textWidget);
List<String> existingValues = valueFor(source, desc);
if (existingValues != null && existingValues.equals(newValues)) {
return;
}
source.setProperty(desc, newValues);
// reload with latest scrubbed values
fillWidget(textWidget, desc, source);
listener.changed(source, desc, newValues);
}
};
textWidget.addListener(SWT.FocusOut, widgetListener);
// textWidget.addListener(SWT.DefaultSelection, widgetListener);
}
Aggregations