Once you know the clicked item, you can change his image. It will listen to clicks inside the tree and compare it with the items inside the tree. You can browse the tree of your site to see the equipment. We can achieve this by adding the following MouseListener to the tree. Treeview GLPI plugin This plugin allows you to browse through your inventory via a tree view in a panel located on the left side of the screen. Now the icon has to change when the user clicks on it. Once you have filled your tree and have a screen similar to below, you can add the real functionality. TrtmChild_1.setFont(FontConstants.FONT_NORMAL) TreeItem trtmChild_1 = new TreeItem(trtmParent, SWT.NONE) TreeItem trtmChild = new TreeItem(trtmParent, SWT.NONE) tImage(ResourceManager.getPluginImage("your_plugin_name", "your_image_name")) TreeItem trtmParent = new TreeItem(treeExample, SWT.NONE) Tcl_tColumnData(trclmnName, new ColumnWeightData(100, ColumnWeightData.MINIMUM_WIDTH, true)) TreeColumn trclmnName = treeViewerColumnName.getColumn() TreeViewerColumn treeViewerColumnName = new TreeViewerColumn(treeViewerExample, SWT.NONE) ![]() TreeExample = treeViewerExample.getTree() TreeViewer treeViewerExample = new TreeViewer(compositeExample, SWT.BORDER | SWT.FULL_SELECTION) ![]() JFace also provides helper classes to effectively manage your system resources, like colors, images and fonts. For example, you find viewers for ComboBoxes, Tables and Trees. TreeColumnLayout tcl_compositeExample = new TreeColumnLayout() ĬtLayout(tcl_compositeExample) JFace provides the viewers framework, which simplifies the mapping of a data model to a visual representation. Add the unchecked icon to the TreeItems on the second level.Įxample: Composite compositeExample = new Composite(composite, SWT.NONE) ĬtLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)) I’ve used these icons for this example:Ĭreate a JFace TreeViewer with one TreeViewerColumn and three TreeItems (don’t use TreeItems with a TreeViewer in your application, use ContentProvider and LabelProvider instead). The first thing you need are two custom icons, one for a checked and one for an unchecked checkbox. As you know, the CheckboxTreeViewer shows a checkbox on every level.Īn added bonus is that now, we can change the look of the checkbox by supplying our own images.Īfter some investigation, I found this solution to be the easiest: It ‘s not just a question of using the JFace CheckboxTreeViewer because we wanted to control on which level in the tree the checkbox was shown. ![]() For an RCP application which we are building at the moment we were in need of a Tree with checkboxes.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |