use of net.sourceforge.pmd.eclipse.ui.preferences.br.SizeChangeListener in project pmd-eclipse-plugin by pmd.
the class FileEditorFactory method newEditorOn.
public Control newEditorOn(Composite parent, final PropertyDescriptor<File> desc, final PropertySource source, final ValueChangeListener listener, SizeChangeListener sizeListener) {
final FilePicker picker = new FilePicker(parent, SWT.SINGLE | SWT.BORDER, "Open", null);
picker.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fillWidget(picker, desc, source);
picker.addFocusOutListener(new Listener() {
public void handleEvent(Event event) {
File newValue = picker.getFile();
File existingValue = valueFor(source, desc);
if (areSemanticEquals(existingValue, newValue)) {
return;
}
setValue(source, desc, newValue);
// redraw
fillWidget(picker, desc, source);
listener.changed(source, desc, newValue);
}
});
return picker;
}
use of net.sourceforge.pmd.eclipse.ui.preferences.br.SizeChangeListener in project pmd-eclipse-plugin by pmd.
the class StringEditorFactory method newEditorOn.
public Control newEditorOn(Composite parent, final PropertyDescriptor<String> desc, final PropertySource source, final ValueChangeListener listener, SizeChangeListener sizeListener) {
final Text text = new Text(parent, SWT.SINGLE | SWT.BORDER);
text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fillWidget(text, desc, source);
text.addListener(SWT.FocusOut, new Listener() {
public void handleEvent(Event event) {
String newValue = text.getText().trim();
String existingValue = valueFor(source, desc);
if (StringUtil.areSemanticEquals(existingValue, newValue)) {
return;
}
setValue(source, desc, newValue);
// redraw
fillWidget(text, desc, source);
listener.changed(source, desc, newValue);
}
});
return text;
}
use of net.sourceforge.pmd.eclipse.ui.preferences.br.SizeChangeListener in project pmd-eclipse-plugin by pmd.
the class TypeEditorFactory method newEditorOn.
public Control newEditorOn(Composite parent, final PropertyDescriptor<Class> desc, final PropertySource source, final ValueChangeListener listener, SizeChangeListener sizeListener) {
final TypeText typeText = new TypeText(parent, SWT.SINGLE | SWT.BORDER, true, // TODO i18l
"Enter a type name");
typeText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fillWidget(typeText, desc, source);
Listener wereDoneListener = new Listener() {
public void handleEvent(Event event) {
Class<?> newValue = typeText.getType(true);
if (newValue == null) {
return;
}
Class<?> existingValue = (Class<?>) valueFor(source, desc);
if (existingValue == newValue) {
return;
}
source.setProperty(desc, newValue);
listener.changed(source, desc, newValue);
adjustRendering(source, desc, typeText);
}
};
typeText.addListener(SWT.FocusOut, wereDoneListener);
typeText.addListener(SWT.DefaultSelection, wereDoneListener);
return typeText;
}
use of net.sourceforge.pmd.eclipse.ui.preferences.br.SizeChangeListener in project pmd-eclipse-plugin by pmd.
the class AbstractMultiValueEditorFactory method convertToDelete.
private void convertToDelete(final Button button, final T toDeleteValue, final Composite parent, final List<Control> newControls, final PropertyDescriptor<List<T>> desc, final PropertySource source, final Text parentWidget, final Label number, final Control widget, final ValueChangeListener changeListener, final SizeChangeListener sizeListener) {
button.setText("-");
Util.removeListeners(button, SWT.Selection);
button.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
delete(number, widget, button, newControls, toDeleteValue, desc, source);
fillWidget(parentWidget, desc, source);
sizeListener.addedRows(-1);
changeListener.changed(source, desc, null);
parent.getParent().layout();
}
});
}
use of net.sourceforge.pmd.eclipse.ui.preferences.br.SizeChangeListener in project pmd-eclipse-plugin by pmd.
the class AbstractMultiValueEditorFactory method newEditorOn.
public Control newEditorOn(final Composite parent, final PropertyDescriptor<List<T>> desc, final PropertySource source, final ValueChangeListener changeListener, final SizeChangeListener sizeListener) {
final Composite panel = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(3, false);
layout.verticalSpacing = 0;
layout.marginHeight = 0;
layout.marginWidth = 0;
panel.setLayout(layout);
final Text textWidget = new Text(panel, SWT.SINGLE | SWT.BORDER);
final Button butt = new Button(panel, SWT.PUSH);
// TODO use triangle icon & rotate 90deg when clicked
butt.setText("...");
butt.addListener(SWT.Selection, new Listener() {
boolean itemsVisible = false;
List<Control> items = new ArrayList<Control>();
public void handleEvent(Event event) {
if (itemsVisible) {
hideCollection(items);
sizeListener.addedRows(items.size() / -WIDGETS_PER_ROW);
} else {
items = openCollection(panel, desc, source, textWidget, changeListener, sizeListener);
sizeListener.addedRows(items.size() / WIDGETS_PER_ROW);
}
itemsVisible = !itemsVisible;
// no raw editing when individual items are available
textWidget.setEditable(!itemsVisible);
parent.layout();
}
});
GridData data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 2;
textWidget.setLayoutData(data);
panel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fillWidget(textWidget, desc, source);
configure(textWidget, desc, source, changeListener);
return panel;
}
Aggregations