use of aQute.bnd.build.model.clauses.ImportPattern in project bndtools by bndtools.
the class ImportPatternsListPart method createSection.
@Override
protected void createSection(Section section, FormToolkit toolkit) {
super.createSection(section, toolkit);
Composite parentComposite = (Composite) getSection().getClient();
pnlDetails = toolkit.createComposite(parentComposite);
toolkit.createLabel(pnlDetails, "Pattern:");
txtPattern = toolkit.createText(pnlDetails, "");
toolkit.createLabel(pnlDetails, "Version:");
txtVersion = toolkit.createText(pnlDetails, "", SWT.BORDER);
btnOptional = toolkit.createButton(pnlDetails, "Optional", SWT.CHECK);
pnlDetails.setLayout(new GridLayout(5, false));
txtPattern.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
txtVersion.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
pnlDetails.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
SWTUtil.recurseEnable(false, pnlDetails);
txtPattern.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
if (!modifyLock.isUnderModification()) {
List<ImportPattern> selectedClauses = getSelection();
if (selectedClauses.size() == 1) {
selectedClauses.get(0).setName(txtPattern.getText());
updateLabels(selectedClauses);
validate();
markDirty();
}
}
}
});
txtVersion.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
if (!modifyLock.isUnderModification()) {
String text = txtVersion.getText();
if (text.length() == 0)
text = null;
List<ImportPattern> selectedClauses = getSelection();
for (ImportPattern clause : selectedClauses) {
clause.getAttribs().put(Constants.VERSION_ATTRIBUTE, text);
}
updateLabels(selectedClauses);
validate();
markDirty();
}
}
});
btnOptional.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (!modifyLock.isUnderModification()) {
boolean optional = btnOptional.getSelection();
List<ImportPattern> patterns = getSelection();
for (ImportPattern pattern : patterns) {
pattern.setOptional(optional);
}
updateLabels(patterns);
validate();
markDirty();
}
}
});
}
Aggregations