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
|
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Scrollable;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.custom.TableEditor;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Button;
import org.eclipse.jface.viewers.TableViewer;
public class FenêtrePrincipale {
protected static final Object CatEtab = null;
private Shell sShell = null;
private Label label = null;
private CCombo cCombo = null;
private Label label1 = null;
private Text text = null;
private Button button = null;
private Button button1 = null;
private Table table1 = null;
private TableItem items = null;
private TableViewer tableViewer = null;
private Label label2 = null;
private CCombo cCombo1 = null;
/**
* @param args
*/
public static void main(String[] args) {
// TODO Raccord de méthode auto-généré
/* Before this is run, be sure to set up the launch configuration (Arguments->VM Arguments)
* for the correct SWT library path in order to run with the SWT dlls.
* The dlls are located in the SWT plugin jar.
* For example, on Windows the Eclipse SWT 3.1 plugin jar is:
* installation_directory\plugins\org.eclipse.swt.win32_3.1.0.jar
*/
Display display = Display.getDefault();
FenêtrePrincipale thisClass = new FenêtrePrincipale();
thisClass.createSShell();
thisClass.sShell.open();
while (!thisClass.sShell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
/**
* This method initializes sShell
*/
private void createSShell() {
sShell = new Shell(SWT.BORDER | SWT.SHELL_TRIM);
sShell.setText("Test Table cCombo");
sShell.setSize(new Point(900, 500));
sShell.setLayout(null);
table1 = new Table(sShell, SWT.NONE);
table1.setHeaderVisible(true);
table1.setLinesVisible(true);
table1.setBounds(new Rectangle(57, 31, 751, 257));
tableViewer = new TableViewer(table1);
TableColumn tableColumn = new TableColumn(table1, SWT.CENTER);
tableColumn.setWidth(50);
tableColumn.setText("Civilité");
tableColumn.setResizable(true);
TableColumn tableColumn1 = new TableColumn(table1, SWT.CENTER);
tableColumn1.setWidth(100);
tableColumn1.setText("Nom");
tableColumn1.setResizable(true);
TableColumn tableColumn2 = new TableColumn(table1, SWT.CENTER);
tableColumn2.setWidth(100);
tableColumn2.setText("Prénom");
tableColumn2.setResizable(true);
TableColumn tableColumn3 = new TableColumn(table1, SWT.CENTER);
tableColumn3.setWidth(150);
tableColumn3.setText("Catégorie etab");
tableColumn3.setResizable(true);
TableColumn tableColumn4 = new TableColumn(table1, SWT.CENTER);
tableColumn4.setWidth(120);
tableColumn4.setText("Nom etab");
tableColumn4.setResizable(true);
TableColumn tableColumn5 = new TableColumn(table1, SWT.CENTER);
tableColumn5.setWidth(100);
tableColumn5.setText("Ville");
tableColumn5.setResizable(true);
TableColumn tableColumn6 = new TableColumn(table1, SWT.CENTER);
tableColumn6.setWidth(150);
tableColumn6.setText("Matière enseignée");
tableColumn6.setResizable(true);
final TableItem ligne1 = new TableItem (table1, SWT.NONE);
label = new Label(sShell, SWT.NONE);
label.setText("Civilité:");
label.setBounds(new Rectangle(31, 314, 79, 19));
cCombo = new CCombo(sShell, SWT.BORDER);
cCombo.add("M.");
cCombo.add("Melle");
cCombo.add("Mme");
cCombo.setBounds(new Rectangle(135, 314, 81, 18));
final String Civilité = cCombo;
label1 = new Label(sShell, SWT.NONE);
label1.setBounds(new Rectangle(269, 315, 37, 17));
label1.setText("Nom:");
text = new Text(sShell, SWT.BORDER);
text.setBounds(new Rectangle(329, 315, 198, 24));
text.setTextLimit(30);
final String Nom = text.getText();
label2 = new Label(sShell, SWT.NONE);
label2.setBounds(new Rectangle(29, 375, 93, 16));
label2.setText("Catégorie etab:");
cCombo1 = new CCombo(sShell, SWT.BORDER);
cCombo1.setBounds(new Rectangle(135, 375, 109, 17));
cCombo1.add("CLG");
cCombo1.add("LYC");
cCombo1.add("LYC PROF");
final String CatEtab = cCombo1.getItem(0);
button = new Button(sShell, SWT.NONE);
button.setBounds(new Rectangle(464, 405, 107, 31));
button.setText("Valider");
button.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
ligne1.setText(0, Civilité);
ligne1.setText(1,Nom);
ligne1.setText(3, CatEtab);
}
});
button1 = new Button(sShell, SWT.NONE);
button1.setBounds(new Rectangle(658, 405, 92, 32));
button1.setText("Quitter");
button1.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
sShell.close();
}
});
}
protected void resetEditors() {
// TODO Raccord de méthode auto-généré
}
} |
Partager