【问题标题】:Eclipse PropertySheetPage - Can it support a multi line property?Eclipse PropertySheetPage - 它可以支持多行属性吗?
【发布时间】:2010-07-14 08:17:13
【问题描述】:

我想使用 Eclipse AdvancedPropertySection,它使用 PropertySheetPage显示和编辑属性,但是我的一些属性 是多行的(例如描述)。

问题: 我无法让 PropertySheetPage 显示多行属性。 它将它们显示为一行,如下所示:

我尝试使用 WrapTextPropertyDescriptor 代替 TextPropertyDescriptor,但它似乎没有帮助。

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

【问题讨论】:

  • 在此处复制扩展 AdvancedPropertySection 的类的代码...

标签: java eclipse view properties line


【解决方案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 更新您的eclipse, 并且只更新包,org.apache.directory.studio.ldapbrowser.common;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-04-16
    • 1970-01-01
    • 1970-01-01
    • 2018-11-09
    相关资源
    最近更新 更多