private ILicense getLicense(IInstallableUnit iu, ILicense license, String locale) { String body = (license != null ? license.getBody() : null); if (body == null || body.length() <= 1 || body.charAt(0) != '%') return license; final String actualKey = body.substring(1); // Strip off the % body = getLocalizedIUProperty(iu, actualKey, locale); return MetadataFactory.createLicense(license.getLocation(), body); }
public boolean isAccepted(ILicense license) { return accepted.contains(license.getUUID()); }
void handleSelectionChanged(IStructuredSelection selection) { if (!selection.isEmpty()) { Object selected = selection.getFirstElement(); if (selected instanceof License) licenseTextBox.setText(((License) selected).getBody()); else if (selected instanceof IUWithLicenseParent) licenseTextBox.setText(((IUWithLicenseParent) selected).license.getBody()); } }
public void widgetSelected(SelectionEvent e) { try { showURL(license.getLocation().toURL()); } catch (Exception e1) { //can't browse invalid location } } });
private void writeLicenses(Collection<ILicense> licenses) { if (licenses != null && licenses.size() > 0) { // In the future there may be more than one license, so we write this // as a collection of one. // See bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=216911 start(LICENSES_ELEMENT); attribute(COLLECTION_SIZE_ATTRIBUTE, licenses.size()); for (ILicense license : licenses) { if (license == null) continue; start(LICENSE_ELEMENT); if (license.getLocation() != null) { attribute(URI_ATTRIBUTE, license.getLocation().toString()); try { // we write the URL attribute for backwards compatibility with 3.4.x // this attribute should be removed if we make a breaking format change. attribute(URL_ATTRIBUTE, URIUtil.toURL(license.getLocation()).toExternalForm()); } catch (MalformedURLException e) { attribute(URL_ATTRIBUTE, license.getLocation().toString()); } } cdata(license.getBody(), true); end(LICENSE_ELEMENT); } end(LICENSES_ELEMENT); } }
public boolean reject(ILicense license) { accepted.remove(license.getUUID()); updatePreferences(); return true; }
private void writeLicenses(Collection<ILicense> licenses) { if (licenses != null && licenses.size() > 0) { // In the future there may be more than one license, so we write this // as a collection of one. // See bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=216911 start(LICENSES_ELEMENT); attribute(COLLECTION_SIZE_ATTRIBUTE, licenses.size()); for (ILicense license : licenses) { if (license == null) continue; start(LICENSE_ELEMENT); if (license.getLocation() != null) { attribute(URI_ATTRIBUTE, license.getLocation().toString()); try { // we write the URL attribute for backwards compatibility with 3.4.x // this attribute should be removed if we make a breaking format change. attribute(URL_ATTRIBUTE, URIUtil.toURL(license.getLocation()).toExternalForm()); } catch (MalformedURLException e) { attribute(URL_ATTRIBUTE, license.getLocation().toString()); } } cdata(license.getBody(), true); end(LICENSE_ELEMENT); } end(LICENSES_ELEMENT); } }
public boolean equals(Object obj) { if (obj == this) return true; if (obj == null) return false; if (obj instanceof ILicense) { ILicense other = (ILicense) obj; if (other.getUUID().equals(getUUID())) return true; } return false; }
private void writeLicenses(Collection<ILicense> licenses) { if (licenses != null && licenses.size() > 0) { // In the future there may be more than one license, so we write this // as a collection of one. // See bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=216911 start(LICENSES_ELEMENT); attribute(COLLECTION_SIZE_ATTRIBUTE, licenses.size()); for (ILicense license : licenses) { if (license == null) continue; start(LICENSE_ELEMENT); if (license.getLocation() != null) { attribute(URI_ATTRIBUTE, license.getLocation().toString()); try { // we write the URL attribute for backwards compatibility with 3.4.x // this attribute should be removed if we make a breaking format change. attribute(URL_ATTRIBUTE, URIUtil.toURL(license.getLocation()).toExternalForm()); } catch (MalformedURLException e) { attribute(URL_ATTRIBUTE, license.getLocation().toString()); } } cdata(license.getBody(), true); end(LICENSE_ELEMENT); } end(LICENSES_ELEMENT); } }
public boolean accept(ILicense license) { accepted.add(license.getUUID()); updatePreferences(); return true; }
final ILicense license = licenses.hasNext() ? licenses.next() : null; if (license != null && license.getBody().length() > 0) { Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); gd.heightHint = computeHeightLimit(text, 20); text.setLayoutData(gd); text.setText(license.getBody()); text.setEditable(false); String filename = (license.getLocation() != null) ? license.getLocation().getPath() : null; if (filename != null && (filename.endsWith(".htm") || filename.endsWith(".html"))) { //$NON-NLS-1$ //$NON-NLS-2$ Label label = new Label(composite, SWT.NONE); link.setText(NLS.bind("<a>{0}</a>", URIUtil.toUnencodedString(license.getLocation()))); //$NON-NLS-1$ gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = computeWidthLimit(link, 80);