Bonjour,

J'ai un bout de code qui crée une boite de dialogue (à partir d'une interface principale), affiche un arbre d’éléments dans cette fenêtre crée, avec la possibilité d'éditer la 2ème colonne dans cette arbre.
Ensuite, via un bouton OK il va mettre à jour l'arbre avec les valeurs modifiées et les ré-afficher dans l'interface d'origine (interface principale).
Le problème c'est que lorsque je clique sur le bouton "Ok" dans la boite de Dialogue, j'ai le message d'erreur "Widget is disposed".
Voilà ci-dessous le code source de la boite de dialogue : création, remplissage, édition et action).
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
public void createBaseAddressInitDialogShell (final Component comp){
		Display display = getViewer().getControl().getDisplay();
		final Shell shell = new Shell(display, SWT.APPLICATION_MODAL | SWT.CLOSE);		
		shell.setSize(400,400);
	    shell.setText("Set Base Address Values");
		ImageDescriptor imgDesc = IPxactRegistryPlugin.getImageDescriptor(IRegisterConstants.SPLASH_ICON);		
		shell.setImage(imgDesc.createImage());
		shell.setLayout(new FormLayout());
		final Tree treeItems = new Tree(shell,SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
		treeItems.setHeaderVisible(true);
 
		Label label = new Label(shell, SWT.NULL);
		label.setText("You can set the base address value for each address block element.");
		TreeColumn column1 = new TreeColumn(treeItems,SWT.LEFT);
		column1.setText("Items");
		column1.setWidth(200);
		TreeColumn column2 = new TreeColumn(treeItems,SWT.LEFT);
		column2.setText("Base Address Value");
		column2.setWidth(200);
 
		if (comp.getModelComponents().size()== 0){
			TreeItem componentItem = new TreeItem(treeItems, SWT.NONE);
			componentItem.setText(new String[] { comp.getName(), null});
			for (int s=0;s<comp.getAddrBlocks().size();s++) {
				TreeItem subItem = new TreeItem(componentItem, SWT.NONE);
			    subItem.setText(new String[] { comp.getAddrBlocks().get(s).getName() + s, comp.getAddrBlocks().get(s).getBaseAddress() });
 
			}
		} else {
			for (int i = 0; i < comp.getModelComponents().size(); i++) {
				TreeItem componentItem = new TreeItem(treeItems, SWT.NONE);
				componentItem.setText(new String[] { comp.getModelComponents().get(i).getName() , null });
				for (int j=0;j<comp.getModelComponents().get(i).getAddrBlocks().size();j++) {
					TreeItem subItem = new TreeItem(componentItem, SWT.NONE);
			        subItem.setText(new String[] { comp.getModelComponents().get(i).getAddrBlocks().get(j).getName() , comp.getModelComponents().get(i).getAddrBlocks().get(j).getBaseAddress() });	 
				}
			}
		}
 
		FormData data = new FormData();
		data.top = new FormAttachment(0,0);
		data.left = new FormAttachment(0,0);
		data.right = new FormAttachment(100);
		data.bottom = new FormAttachment(75);
		treeItems.setLayoutData(data);
		treeItems.setFont(IRegisterConstants.ARIAL_FONT);
		for(int k=0; k<treeItems.getItemCount();k++) {
			treeItems.getItem(k).setExpanded(true);
			for (int l=0; l<treeItems.getItem(k).getItemCount();l++) {
				treeItems.getItem(k).getItem(l).setExpanded(true);
			}
		}
		treeItems.setSize(400,800);
	    treeItems.setLinesVisible(true);
 
 
 
    final TreeEditor editor = new TreeEditor(treeItems);
		editor.horizontalAlignment = SWT.LEFT;
		editor.grabHorizontal = true;
		editor.minimumWidth = 50;
		final int EDITABLECOLUMN = 1;
 
		treeItems.addSelectionListener(new SelectionListener() {
 
			@Override
			public void widgetSelected(SelectionEvent e) {
				Control oldEditor = editor.getEditor();
				if (oldEditor != null) oldEditor.dispose();
 
            	TreeItem item = (TreeItem)e.item;
				if (item == null || item.getItemCount() > 0) return;
 
				Text newEditor = new Text(treeItems, SWT.NONE);
				newEditor.setText(item.getText(EDITABLECOLUMN));
				newEditor.addModifyListener(new ModifyListener() {
					public void modifyText(ModifyEvent me) {
						Text text = (Text)editor.getEditor();
						editor.getItem().setText(EDITABLECOLUMN, text.getText());
					}
				});
				newEditor.selectAll();
				newEditor.setFocus();
				editor.setEditor(newEditor, item, EDITABLECOLUMN);
				item.setText(EDITABLECOLUMN,editor.getItem().getText(EDITABLECOLUMN));
			}
 
			@Override
			public void widgetDefaultSelected(SelectionEvent e) {
				// TODO Auto-generated method stub
 
			}
		});
 
		Button cancelButton = new Button(shell, SWT.PUSH);
		cancelButton.setText("&Cancel");		
		cancelButton.addListener(SWT.MouseDown, new Listener() {
			public void handleEvent(Event event) {				
				shell.dispose();
			}
		});
 
		Button okButton = new Button(shell, SWT.PUSH);
		okButton.setText("&OK");			
		okButton.addListener(SWT.MouseDown, new Listener(){
			public void handleEvent(Event event){				
				if (comp == null) return;	        
				shell.dispose();
				try {
					setBaseAddressValue((Component)comp, treeItems);
				} catch (Exception e) {
					reportErrors(getShell(),  
							"Set Base Address Value", 
							e.getMessage(), 
					"Setting the base address value failed." );
					DebugPlugin.logMessage(e.getMessage(), null);
				}
			}
 
		});
 
		data = new FormData();
		data.top = new FormAttachment(treeItems,10);	  				
		data.right = new FormAttachment(okButton,110);	  				
		cancelButton.setLayoutData(data);			
		data = new FormData();
		data.top = new FormAttachment(treeItems,10);
		data.right = new FormAttachment(50);
		data.width = 50;
		okButton.setLayoutData(data);		
		shell.setDefaultButton(okButton);
		shell.open();		
 
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
 
	}
Merci d'avance pour votre aide.