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 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
|
package com.eclipse.rcp.app1.view;
import java.io.File;
import java.util.ArrayList;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.ViewPart;
import com.eclipse.rcp.app1.controller.ParametrageController;
import com.eclipse.rcp.app1.view.parametrage.listeners.AffaireSelectionListener;
import com.eclipse.rcp.app1.view.parametrage.listeners.ListMatSelectionListener;
import com.eclipse.rcp.app1.view.parametrage.listeners.MatSelectionListener;
public class ParametrageStep1 extends ViewPart {
private ParametrageController parametrageController = null;
private Text textLieu = null;
private Text textMat = null;
private Label labelListMat = null;
private Table tableMat = null;
private Button btnNext = null;
private Composite parent = null;
public ParametrageStep1() {
parametrageController = new ParametrageController(this);
}
@Override
public void createPartControl(Composite parent) {
this.parent = 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",14,0));
GridData titreGD = new GridData(GridData.FILL_HORIZONTAL);
titreGD.horizontalSpan = 3;
titreGD.heightHint = 70;
labelTitre.setLayoutData(titreGD);
Label labelLieu = new Label(parent, SWT.NONE);
labelLieu.setText("Lieu de l'affaire : ");
labelLieu.setFont(new Font(null,"Arial",10,0));
labelLieu.setToolTipText("Indiquer le dossier racine de l'affaire");
textLieu = new Text(parent, SWT.BORDER);
textLieu.setText("Chemin de l'affaire");
textLieu.setFont(new Font(null,"Arial",10,0));
GridData affaireGD = new GridData(GridData.CENTER);
affaireGD.widthHint = 300;
textLieu.setLayoutData(affaireGD);
Button btnLieuAffaire = new Button(parent, SWT.NONE);
btnLieuAffaire.setText("...");
btnLieuAffaire.addSelectionListener(new AffaireSelectionListener(parametrageController));
Label labelMat = new Label(parent, SWT.NONE);
labelMat.setText("Lieu des matrices de test : ");
labelMat.setFont(new Font(null,"Arial",10,0));
labelMat.setToolTipText("Indiquer le dossier racine des matrices de test");
textMat = new Text(parent, SWT.BORDER);
textMat.setText("Chemin des matrices de test");
textMat.setFont(new Font(null,"Arial",10,0));
affaireGD.widthHint = 300;
textMat.setLayoutData(affaireGD);
Button btnLieuMat = new Button(parent, SWT.NONE);
btnLieuMat.setText("...");
btnLieuMat.addSelectionListener(new MatSelectionListener(parametrageController));
}
@Override
public void setFocus() {
}
/**
* Update TextLieu and TextMat with the selected path
* @param myUpdatedText
*/
public void updateTextLieuAndMat(String myUpdatedText){
textLieu.setText(myUpdatedText);
textMat.setText(myUpdatedText + "path");
}
/**
* Update TextMat with the selected path
* @param myUpdatedText
*/
public void updateTextMat(String myUpdatedText){
textMat.setText(myUpdatedText);
}
/**
* Update the list of matrices
* @param myUpdateListMat
*/
public void updateListMat(String[] listMat){
if (labelListMat == null){
Label labelListMat = new Label(this.parent, SWT.NONE);
labelListMat.setText("Matrices présentes : ");
labelListMat.setFont(new Font(null,"Arial",10,0));
labelListMat = labelListMat;
}
//Si un tableau de matrice existe déjà alors le supprimer
//pour en créer un nouveau
if (tableMat != null){
tableMat.dispose();
}
Table tableMat = new Table(this.parent, SWT.CHECK);
TableColumn columnMatName = new TableColumn(tableMat, SWT.LEFT);
columnMatName.setText("Nom de la matrice");
columnMatName.setWidth(300);
columnMatName.setResizable(false);
tableMat.setHeaderVisible(true);
tableMat.setLinesVisible(true);
//Création du tableau comportant les différentes matrices
for (int i=0; i<listMat.length; i++){
File mat = new File(listMat[i]);
TableItem line = new TableItem(tableMat,SWT.NONE);
line.setText(mat.getName());
line.setChecked(true);
}
GridData tabMatGD = new GridData(GridData.FILL_HORIZONTAL);
tabMatGD.horizontalSpan = 2;
tabMatGD.horizontalAlignment = SWT.LEFT;
tableMat.setLayoutData(tabMatGD);
tableMat.setToolTipText("Indiquer les matrices de test que l'on veut traiter");
this.tableMat = tableMat;
if (btnNext != null){
btnNext.dispose();
}
GridData btnNextGD = new GridData(GridData.FILL_HORIZONTAL);
btnNextGD.horizontalSpan = 3;
btnNextGD.horizontalAlignment = SWT.CENTER;
btnNextGD.verticalIndent = 40;
Button btnNext = new Button(parent, SWT.NONE);
btnNext.setText("Suivant");
btnNext.setLayoutData(btnNextGD);
btnNext.addSelectionListener(new ListMatSelectionListener(parametrageController));
btnNext = btnNext;
this.parent.layout();
}
//Retourne une liste contenant les matrices cochées dans la table des matrices
public ArrayList<String> getListTableChecked(){
TableItem[] listItem = tableMat.getItems();
ArrayList<String> listMatChecked = new ArrayList<String>();
for (int i=0; i<listItem.length; i++){
boolean checked = listItem[i].getChecked();
if (checked){
listMatChecked.add(listItem[i].getText());
}
}
return listMatChecked;
}
//Retourne une liste contenant les matrices NON cochées dans la table des matrices
public ArrayList<String> getListTableNotChecked(){
TableItem[] listItem = tableMat.getItems();
ArrayList<String> listMatNotChecked = new ArrayList<String>();
for (int i=0; i<listItem.length; i++){
boolean checked = listItem[i].getChecked();
if (!checked){
listMatNotChecked.add(listItem[i].getText());
}
}
return listMatNotChecked;
}
public void updateNextView(ArrayList<String> listMatNotChecked){
Boolean reponse = true;
if (!listMatNotChecked.isEmpty()){
reponse = MessageDialog.openConfirm(this.parent.getShell(),
"Confirmation", "Vous n'avez pas sélectionné les matrices suivantes : \n\n"
+ listMatNotChecked.toString()+ ". \n\nEtes vous sûr de vouloir continuer?");
}
if (reponse){
}
}
} |
Partager