Application RCP, modèle MVC avec SWT
Bonjour à tous :D
Je suis débutant et j'ai du mal à comprendre le fonctionnement du modèle MVC.
Voici la hiérarchie de mes classes :
src
-- com.eclipse.rcp.app1
------ Activator
------ Application
------ ApplicationActionBarAdvisor
------ ApplicationWorkbenchAdvisor
------ ApplicationWorkbenchWindow
------ Perspective
-- com.eclipse.rcp.app1.controller
------ DirectorySlectionListener
-- com.eclipse.rcp.app1.view
------ Complements
------ Etapes
------ Parametrage
Donc déjà, si j'ai bien compris suivant ma hiérarchie j'ai bien le modèle MVC non ?
Enfin j'ai surtout un problème. J'ai une classe où je créai mon interface graphique :
Code:
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
|
package com.eclipse.rcp.app1.view;
import com.eclipse.rcp.app1.controller.DirectorySelectionListener;
public class Parametrage extends ViewPart {
public Parametrage() {
// TODO Auto-generated constructor stub
}
@Override
public void createPartControl(Composite parent) {
createEtape1(parent);
}
@Override
public void setFocus() {
// TODO Auto-generated method stub
}
public void createEtape1(Composite parent){
GridLayout lieuAffaire = new GridLayout(3,false);
parent.setLayout(lieuAffaire);
lieuAffaire.marginLeft = 300;
Label labelTitre = new Label(parent,SWT.NONE);
labelTitre.setText("Sélection du lieu de l'affaire et des matrices de test");
labelTitre.setFont(new Font(null,"Arial",18,0));
GridData titreGD = new GridData(GridData.FILL_HORIZONTAL);
titreGD.horizontalSpan = 3;
titreGD.heightHint = 70;
titreGD.horizontalIndent = -45;
titreGD.verticalIndent = 20;
labelTitre.setLayoutData(titreGD);
Label labelLieu = new Label(parent, SWT.NONE);
labelLieu.setText("Lieu de l'affaire : ");
labelLieu.setFont(new Font(null,"Arial",13,0));
Text textLieu = new Text(parent, SWT.BORDER);
textLieu.setText("Chemin de l'affaire");
textLieu.setFont(new Font(null,"Arial",13,0));
GridData affaireGD = new GridData(GridData.CENTER);
affaireGD.widthHint = 220;
textLieu.setLayoutData(affaireGD);
Button btnLieuAffaire = new Button(parent, SWT.NONE);
btnLieuAffaire.setText("...");
btnLieuAffaire.addSelectionListener(new DirectorySelectionListener(textLieu)); |
Et une classe pour le traitement de mon bouton :
Code:
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
| package com.eclipse.rcp.app1.controller;
public class DirectorySelectionListener implements SelectionListener {
final IWorkbench workbench = PlatformUI.getWorkbench();
final Display display = workbench.getDisplay();
Shell shell = new Shell (display);
private Text textLieu;
public DirectorySelectionListener(Text textLieu){
this.textLieu = textLieu;
}
@Override
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent evt) {
// TODO Auto-generated method stub
}
@Override
public void widgetSelected(org.eclipse.swt.events.SelectionEvent evt) {
// TODO Auto-generated method stub
DirectoryDialog leDialogue = new DirectoryDialog(shell, SWT.OPEN);
leDialogue.setText("Choix du répertoire");
try
{
textLieu.setText(leDialogue.open());
}
catch (IllegalArgumentException e) {}
}
} |
Donc là j'ai bien séparé la vue de mon contrôleur non ?
Le truc que je ne comprend pas c'est comment puis-je faire pour pouvoir modifier plusieurs éléments de mon interface graphique ?
En fait lorsque je clique sur le bouton j'aimerai modifier plusieurs éléments de mon interface mais le problème c'est que dans le contrôleur je ne peux récupérer seulement le bouton.
Je vous remercie pour votre aide.
Cordialement,
Leniouns