2010-07-14 28 views
1

我想使用Eclipse AdvancedPropertySection其使用PropertySheetPage显示和编辑属性,但我的一些性质 是多线(例如描述)。Eclipse PropertySheetPage - 它可以支持多行属性吗?

问题: 我无法获取PropertySheetPage以显示多行属性。 它显示他们为单行,就像这样:

alt text

我尝试使用,而不是TextPropertyDescriptor WrapTextPropertyDescriptor,但它似乎并没有帮助。

有没有办法使用AdvancedPropertySection(PropertySheetPage)显示多行属性?

+0

将您的代码复制到扩展AdvancedPropertySection的类中... – nanda 2010-07-14 08:41:29

回答

1

也就是说,如果你按照这个教程很简单:http://www.eclipse.org/articles/Article-Properties-View/properties-view.html

您可以创建自己的自定义属性描述符。

我已经解决了这个问题是这样的:

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(); 
    } 

} 

这是你自己的描述:

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; 

    } 


} 

用途:

properties.add(new TextDataPropertyDescriptor(YourClass.PROPERTY_CONTENT,"Content")); 

使用import org.apache.directory.studio.ldapbrowser.common.dialogs.TextDialog;,您可以更新您的日食与插件,http://directory.apache.org/studio/downloads.html, 和更新这个包,org.apache.directory.studio.ldapbrowser.common;

相关问题