1. To achieve a basic:
The procedure is as follows:
1 ImportOrg.eclipse.jface.dialogs.Dialog;2 Importorg.eclipse.jface.dialogs.IDialogConstants;3 4 Importjavax.swing.text.StyleConstants.ColorConstants;5 6 ImportOrg.eclipse.swt.SWT;7 ImportOrg.eclipse.swt.events.SelectionAdapter;8 Importorg.eclipse.swt.events.SelectionEvent;9 ImportOrg.eclipse.swt.graphics.Point;Ten Importorg.eclipse.swt.layout.FillLayout; One ImportOrg.eclipse.swt.layout.GridData; A Importorg.eclipse.swt.layout.GridLayout; - ImportOrg.eclipse.swt.widgets.Composite; - ImportOrg.eclipse.swt.widgets.Control; the ImportOrg.eclipse.swt.widgets.Group; - ImportOrg.eclipse.swt.widgets.Shell; - ImportOrg.eclipse.swt.widgets.TabFolder; - ImportOrg.eclipse.swt.widgets.TabItem; + Importorg.eclipse.swt.widgets.Table; - ImportOrg.eclipse.swt.widgets.TableColumn; + ImportOrg.eclipse.swt.widgets.TableItem; A ImportOrg.eclipse.swt.widgets.Tree; at ImportOrg.eclipse.swt.widgets.TreeItem; - - Public classCustompropertydialogextendsDialog { - Privatetable table; - Privatetree tree; - protectedCustompropertydialog (Shell parentshell) { in Super(Parentshell); - //TODO auto-generated Constructor stub to } + - @Override the protectedPoint getinitialsize () { * return NewPoint (500,500);//Width and Height $ }Panax Notoginseng - @Override the protectedControl Createdialogarea (Composite parent) { +Composite Composite =NewComposite (parent, SWT.) NONE); AGridLayout layout =NewGridLayout (); theLayout.marginheight =convertverticaldlustopixels (idialogconstants.vertical_margin); +Layout.marginwidth =converthorizontaldlustopixels (idialogconstants.horizontal_margin); -Layout.verticalspacing =convertverticaldlustopixels (idialogconstants.vertical_spacing); $Layout.horizontalspacing =converthorizontaldlustopixels (idialogconstants.horizontal_spacing); $ composite.setlayout (layout); -Composite.setlayoutdata (NewGriddata (Griddata.fill_both)); - Applydialogfont (composite); the -Tabfolder Tabfolder =NewTabfolder (COMPOSITE,SWT. BORDER);Wuyi //tabfolder.setsize (+); theTabfolder.setlayoutdata (NewGriddata (Griddata.fill_both)); - WuTabItem tabItem1 =NewTabItem (TABFOLDER,SWT. NONE); -Tabitem1.settext ("attribute edit"); About $Composite composite1 =NewComposite (TABFOLDER,SWT. NONE); -Tabitem1.setcontrol (COMPOSITE1);//Setcontrol means that when you choose TabItem1, Composite1 is displayed. - -GridLayout compisite1layout =NewGridLayout (); ALayout.numcolumns = 1; + composite1.setlayout (compisite1layout); the - //Composite1 's layout, there are two group, one is tree, one is table $Group Treegroup =NewGroup (COMPOSITE1,SWT. NONE); theTreegroup.settext ("Tree"); theGriddata Griddata =NewGriddata (griddata.fill_both); theGriddata.heighthint = 50; the Treegroup.setlayoutdata (griddata); -Treegroup.setlayout (NewGridLayout (1,false)); in the //Treegroup specific content, data in the program here, how can I get the data? the { AboutTree =NewTree (TREEGROUP,SWT. single); theTree.setlayoutdata (NewGriddata (Griddata.fill_both)); the //Add first element theTreeItem STU1 =NewTreeItem (TREE,SWT. NONE); +Stu1.settext ("Xingoo"); - { theTreeItem Info1 =NewTreeItem (STU1,SWT. NONE);BayiInfo1.settext ("age:25"); the theTreeItem Info2 =NewTreeItem (STU1,SWT. NONE); -Info2.settext ("tel:12345"); - } the //Add a second element theTreeItem STU2 =NewTreeItem (TREE,SWT. NONE); theStu2.settext ("Halo"); the { -TreeItem Info3 =NewTreeItem (STU2,SWT. NONE); theInfo3.settext ("age:25"); the theTreeItem Info4 =NewTreeItem (STU2,SWT. NONE);94Info4.settext ("tel:67890"); the } the the //It needs to be changed, and when clicked, I'm not going to add it, but to make it tick the corresponding data in the table .98Tree.addselectionlistener (NewSelectionadapter () { About Public voidwidgetselected (selectionevent evt) { - //here is set, click on Add a Tableitem101Tableitem item =NewTableitem (TABLE,SWT. NONE);102Item.settext (NewString[]{tree.getselection () [0].tostring (), tree.getselection () [0].gettext ()});103 }104 }); the }106 107 //Composite1 's layout, there are two group, one is tree, one is table108Group TableGroup =NewGroup (COMPOSITE1,SWT. NONE);109Tablegroup.settext ("Table"); theGriddata GD =NewGriddata (griddata.fill_both);111Gd.heighthint = 20; the Tablegroup.setlayoutdata (GD);113Tablegroup.setlayout (NewGridLayout (1,false)); the the //specific content of TableGroup the{//Create a single, bounded, row-wide table with one selection117Table =NewTable (TABLEGROUP,SWT. Single | Swt. BORDER |SWT. full_selection);118Table.setheadervisible (true);//Set table header visible119Table.setlinesvisible (true);//Set Line Visible -Table.setlayoutdata (NewGriddata (Griddata.fill_both));121 //To start setting up columns, the columns I need should increase speed and coordinates122TableColumn Column1 =NewTableColumn (TABLE,SWT. NULL);123Column1.settext ("model name");124 Column1.pack (); theColumn1.setwidth (100);126 127TableColumn Column2 =NewTableColumn (TABLE,SWT. NULL); -Column2.settext ("Parent model");129 Column2.pack (); theColumn2.setwidth (100);131 theTableColumn Column3 =NewTableColumn (TABLE,SWT. NULL);133Column3.settext ("Speed");134 Column3.pack ();135Column3.setwidth (100);136 137TableColumn COLUMN4 =NewTableColumn (TABLE,SWT. NULL);138Column4.settext ("Coordinate system");139 Column4.pack (); $Column4.setwidth (100);141 }142 143 returnComposite;144 }145}
View Code
2. The missing part:
(1) How data in tree and table is obtained. This parameter is in the file. (2) Click on the event, now the setting is to click on the tree,table to add a corresponding section. What I want to do is, click on this and the table will be located here. (3) Table currently inside is not editable, how to modify to be editable. (4) is not to add an Apply button in the composite1 or Tabholder, or many changes, only one of the outermost OK key, always feel not very good.
Robottask: Implementation of the Property Editing dialog box