]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/BundleDetailsPage.java
Clean session management.
[gpl/argeo-slc.git] / plugins / org.argeo.slc.client.ui.dist / src / main / java / org / argeo / slc / client / ui / dist / editors / BundleDetailsPage.java
index 38f53794161586fab44be6aad46174a4286d1ce1..e34c2dbf51ea51da0b38b6a24816446618406668 100644 (file)
@@ -31,6 +31,9 @@ import org.argeo.slc.client.ui.dist.DistImages;
 import org.argeo.slc.client.ui.dist.utils.AbstractHyperlinkListener;
 import org.argeo.slc.jcr.SlcNames;
 import org.argeo.slc.jcr.SlcTypes;
+import org.argeo.slc.repo.RepoConstants;
+import org.argeo.slc.repo.RepoUtils;
+import org.eclipse.jface.dialogs.IMessageProvider;
 import org.eclipse.jface.viewers.ColumnLabelProvider;
 import org.eclipse.jface.viewers.IStructuredContentProvider;
 import org.eclipse.jface.viewers.ITreeContentProvider;
@@ -44,6 +47,7 @@ import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Table;
 import org.eclipse.swt.widgets.Text;
@@ -61,9 +65,8 @@ import org.eclipse.ui.forms.widgets.ScrolledForm;
 import org.eclipse.ui.forms.widgets.Section;
 
 /**
- * Presents main information of a given OSGI bundle
+ * Present main information of a given OSGI bundle
  */
-
 public class BundleDetailsPage extends FormPage implements SlcNames, SlcTypes {
        // private final static Log log =
        // LogFactory.getLog(ArtifactDetailsPage.class);
@@ -87,6 +90,7 @@ public class BundleDetailsPage extends FormPage implements SlcNames, SlcTypes {
                        form.setText(currBundle.hasProperty(DistConstants.SLC_BUNDLE_NAME) ? currBundle
                                        .getProperty(DistConstants.SLC_BUNDLE_NAME).getString()
                                        : "");
+                       form.setMessage(" ", IMessageProvider.NONE);
                        Composite body = form.getBody();
                        GridLayout layout = new GridLayout(1, false);
                        layout.marginWidth = 5;
@@ -98,7 +102,7 @@ public class BundleDetailsPage extends FormPage implements SlcNames, SlcTypes {
                        createExportPackageSection(body);
                        createImportPackageSection(body);
                        createReqBundleSection(body);
-                       createMavenSnipet(body);
+                       createMavenSnippet(body);
 
                } catch (RepositoryException e) {
                        throw new SlcException("unexpected error "
@@ -106,7 +110,7 @@ public class BundleDetailsPage extends FormPage implements SlcNames, SlcTypes {
                }
        }
 
-       /** Add useful info for the current bundle */
+       /** Displays useful info for the current bundle */
        private void createdetailsPart(Composite parent) throws RepositoryException {
                Composite details = toolkit.createComposite(parent);
                GridLayout layout = new GridLayout(2, false);
@@ -116,12 +120,25 @@ public class BundleDetailsPage extends FormPage implements SlcNames, SlcTypes {
                createField(details, "Symbolic name", SlcNames.SLC_SYMBOLIC_NAME);
                createField(details, "Version", SlcNames.SLC_BUNDLE_VERSION);
                createField(details, "Group Id", SlcNames.SLC_GROUP_ID);
-               // Single sourcing issue: this does not works with rap
                createHyperlink(details, "Licence", DistConstants.SLC_BUNDLE_LICENCE);
-               // createField(details, "Licence", DistConstants.SLC_BUNDLE_LICENCE);
-
                createField(details, "Vendor", DistConstants.SLC_BUNDLE_VENDOR);
+               addSourceAvailableLabel(details);
+       }
+
+       // helper to check if sources are available
+       private void addSourceAvailableLabel(Composite parent) {
+               Button srcChk = toolkit.createButton(parent, "Sources available",
+                               SWT.CHECK);
+               srcChk.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
 
+               try {
+                       String srcPath = RepoUtils.relatedPdeSourcePath(
+                                       RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH, currBundle);
+                       srcChk.setSelection(currBundle.getSession().nodeExists(srcPath));
+               } catch (RepositoryException e) {
+                       throw new SlcException("Unable to check sources", e);
+               }
+               srcChk.setEnabled(false);
        }
 
        // Workaround to add an artificial level to the export package browser
@@ -512,7 +529,7 @@ public class BundleDetailsPage extends FormPage implements SlcNames, SlcTypes {
        }
 
        /** Creates a text area with corresponding maven snippet */
-       private void createMavenSnipet(Composite parent) {
+       private void createMavenSnippet(Composite parent) {
                mavenSnippet = new Text(parent, SWT.MULTI | SWT.WRAP | SWT.BORDER);
                GridData gd = new GridData(GridData.FILL_HORIZONTAL);
                gd.grabExcessHorizontalSpace = true;
@@ -526,9 +543,9 @@ public class BundleDetailsPage extends FormPage implements SlcNames, SlcTypes {
                try {
                        StringBuffer sb = new StringBuffer();
                        sb.append("<dependency>\n");
-                       sb.append("\t<groupeId>");
+                       sb.append("\t<groupId>");
                        sb.append(currBundle.getProperty(SLC_GROUP_ID).getString());
-                       sb.append("</groupeId>\n");
+                       sb.append("</groupId>\n");
                        sb.append("\t<artifactId>");
                        sb.append(currBundle.getProperty(SLC_ARTIFACT_ID).getString());
                        sb.append("</artifactId>\n");