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
| final Composite compositeParent = parent;
compositeParent.setLayout(new FormLayout());
final Label findLabel = new Label(compositeParent, SWT.NONE);
FormData fd_label = new FormData();
fd_label.left = new FormAttachment(17, 0);
fd_label.top = new FormAttachment(0, 10);
findLabel.setLayoutData(fd_label);
findLabel.setText("Select a type:");
final Combo classTypeCombo = new Combo(compositeParent, SWT.READ_ONLY);
final FormData fd_combo = new FormData();
fd_combo.left = new FormAttachment(findLabel, 15, SWT.RIGHT);
fd_combo.top = new FormAttachment(0, 10);
classTypeCombo.setLayoutData(fd_combo);
classTypeCombo.setText("Choose a Class Type");
//La méthode fillClassCombo permet de remplir la Combo...
classTypeCombo.setItems(fillClassCombo());
final ScrolledComposite scroll = new ScrolledComposite(compositeParent, SWT.BORDER | SWT.V_SCROLL);
FormData fd_scroll = new FormData();
fd_scroll.top = new FormAttachment(findLabel, 32, SWT.BOTTOM);
scroll.setLayout(new FormLayout());
scroll.setLayoutData(fd_scroll);
composite = new Composite(scroll, SWT.NONE);
composite.setLayout(new FormLayout());
FormData fd_composite = new FormData();
fd_composite.top = new FormAttachment(classTypeCombo, 0, SWT.TOP);
composite.setLayoutData(fd_composite);
setControl(scroll);
classTypeCombo.addListener(SWT.Selection, new Listener()
{
@Override
public void handleEvent(Event event)
{
if (classTypeCombo.getSelectionIndex() != -1)
{
if (composite != null && !composite.isDisposed())
{
composite.dispose();
}
composite = new Composite(scroll, SWT.NONE);
composite.setLayout(new FormLayout());
scroll.setContent(composite);
String className = classTypeCombo.getItem(classTypeCombo.getSelectionIndex());
//Méthode permettant d'obtenir les attributs grâce au nom d'une Classe
List < String > attributes = getAttributesByClass(className);
Label idLabel = null;
if (attributes != null)
{
Iterator < String > itAttributes = attributes.iterator();
String idLabelName = "Enter Functionnal Key values : ";
idLabel = new Label(composite, SWT.NONE);
FormData fd_label = new FormData(), fd_text;
fd_label.top = new FormAttachment(findLabel, 32, SWT.BOTTOM);
fd_label.left = new FormAttachment(0, 10);
idLabel.setLayoutData(fd_label);
idLabel.setText(idLabelName);
Text idText;
while (itAttributes.hasNext()) {
idLabelName = itAttributes.next();
fd_label = new FormData();
fd_label.top = new FormAttachment(idLabel, 20, SWT.BOTTOM);
fd_label.left = new FormAttachment(0, 20);
idLabel = new Label(composite, SWT.NONE);
idLabel.setLayoutData(fd_label);
idLabel.setText(idLabelName);
idText = new Text(composite, SWT.BORDER);
fd_text = new FormData();
fd_text.left = new FormAttachment(idLabel, 15, SWT.RIGHT);
fd_text.top = new FormAttachment(idLabel, 0, SWT.TOP);
idText.setLayoutData(fd_text);
idText.setSize(100, -1);
}
}
//Méthode permettant d'obtenir les labels grâce au nom d'une Classe.
List < String > labels = getLabelsByClass(className);
if (labels != null)
{
Iterator < String > itLabels = labels.iterator();
String pkLabelName = "Enter Labels values : ";
Label pkLabel = new Label(composite, SWT.NONE);
FormData fd_label = new FormData(), fd_text;
boolean idLabelNull = idLabel == null;
fd_label.top = new FormAttachment(idLabelNull ? findLabel : idLabel,
idLabelNull ? 32 : 25, SWT.BOTTOM);
fd_label.left = new FormAttachment(0, 10);
pkLabel.setLayoutData(fd_label);
pkLabel.setText(pkLabelName);
Text pkText;
while (itLabels.hasNext()) {
pkLabelName = itLabels.next();
fd_label = new FormData();
fd_label.top = new FormAttachment(pkLabel, 20, SWT.BOTTOM);
fd_label.left = new FormAttachment(0, 20);
pkLabel = new Label(composite, SWT.NONE);
pkLabel.setLayoutData(fd_label);
pkLabel.setText(pkLabelName);
pkText = new Text(composite, SWT.BORDER);
fd_text = new FormData();
fd_text.left = new FormAttachment(pkLabel, 15, SWT.RIGHT);
fd_text.top = new FormAttachment(pkLabel, 0, SWT.TOP);
pkText.setLayoutData(fd_text);
pkText.setSize(100, -1);
}
}
scroll.setMinWidth(200);
scroll.setMinHeight(200);
scroll.setExpandVertical(true);
scroll.setContent(composite);
composite.layout(true);
compositeParent.layout(true);
compositeParent.update();
}
}
}); |
Partager