I want to use the Eclipse AdvancedPropertySection which uses PropertySheetPage to display and edit properties, but some of my properties are multi line (e.g. Description).
Problem: I can't get the PropertySheetPage to display multi line properties. It displays them as a single line, like this:
I tried using WrapT开发者_如何学编程extPropertyDescriptor instead of TextPropertyDescriptor, but it doesn't seem to help.
Is there a way to display multi line properties using the AdvancedPropertySection(PropertySheetPage)?
That's simple if you follow this tutorial: http://www.eclipse.org/articles/Article-Properties-View/properties-view.html
You can creating your own custom property descriptor.
I've solved the problem like this:
import org.apache.directory.studio.ldapbrowser.common.dialogs.TextDialog;
import org.eclipse.jface.viewers.DialogCellEditor;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
public class TextDialogCellEditor extends DialogCellEditor{
protected TextDialogCellEditor(Composite parent) {
super(parent);
}
@Override
protected Object openDialogBox(Control cellEditorWindow) {
TextDialog textDialog = new TextDialog(cellEditorWindow.getShell(),(String)getValue());
textDialog.open();
if(textDialog.getReturnCode()==textDialog.OK){
setValue(textDialog.getText());
}
return getValue();
}
}
This is your own descriptor:
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.views.properties.PropertyDescriptor;
public class TextDataPropertyDescriptor extends PropertyDescriptor{
public TextDataPropertyDescriptor(Object id, String displayName) {
super(id, displayName);
// TODO Auto-generated constructor stub
}
@Override
public CellEditor createPropertyEditor(Composite parent) {
CellEditor editor = new TextDialogCellEditor(parent);
if (getValidator() != null)
editor.setValidator(getValidator());
return editor;
}
}
Use:
properties.add(new TextDataPropertyDescriptor(YourClass.PROPERTY_CONTENT,"Content"));
Using import org.apache.directory.studio.ldapbrowser.common.dialogs.TextDialog;
, you can update your eclipse with the plugin, http://directory.apache.org/studio/downloads.html,
and update only the package, org.apache.directory.studio.ldapbrowser.common;
.
精彩评论