GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing wiki.eclipse.org — Nebula PropertyTable - Eclipsepedia
Jump to: navigation,
search
Nebula PropertyTableIntroductionA widget that allow user to set up properties in a table or a tree table. Contents
UsageThe first thing to do is to instantiate the widget : final PropertyTable table = new PropertyTable(tabFolder, SWT.NONE); By default, the table shows items in categories, the "sort" and "show description" buttons are displayed, and the description panel is present. You can customize your widget with the following methods : final PropertyTable table = new PropertyTable(tabFolder, SWT.NONE); table.showButtons(); table.hideButtons(); table.viewAsCategories(); table.viewAsFlatList(); table.showDescription(); table.hideDescription(); Then you fill your table with PTProperty objects. These objects are composed of the following fields :
public PTProperty(final String name, final String displayName, final String description); public PTProperty(final String name, final String displayName, final String description, final Object value): You can group your properties in the same category. If you choose the view "as category", all properties will appear in a tree under the category. Because all setters return the PTProperty itself, you can chain multiple setters : table.addProperty(new PTProperty("id", "Identifier", "Description for identifier", "My id")).setCategory("General");
table.addProperty(new PTProperty("text", "Description", "Description for the description field", "blahblah...")).setCategory("General");
table.addProperty(new PTProperty("url", "URL:", "This is a nice URL", "http://www.google.com").setCategory("General")).setEditor(new PTURLEditor());
table.addProperty(new PTProperty("password", "Password", "Enter your password and keep it secret...", "password")).setCategory("General").setEditor(new PTPasswordEditor());
EditorsIf no editor is set, the PropertyTable will use by default the PTStringEditor. PTStringEditorAccepted data type : All Constructor : This editor is used to modify any kind of property. It is represented by a Text widget. PTIntegerEditorAccepted data type : Integer Constructor : This editor is used to modify an Integer. It is represented by a Text widget that accepts only integer values. PTFloatEditorAccepted data type : Float Constructor : This editor is used to modify a Float. It is represented by a Text widget that accepts only float values. PTURLEditorAccepted data type : String (URL) Constructor : This editor is used to modify any kind of property. It is represented by a Text widget. PTPasswordEditorAccepted data type : All Constructor : This editor is used to modify any kind of property. It is represented by a Text widget. PTSpinnerEditorAccepted data type : Integer Constructor : This editor is used to modify an Integer. It is represented by a Spinner widget. PTFileEditorAccepted data type : String Constructor : This editor is used to modify any kind of property that correspond to a file path. It is represented by a text with 2 buttons. The "X" button erases the value of the property (set it to null). The "..." button opens a new window that allow the user to pick a file. PTDirectoryEditorAccepted data type : String Constructor : This editor is used to modify any kind of property that correspond to a directory path. It is represented by a text with 2 buttons. The "X" button erases the value of the property (set it to null). The "..." button opens a new window that allow the user to pick a directory. PTComboEditorAccepted data type : All Constructors : public PTComboEditor(final boolean readOnly, final Object... data) public PTComboEditor(final Object... data) This editor is used to modify any kind of property. It is represented by a Combo widget. The PropertyTable uses the toString() method of the object to display value, so you can use a Java Bean. PTCheckboxEditorAccepted data type : Boolean Constructor : This editor is used to modify a boolean property. It is represented by a Checkbox widget. PTColorEditorAccepted data type : org.eclipse.swt.graphics.Color Constructor : This editor is used to modify A Color. It is represented by a text with 2 buttons. The "X" button erases the value of the property (set it to null). The "..." button opens a new window that allow the user to pick a color. PTFontEditorAccepted data type : org.eclipse.swt.graphics.FontData Constructor : This editor is used to modify a Font. It is represented by a text with 2 buttons. The "X" button erases the value of the property (set it to null). The "..." button opens a new window that allow the user to pick a Font. PTDateEditorAccepted data type : java.util.date Constructor : This editor is used to modify a date (no time). It is represented by a DateTime widget. PTDimensionEditorAccepted data type : 'java.awt.Dimension' Constructor : This editor is used to modify a Dimension. It is represented by a text with 2 buttons. The "X" button erases the value of the property (set it to null). The "..." button opens a new window that allow the user to enter the width and the height of a dimension. PTRectangleEditorAccepted data type : org.eclipse.swt.graphics.Rectangle Constructor : This editor is used to modify a Dimension. It is represented by a text with 2 buttons. The "X" button erases the value of the property (set it to null). The "..." button opens a new window that allow the user to enter the x coordinate, the y coordinate, the width and the height of a rectangle. PTInsetsEditorAccepted data type : java.awt.Insets Constructor : This editor is used to modify a Insets object. It is represented by a text with 2 buttons. The "X" button erases the value of the property (set it to null). The "..." button opens a new window that allow the user to enter the top, the left, the bottom and the right part of an insets. ListenersYou can add a PTPropertyChangeListener that is called when the value of the property has changed. The method is called When a change is detected, you can access the PTProperty underlying object. One can change the font, the background color or the foreground color of the "display name". Example: final Font font = SWTGraphicUtil.buildFontFrom(table, SWT.BOLD, 10);
table.addListener(SWT.Dispose, e -> {
SWTGraphicUtil.safeDispose(font);
});
table.addChangeListener(property -> {
System.out.println("Change for " + property.getDisplayName() + ": new value is " + property.getValue());
property.changeFont(font);
property.changeForegroundColor(table.getDisplay().getSystemColor(SWT.COLOR_WHITE));
property.changeBackgroundColor(table.getDisplay().getSystemColor(SWT.COLOR_RED));
});
UpdateIf you wish to update the values, just call the methods Discard changeYou can discard changes by calling the method Example3 snippets called PropertyTableSnippet, PropertyTableSnippetRefresh and PropertyTableSnippetChangeListener are available in the plugin org.eclipse.nebula.widgets.opal.propertytable.snippets. The examples are available here: This page was last modified 15:19, 19 September 2021 by Eclipsepedia anonymous user Unnamed Poltroon. |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |