Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "JFaceSnippets"
(→Snippet058CellNavigationIn34) |
(→Snippet061FakedNativeCellEditor) |
||
Line 323: | Line 323: | ||
=== [http://git.eclipse.org/c/platform/eclipse.platform.ui.git/plain/examples/org.eclipse.jface.snippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippets/viewers/Snippet061FakedNativeCellEditor.java Snippet061FakedNativeCellEditor] === | === [http://git.eclipse.org/c/platform/eclipse.platform.ui.git/plain/examples/org.eclipse.jface.snippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippets/viewers/Snippet061FakedNativeCellEditor.java Snippet061FakedNativeCellEditor] === | ||
Full featured native looking viewer with checkboxes in an arbitary column | Full featured native looking viewer with checkboxes in an arbitary column | ||
+ | |||
+ | You also need these classes: | ||
+ | * [http://git.eclipse.org/c/platform/eclipse.platform.ui.git/plain/examples/org.eclipse.jface.snippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippets/viewers/BooleanCellEditor.java BooleanCellEditor.java] | ||
+ | |||
+ | |||
[[Image:Snippet061FakedNativeCellEditor.png]] | [[Image:Snippet061FakedNativeCellEditor.png]] |
Revision as of 07:03, 10 September 2018
JFace-Snippets are small easy understandable programming example how to use the JFace API. To browse the examples, navigate to the examples GIT repository.
The header section of each snippet is a link to the plain source. You can copy the source and paste it directly on the source folder or package in an eclipse project. The package and the class will be created automatically.
Contents
- 1 Dialogs
- 2 Layout
- 3 Viewers
- 3.1 Snippet001TableViewer
- 3.2 Snippet002TreeViewer
- 3.3 Snippet003TableLabelProvider
- 3.4 Snippet004HideSelection
- 3.5 Snippet005TreeCustomMenu
- 3.6 Snippet006TableMultiLineCells
- 3.7 Snippet007FullSelection
- 3.8 Snippet008RevealElement
- 3.9 Snippet009CellEditors
- 3.10 Snippet010OwnerDraw
- 3.11 Snippet011CustomTooltips
- 3.12 Snippet013TableViewerNoMandatoryLabelProvider
- 3.13 Snippet014TreeViewerNoMandatoryLabelProvider
- 3.14 Snippet015CustomTooltipsForTree
- 3.15 Snippet017TableViewerHideShowColumns
- 3.16 Snippet018TableViewerAddRemoveColumnsWithEditing
- 3.17 Snippet019TableViewerAddRemoveColumnsWithEditingNewAPI
- 3.18 Snippet021CellEditorsOnDoubleClick
- 3.19 Snippet024TableViewerExplore
- 3.20 Snippet025TabEditing
- 3.21 Snippet026TreeViewerTabEditing
- 3.22 Snippet027ComboBoxCellEditors
- 3.23 Snippet029VirtualTableViewer
- 3.24 Snippet030VirtualLazyTableViewer
- 3.25 Snippet031TableViewerCustomTooltipsMultiSelection
- 3.26 Snippet034CellEditorPerRowNewAPI
- 3.27 Snippet035TableCursorCellHighlighter
- 3.28 Snippet036FocusBorderCellHighlighter
- 3.29 Snippet037FancyCustomTooltips
- 3.30 Snippet038TreeViewerInlinelEditingOldAPI
- 3.31 Snippet039ListViewer
- 3.32 Snippet040TableViewerSorting
- 3.33 Snippet 041 - Table Viewer Alternating Colors and Viewer Filters
- 3.34 Snippet042ToolTipSupportFor32API
- 3.35 Snippet043TreeViewerKeyboardEditing
- 3.36 Snippet044TableViewerKeyboardEditing
- 3.37 Snippet045TableViewerFillFromBackgroundThread
- 3.38 Snippet046UpdateViewerFromBackgroundThread
- 3.39 Snippet047VirtualLazyTreeViewer
- 3.40 Snippet048TreeViewerTabWithCheckboxFor3_3
- 3.41 Snippet049StyledCellLabelProvider
- 3.42 Snippet050DelegatingStyledCellLabelProvider
- 3.43 Snippet051TableCenteredImage
- 3.44 Snippet052DoubleClickCellEditor
- 3.45 Snippet053StartEditorWithContextMenu
- 3.46 Snippet055HideShowColumn
- 3.47 Snippet056BooleanCellEditor
- 3.48 Snippet057TableViewerSkipHiddenCells
- 3.49 Snippet058CellNavigationIn34
- 3.50 Snippet060TextCellEditorWithContentProposal
- 3.51 Snippet061FakedNativeCellEditor
- 3.52 Snippet062TextAndDialogCellEditor
- 3.53 Snippet063ComboViewer
- 4 Window
- 5 Wizard
Dialogs
Dialog with Image Buttons
Demonstrates usage of Icons in Buttons of Dialogs
Drop these icons also in the same package
Layout
Grid Layout Factory
Demonstrates usage of the GridLayoutFactory to make more readable
Snippet016TableLayout
Demonstrates (dynamic)layout support for TableColumns available as of JFace 3.3
Snippet027TreeLayout
Demonstrates (dynamic)layout support for TreeColumns available as of JFace 3.3
Viewers
Snippet001TableViewer
Demonstrates a simply TableViewer with one column. It holds all important classes used for all Table-like JFace-Viewers (LabelProvider,IStructuredContentProvider)
Snippet002TreeViewer
Demonstrates a simply TreeViewer with one column. It describes all important classes used for all Tree-like JFace-Viewers (LabelProvider,ITreeContentProvider)
Snippet003TableLabelProvider
Demonstrates tables with more than one column and the usage of ITableLabelProvider
Snippet004HideSelection
Demonstrates how the selection can be hidden when the user click in a tablerow/column which doesn't hold any information. The standard behaviour of SWT-Table is to leave the selection on the last column. This snippet removes the selection if the user clicks in an area not selectable
Snippet005TreeCustomMenu
Demonstrates how to create a different context menu depending on which item in the tree is currently selected this can also be used with a table of course
Snippet006TableMultiLineCells
Demonstrates first use case for the new OwnerDraw-Support added to JFace in 3.3 (available at SWT-Level since 3.2). This example uses the new Viewers API in this special case the OwnerDrawLabelProvider to make items with more than one line of text.
Snippet007FullSelection
Demonstrates how you can use a use inline editing in tables with multiple columns which requires to use SWT.FULL_SELECTION but hiding the selection from the user.
Snippet008RevealElement
Demonstrates how you can scroll a TableViewer to the specific model element using TableViewer#reveal(Object)
Snippet009CellEditors
Demonstrates minimal example when trying to add inline editing to tables to get familiar with the various classes needed (3.2 API)
Snippet010OwnerDraw
Demonstrates usage of new OwnerDraw-Support feature provided by JFace in 3.3(available in SWT since 3.2). This example uses the new Viewers API in this special case the OwnerDrawLabelProvider.
Snippet011CustomTooltips
Demonstrates usage of new custom tooltip support in 3.3 used to provide a tooltip for each cell in TableViewer
Snippet013TableViewerNoMandatoryLabelProvider
Demonstrates usage of none mandatory LabelProviders in TableViewers to set colors and fonts with 3.2-API
Snippet014TreeViewerNoMandatoryLabelProvider
Demonstrates usage of none mandatory LabelProviders in TreeViewers to set colors and font with 3.2-API
Snippet015CustomTooltipsForTree
Demonstrates usage of custom tooltip support used to provide a tooltip for each cell in a TreeViewer
Snippet017TableViewerHideShowColumns
Demonstrates hiding and showing of columns (animated)
Snippet018TableViewerAddRemoveColumnsWithEditing
Demonstrates adding/removing of columns in conjunction with inline editing which makes this a bit tougher than without it (using 3.2 API)
See also: Snippet019TableViewerAddRemoveColumnsWithEditingNewAPI
Snippet019TableViewerAddRemoveColumnsWithEditingNewAPI
Demonstrates adding/removing of columns in conjunction with the inline editing but with the new JFace-API who makes this a much easier and less error prone
Snippet021CellEditorsOnDoubleClick
Demonstrates editor activation on double-click with the 3.2 API which makes this fairly complex
Snippet024TableViewerExplore
Demonstrates the base classes of 3.3 API
Snippet025TabEditing
Demonstrates how one can use the new 3.3 API to add tab-editing support to your viewer
Press Tab to jump from cell to cell
Snippet026TreeViewerTabEditing
Demonstrates all fancy things one can do with new 3.3 API (Tab-Editing, Keyboard-Navigation from Cell to Cell, Editor-Activation with the Keyboard)
Snippet027ComboBoxCellEditors
Demonstrates usage of the ComboBoxCellEditor in JFace-Viewers
Snippet029VirtualTableViewer
Demonstrates usage of JFace-Viewers in virtual mode with an ordinary content provider (often the bottel neck is not the model but the UI). Using this Virtual viewers in conjunction with an ordinary content provider has the advantage that Sorting and Filtering is supported in 3.3.
Snippet030VirtualLazyTableViewer
Demonstrates usage of JFace-Viewer virtual mode with a lazy content provider
Snippet031TableViewerCustomTooltipsMultiSelection
Demonstrates creation of tooltips for cells for pre 3.3 users
Snippet034CellEditorPerRowNewAPI
Demonstrates different CellEditor-Types in one COLUMN of JFace-Viewers
Snippet035TableCursorCellHighlighter
Demonstrates keyboard navigation in TableViewers using a TableCursor showing the flexibility of the cell navigation support
You also need these classes:
Snippet036FocusBorderCellHighlighter
Demonstrates keyboard navigation by highlighting the currently selected cell with a focus border showing once more the flexibility of the cell navigation support
You also need:
Snippet037FancyCustomTooltips
Demonstrates customizability of the 3.3 JFace-Support for cell tooltips using the Browser-Widget and presenting HTML
Snippet038TreeViewerInlinelEditingOldAPI
Demonstrates editing support as of 3.2 for TreeViewers
Snippet039ListViewer
Demonstrates a very simple usage of ListViewer
Snippet040TableViewerSorting
Demonstrates sorting(asc/desc) in TableViewers by clicking the column header.
Snippet 041 - Table Viewer Alternating Colors and Viewer Filters
Demonstrates how to achieve alternating row-colors with TableViewer. It can also be used in conjunction with virtual-bits to even work with big tables (e.g. 100,000 rows in this example). In addition, this snippet provided a button that will demonstrate the usage of viewer filters.
Snippet042ToolTipSupportFor32API
Because ColumnViewerToolTipSupport forces one to use the new 3.3 CellLabelProvider-API it is of no use for people stuck with the old LabelProvider API. This snippet shows how a potential class for 3.2 API could look like.
Snippet043TreeViewerKeyboardEditing
Demonstrates the JFace 3.3 keyboard editing support for Trees without columns. Tabbing from editor to editor is supported since 3.4. In addition this snippet provided a button that shows how to enter in edit mode programmatically.
Snippet044TableViewerKeyboardEditing
Demonstrates the JFace 3.3 keyboard editing support for Tables without columns. Tabbing from editor to editor is supported since 3.4.
You also need:
Snippet045TableViewerFillFromBackgroundThread
Demonstrates how a TableViewer with a sorter can be filled from a NON-UI thread
Snippet046UpdateViewerFromBackgroundThread
Demonstrates how to update a viewer from a long running task (which is executed in a thread) and calls back to the UI-Thread using asyncExec
Snippet047VirtualLazyTreeViewer
Demonstrates the usage of ILazyContentProvider in conjunction with a Virtual-TreeViewer. The snippet shows how using a lazy tree can minimize the memory footprint and maximize the speed when viewing large models.
Snippet048TreeViewerTabWithCheckboxFor3_3
Demonstrates how to overcome a limitation when it comes to key-navigation and CheckBoxEditors in 3.3.1.
This is a workaround for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=198502
Snippet049StyledCellLabelProvider
Demonstrates a new LabelProvider-Type which uses StyleRanges. This Snippet requires SWT/JFace 3.4.
Snippet050DelegatingStyledCellLabelProvider
Demonstrates how you can add styled text by wrapping an existing label provider. This Snippet requires SWT/JFace 3.4.
Snippet051TableCenteredImage
Demonstrate how to center an image and create graphics in a cell using owner draw.
Snippet052DoubleClickCellEditor
Demonstrate how to start cell-editors on double click.
Snippet053StartEditorWithContextMenu
Demonstrate how to start up a cell editor with a context menu and not with mouse clicking on the cell.
Snippet055HideShowColumn
Demonstrate hiding and showing columns and starting a cell editor programmatically.
Snippet056BooleanCellEditor
Demonstrate a custom cell-editor which uses a real Checkbox-Button
You also need these classes:
Snippet057TableViewerSkipHiddenCells
Example of showing how easy cell-navigation with hidden cells is. Use the cursor keys to navigate between cells. Then use the context menu to hide a column.
Shows how to automatically reveal cells when navigating. Run the snippet and then edit the first cell by double clicking. Pressing tab will advance to the next cell in edit mode and reveal the cell if it is not in the viewport.
Snippet060TextCellEditorWithContentProposal
Show how to use content-proposal inside a CellEditor
Snippet061FakedNativeCellEditor
Full featured native looking viewer with checkboxes in an arbitary column
You also need these classes:
Snippet062TextAndDialogCellEditor
Demonstrates usage of TextAndDialogCellEditor. The email column uses the TextAndDialogCellEditor; othe columns use ordinary TextCellEditor.
Snippet063ComboViewer
Show how to use ComboViewer and set a inital selection
Window
Snippet020CustomizedControlTooltips
Demonstrates usage of new JFace 3.3 to show really cool ToolTips for your controls
Snippet031TableStaticTooltip
Demonstrates creation of ToolTips for Tables without using the JFace-Viewers API but only JFace-Tooltips
Wizard
Wizard with Long Running Operation from Page
Demonstrates how to work with JFace-Wizards and fill a TableViewer from a Background-Thread without blocking the UI showing a progress bar in the meanwhile
Wizard with Progress and Cancel
Demonstrates a wizard with internal progress.
File:Snippet071WizardWithProgressAndCancel.png
Wizard with Progress Subtasks and Cancel
Demonstrates a wizard with internal progress using SubMonitor and subtasks.