use of aQute.bnd.build.model.clauses.ImportPattern in project liferay-ide by liferay.
the class PortletTemplate method modifyInitialBndModel.
@Override
public void modifyInitialBndModel(BndEditModel model, String projectName, ProjectPaths projectPaths) {
super.modifyInitialBndModel(model, projectName, projectPaths);
String buildpath = "${buildpath-rule}";
model.setBuildPath(Collections.singletonList(new VersionedClause(buildpath, Attrs.EMPTY_ATTRS)));
model.setIncludeResource(Collections.singletonList("${includeresource-rule}"));
ImportPattern[] patterns = { new ImportPattern("${imports-rule}", Attrs.EMPTY_ATTRS), new ImportPattern("*", new Attrs()) };
patterns[1].setOptional(true);
model.setImportPatterns(Arrays.asList(patterns));
model.setGenericString("Web-ContextPath", "/" + projectName);
String safePackageName = safePackageName(projectName);
String wholePackageName = "(osgi.identity=" + safePackageName + ")";
CapReqBuilder cap = new CapReqBuilder(IdentityNamespace.IDENTITY_NAMESPACE);
cap.addDirective(Namespace.REQUIREMENT_FILTER_DIRECTIVE, wholePackageName);
model.setRunRequires(Collections.singletonList(cap.buildSyntheticRequirement()));
}
use of aQute.bnd.build.model.clauses.ImportPattern in project bndtools by bndtools.
the class ImportPatternsListPart method doAddClauses.
@Override
protected void doAddClauses(Collection<? extends ImportPattern> clauses, int index, boolean select) {
boolean appendStar = getClauses().isEmpty();
super.doAddClauses(clauses, index, select);
if (appendStar) {
// $NON-NLS-1$
ImportPattern starPattern = new ImportPattern("*", new Attrs());
super.doAddClauses(Arrays.asList(starPattern), -1, false);
}
}
use of aQute.bnd.build.model.clauses.ImportPattern in project bndtools by bndtools.
the class ImportPatternsListPart method propertyChange.
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (PROP_SELECTION.equals(evt.getPropertyName())) {
final List<ImportPattern> selectedClauses = getSelection();
modifyLock.modifyOperation(new Runnable() {
@Override
public void run() {
if (selectedClauses.isEmpty()) {
SWTUtil.recurseEnable(false, pnlDetails);
txtPattern.setText("");
txtVersion.setText("");
btnOptional.setSelection(false);
} else if (selectedClauses.size() == 1) {
SWTUtil.recurseEnable(true, pnlDetails);
ImportPattern pattern = selectedClauses.get(0);
txtPattern.setText(pattern.getName() != null ? pattern.getName() : "");
txtVersion.setText(pattern.getVersionRange() != null ? pattern.getVersionRange() : "");
btnOptional.setSelection(pattern.isOptional());
} else {
SWTUtil.recurseEnable(false, pnlDetails);
btnOptional.setEnabled(true);
pnlDetails.setEnabled(true);
boolean differs = false;
boolean first = selectedClauses.get(0).isOptional();
for (ImportPattern pattern : selectedClauses) {
if (first != pattern.isOptional()) {
differs = true;
break;
}
}
if (differs) {
btnOptional.setGrayed(true);
} else {
btnOptional.setGrayed(false);
btnOptional.setSelection(first);
}
}
}
});
} else {
super.propertyChange(evt);
}
}
use of aQute.bnd.build.model.clauses.ImportPattern in project bndtools by bndtools.
the class ImportPatternsListPart method validate.
@Override
public void validate() {
IMessageManager msgs = getManagedForm().getMessageManager();
msgs.setDecorationPosition(SWT.TOP | SWT.RIGHT);
String noStarWarning = null;
String actionMessage = null;
List<ImportPattern> patterns = getClauses();
if (!patterns.isEmpty()) {
for (Iterator<ImportPattern> iter = patterns.iterator(); iter.hasNext(); ) {
ImportPattern pattern = iter.next();
if (pattern.getName().equals("*") && iter.hasNext()) {
noStarWarning = "The catch-all pattern \"*\" should be in the last position.";
actionMessage = "Move \"*\" pattern to the last position.";
break;
}
}
if (noStarWarning == null) {
ImportPattern last = patterns.get(patterns.size() - 1);
if (!last.getName().equals("*")) {
noStarWarning = "The catch-all pattern \"*\" should be present and in the last position.";
actionMessage = "Add missing \"*\" pattern.";
}
}
}
if (noStarWarning != null) {
msgs.addMessage("_warning_no_star", noStarWarning, new FixMissingStarsAction(actionMessage), IMessageProvider.WARNING);
} else {
msgs.removeMessage("_warning_no_star");
}
}
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