2010-07-14 75 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;