diff --git a/components/blitz/src/pojos/DataObject.java b/components/blitz/src/pojos/DataObject.java
index 190f71eabda..deb830275b1 100644
--- a/components/blitz/src/pojos/DataObject.java
+++ b/components/blitz/src/pojos/DataObject.java
@@ -391,6 +391,17 @@ public Timestamp getUpdated() {
return timeOfEvent(getDetails().getUpdateEvent());
}
+ /**
+ * Returns the id of the group.
+ *
+ * @return See above.
+ */
+ public long getGroupId() {
+ Details d = getDetails();
+ if (d == null) return -1;
+ if (d.getGroup() == null) return -1;
+ return d.getGroup().getId().getValue();
+ }
// ~ VIEWS
// =========================================================================
// These methods should never a null value
diff --git a/components/blitz/src/pojos/ExperimenterData.java b/components/blitz/src/pojos/ExperimenterData.java
index 5299fec6a33..122ccb66e1c 100644
--- a/components/blitz/src/pojos/ExperimenterData.java
+++ b/components/blitz/src/pojos/ExperimenterData.java
@@ -294,4 +294,14 @@ public boolean isActive()
return false;
}
+ /**
+ * Overridden to return the id of the default group.
+ * @see DataObject#getGroupId()
+ */
+ public long getGroupId() {
+ GroupData g = getDefaultGroup();
+ if (g == null) return -1;
+ return g.getId();
+ }
+
}
diff --git a/components/blitz/src/pojos/GroupData.java b/components/blitz/src/pojos/GroupData.java
index fb31d9678af..b7994f41301 100644
--- a/components/blitz/src/pojos/GroupData.java
+++ b/components/blitz/src/pojos/GroupData.java
@@ -182,6 +182,13 @@ && asGroup().sizeOfGroupExperimenterMap() >= 0) {
return experimenters == null ? null : new HashSet(experimenters);
}
+ /**
+ * Overridden to return the id of the object.
+ * @see DataObject#getGroupId()
+ */
+ public long getGroupId() {
+ return getId();
+ }
// Link mutations
/**
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/AnnotatedFilter.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/AnnotatedFilter.java
index 0438ec900f9..a9f3fcdb85d 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/AnnotatedFilter.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/AnnotatedFilter.java
@@ -37,6 +37,7 @@
//Application-internal dependencies
import org.openmicroscopy.shoola.agents.dataBrowser.view.DataBrowser;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.CallHandle;
import pojos.DataObject;
import pojos.TagAnnotationData;
@@ -98,6 +99,7 @@ private void checkType(Class value)
*
* @param viewer The viewer this data loader is for.
* Mustn't be null
.
+ * @param ctx The security context.
* @param type One of the annotation type.
* Mustn't be null
.
* @param annotated Pass true
to filter the annotated nodes,
@@ -105,10 +107,10 @@ private void checkType(Class value)
* @param nodes The collection of objects to filter.
* Mustn't be null
.
*/
- public AnnotatedFilter(DataBrowser viewer, Class type, boolean annotated,
- Collection nodes)
+ public AnnotatedFilter(DataBrowser viewer, SecurityContext ctx, Class type,
+ boolean annotated, Collection nodes)
{
- super(viewer);
+ super(viewer, ctx);
if (nodes == null || nodes.size() == 0)
throw new IllegalArgumentException("No nodes to filter.");
checkType(type);
@@ -139,8 +141,8 @@ public AnnotatedFilter(DataBrowser viewer, Class type, boolean annotated,
public void load()
{
long userID = -1;//DataBrowserAgent.getUserDetails().getId();
- handle = mhView.filterByAnnotated(nodeType, nodeIds, annotationType,
- annotated, userID, this);
+ handle = mhView.filterByAnnotated(ctx, nodeType, nodeIds,
+ annotationType, annotated, userID, this);
}
/**
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/CommentsFilter.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/CommentsFilter.java
index f157afc3f89..893f3613b97 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/CommentsFilter.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/CommentsFilter.java
@@ -35,6 +35,7 @@
//Application-internal dependencies
import org.openmicroscopy.shoola.agents.dataBrowser.view.DataBrowser;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.CallHandle;
import pojos.DataObject;
import pojos.TextualAnnotationData;
@@ -78,16 +79,17 @@ public class CommentsFilter
*
* @param viewer The viewer this data loader is for.
* Mustn't be null
.
+ * @param ctx The security context.
* @param comments The collection of comments to filter by.
* If null
or empty
* retrieve the uncommented objects.
* @param nodes The collection of objects to filter.
* Mustn't be null
.
*/
- public CommentsFilter(DataBrowser viewer, List comments,
- Collection nodes)
+ public CommentsFilter(DataBrowser viewer, SecurityContext ctx,
+ List comments, Collection nodes)
{
- super(viewer);
+ super(viewer, ctx);
if (nodes == null || nodes.size() == 0)
throw new IllegalArgumentException("No nodes to filter.");
this.comments = comments;
@@ -116,8 +118,8 @@ public CommentsFilter(DataBrowser viewer, List comments,
public void load()
{
long userID = -1;//DataBrowserAgent.getUserDetails().getId();
- handle = mhView.filterByAnnotation(nodeType, nodeIds,
- TextualAnnotationData.class, comments, userID, this);
+ handle = mhView.filterByAnnotation(ctx, nodeType, nodeIds,
+ TextualAnnotationData.class, comments, userID, this);
}
/**
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/DataBrowserAgent.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/DataBrowserAgent.java
index a6dfaf7397b..815480f5cfe 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/DataBrowserAgent.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/DataBrowserAgent.java
@@ -78,6 +78,16 @@ public class DataBrowserAgent
*/
public static Registry getRegistry() { return registry; }
+ /**
+ * Returns the available user groups.
+ *
+ * @return See above.
+ */
+ public static Set getAvailableUserGroups()
+ {
+ return (Set) registry.lookup(LookupNames.USER_GROUP_DETAILS);
+ }
+
/**
* Helper method returning the current user's details.
*
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/DataBrowserLoader.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/DataBrowserLoader.java
index 7972926c152..b11b5b30e01 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/DataBrowserLoader.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/DataBrowserLoader.java
@@ -32,6 +32,7 @@
import org.openmicroscopy.shoola.agents.dataBrowser.view.DataBrowser;
import org.openmicroscopy.shoola.env.config.Registry;
import org.openmicroscopy.shoola.env.data.events.DSCallAdapter;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.DataHandlerView;
import org.openmicroscopy.shoola.env.data.views.DataManagerView;
import org.openmicroscopy.shoola.env.data.views.HierarchyBrowsingView;
@@ -65,33 +66,39 @@ public abstract class DataBrowserLoader
{
/** The viewer this data loader is for. */
- protected final DataBrowser viewer;
+ protected final DataBrowser viewer;
/** Convenience reference for subclasses. */
- protected final Registry registry;
+ protected final Registry registry;
/** Convenience reference for subclasses. */
- protected final HierarchyBrowsingView hiBrwView;
+ protected final HierarchyBrowsingView hiBrwView;
/** Convenience reference for subclasses. */
- protected final DataHandlerView dhView;
+ protected final DataHandlerView dhView;
/** Convenience reference for subclasses. */
- protected final MetadataHandlerView mhView;
+ protected final MetadataHandlerView mhView;
/** Convenience reference for subclasses. */
- protected final DataManagerView dmView;
+ protected final DataManagerView dmView;
+
+ /** The security context.*/
+ protected final SecurityContext ctx;
/**
* Creates a new instance.
*
* @param viewer The viewer this data loader is for.
* Mustn't be null
.
+ * @param ctx The security context.
*/
- protected DataBrowserLoader(DataBrowser viewer)
+ protected DataBrowserLoader(DataBrowser viewer, SecurityContext ctx)
{
- if (viewer == null) throw new NullPointerException("No viewer.");
+ if (viewer == null) throw new NullPointerException("No viewer.");
+ if (ctx == null) throw new NullPointerException("No security context.");
this.viewer = viewer;
+ this.ctx = ctx;
registry = DataBrowserAgent.getRegistry();
hiBrwView = (HierarchyBrowsingView)
registry.getDataServicesView(HierarchyBrowsingView.class);
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/DataBrowserTranslator.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/DataBrowserTranslator.java
index 82f54d8f533..afc62b4ed73 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/DataBrowserTranslator.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/DataBrowserTranslator.java
@@ -44,6 +44,7 @@
import pojos.DatasetData;
import pojos.ExperimenterData;
import pojos.FileData;
+import pojos.GroupData;
import pojos.ImageData;
import pojos.MultiImageData;
import pojos.PermissionData;
@@ -565,6 +566,36 @@ else if (ho instanceof ImageData) {
return results;
}
+ /**
+ * Transforms a set of {@link DataObject}s into their corresponding
+ * visualization objects. The elements of the set only be {@link ImageData}.
+ * The {@link ImageData}s are added to a {@link ImageSet}.
+ *
+ * @param dataObjects The {@link DataObject}s to transform.
+ * Mustn't be null
.
+ * @param userID The id of the current user.
+ * @param group The the group the current user selects when
+ * retrieving the data.
+ * @return See above.
+ */
+ public static ImageSet transformObjects(Collection dataObjects, long userID,
+ GroupData group)
+ {
+ if (dataObjects == null)
+ throw new IllegalArgumentException("No objects.");
+ Set results = new HashSet();
+ DataObject ho;
+ Iterator i = dataObjects.iterator();
+ long groupId = group.getId();
+ ImageSet groupNode = new ImageSet(group.getName(), group);
+ while (i.hasNext()) {
+ ho = (DataObject) i.next();
+ if (isReadable(ho, userID, groupId) && ho instanceof ImageData)
+ linkImageTo((ImageData) ho, groupNode);
+ }
+ return groupNode;
+ }
+
/**
* Transforms a set of {@link DataObject}s into their corresponding
* visualization objects. The elements of the set only be {@link ImageData}.
@@ -573,26 +604,25 @@ else if (ho instanceof ImageData) {
* @param dataObjects The {@link DataObject}s to transform.
* Mustn't be null
.
* @param userID The id of the current user.
- * @param groupID The id of the group the current user selects when
- * retrieving the data.
+ * @param groupId The id of the group the current user selects when
+ * retrieving the data.
* @return See above.
*/
- public static Set transformObjects(Collection dataObjects, long userID,
- long groupID)
+ public static Set transformObjects(Collection dataObjects,
+ long userID, long groupId)
{
if (dataObjects == null)
throw new IllegalArgumentException("No objects.");
- Set results = new HashSet();
+ Set results = new HashSet();
DataObject ho;
Iterator i = dataObjects.iterator();
while (i.hasNext()) {
ho = (DataObject) i.next();
- if (isReadable(ho, userID, groupID) && ho instanceof ImageData)
+ if (isReadable(ho, userID, groupId) && ho instanceof ImageData)
results.add(linkImageTo((ImageData) ho, null));
}
return results;
}
-
/**
* Transforms a set of {@link DataObject}s into their corresponding
* visualization objects. The elements of the set only be {@link ImageData}.
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/DataFilter.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/DataFilter.java
index 63b4acd8df0..0a1bd4e1def 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/DataFilter.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/DataFilter.java
@@ -36,6 +36,7 @@
//Application-internal dependencies
import org.openmicroscopy.shoola.agents.dataBrowser.view.DataBrowser;
import org.openmicroscopy.shoola.env.data.util.FilterContext;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.CallHandle;
import pojos.DataObject;
@@ -78,14 +79,15 @@ public class DataFilter
*
* @param viewer The viewer this data loader is for.
* Mustn't be null
.
+ * @param ctx The security context.
* @param context The filtering context. Mustn't be null
.
* @param nodes The collection of objects to filter.
* Mustn't be null
.
*/
- public DataFilter(DataBrowser viewer, FilterContext context,
- Collection nodes)
+ public DataFilter(DataBrowser viewer, SecurityContext ctx,
+ FilterContext context, Collection nodes)
{
- super(viewer);
+ super(viewer, ctx);
if (nodes == null || nodes.size() == 0)
throw new IllegalArgumentException("No nodes to filter.");
if (context == null)
@@ -116,7 +118,8 @@ public DataFilter(DataBrowser viewer, FilterContext context,
public void load()
{
long userID = -1;//DataBrowserAgent.getUserDetails().getId();
- handle = mhView.filterData(nodeType, nodeIds, context, userID, this);
+ handle = mhView.filterData(ctx, nodeType, nodeIds, context, userID,
+ this);
}
/**
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/DataObjectCreator.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/DataObjectCreator.java
index 3086c811974..0e4ad55ce69 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/DataObjectCreator.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/DataObjectCreator.java
@@ -31,6 +31,7 @@
//Application-internal dependencies
import org.openmicroscopy.shoola.agents.dataBrowser.view.DataBrowser;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.CallHandle;
import pojos.DataObject;
@@ -70,16 +71,17 @@ public class DataObjectCreator
*
* @param viewer The viewer this data loader is for.
* Mustn't be null
.
+ * @param ctx The security context.
* @param parent The parent of the DataObject
to create
* or null
.
* @param data The DataObject
to create.
* Mustn't be null
.
* @param children The nodes to add to the newly created object.
*/
- public DataObjectCreator(DataBrowser viewer, DataObject parent,
- DataObject data, Collection children)
+ public DataObjectCreator(DataBrowser viewer, SecurityContext ctx,
+ DataObject parent, DataObject data, Collection children)
{
- super(viewer);
+ super(viewer, ctx);
if (data == null)
throw new IllegalArgumentException("No object to create.");
this.data = data;
@@ -99,7 +101,7 @@ public DataObjectCreator(DataBrowser viewer, DataObject parent,
*/
public void load()
{
- handle = mhView.createDataObject(parent, data, children, this);
+ handle = mhView.createDataObject(ctx, parent, data, children, this);
}
/**
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/DataObjectSaver.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/DataObjectSaver.java
index e2bd8b71dc1..08bf288be9b 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/DataObjectSaver.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/DataObjectSaver.java
@@ -30,6 +30,7 @@
//Application-internal dependencies
import org.openmicroscopy.shoola.agents.dataBrowser.view.DataBrowser;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.CallHandle;
/**
@@ -63,14 +64,15 @@ public class DataObjectSaver
*
* @param viewer The viewer this data loader is for.
* Mustn't be null
.
+ * @param ctx The security context.
* @param datasets The datasets to add the images to.
* Mustn't be null
.
* @param images The images to add. Mustn't be null
.
*/
- public DataObjectSaver(DataBrowser viewer, Collection datasets,
- Collection images)
+ public DataObjectSaver(DataBrowser viewer, SecurityContext ctx,
+ Collection datasets, Collection images)
{
- super(viewer);
+ super(viewer, ctx);
if (datasets == null || datasets.size() == 0)
throw new IllegalArgumentException("No datasets to add the images" +
" to.");
@@ -93,7 +95,7 @@ public DataObjectSaver(DataBrowser viewer, Collection datasets,
public void load()
{
- handle = dmView.addExistingObjects(datasets, images, this);
+ handle = dmView.addExistingObjects(ctx, datasets, images, this);
}
/**
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/DatasetsLoader.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/DatasetsLoader.java
index 9d4847cc093..66d43257862 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/DatasetsLoader.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/DatasetsLoader.java
@@ -31,6 +31,7 @@
//Application-internal dependencies
import org.openmicroscopy.shoola.agents.dataBrowser.view.DataBrowser;
import org.openmicroscopy.shoola.agents.metadata.MetadataViewerAgent;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.CallHandle;
import pojos.DatasetData;
import pojos.ExperimenterData;
@@ -62,10 +63,11 @@ public class DatasetsLoader
*
* @param viewer The viewer this data loader is for.
* Mustn't be null
.
+ * @param ctx The security context.
*/
- public DatasetsLoader(DataBrowser viewer)
+ public DatasetsLoader(DataBrowser viewer, SecurityContext ctx)
{
- super(viewer);
+ super(viewer, ctx);
}
/**
@@ -86,7 +88,7 @@ public void load()
ExperimenterData exp = MetadataViewerAgent.getUserDetails();
GroupData group = exp.getDefaultGroup();
- handle = dmView.loadContainerHierarchy(DatasetData.class, null,
+ handle = dmView.loadContainerHierarchy(ctx, DatasetData.class, null,
false, exp.getId(), group.getId(), this);
}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/IconManager.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/IconManager.java
index 25138677e45..f3ec4ae7b0e 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/IconManager.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/IconManager.java
@@ -209,13 +209,28 @@ public class IconManager
public static final int FILTER_BY_MENU = 50;
/** The Send comment
icon. */
- public static final int SEND_COMMENT = 51;
+ public static final int SEND_COMMENT = 51;
+
+ /** The Personal
icon. */
+ public static final int PERSONAL = 52;
+
+ /** The Private Group
icon. */
+ public static final int PRIVATE_GROUP = 53;
+
+ /** The Read Group
icon. */
+ public static final int READ_GROUP = 54;
+
+ /** The Read Link Group
icon. */
+ public static final int READ_LINK_GROUP = 55;
+
+ /** The Public Group
icon. */
+ public static final int PUBLIC_GROUP = 56;
/**
* The maximum ID used for the icon IDs.
* Allows to correctly build arrays for direct indexing.
*/
- private static final int MAX_ID = 51;
+ private static final int MAX_ID = 56;
/** Paths of the icon files. */
private static String[] relPaths = new String[MAX_ID+1];
@@ -274,6 +289,11 @@ public class IconManager
relPaths[TAG_FILTER] = "eclipse_filter_ps16.png";
relPaths[FILTER_BY_MENU] = "eclipse_view_menu16.png";
relPaths[SEND_COMMENT] = "nuvola_mail_send16.png";
+ relPaths[PRIVATE_GROUP] = "nuvola_ledred16.png";
+ relPaths[READ_GROUP] = "nuvola_ledorange_readOnly16.png";
+ relPaths[READ_LINK_GROUP] = "nuvola_ledorange16.png";
+ relPaths[PUBLIC_GROUP] = "nuvola_ledgreen16.png";
+ relPaths[PERSONAL] = "nuvola_personal16.png";
}
/** The sole instance. */
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/PlateSaver.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/PlateSaver.java
index 29774ae60d6..b23eb5c4e93 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/PlateSaver.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/PlateSaver.java
@@ -30,6 +30,7 @@
//Application-internal dependencies
import org.openmicroscopy.shoola.agents.dataBrowser.view.DataBrowser;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.CallHandle;
import pojos.DataObject;
@@ -61,11 +62,13 @@ public class PlateSaver
*
* @param viewer The viewer this data loader is for.
* Mustn't be null
.
+ * @param ctx The security context.
* @param toUpdate The collection of objects to update.
*/
- public PlateSaver(DataBrowser viewer, List toUpdate)
+ public PlateSaver(DataBrowser viewer, SecurityContext ctx,
+ List toUpdate)
{
- super(viewer);
+ super(viewer, ctx);
if (toUpdate == null || toUpdate.size() == 0)
throw new IllegalArgumentException("No objects to update.");
this.toUpdate = toUpdate;
@@ -83,7 +86,7 @@ public PlateSaver(DataBrowser viewer, List toUpdate)
*/
public void load()
{
- handle = mhView.updateDataObjects(toUpdate, this);
+ handle = mhView.updateDataObjects(ctx, toUpdate, this);
}
/**
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/RateFilter.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/RateFilter.java
index 87d1058df79..291cbea4a04 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/RateFilter.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/RateFilter.java
@@ -35,6 +35,7 @@
//Application-internal dependencies
import org.openmicroscopy.shoola.agents.dataBrowser.view.DataBrowser;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.CallHandle;
import pojos.DataObject;
import pojos.RatingAnnotationData;
@@ -136,14 +137,15 @@ private RatingAnnotationData getAnnotation(List ratings)
*
* @param viewer The viewer this data loader is for.
* Mustn't be null
.
+ * @param ctx The security context.
* @param rate One of the constants defined by this class.
* @param nodes The collection of objects to filter.
* Mustn't be null
.
*/
- public RateFilter(DataBrowser viewer, int rate,
+ public RateFilter(DataBrowser viewer, SecurityContext ctx, int rate,
Collection nodes)
{
- super(viewer);
+ super(viewer, ctx);
if (nodes == null || nodes.size() == 0)
throw new IllegalArgumentException("No nodes to filter.");
checkRate(rate);
@@ -173,7 +175,7 @@ public RateFilter(DataBrowser viewer, int rate,
public void load()
{
long userID = -1;//DataBrowserAgent.getUserDetails().getId();
- handle = mhView.loadRatings(nodeType, nodeIds, userID, this);
+ handle = mhView.loadRatings(ctx, nodeType, nodeIds, userID, this);
}
/**
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/ReportLoader.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/ReportLoader.java
index 91c80b7d9d9..df7f5a62396 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/ReportLoader.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/ReportLoader.java
@@ -39,6 +39,7 @@
//Application-internal dependencies
import org.openmicroscopy.shoola.agents.dataBrowser.browser.ImageNode;
import org.openmicroscopy.shoola.agents.dataBrowser.view.DataBrowser;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.util.StructuredDataResults;
import org.openmicroscopy.shoola.env.data.views.CallHandle;
import pojos.DataObject;
@@ -83,14 +84,15 @@ public class ReportLoader
*
* @param viewer The viewer this data loader is for.
* Mustn't be null
.
+ * @param ctx The security context.
* @param types The types of annotation to add to the report.
* @param images The images the report is for.
* @param path The name of the report file.
*/
- public ReportLoader(DataBrowser viewer, List types,
- Collection images, String path)
+ public ReportLoader(DataBrowser viewer, SecurityContext ctx,
+ List types, Collection images, String path)
{
- super(viewer);
+ super(viewer, ctx);
if (images == null || images.size() == 0)
throw new IllegalArgumentException("No images specified.");
if (path == null || path.trim().length() == 0)
@@ -122,7 +124,7 @@ public ReportLoader(DataBrowser viewer, List types,
*/
public void load()
{
- handle = mhView.loadStructuredData(nodes, -1, false, this);
+ handle = mhView.loadStructuredData(ctx, nodes, -1, false, this);
}
/**
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/TabularDataLoader.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/TabularDataLoader.java
index 47ba1cd2e1e..5d016cc8a71 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/TabularDataLoader.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/TabularDataLoader.java
@@ -32,6 +32,7 @@
import org.openmicroscopy.shoola.agents.dataBrowser.view.DataBrowser;
import org.openmicroscopy.shoola.env.data.model.TableParameters;
import org.openmicroscopy.shoola.env.data.model.TableResult;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.CallHandle;
import pojos.DataObject;
import pojos.PlateData;
@@ -65,11 +66,13 @@ public class TabularDataLoader
*
* @param viewer The viewer this data loader is for.
* Mustn't be null
.
+ * @param ctx The security context.
* @param ids The identifier of the files hosting the tabular data.
*/
- public TabularDataLoader(DataBrowser viewer, List ids)
+ public TabularDataLoader(DataBrowser viewer, SecurityContext ctx,
+ List ids)
{
- super(viewer);
+ super(viewer, ctx);
if (ids == null || ids.size() <= 0)
throw new IllegalArgumentException("No file to retrieve.");
parameters = new TableParameters(ids);
@@ -80,11 +83,13 @@ public TabularDataLoader(DataBrowser viewer, List ids)
*
* @param viewer The viewer this data loader is for.
* Mustn't be null
.
+ * @param ctx The security context.
* @param object The object to handle. Mustn't be null
.
*/
- public TabularDataLoader(DataBrowser viewer, DataObject object)
+ public TabularDataLoader(DataBrowser viewer, SecurityContext ctx,
+ DataObject object)
{
- super(viewer);
+ super(viewer, ctx);
if (object == null)
throw new IllegalArgumentException("No file to retrieve.");
if (!(object instanceof PlateData || object instanceof ScreenData)) {
@@ -99,7 +104,7 @@ public TabularDataLoader(DataBrowser viewer, DataObject object)
*/
public void load()
{
- handle = mhView.loadTabularData(parameters, -1, this);
+ handle = mhView.loadTabularData(ctx, parameters, -1, this);
}
/**
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/TagsFilter.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/TagsFilter.java
index 453b0ff33fa..ed9e41a899c 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/TagsFilter.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/TagsFilter.java
@@ -35,6 +35,7 @@
//Application-internal dependencies
import org.openmicroscopy.shoola.agents.dataBrowser.view.DataBrowser;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.CallHandle;
import pojos.DataObject;
import pojos.TagAnnotationData;
@@ -78,16 +79,17 @@ public class TagsFilter
*
* @param viewer The viewer this data loader is for.
* Mustn't be null
.
+ * @param ctx The security context.
* @param tags The collection of tags to filter by.
* If null
or empty
* retrieve the uncommented objects.
* @param nodes The collection of objects to filter.
* Mustn't be null
.
*/
- public TagsFilter(DataBrowser viewer, List tags,
- Collection nodes)
+ public TagsFilter(DataBrowser viewer, SecurityContext ctx,
+ List tags, Collection nodes)
{
- super(viewer);
+ super(viewer, ctx);
if (nodes == null || nodes.size() == 0)
throw new IllegalArgumentException("No nodes to filter.");
this.tags = tags;
@@ -116,7 +118,7 @@ public TagsFilter(DataBrowser viewer, List tags,
public void load()
{
long userID = -1;//DataBrowserAgent.getUserDetails().getId();
- handle = mhView.filterByAnnotation(nodeType, nodeIds,
+ handle = mhView.filterByAnnotation(ctx, nodeType, nodeIds,
TagAnnotationData.class, tags, userID, this);
}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/TagsLoader.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/TagsLoader.java
index 294a93b53ca..50e0ac22f9b 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/TagsLoader.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/TagsLoader.java
@@ -31,6 +31,7 @@
//Application-internal dependencies
import org.openmicroscopy.shoola.agents.dataBrowser.view.DataBrowser;
import org.openmicroscopy.shoola.env.data.model.AdminObject;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.CallHandle;
import pojos.ExperimenterData;
import pojos.TagAnnotationData;
@@ -62,10 +63,11 @@ public class TagsLoader
*
* @param viewer The viewer this data loader is for.
* Mustn't be null
.
+ * @param ctx The security context.
*/
- public TagsLoader(DataBrowser viewer)
+ public TagsLoader(DataBrowser viewer, SecurityContext ctx)
{
- super(viewer);
+ super(viewer, ctx);
}
/**
@@ -97,7 +99,7 @@ public void load()
userID = -1;
}
- handle = mhView.loadExistingAnnotations(TagAnnotationData.class,
+ handle = mhView.loadExistingAnnotations(ctx, TagAnnotationData.class,
userID, groupID, this);
}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/ThumbnailFieldsLoader.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/ThumbnailFieldsLoader.java
index 1267eb6796d..6266d7d7b3a 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/ThumbnailFieldsLoader.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/ThumbnailFieldsLoader.java
@@ -32,6 +32,7 @@
//Application-internal dependencies
import org.openmicroscopy.shoola.agents.dataBrowser.view.DataBrowser;
import org.openmicroscopy.shoola.env.data.events.DSCallFeedbackEvent;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.CallHandle;
import pojos.DataObject;
@@ -72,16 +73,17 @@ public class ThumbnailFieldsLoader
*
* @param viewer The viewer this data loader is for.
* Mustn't be null
.
+ * @param ctx The security context.
* @param images The ImageData
objects for the images whose
* thumbnails have to be fetched.
* Mustn't be null
.
* @param row The row identifying the well.
* @param column The column identifying the well.
*/
- public ThumbnailFieldsLoader(DataBrowser viewer,
+ public ThumbnailFieldsLoader(DataBrowser viewer, SecurityContext ctx,
Collection images, int row, int column)
{
- super(viewer);
+ super(viewer, ctx);
if (images == null)
throw new IllegalArgumentException("Collection shouldn't be null.");
this.images = images;
@@ -96,7 +98,7 @@ public ThumbnailFieldsLoader(DataBrowser viewer,
public void load()
{
long userID = DataBrowserAgent.getUserDetails().getId();
- handle = hiBrwView.loadThumbnails(images,
+ handle = hiBrwView.loadThumbnails(ctx, images,
ThumbnailProvider.THUMB_MAX_WIDTH,
ThumbnailProvider.THUMB_MAX_HEIGHT,
userID, ThumbnailLoader.IMAGE, this);
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/ThumbnailLoader.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/ThumbnailLoader.java
index 8d6c12d73c6..52a591ab4ba 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/ThumbnailLoader.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/ThumbnailLoader.java
@@ -35,6 +35,7 @@
import org.openmicroscopy.shoola.agents.dataBrowser.view.DataBrowser;
import org.openmicroscopy.shoola.env.data.events.DSCallFeedbackEvent;
import org.openmicroscopy.shoola.env.data.model.ThumbnailData;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.CallHandle;
import org.openmicroscopy.shoola.env.data.views.HierarchyBrowsingView;
import pojos.DataObject;
@@ -102,13 +103,14 @@ public class ThumbnailLoader
*
* @param viewer The viewer this data loader is for.
* Mustn't be null
.
+ * @param ctx The security context.
* @param objects The DataObject
s associated to the images
* to fetch. Mustn't be null
.
*/
- public ThumbnailLoader(DataBrowser viewer, Collection objects,
- int type)
+ public ThumbnailLoader(DataBrowser viewer, SecurityContext ctx,
+ Collection objects, int type)
{
- this(viewer, objects, true, type);
+ this(viewer, ctx, objects, true, type);
}
/**
@@ -116,12 +118,14 @@ public ThumbnailLoader(DataBrowser viewer, Collection objects,
*
* @param viewer The viewer this data loader is for.
* Mustn't be null
.
+ * @param ctx The security context.
* @param objects The DataObject
s associated to the images
* to fetch. Mustn't be null
.
*/
- public ThumbnailLoader(DataBrowser viewer, Collection objects)
+ public ThumbnailLoader(DataBrowser viewer, SecurityContext ctx,
+ Collection objects)
{
- this(viewer, objects, true, IMAGE);
+ this(viewer, ctx, objects, true, IMAGE);
}
/**
@@ -129,16 +133,17 @@ public ThumbnailLoader(DataBrowser viewer, Collection objects)
*
* @param viewer The viewer this data loader is for.
* Mustn't be null
.
+ * @param ctx The security context.
* @param objects The DataObject
s associated to the images
* to fetch. Mustn't be null
.
* @param thumbnail Pass true
to retrieve image at a thumbnail
* size, false
otherwise.
* @param type The type of thumbnails to load.
*/
- public ThumbnailLoader(DataBrowser viewer, Collection objects,
- boolean thumbnail, int type)
+ public ThumbnailLoader(DataBrowser viewer, SecurityContext ctx,
+ Collection objects, boolean thumbnail, int type)
{
- super(viewer);
+ super(viewer, ctx);
if (objects == null)
throw new IllegalArgumentException("Collection shouldn't be null.");
if (type < 0) this.type = IMAGE;
@@ -156,12 +161,12 @@ public void load()
{
long userID = DataBrowserAgent.getUserDetails().getId();
if (thumbnail)
- handle = hiBrwView.loadThumbnails(objects,
+ handle = hiBrwView.loadThumbnails(ctx, objects,
ThumbnailProvider.THUMB_MAX_WIDTH,
ThumbnailProvider.THUMB_MAX_HEIGHT,
userID, type, this);
else
- handle = hiBrwView.loadThumbnails(objects,
+ handle = hiBrwView.loadThumbnails(ctx, objects,
3*ThumbnailProvider.THUMB_MAX_WIDTH,
3*ThumbnailProvider.THUMB_MAX_HEIGHT,
userID, type, this);
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/actions/MoveToAction.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/actions/MoveToAction.java
new file mode 100644
index 00000000000..d605db1a77e
--- /dev/null
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/actions/MoveToAction.java
@@ -0,0 +1,139 @@
+/*
+ * org.openmicroscopy.shoola.agents.treeviewer.actions.MoveToAction
+ *
+ *------------------------------------------------------------------------------
+ * Copyright (C) 2006-2012 University of Dundee & Open Microscopy Environment.
+ * All rights reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *------------------------------------------------------------------------------
+ */
+package org.openmicroscopy.shoola.agents.dataBrowser.actions;
+
+
+
+//Java imports
+import java.awt.event.ActionEvent;
+import java.util.List;
+
+import javax.swing.Action;
+import javax.swing.Icon;
+
+
+//Third-party libraries
+
+//Application-internal dependencies
+import org.openmicroscopy.shoola.agents.dataBrowser.DataBrowserAgent;
+import org.openmicroscopy.shoola.agents.dataBrowser.IconManager;
+import org.openmicroscopy.shoola.agents.dataBrowser.browser.Browser;
+import org.openmicroscopy.shoola.agents.dataBrowser.view.DataBrowser;
+import org.openmicroscopy.shoola.agents.events.treeviewer.MoveToEvent;
+import org.openmicroscopy.shoola.env.data.model.AdminObject;
+import org.openmicroscopy.shoola.util.ui.UIUtilities;
+
+import pojos.DataObject;
+import pojos.GroupData;
+
+/**
+ * Indicates to move the data to the selected group.
+ *
+ * @author Jean-Marie Burel
+ * j.burel@dundee.ac.uk
+ * @since Beta4.4
+ */
+public class MoveToAction
+ extends DataBrowserAction
+{
+
+ /** The name of the action.*/
+ public static final String NAME = "Move to";
+
+ /** The name of the action.*/
+ public static final String DESCRIPTION = "Select the group where to" +
+ " move the data.";
+
+ /** The group to move the data to.*/
+ private GroupData group;
+
+ /**
+ * Sets the icon and tool tip text according to the permissions of the
+ * group.
+ */
+ private void setPermissions()
+ {
+ IconManager im = IconManager.getInstance();
+ Icon icon = im.getIcon(IconManager.PERSONAL);
+ int level =
+ DataBrowserAgent.getRegistry().getAdminService().getPermissionLevel(
+ group);
+ String desc = "";
+ switch (level) {
+ case AdminObject.PERMISSIONS_PRIVATE:
+ desc = AdminObject.PERMISSIONS_PRIVATE_TEXT;
+ icon = im.getIcon(IconManager.PRIVATE_GROUP);
+ break;
+ case AdminObject.PERMISSIONS_GROUP_READ:
+ desc = AdminObject.PERMISSIONS_GROUP_READ_TEXT;
+ icon = im.getIcon(IconManager.READ_GROUP);
+ break;
+ case AdminObject.PERMISSIONS_GROUP_READ_LINK:
+ desc = AdminObject.PERMISSIONS_GROUP_READ_LINK_TEXT;
+ icon = im.getIcon(IconManager.READ_LINK_GROUP);
+ break;
+ case AdminObject.PERMISSIONS_PUBLIC_READ:
+ desc = AdminObject.PERMISSIONS_PUBLIC_READ_TEXT;
+ icon = im.getIcon(IconManager.PUBLIC_GROUP);
+ break;
+ case AdminObject.PERMISSIONS_PUBLIC_READ_WRITE:
+ desc = AdminObject.PERMISSIONS_PUBLIC_READ_WRITE_TEXT;
+ icon = im.getIcon(IconManager.PUBLIC_GROUP);
+ }
+
+ putValue(Action.SMALL_ICON, icon);
+ putValue(Action.SHORT_DESCRIPTION, UIUtilities.formatToolTipText(desc));
+ }
+
+ /**
+ * Creates a new instance.
+ *
+ * @param model Reference to the Model. Mustn't be null
.
+ * @param group The selected group.
+ */
+ public MoveToAction(DataBrowser model, GroupData group)
+ {
+ super(model);
+ if (group == null)
+ throw new IllegalArgumentException("No group.");
+ this.group = group;
+ setEnabled(true);
+ putValue(Action.NAME, group.getName()+"...");
+ setPermissions();
+ }
+
+ /**
+ * Moves the selected objects to the group.
+ * @see java.awt.event.ActionListener#actionPerformed(ActionEvent)
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ Browser b = model.getBrowser();
+ if (b == null) return;
+ MoveToEvent evt = new MoveToEvent(group, (List)
+ b.getSelectedDataObjects());
+ DataBrowserAgent.getRegistry().getEventBus().post(evt);
+ }
+
+}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/actions/TaggingAction.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/actions/TaggingAction.java
index df8c78c0912..f583863325f 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/actions/TaggingAction.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/actions/TaggingAction.java
@@ -25,6 +25,11 @@
//Java imports
import java.awt.event.ActionEvent;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
import javax.swing.Action;
//Third-party libraries
@@ -35,6 +40,7 @@
import org.openmicroscopy.shoola.agents.dataBrowser.view.DataBrowser;
import org.openmicroscopy.shoola.util.ui.UIUtilities;
+import pojos.DataObject;
import pojos.DatasetData;
import pojos.ImageData;
import pojos.PlateData;
@@ -74,11 +80,22 @@ protected void onDisplayChange(ImageDisplay node)
setEnabled(false);
return;
}
- Object object = node.getHierarchyObject();
- if (object instanceof ImageData || object instanceof DatasetData ||
- object instanceof ProjectData || object instanceof ScreenData ||
- object instanceof PlateData) {
- setEnabled(model.isWritable(object));
+ Object ho = node.getHierarchyObject();
+ if (ho instanceof ImageData || ho instanceof DatasetData ||
+ ho instanceof ProjectData || ho instanceof ScreenData ||
+ ho instanceof PlateData) {
+ if (model.isWritable(ho)) {
+ Collection l = model.getBrowser().getSelectedDataObjects();
+ List ids = new ArrayList();
+ Iterator i = l.iterator();
+ DataObject data;
+ while (i.hasNext()) {
+ data = (DataObject) i.next();
+ if (!ids.contains(data.getGroupId()))
+ ids.add(data.getGroupId());
+ }
+ setEnabled(ids.size() == 1);
+ } else setEnabled(false);
} else setEnabled(false);
}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/browser/BrowserControl.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/browser/BrowserControl.java
index c4224bd0771..8c6e61fcf29 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/browser/BrowserControl.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/browser/BrowserControl.java
@@ -530,7 +530,7 @@ public void mousePressed(MouseEvent me)
ctrl = me.isControlDown();
if (UIUtilities.isMacOS()) ctrl = me.isMetaDown();
leftMouseButton = SwingUtilities.isLeftMouseButton(me);
- if (UIUtilities.isMacOS() || UIUtilities.isLinuxOS())
+ if (!UIUtilities.isWindowsOS())
onClick(me, false);
}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/browser/BrowserModel.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/browser/BrowserModel.java
index dba496f12ea..e2eeef86d44 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/browser/BrowserModel.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/browser/BrowserModel.java
@@ -263,33 +263,40 @@ void setSelectedCell(CellDisplay cell)
String currentPathString(ImageDisplay parent)
{
StringBuffer buf = new StringBuffer();
- StringBuffer titleBuf = new StringBuffer();
+ List titleBuf = new ArrayList();
while (parent != null && !(parent instanceof RootDisplay)) {
if (parent instanceof CellDisplay) {
int type = ((CellDisplay) parent).getType();
if (type == CellDisplay.TYPE_HORIZONTAL)
- titleBuf.append("column: "+parent.getTitle());
- else titleBuf.append("row: "+parent.getTitle());
+ titleBuf.add("column: "+parent.getTitle());
+ else titleBuf.add("row: "+parent.getTitle());
} else if (parent instanceof WellImageSet) {
WellImageSet wiNode = (WellImageSet) parent;
- titleBuf.append(wiNode.getTitle());
+ titleBuf.add(wiNode.getTitle());
} else if (parent instanceof WellSampleNode) {
Object o = ((WellSampleNode) parent).getParentObject();
if (o instanceof WellData) {
- titleBuf.append(((WellData) o).getPlate().getName());
- if (titleBuf.length() != 0)
- titleBuf.append(" > ");
- titleBuf.append(parent.getTitle());
- if (titleBuf.length() == 0) titleBuf.append("[..]");
+ titleBuf.add(((WellData) o).getPlate().getName());
+ //if (titleBuf.s() != 0)
+ // titleBuf.append(" > ");
+ titleBuf.add(parent.getTitle());
+ if (titleBuf.size() == 0) titleBuf.add("[..]");
+ //if (titleBuf.length() == 0) titleBuf.append("[..]");
}
} else {
- titleBuf.append(parent.getTitle());
- if (titleBuf.length() == 0) titleBuf.append("[..]");
- if (parent instanceof ImageSet) buf.insert(0, " > ");
+ //titleBuf.append(parent.getTitle());
+ titleBuf.add(parent.getTitle());
+ //if (titleBuf.length() == 0) titleBuf.append("[..]");
+ //if (parent instanceof ImageSet) buf.insert(0, " > ");
}
- buf.insert(0, titleBuf.toString());
+ //buf.insert(0, titleBuf.toString());
parent = parent.getParentDisplay();
}
+ int n = titleBuf.size();
+ for (int i = 0; i < n; i++) {
+ buf.append(titleBuf.get(n-1-i));
+ if (i != (n-1)) buf.append(">");
+ }
return buf.toString();
}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/browser/ImageSet.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/browser/ImageSet.java
index c0b8ac5fbfc..00b5bc802b8 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/browser/ImageSet.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/browser/ImageSet.java
@@ -22,10 +22,10 @@
*/
package org.openmicroscopy.shoola.agents.dataBrowser.browser;
-import java.awt.event.KeyListener;
//Java imports
+import java.awt.event.KeyListener;
//Third-party libraries
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/graphx/nuvola_ledgreen16.png b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/graphx/nuvola_ledgreen16.png
new file mode 100644
index 00000000000..08b9c9d4d00
Binary files /dev/null and b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/graphx/nuvola_ledgreen16.png differ
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/graphx/nuvola_ledorange16.png b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/graphx/nuvola_ledorange16.png
new file mode 100644
index 00000000000..f8545721c98
Binary files /dev/null and b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/graphx/nuvola_ledorange16.png differ
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/graphx/nuvola_ledorange_readLink16.png b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/graphx/nuvola_ledorange_readLink16.png
new file mode 100644
index 00000000000..4d35a7cad83
Binary files /dev/null and b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/graphx/nuvola_ledorange_readLink16.png differ
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/graphx/nuvola_ledorange_readOnly16.png b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/graphx/nuvola_ledorange_readOnly16.png
new file mode 100644
index 00000000000..ab94ebb4cc3
Binary files /dev/null and b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/graphx/nuvola_ledorange_readOnly16.png differ
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/graphx/nuvola_ledred16.png b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/graphx/nuvola_ledred16.png
new file mode 100644
index 00000000000..bdb53d4e571
Binary files /dev/null and b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/graphx/nuvola_ledred16.png differ
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/graphx/nuvola_personal16.png b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/graphx/nuvola_personal16.png
new file mode 100644
index 00000000000..4aeaa1d3b6f
Binary files /dev/null and b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/graphx/nuvola_personal16.png differ
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/DataBrowserComponent.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/DataBrowserComponent.java
index 4a79e23ec0f..d7b73c6d66e 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/DataBrowserComponent.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/DataBrowserComponent.java
@@ -68,6 +68,7 @@
import org.openmicroscopy.shoola.env.data.model.TableResult;
import org.openmicroscopy.shoola.env.data.model.ThumbnailData;
import org.openmicroscopy.shoola.env.data.util.FilterContext;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.util.StructuredDataResults;
import org.openmicroscopy.shoola.env.event.EventBus;
import org.openmicroscopy.shoola.env.log.LogMessage;
@@ -1545,6 +1546,18 @@ public void viewDisplay(ImageDisplay node)
Object go;
ViewImageObject object;
if (uo instanceof ImageData) {
+ if (model instanceof SearchModel) {
+ ImageData img = (ImageData) uo;
+ SecurityContext ctx = new SecurityContext(img.getGroupId());
+ object = new ViewImageObject(img);
+ go = view.getParentOfNodes();
+ if (go instanceof DataObject)
+ data = (DataObject) go;
+ object.setContext(data, null);
+ bus.post(new ViewImage(ctx, object, null));
+ } else {
+ firePropertyChange(VIEW_IMAGE_NODE_PROPERTY, null, uo);
+ }
/*
object = new ViewImageObject((ImageData) uo);
go = view.getParentOfNodes();
@@ -1554,18 +1567,19 @@ public void viewDisplay(ImageDisplay node)
bus.post(new ViewImage(object, null));
if (go instanceof DataObject) data = (DataObject) go;
*/
- firePropertyChange(VIEW_IMAGE_NODE_PROPERTY, null, uo);
+
} else if (uo instanceof WellSampleData) {
object = new ViewImageObject((WellSampleData) uo);
WellSampleNode wsn = (WellSampleNode) node;
Object parent = wsn.getParentObject();
+
if (parent instanceof DataObject) {
go = view.getGrandParentOfNodes();
if (go instanceof DataObject)
data = (DataObject) go;
object.setContext((DataObject) parent, data);
}
- bus.post(new ViewImage(object, null));
+ bus.post(new ViewImage(model.getSecurityContext(), object, null));
}
}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/DataBrowserControl.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/DataBrowserControl.java
index 305e9e06c20..59e33b39007 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/DataBrowserControl.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/DataBrowserControl.java
@@ -43,10 +43,12 @@
//Third-party libraries
//Application-internal dependencies
+import org.openmicroscopy.shoola.agents.dataBrowser.DataBrowserAgent;
import org.openmicroscopy.shoola.agents.dataBrowser.actions.CreateExperimentAction;
import org.openmicroscopy.shoola.agents.dataBrowser.actions.FieldsViewAction;
import org.openmicroscopy.shoola.agents.dataBrowser.actions.ManageObjectAction;
import org.openmicroscopy.shoola.agents.dataBrowser.actions.ManageRndSettingsAction;
+import org.openmicroscopy.shoola.agents.dataBrowser.actions.MoveToAction;
import org.openmicroscopy.shoola.agents.dataBrowser.actions.RefreshAction;
import org.openmicroscopy.shoola.agents.dataBrowser.actions.SaveAction;
import org.openmicroscopy.shoola.agents.dataBrowser.actions.SendFeedbackAction;
@@ -62,6 +64,7 @@
import org.openmicroscopy.shoola.agents.dataBrowser.util.FilteringDialog;
import org.openmicroscopy.shoola.agents.dataBrowser.util.QuickFiltering;
import org.openmicroscopy.shoola.agents.util.SelectionWizard;
+import org.openmicroscopy.shoola.agents.util.ViewerSorter;
import org.openmicroscopy.shoola.agents.util.ui.EditorDialog;
import org.openmicroscopy.shoola.agents.util.ui.RollOverThumbnailManager;
import org.openmicroscopy.shoola.env.data.model.ApplicationData;
@@ -73,6 +76,7 @@
import org.openmicroscopy.shoola.util.ui.search.SearchObject;
import pojos.DataObject;
import pojos.DatasetData;
+import pojos.GroupData;
/**
* The DataBrowser's Controller.
@@ -158,6 +162,9 @@ class DataBrowserControl
/** Maps actions ids onto actual Action
object. */
private Map actionsMap;
+ /** One per group.*/
+ private List moveActions;
+
/** Helper method to create all the UI actions. */
private void createActions()
{
@@ -309,6 +316,25 @@ void initialize(DataBrowser model, DataBrowserUI view)
*/
Action getAction(Integer id) { return actionsMap.get(id); }
+ /**
+ * Returns the actions used to move data between groups.
+ *
+ * @return See abo.ve
+ */
+ List getMoveAction()
+ {
+ if (moveActions != null) return moveActions;
+ Set l = DataBrowserAgent.getAvailableUserGroups();
+ ViewerSorter sorter = new ViewerSorter();
+ List values = sorter.sort(l);
+ moveActions = new ArrayList(l.size());
+ Iterator i = values.iterator();
+ while (i.hasNext()) {
+ moveActions.add(new MoveToAction(model, (GroupData) i.next()));
+ }
+ return moveActions;
+ }
+
/**
* Views the selected well sample field while browsing a plate.
*
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/DataBrowserFactory.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/DataBrowserFactory.java
index 1a36b80d6f4..32037ee2511 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/DataBrowserFactory.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/DataBrowserFactory.java
@@ -35,11 +35,9 @@
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
-
-import omero.model.PlateAcquisition;
-
import org.openmicroscopy.shoola.agents.util.browser.TreeImageDisplay;
import org.openmicroscopy.shoola.agents.util.browser.TreeImageTimeSet;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
//Third-party libraries
@@ -103,8 +101,8 @@ public static final void discardAll()
* @param result The value to set.
* @return See above.
*/
- public static final DataBrowser getSearchBrowser(Collection
- result)
+ public static final DataBrowser getSearchBrowser(
+ Map> result)
{
return singleton.createSearchDataBrowser(result);
}
@@ -122,6 +120,7 @@ public static final DataBrowser getSearchBrowser()
/**
* Creates a new {@link DataBrowser} for the passed collection of images.
*
+ * @param ctx The security context.
* @param ancestors Map containing the ancestors of the node.
* @param parent The parent's node.
* @param wells The collection to set.
@@ -129,84 +128,93 @@ public static final DataBrowser getSearchBrowser()
* false
otherwise.
* @return See above.
*/
- public static final DataBrowser getWellsDataBrowser(Map
- ancestors, Object parent, Set wells, boolean withThumbnails)
+ public static final DataBrowser getWellsDataBrowser(
+ SecurityContext ctx, Map ancestors, Object parent,
+ Set wells, boolean withThumbnails)
{
- return singleton.createWellsDataBrowser(ancestors, parent, wells,
+ return singleton.createWellsDataBrowser(ctx, ancestors, parent, wells,
withThumbnails);
}
/**
* Creates a new {@link DataBrowser} for the passed collection of images.
*
+ * @param ctx The security context.
* @param grandParent The grandparent of the node.
* @param parent The parent's node.
* @param images The collection to set.
* @param node The node to handle.
* @return See above.
*/
- public static final DataBrowser getDataBrowser(Object grandParent,
+ public static final DataBrowser getDataBrowser(
+ SecurityContext ctx, Object grandParent,
Object parent, Collection images,
TreeImageDisplay node)
{
- return singleton.createImagesDataBrowser(grandParent, parent, images,
- node);
+ return singleton.createImagesDataBrowser(ctx, grandParent, parent,
+ images, node);
}
/**
* Creates a new {@link DataBrowser} for the passed collection of images.
*
+ * @param ctx The security context.
* @param parent The parent's node.
* @param nodes The collection to set.
* @param withImages Pass true
to indicate that the images
* are loaded, false
otherwise.
* @return See above.
*/
- public static final DataBrowser getTagsBrowser(TagAnnotationData parent,
+ public static final DataBrowser getTagsBrowser(
+ SecurityContext ctx, TagAnnotationData parent,
Collection nodes, boolean withImages)
{
- return singleton.createTagsDataBrowser(parent, nodes, withImages);
+ return singleton.createTagsDataBrowser(ctx, parent, nodes, withImages);
}
/**
* Creates a new {@link DataBrowser} for the passed collection of
* experimenters.
*
+ * @param ctx The security context.
* @param parent The parent's node.
* @param experimenters The collection to set.
* @return See above.
*/
- public static final DataBrowser getGroupsBrowser(GroupData parent,
- Collection experimenters)
+ public static final DataBrowser getGroupsBrowser(
+ SecurityContext ctx, GroupData parent,
+ Collection experimenters)
{
- return singleton.createGroupsBrowser(parent, experimenters);
+ return singleton.createGroupsBrowser(ctx, parent, experimenters);
}
/**
* Creates a new {@link DataBrowser} for the passed collection of
* files.
*
+ * @param ctx The security context.
* @param parent The parent's node.
* @param experimenters The collection to set.
* @return See above.
*/
- public static final DataBrowser getFSFolderBrowser(FileData parent,
- Collection files)
+ public static final DataBrowser getFSFolderBrowser(
+ SecurityContext ctx, FileData parent, Collection files)
{
- return singleton.createFSFolderBrowser(parent, files);
+ return singleton.createFSFolderBrowser(ctx, parent, files);
}
/**
* Creates a new {@link DataBrowser} for the passed collection of datasets.
*
+ * @param ctx The security context.
* @param parent The parent's node.
* @param nodes The collection to set.
* @return See above.
*/
- public static final DataBrowser getDataBrowser(ProjectData parent,
- Set nodes)
+ public static final DataBrowser getDataBrowser(SecurityContext ctx,
+ ProjectData parent, Set nodes)
{
- return singleton.createDatasetsDataBrowser(parent, nodes);
+ return singleton.createDatasetsDataBrowser(ctx, parent, nodes);
}
/**
@@ -389,6 +397,7 @@ private DataBrowserFactory()
/**
* Creates a new {@link DataBrowser} for the passed collection of wells.
*
+ * @param ctx The security context.
* @param ancestors Map containing the ancestors of the node.
* @param parent The parent's node.
* @param wells The collection to set.
@@ -396,7 +405,8 @@ private DataBrowserFactory()
* false
otherwise.
* @return See above.
*/
- private DataBrowser createWellsDataBrowser(Map ancestors,
+ private DataBrowser createWellsDataBrowser(SecurityContext ctx,
+ Map ancestors,
Object parent, Set wells, boolean withThumbnails)
{
Object p = parent;
@@ -415,7 +425,7 @@ private DataBrowser createWellsDataBrowser(Map ancestors,
break;
}
}
- DataBrowserModel model = new WellsModel(p, wells, withThumbnails);
+ DataBrowserModel model = new WellsModel(ctx, p, wells, withThumbnails);
model.setGrandParent(go);
DataBrowserComponent comp = new DataBrowserComponent(model);
model.initialize(comp);
@@ -440,17 +450,19 @@ private DataBrowser createWellsDataBrowser(Map ancestors,
/**
* Creates a new {@link DataBrowser} for the passed collection of images.
*
+ * @param ctx The security context.
* @param grandParent The grandParent of the node.
* @param parent The parent's node.
* @param images The collection to set.
* @param experimenter The experimenter associated to the node.
* @return See above.
*/
- private DataBrowser createImagesDataBrowser(Object grandParent,
+ private DataBrowser createImagesDataBrowser(
+ SecurityContext ctx, Object grandParent,
Object parent, Collection images,
TreeImageDisplay node)
{
- DataBrowserModel model = new ImagesModel(parent, images);
+ DataBrowserModel model = new ImagesModel(ctx, parent, images);
model.setGrandParent(grandParent);
DataBrowserComponent comp = new DataBrowserComponent(model);
model.initialize(comp);
@@ -466,14 +478,15 @@ private DataBrowser createImagesDataBrowser(Object grandParent,
/**
* Creates a new {@link DataBrowser} for the passed collection of datasets.
*
+ * @param ctx The security context.
* @param parent The parent's node.
* @param datasets The collection to set.
* @return See above.
*/
- private DataBrowser createDatasetsDataBrowser(DataObject parent,
- Set datasets)
+ private DataBrowser createDatasetsDataBrowser(SecurityContext ctx,
+ DataObject parent, Set datasets)
{
- DataBrowserModel model = new DatasetsModel(parent, datasets);
+ DataBrowserModel model = new DatasetsModel(ctx, parent, datasets);
DataBrowserComponent comp = new DataBrowserComponent(model);
model.initialize(comp);
comp.initialize();
@@ -499,16 +512,19 @@ private DataBrowser createDatasetsDataBrowser(DataObject parent,
/**
* Creates a new {@link DataBrowser} for the passed collection of tags.
*
+ * @param ctx The security context.
* @param parent The parent's node.
* @param dataObjects The collection to set.
* @param withImages Pass true
to indicate that the images
* are loaded, false
otherwise.
* @return See above.
*/
- private DataBrowser createTagsDataBrowser(DataObject parent,
- Collection dataObjects, boolean withImages)
+ private DataBrowser createTagsDataBrowser(SecurityContext ctx,
+ DataObject parent, Collection dataObjects,
+ boolean withImages)
{
- DataBrowserModel model = new TagsModel(parent, dataObjects, withImages);
+ DataBrowserModel model = new TagsModel(ctx, parent, dataObjects,
+ withImages);
DataBrowserComponent comp = new DataBrowserComponent(model);
model.initialize(comp);
comp.initialize();
@@ -521,14 +537,15 @@ private DataBrowser createTagsDataBrowser(DataObject parent,
* Creates a new {@link DataBrowser} for the passed collection of
* experimenters.
*
+ * @param ctx The security context.
* @param parent The parent's node.
* @param experimenters The collection to set.
* @return See above.
*/
- private DataBrowser createGroupsBrowser(GroupData parent,
- Collection experimenters)
+ private DataBrowser createGroupsBrowser(SecurityContext ctx,
+ GroupData parent, Collection experimenters)
{
- DataBrowserModel model = new GroupModel(parent, experimenters);
+ DataBrowserModel model = new GroupModel(ctx, parent, experimenters);
DataBrowserComponent comp = new DataBrowserComponent(model);
model.initialize(comp);
comp.initialize();
@@ -540,14 +557,15 @@ private DataBrowser createGroupsBrowser(GroupData parent,
/**
* Creates a new {@link DataBrowser} for the passed collection of files.
*
+ * @param ctx The security context.
* @param parent The parent's node.
* @param files The collection to set.
* @return See above.
*/
- private DataBrowser createFSFolderBrowser(FileData parent,
- Collection files)
+ private DataBrowser createFSFolderBrowser(SecurityContext ctx,
+ FileData parent, Collection files)
{
- DataBrowserModel model = new FSFolderModel(parent, files);
+ DataBrowserModel model = new FSFolderModel(ctx, parent, files);
DataBrowserComponent comp = new DataBrowserComponent(model);
model.initialize(comp);
comp.initialize();
@@ -559,11 +577,11 @@ private DataBrowser createFSFolderBrowser(FileData parent,
/**
* Creates a new {@link DataBrowser} for the passed result.
*
- * @param result The result of the search.
+ * @param result The result of the search.
* @return See above.
*/
- private DataBrowser createSearchDataBrowser(Collection
- result)
+ private DataBrowser createSearchDataBrowser(
+ Map> result)
{
DataBrowserModel model = new SearchModel(result);
DataBrowserComponent comp = new DataBrowserComponent(model);
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/DataBrowserModel.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/DataBrowserModel.java
index 8636c6207d9..14bd500fd6d 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/DataBrowserModel.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/DataBrowserModel.java
@@ -57,7 +57,6 @@
import org.openmicroscopy.shoola.agents.dataBrowser.browser.ImageNode;
import org.openmicroscopy.shoola.agents.dataBrowser.layout.Layout;
import org.openmicroscopy.shoola.agents.dataBrowser.layout.LayoutFactory;
-import org.openmicroscopy.shoola.agents.dataBrowser.layout.LayoutUtils;
import org.openmicroscopy.shoola.agents.dataBrowser.visitor.ResetThumbnailVisitor;
import org.openmicroscopy.shoola.agents.metadata.MetadataViewerAgent;
import org.openmicroscopy.shoola.agents.util.EditorUtil;
@@ -66,6 +65,8 @@
import org.openmicroscopy.shoola.env.data.model.ApplicationData;
import org.openmicroscopy.shoola.env.data.model.TableResult;
import org.openmicroscopy.shoola.env.data.util.FilterContext;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
+
import pojos.DataObject;
import pojos.DatasetData;
import pojos.ExperimenterData;
@@ -130,7 +131,7 @@ abstract class DataBrowserModel
static final int FS_FOLDER = 9;
/** Holds one of the state flags defined by {@link DataBrowser}. */
- private int state;
+ protected int state;
/** Maps an image id to the list of thumbnail providers for that image. */
private ThumbnailsManager thumbsManager;
@@ -183,11 +184,19 @@ abstract class DataBrowserModel
/** The grandparent of the node. Used as back pointer. */
protected Object grandParent;
- /** Creates a new instance. */
- DataBrowserModel()
+ /** The security context.*/
+ protected SecurityContext ctx;
+
+ /**
+ * Creates a new instance.
+ *
+ * @param ctx The security context.
+ */
+ DataBrowserModel(SecurityContext ctx)
{
sorter = new ViewerSorter();
- state = DataBrowser.NEW;
+ state = DataBrowser.NEW;
+ this.ctx = ctx;
}
/**
@@ -431,7 +440,7 @@ void cancelSlideShow()
void fireFilteringByRate(int rate, Set nodes)
{
state = DataBrowser.FILTERING;
- RateFilter loader = new RateFilter(component, rate, nodes);
+ RateFilter loader = new RateFilter(component, ctx, rate, nodes);
loader.load();
}
@@ -444,7 +453,7 @@ void fireFilteringByRate(int rate, Set nodes)
void fireFilteringByTags(List tags, Set nodes)
{
state = DataBrowser.FILTERING;
- TagsFilter loader = new TagsFilter(component, tags, nodes);
+ TagsFilter loader = new TagsFilter(component, ctx, tags, nodes);
loader.load();
}
@@ -457,7 +466,8 @@ void fireFilteringByTags(List tags, Set nodes)
void fireFilteringByComments(List comments, Set nodes)
{
state = DataBrowser.FILTERING;
- CommentsFilter loader = new CommentsFilter(component, comments, nodes);
+ CommentsFilter loader = new CommentsFilter(component, ctx, comments,
+ nodes);
loader.load();
}
@@ -470,7 +480,7 @@ void fireFilteringByComments(List comments, Set nodes)
void fireFilteringByContext(FilterContext context, Set nodes)
{
state = DataBrowser.FILTERING;
- DataFilter loader = new DataFilter(component, context, nodes);
+ DataFilter loader = new DataFilter(component, ctx, context, nodes);
loader.load();
}
@@ -488,8 +498,8 @@ void fireFilteringByAnnotated(Class annotationType, boolean annotated,
Set nodes)
{
state = DataBrowser.FILTERING;
- AnnotatedFilter loader = new AnnotatedFilter(component, annotationType,
- annotated, nodes);
+ AnnotatedFilter loader = new AnnotatedFilter(component, ctx,
+ annotationType, annotated, nodes);
loader.load();
}
@@ -497,14 +507,14 @@ void fireFilteringByAnnotated(Class annotationType, boolean annotated,
void fireTagsLoading()
{
state = DataBrowser.LOADING;
- TagsLoader loader = new TagsLoader(component);
+ TagsLoader loader = new TagsLoader(component, ctx);
loader.load();
}
/** Starts an asynchronous call to load the existing datasets. */
void fireExisitingDatasetsLoading()
{
- DatasetsLoader loader = new DatasetsLoader(component);
+ DatasetsLoader loader = new DatasetsLoader(component, ctx);
loader.load();
}
@@ -529,9 +539,8 @@ void fireFullSizeLoading(Collection images)
if (nodes.size() > 0) {
fullSizeThumbsManager = new ThumbnailsManager(toKeep,
toKeep.size());
- ThumbnailLoader loader = new ThumbnailLoader(component, nodes,
- false,
- ThumbnailLoader.IMAGE);
+ ThumbnailLoader loader = new ThumbnailLoader(component, ctx,
+ nodes, false, ThumbnailLoader.IMAGE);
loader.load();
state = DataBrowser.LOADING_SLIDE_VIEW;
}
@@ -561,8 +570,8 @@ void fireDataSaving(DataObject data, Collection images)
p = null;
}
}
- DataObjectCreator loader = new DataObjectCreator(component, p, data,
- images);
+ DataObjectCreator loader = new DataObjectCreator(component, ctx,
+ p, data, images);
loader.load();
}
@@ -574,7 +583,7 @@ void fireDataSaving(DataObject data, Collection images)
*/
void fireDataSaving(Collection datasets, Collection images)
{
- DataObjectSaver loader = new DataObjectSaver(component, datasets,
+ DataObjectSaver loader = new DataObjectSaver(component, ctx, datasets,
images);
loader.load();
}
@@ -589,7 +598,7 @@ void fireDataSaving(Collection datasets, Collection images)
void fireReportLoading(Collection images, List types,
String name)
{
- ReportLoader loader = new ReportLoader(component, types,
+ ReportLoader loader = new ReportLoader(component, ctx, types,
sorter.sort(images), name);
loader.load();
}
@@ -743,10 +752,10 @@ void fireTabularDataLoading(List data)
if (data == null) {
if (this instanceof WellsModel) {
if (grandParent instanceof ScreenData) {
- loader = new TabularDataLoader(component,
+ loader = new TabularDataLoader(component, ctx,
(DataObject) grandParent);
} else if (parent instanceof PlateData) {
- loader = new TabularDataLoader(component,
+ loader = new TabularDataLoader(component, ctx,
(DataObject) parent);
}
}
@@ -758,7 +767,7 @@ void fireTabularDataLoading(List data)
fa = i.next();
ids.add(fa.getFileID());
}
- loader = new TabularDataLoader(component, ids);
+ loader = new TabularDataLoader(component, ctx, ids);
}
if (loader != null) loader.load();
}
@@ -789,6 +798,25 @@ int getLayoutIndex()
return layout.getIndex();
}
+ /**
+ * Returns the security context.
+ *
+ * @return See above.
+ */
+ SecurityContext getSecurityContext() { return ctx; }
+
+ /**
+ * Returns true
if the user belongs to only one group,
+ * false
otherwise.
+ *
+ * @return See above.
+ */
+ boolean isSingleGroup()
+ {
+ Set l = DataBrowserAgent.getAvailableUserGroups();
+ return l.size() <= 1;
+ }
+
/**
* Creates a data loader that can retrieve the hierarchy objects needed
* by this model.
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/DataBrowserUI.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/DataBrowserUI.java
index 1bfd8b8b4fe..c639c8b7698 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/DataBrowserUI.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/DataBrowserUI.java
@@ -532,7 +532,9 @@ void viewSelectedNode()
if (!(node instanceof ImageNode)) return;
ImageData data = (ImageData) node.getHierarchyObject();
EventBus bus = DataBrowserAgent.getRegistry().getEventBus();
- bus.post(new ViewImage(new ViewImageObject(data), null));
+
+ bus.post(new ViewImage(model.getSecurityContext(),
+ new ViewImageObject(data), null));
}
/**
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/DatasetsModel.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/DatasetsModel.java
index f0c86cf8588..7101ad2c314 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/DatasetsModel.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/DatasetsModel.java
@@ -41,6 +41,8 @@
import org.openmicroscopy.shoola.agents.dataBrowser.browser.BrowserFactory;
import org.openmicroscopy.shoola.agents.dataBrowser.browser.ImageDisplay;
import org.openmicroscopy.shoola.agents.dataBrowser.browser.ImageNode;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
+
import pojos.DatasetData;
import pojos.ImageData;
@@ -65,12 +67,13 @@ class DatasetsModel
/**
* Creates a new instance.
*
+ * @param ctx The security context.
* @param parent The parent of the datasets.
* @param datasets The collection to datasets the model is for.
*/
- DatasetsModel(Object parent, Set datasets)
+ DatasetsModel(SecurityContext ctx, Object parent, Set datasets)
{
- super();
+ super(ctx);
if (datasets == null)
throw new IllegalArgumentException("No datasets.");
this.parent = parent;
@@ -97,9 +100,7 @@ class DatasetsModel
img.getDefaultPixels();
ids.add(img.getId());
numberOfImages++;
- } catch (Exception e) {
-
- }
+ } catch (Exception e) {}
}
}
}
@@ -154,13 +155,12 @@ protected DataBrowserLoader createDataLoader(boolean refresh,
loaded.add(img.getId());
imagesLoaded++;
} catch (Exception e) {}
-
}
}
}
}
if (imgs.size() == 0) return null;
- return new ThumbnailLoader(component, sorter.sort(imgs));
+ return new ThumbnailLoader(component, ctx, sorter.sort(imgs));
}
/**
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/FSFolderModel.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/FSFolderModel.java
index 1c8d34f9fad..87b29388bc2 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/FSFolderModel.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/FSFolderModel.java
@@ -38,6 +38,8 @@
import org.openmicroscopy.shoola.agents.dataBrowser.browser.BrowserFactory;
import org.openmicroscopy.shoola.agents.dataBrowser.browser.ImageDisplay;
import org.openmicroscopy.shoola.agents.dataBrowser.browser.ImageNode;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
+
import pojos.DataObject;
import pojos.ImageData;
import pojos.MultiImageData;
@@ -62,12 +64,14 @@ class FSFolderModel
/**
* Creates a new instance.
*
+ * @param ctx The security context.
* @param parent The parent of the experimenters.
* @param datasets The collection to experimenters the model is for.
*/
- FSFolderModel(Object parent, Collection files)
+ FSFolderModel(SecurityContext ctx, Object parent,
+ Collection files)
{
- super();
+ super(ctx);
if (files == null)
throw new IllegalArgumentException("No files.");
this.parent = parent;
@@ -151,7 +155,7 @@ protected DataBrowserLoader createDataLoader(boolean refresh,
}
}
if (imgs.size() == 0) return null;
- return new ThumbnailLoader(component, sorter.sort(imgs),
+ return new ThumbnailLoader(component, ctx, sorter.sort(imgs),
ThumbnailLoader.FS_FILE);
}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/GroupModel.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/GroupModel.java
index d9fb29af674..ce19325245b 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/GroupModel.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/GroupModel.java
@@ -39,6 +39,8 @@
import org.openmicroscopy.shoola.agents.dataBrowser.browser.BrowserFactory;
import org.openmicroscopy.shoola.agents.dataBrowser.browser.ImageDisplay;
import org.openmicroscopy.shoola.agents.dataBrowser.browser.ImageNode;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
+
import pojos.DataObject;
import pojos.ExperimenterData;
import pojos.ImageData;
@@ -63,13 +65,15 @@ class GroupModel
/**
* Creates a new instance.
- *
+ *
+ * @param ctx The security context.
* @param parent The parent of the experimenters.
* @param datasets The collection to experimenters the model is for.
*/
- GroupModel(Object parent, Collection experimenters)
+ GroupModel(SecurityContext ctx, Object parent,
+ Collection experimenters)
{
- super();
+ super(ctx);
if (experimenters == null)
throw new IllegalArgumentException("No experimenters.");
this.parent = parent;
@@ -132,7 +136,7 @@ protected DataBrowserLoader createDataLoader(boolean refresh,
}
}
if (imgs.size() == 0) return null;
- return new ThumbnailLoader(component, sorter.sort(imgs),
+ return new ThumbnailLoader(component, ctx, sorter.sort(imgs),
ThumbnailLoader.EXPERIMENTER);
}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/ImagesModel.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/ImagesModel.java
index 129a62a36ec..3936fe26dcb 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/ImagesModel.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/ImagesModel.java
@@ -39,6 +39,8 @@
import org.openmicroscopy.shoola.agents.dataBrowser.browser.BrowserFactory;
import org.openmicroscopy.shoola.agents.dataBrowser.browser.ImageDisplay;
import org.openmicroscopy.shoola.agents.dataBrowser.browser.ImageNode;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
+
import pojos.ImageData;
/**
@@ -64,12 +66,14 @@ class ImagesModel
/**
* Creates a new instance.
*
+ * @param ctx The security context.
* @param parent The parent.
* @param images The collection to images the model is for.
*/
- ImagesModel(Object parent, Collection images)
+ ImagesModel(SecurityContext ctx, Object parent,
+ Collection images)
{
- super();
+ super(ctx);
if (images == null)
throw new IllegalArgumentException("No images.");
this.images = images;
@@ -131,7 +135,7 @@ protected DataBrowserLoader createDataLoader(boolean refresh,
}
}
if (imgs.size() == 0) return null;
- return new ThumbnailLoader(component, sorter.sort(imgs));
+ return new ThumbnailLoader(component, ctx, sorter.sort(imgs));
}
/**
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/PlatesModel.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/PlatesModel.java
index 34d24f43402..857fc5aad53 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/PlatesModel.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/PlatesModel.java
@@ -38,6 +38,8 @@
import org.openmicroscopy.shoola.agents.dataBrowser.DataBrowserTranslator;
import org.openmicroscopy.shoola.agents.dataBrowser.browser.BrowserFactory;
import org.openmicroscopy.shoola.agents.dataBrowser.browser.ImageDisplay;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
+
import pojos.PlateData;
/**
@@ -60,12 +62,13 @@ class PlatesModel
/**
* Creates a new instance.
*
+ * @param ctx The security context.
* @param parent The parent of the plates.
* @param datasets The collection to plates the model is for.
*/
- PlatesModel(Object parent, Set plates)
+ PlatesModel(SecurityContext ctx, Object parent, Set plates)
{
- super();
+ super(ctx);
if (plates == null)
throw new IllegalArgumentException("No plates.");
this.parent = parent;
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/PopupMenu.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/PopupMenu.java
index a5d44240703..885b99042d5 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/PopupMenu.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/PopupMenu.java
@@ -26,7 +26,6 @@
//Java imports
import java.util.Iterator;
import java.util.List;
-
import javax.swing.BorderFactory;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
@@ -34,12 +33,13 @@
import javax.swing.JSeparator;
import javax.swing.border.BevelBorder;
-import org.openmicroscopy.shoola.agents.dataBrowser.IconManager;
-import org.openmicroscopy.shoola.agents.dataBrowser.actions.ViewOtherAction;
//Third-party libraries
//Application-internal dependencies
+import org.openmicroscopy.shoola.agents.dataBrowser.IconManager;
+import org.openmicroscopy.shoola.agents.dataBrowser.actions.MoveToAction;
+import org.openmicroscopy.shoola.agents.dataBrowser.actions.ViewOtherAction;
/**
* Pop-up menu for nodes in the browser display.
@@ -103,6 +103,23 @@ class PopupMenu
/** Reference to the control. */
private DataBrowserControl controller;
+ /**
+ * Creates a menu if the various groups the data can be moved to.
+ *
+ * @return See above.
+ */
+ private JMenu createMoveToMenu()
+ {
+ List actions = controller.getMoveAction();
+ if (actions.size() <= 1) return null;
+ JMenu menu = new JMenu(MoveToAction.NAME);
+ Iterator i = actions.iterator();
+ while (i.hasNext()) {
+ menu.add(new JMenuItem(i.next()));
+ }
+ return menu;
+ }
+
/**
* Initializes the menu items with the given actions.
*
@@ -159,6 +176,8 @@ private void buildGUI()
add(cutElement);
add(copyElement);
add(pasteElement);
+ JMenu m = createMoveToMenu();
+ if (m != null) add(m);
add(removeElement);
add(new JSeparator(JSeparator.HORIZONTAL));
add(tagElement);
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/ProjectsModel.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/ProjectsModel.java
index 8f9a83fce80..2c655278748 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/ProjectsModel.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/ProjectsModel.java
@@ -35,6 +35,8 @@
//Application-internal dependencies
import org.openmicroscopy.shoola.agents.dataBrowser.DataBrowserLoader;
import org.openmicroscopy.shoola.agents.dataBrowser.browser.ImageDisplay;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
+
import pojos.ProjectData;
/**
@@ -54,6 +56,16 @@ class ProjectsModel
extends DataBrowserModel
{
+ /**
+ * Creates a new instance.
+ *
+ * @param ctx The security context.
+ */
+ ProjectsModel(SecurityContext ctx)
+ {
+ super(ctx);
+ }
+
protected DataBrowserLoader createDataLoader(boolean refresh,
Collection ids)
{
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/SearchModel.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/SearchModel.java
index 51f3b615547..8f0ee72bbe0 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/SearchModel.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/SearchModel.java
@@ -26,9 +26,13 @@
//Java imports
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Set;
+import java.util.Map.Entry;
//Third-party libraries
@@ -40,7 +44,10 @@
import org.openmicroscopy.shoola.agents.dataBrowser.browser.BrowserFactory;
import org.openmicroscopy.shoola.agents.dataBrowser.browser.ImageDisplay;
import org.openmicroscopy.shoola.agents.dataBrowser.browser.ImageNode;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
+
import pojos.DataObject;
+import pojos.GroupData;
import pojos.ImageData;
/**
@@ -60,44 +67,83 @@ class SearchModel
extends DataBrowserModel
{
- /** The images to lay out. */
- private Collection results;
+ /** The result to display. */
+ private Map> results;
+
+ /**
+ * Returns the group corresponding to the specified id.
+ *
+ * @param groupId The id of the group.
+ * @return See above.
+ */
+ private GroupData getGroup(long groupId)
+ {
+ Set groups = DataBrowserAgent.getAvailableUserGroups();
+ Iterator i = groups.iterator();
+ GroupData g;
+ while (i.hasNext()) {
+ g = (GroupData) i.next();
+ if (g.getId() == groupId) return g;
+ }
+ return null;
+ }
/**
* Creates a new instance.
*
* @param results The results to display.
*/
- SearchModel(Collection results)
+ SearchModel(Map> results)
{
- super();
+ super(null);
if (results == null)
throw new IllegalArgumentException("No results.");
this.results = results;
- numberOfImages = results.size();
+ numberOfImages = 0;
long userID = DataBrowserAgent.getUserDetails().getId();
- Set vis = DataBrowserTranslator.transformObjects(results, userID, 0);
- browser = BrowserFactory.createBrowser(vis);
- //layoutBrowser();
+ Set vis = new HashSet();
+ Iterator i = results.entrySet().iterator();
+ Entry e;
+ SecurityContext ctx;
+ GroupData g;
+ Collection objects;
+ boolean singleGroup = isSingleGroup();
+ while (i.hasNext()) {
+ e = (Entry) i.next();
+ ctx = (SecurityContext) e.getKey();
+
+ objects = (Collection) e.getValue();
+ numberOfImages += objects.size();
+ if (singleGroup) {
+ vis.addAll(DataBrowserTranslator.transformObjects(objects,
+ userID, ctx.getGroupID()));
+ } else {
+ g = getGroup(ctx.getGroupID());
+ if (g != null && objects != null && objects.size() > 0)
+ vis.add(DataBrowserTranslator.transformObjects(objects,
+ userID, g));
+ }
+ }
+ browser = BrowserFactory.createBrowser(vis);
}
/**
- * Creates a concrete loader.
- * @see DataBrowserModel#createDataLoader(boolean, Collection)
+ * Overridden to start several loaders.
*/
- protected DataBrowserLoader createDataLoader(boolean refresh,
- Collection ids)
+ void loadData(boolean refresh, Collection ids)
{
if (refresh) imagesLoaded = 0;
if (imagesLoaded != 0 && ids != null)
imagesLoaded = imagesLoaded-ids.size();
- if (imagesLoaded == numberOfImages) return null;
- //only load thumbnails not loaded.
+ if (imagesLoaded == numberOfImages) return;
+ Map> map = new HashMap>();
List nodes = browser.getVisibleImageNodes();
- if (nodes == null || nodes.size() == 0) return null;
+ if (nodes == null || nodes.size() == 0) return;
Iterator i = nodes.iterator();
ImageNode node;
- List imgs = new ArrayList();
+ ImageData image;
+ long groupId;
+ List imgs;
if (ids != null) {
ImageData img;
while (i.hasNext()) {
@@ -105,7 +151,13 @@ protected DataBrowserLoader createDataLoader(boolean refresh,
img = (ImageData) node.getHierarchyObject();
if (ids.contains(img.getId())) {
if (node.getThumbnail().getFullScaleThumb() == null) {
- imgs.add((ImageData) node.getHierarchyObject());
+ image = (ImageData) node.getHierarchyObject();
+ groupId = image.getGroupId();
+ if (!map.containsKey(groupId)) {
+ map.put(groupId, new ArrayList());
+ }
+ imgs = map.get(groupId);
+ imgs.add(image);
imagesLoaded++;
}
}
@@ -114,12 +166,38 @@ protected DataBrowserLoader createDataLoader(boolean refresh,
while (i.hasNext()) {
node = i.next();
if (node.getThumbnail().getFullScaleThumb() == null) {
- imgs.add((ImageData) node.getHierarchyObject());
+ image = (ImageData) node.getHierarchyObject();
+ groupId = image.getGroupId();
+ if (!map.containsKey(groupId)) {
+ map.put(groupId, new ArrayList());
+ }
+ imgs = map.get(groupId);
+ imgs.add(image);
imagesLoaded++;
}
}
}
- return new ThumbnailLoader(component, sorter.sort(imgs));
+ if (map.size() == 0) return;
+ Entry e;
+ Iterator j = map.entrySet().iterator();
+ DataBrowserLoader loader;
+ while (j.hasNext()) {
+ e = (Entry) j.next();
+ loader = new ThumbnailLoader(component, new SecurityContext(
+ (Long) e.getKey()), sorter.sort((List) e.getValue()));
+ loader.load();
+ }
+ state = DataBrowser.LOADING;
+ }
+
+ /**
+ * Creates a concrete loader.
+ * @see DataBrowserModel#createDataLoader(boolean, Collection)
+ */
+ protected DataBrowserLoader createDataLoader(boolean refresh,
+ Collection ids)
+ {
+ return null;
}
/**
@@ -133,5 +211,5 @@ protected DataBrowserLoader createDataLoader(boolean refresh,
* @see DataBrowserModel#getNodes()
*/
protected List getNodes() { return null; }
-
+
}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/SlideShowView.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/SlideShowView.java
index a7f34c59532..ff7ae64feb7 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/SlideShowView.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/SlideShowView.java
@@ -615,13 +615,14 @@ public void mousePressed(MouseEvent e)
public void mouseReleased(MouseEvent e)
{
Object src = e.getSource();
+ /*
ImageDisplay d = findParentDisplay(src);
if (d instanceof ImageNode && !(d.getTitleBar() == src)
&& e.getClickCount() == 2) {
EventBus bus = DataBrowserAgent.getRegistry().getEventBus();
bus.post(new ViewImage(new ViewImageObject(
(ImageData) d.getHierarchyObject()), null));
- }
+ }*/
}
/**
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/TagSetsModel.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/TagSetsModel.java
index 9ca3d940182..4b7aacc9ba5 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/TagSetsModel.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/TagSetsModel.java
@@ -40,6 +40,7 @@
import org.openmicroscopy.shoola.agents.dataBrowser.browser.BrowserFactory;
import org.openmicroscopy.shoola.agents.dataBrowser.browser.ImageDisplay;
import org.openmicroscopy.shoola.agents.dataBrowser.browser.ImageNode;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import pojos.DataObject;
import pojos.DatasetData;
@@ -70,12 +71,14 @@ class TagSetsModel
/**
* Creates a new instance.
*
+ * @param ctx The security context.
* @param parent The parent of the datasets.
* @param tagSets The collection to datasets the model is for.
*/
- TagSetsModel(Object parent, Set tagSets)
+ TagSetsModel(SecurityContext ctx, Object parent,
+ Set tagSets)
{
- super();
+ super(ctx);
if (tagSets == null)
throw new IllegalArgumentException("No images.");
this.tagSets = tagSets;
@@ -153,7 +156,7 @@ protected DataBrowserLoader createDataLoader(boolean refresh,
}
}
if (imgs.size() == 0) return null;
- return new ThumbnailLoader(component, sorter.sort(imgs));
+ return new ThumbnailLoader(component, ctx, sorter.sort(imgs));
}
/**
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/TagsModel.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/TagsModel.java
index c8c12a397ca..e423cc235cc 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/TagsModel.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/TagsModel.java
@@ -40,6 +40,8 @@
import org.openmicroscopy.shoola.agents.dataBrowser.browser.BrowserFactory;
import org.openmicroscopy.shoola.agents.dataBrowser.browser.ImageDisplay;
import org.openmicroscopy.shoola.agents.dataBrowser.browser.ImageNode;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
+
import pojos.DataObject;
import pojos.DatasetData;
import pojos.ImageData;
@@ -68,15 +70,16 @@ public class TagsModel
/**
* Creates a new instance.
*
+ * @param ctx The security context.
* @param parent The parent of the datasets.
* @param tagSets The collection to datasets the model is for.
* @param withImages Pass true
to indicate that the images
* are loaded, false
otherwise.
*/
- TagsModel(Object parent, Collection dataObjects,
- boolean withImages)
+ TagsModel(SecurityContext ctx, Object parent,
+ Collection dataObjects, boolean withImages)
{
- super();
+ super(ctx);
if (dataObjects == null)
throw new IllegalArgumentException("No dataObjects.");
this.dataObjects = dataObjects;
@@ -213,7 +216,7 @@ protected DataBrowserLoader createDataLoader(boolean refresh,
}
}
if (imgs.size() == 0) return null;
- return new ThumbnailLoader(component, sorter.sort(imgs));
+ return new ThumbnailLoader(component, ctx, sorter.sort(imgs));
}
/**
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/WellsModel.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/WellsModel.java
index 4e3c1f250f3..267f246cd3b 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/WellsModel.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/WellsModel.java
@@ -57,6 +57,7 @@
import org.openmicroscopy.shoola.agents.dataBrowser.browser.WellSampleNode;
import org.openmicroscopy.shoola.agents.dataBrowser.layout.LayoutFactory;
import org.openmicroscopy.shoola.env.data.model.TableResult;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.util.image.geom.Factory;
import org.openmicroscopy.shoola.util.ui.PlateGrid;
import org.openmicroscopy.shoola.util.ui.UIUtilities;
@@ -229,14 +230,16 @@ private void handleCellSelection(CellDisplay cell, WellImageSet well,
/**
* Creates a new instance.
*
+ * @param ctx The security context.
* @param parent The parent of the wells.
* @param wells The collection to wells the model is for.
* @param withThumbnails Pass true
to load the thumbnails,
* false
otherwise.
*/
- WellsModel(Object parent, Set wells, boolean withThumbnails)
+ WellsModel(SecurityContext ctx, Object parent, Set wells,
+ boolean withThumbnails)
{
- super();
+ super(ctx);
if (wells == null)
throw new IllegalArgumentException("No wells.");
this.withThumbnails = withThumbnails;
@@ -501,7 +504,7 @@ void viewField(int index)
plate.setDefaultSample(selectedField);
List list = new ArrayList();
list.add(plate);
- DataBrowserLoader loader = new PlateSaver(component, list);
+ DataBrowserLoader loader = new PlateSaver(component, ctx, list);
loader.load();
}
}
@@ -553,7 +556,7 @@ void setSelectedCell(CellDisplay cell)
}
}
if (results.size() > 0) {
- DataBrowserLoader loader = new PlateSaver(component, results);
+ DataBrowserLoader loader = new PlateSaver(component, ctx, results);
loader.load();
}
}
@@ -663,7 +666,7 @@ DataBrowserLoader createFieldsLoader(int row, int column)
}
if (images.size() == 0) return null;
- return new ThumbnailFieldsLoader(component, images, row, column);
+ return new ThumbnailFieldsLoader(component, ctx, images, row, column);
}
/**
@@ -699,7 +702,7 @@ protected DataBrowserLoader createDataLoader(boolean refresh,
}
if (images.size() == 0) return null;
- return new ThumbnailLoader(component, images);
+ return new ThumbnailLoader(component, ctx, images);
}
/**
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/BrowserLoader.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/BrowserLoader.java
index b21ab7bf267..ec850341d79 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/BrowserLoader.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/BrowserLoader.java
@@ -31,6 +31,7 @@
import org.openmicroscopy.shoola.agents.editor.browser.Browser;
import org.openmicroscopy.shoola.env.config.Registry;
import org.openmicroscopy.shoola.env.data.events.DSCallAdapter;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.MetadataHandlerView;
import org.openmicroscopy.shoola.env.log.LogMessage;
@@ -60,24 +61,30 @@ public abstract class BrowserLoader
{
/** The browser this data loader is for. */
- protected final Browser viewer;
+ protected final Browser viewer;
/** Convenience reference for subclasses. */
- protected final Registry registry;
+ protected final Registry registry;
/** Convenience reference for subclasses. */
- protected final MetadataHandlerView mhView;
+ protected final MetadataHandlerView mhView;
+ /** The security context.*/
+ protected final SecurityContext ctx;
+
/**
* Creates a new instance.
*
* @param viewer The browser this data loader is for.
* Mustn't be null
.
+ * @param ctx The security context.
*/
- protected BrowserLoader(Browser viewer)
+ protected BrowserLoader(Browser viewer, SecurityContext ctx)
{
- if (viewer == null) throw new NullPointerException("No viewer.");
+ if (viewer == null) throw new NullPointerException("No viewer.");
+ if (ctx == null) throw new NullPointerException("No security context.");
this.viewer = viewer;
+ this.ctx = ctx;
registry = EditorAgent.getRegistry();
mhView = (MetadataHandlerView)
registry.getDataServicesView(MetadataHandlerView.class);
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/EditorAgent.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/EditorAgent.java
index 644b30feef3..bc0aa23d7d1 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/EditorAgent.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/EditorAgent.java
@@ -24,8 +24,11 @@
//Java imports
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.io.File;
import java.util.List;
+import java.util.Set;
import javax.swing.JButton;
import javax.swing.JMenuItem;
@@ -40,6 +43,8 @@
import org.openmicroscopy.shoola.agents.events.editor.CopyEvent;
import org.openmicroscopy.shoola.agents.events.editor.EditFileEvent;
import org.openmicroscopy.shoola.agents.events.editor.ShowEditorEvent;
+import org.openmicroscopy.shoola.agents.events.importer.LoadImporter;
+import org.openmicroscopy.shoola.agents.events.treeviewer.ChangeUserGroupEvent;
import org.openmicroscopy.shoola.agents.util.EditorUtil;
import org.openmicroscopy.shoola.env.Agent;
import org.openmicroscopy.shoola.env.Environment;
@@ -50,6 +55,7 @@
import org.openmicroscopy.shoola.env.data.model.ApplicationData;
import org.openmicroscopy.shoola.env.data.model.DownloadActivityParam;
import org.openmicroscopy.shoola.env.data.util.AgentSaveInfo;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.event.AgentEvent;
import org.openmicroscopy.shoola.env.event.AgentEventListener;
import org.openmicroscopy.shoola.env.event.EventBus;
@@ -57,6 +63,7 @@
import org.openmicroscopy.shoola.env.ui.UserNotifier;
import pojos.ExperimenterData;
import pojos.FileAnnotationData;
+import pojos.GroupData;
/**
* The Editor agent.
@@ -76,7 +83,10 @@ public class EditorAgent
{
/** Reference to the registry. */
- private static Registry registry;
+ private static Registry registry;
+
+ /** The group id if set.*/
+ private long groupId;
/**
* Helper method.
@@ -96,6 +106,16 @@ public static ExperimenterData getUserDetails()
LookupNames.CURRENT_USER_DETAILS);
}
+ /**
+ * Returns the available user groups.
+ *
+ * @return See above.
+ */
+ public static Set getAvailableUserGroups()
+ {
+ return (Set) registry.lookup(LookupNames.USER_GROUP_DETAILS);
+ }
+
/**
* Returns true
if an OMERO server is available,
* false
otherwise.
@@ -165,14 +185,19 @@ public static String getEditorAutosave()
public static Editor openLocalFile(File file)
{
- if (file == null) return null;
- if (!file.exists()) return null;
+ if (file == null) return null;
+ if (!file.exists()) return null;
// gets a blank editor (one that has been created with a 'blank' model),
// OR an existing editor if one has the same
// file ID (will be 0 if editor file is local) and same file name, OR
// creates a new editor model and editor with this new file.
- Editor editor = EditorFactory.getEditor(file);
+
+ ExperimenterData exp = getUserDetails();
+ SecurityContext ctx = null;
+ if (exp != null)
+ ctx = new SecurityContext(exp.getDefaultGroup().getId());
+ Editor editor = EditorFactory.getEditor(ctx, file);
// activates the editor
// if the editor is 'blank' or has just been created (above),
@@ -205,7 +230,8 @@ private void handleFileEdition(EditFileEvent event)
FileAnnotationData data = event.getFileAnnotation();
if (data == null) {
if (event.getFileAnnotationID() > 0)
- editor = EditorFactory.getEditor(event.getFileAnnotationID());
+ editor = EditorFactory.getEditor(event.getSecurityContext(),
+ event.getFileAnnotationID());
} else {
if (data.getId() <= 0) return;
String name = data.getFileName();
@@ -215,7 +241,8 @@ private void handleFileEdition(EditFileEvent event)
FileAnnotationData.EDITOR_PROTOCOL_NS.equals(ns) ||
FileAnnotationData.COMPANION_FILE_NS.equals(ns) ||
EditorUtil.isEditorFile(name))
- editor = EditorFactory.getEditor(data);
+ editor = EditorFactory.getEditor(event.getSecurityContext(),
+ data);
else {
ApplicationData app = new ApplicationData("");
UserNotifier un = getRegistry().getUserNotifier();
@@ -235,12 +262,12 @@ private void handleFileEdition(EditFileEvent event)
new File(path), null);
}
activity.setApplicationData(app);
- un.notifyActivity(activity);
+ un.notifyActivity(event.getSecurityContext(), activity);
return;
}
}
if (editor != null)
- editor.activate(); // starts file downloading
+ editor.activate();// starts file downloading
}
/**
@@ -254,18 +281,19 @@ private void handleShowEditor(ShowEditorEvent evt)
AutosaveRecovery autosaveRecovery = new AutosaveRecovery();
Editor editor = null;
if (evt == null) {
- editor = EditorFactory.getEditor();
+ editor = EditorFactory.getEditor(null);
if (editor != null) editor.activate();
autosaveRecovery.checkForRecoveredFiles(); // now check
return;
}
if (evt.getParent() == null)
- editor = EditorFactory.getEditor();
+ editor = EditorFactory.getEditor(evt.getSecurityContext());
else {
int editorType = Editor.PROTOCOL;
if (evt.getType() == ShowEditorEvent.EXPERIMENT)
editorType = Editor.EXPERIMENT;
- editor = EditorFactory.getEditor(evt.getParent(), evt.getName(),
+ editor = EditorFactory.getEditor(evt.getSecurityContext(),
+ evt.getParent(), evt.getName(),
editorType);
}
autosaveRecovery.checkForRecoveredFiles(); // now check
@@ -310,12 +338,35 @@ private void handleCopyData(CopyEvent evt)
private void register()
{
TaskBar tb = registry.getTaskBar();
- RegisterAction a = new RegisterAction();
- //register with tool bar
- JButton b = new JButton(a);
+ IconManager icons = IconManager.getInstance();
+ JButton b = new JButton(icons.getIcon(IconManager.EDITOR));
+ b.setToolTipText(RegisterAction.DESCRIPTION);
+ ActionListener l = new ActionListener() {
+
+ /** Posts an event to start the agent.*/
+ public void actionPerformed(ActionEvent e) {
+ EventBus bus = registry.getEventBus();
+ ExperimenterData exp = (ExperimenterData) registry.lookup(
+ LookupNames.CURRENT_USER_DETAILS);
+ if (exp == null) return;
+ GroupData gp = null;
+ try {
+ gp = exp.getDefaultGroup();
+ } catch (Exception ex) {
+ //No default group
+ }
+ long id = -1;
+ if (gp != null) id = gp.getId();
+ if (groupId == -1) groupId = id;
+ bus.post(new ShowEditorEvent(new SecurityContext(groupId)));
+ }
+ };
+ b.addActionListener(l);
tb.addToToolBar(TaskBar.AGENTS, b);
//register with File menu
- JMenuItem item = new JMenuItem(a);
+ JMenuItem item = new JMenuItem(icons.getIcon(IconManager.EDITOR));
+ item.setToolTipText(RegisterAction.DESCRIPTION);
+ item.addActionListener(l);
item.setText(RegisterAction.NAME);
tb.addToMenu(TaskBar.FILE_MENU, item);
}
@@ -352,6 +403,7 @@ public void setContext(Registry ctx)
bus.register(this, CopyEvent.class);
bus.register(this, UserGroupSwitched.class);
bus.register(this, ReconnectedEvent.class);
+ bus.register(this, ChangeUserGroupEvent.class);
//Register itself for the toolbar.
register();
}
@@ -403,6 +455,10 @@ else if (e instanceof UserGroupSwitched)
handleUserGroupSwitched((UserGroupSwitched) e);
else if (e instanceof ReconnectedEvent)
handleReconnectedEvent((ReconnectedEvent) e);
+ else if (e instanceof ChangeUserGroupEvent) {
+ ChangeUserGroupEvent evt = (ChangeUserGroupEvent) e;
+ groupId = evt.getGroupID();
+ }
}
}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/EditorLoader.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/EditorLoader.java
index 7c56ebf8a7f..d60ae7c999e 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/EditorLoader.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/EditorLoader.java
@@ -31,6 +31,7 @@
import org.openmicroscopy.shoola.agents.editor.view.Editor;
import org.openmicroscopy.shoola.env.config.Registry;
import org.openmicroscopy.shoola.env.data.events.DSCallAdapter;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.MetadataHandlerView;
import org.openmicroscopy.shoola.env.log.LogMessage;
@@ -60,24 +61,30 @@ public abstract class EditorLoader
{
/** The browser this data loader is for. */
- protected final Editor viewer;
+ protected final Editor viewer;
/** Convenience reference for subclasses. */
- protected final Registry registry;
+ protected final Registry registry;
/** Convenience reference for subclasses. */
- protected final MetadataHandlerView mhView;
+ protected final MetadataHandlerView mhView;
+ /** The security context.*/
+ protected final SecurityContext ctx;
+
/**
* Creates a new instance.
*
* @param viewer The browser this data loader is for.
* Mustn't be null
.
+ * @param ctx The security context.
*/
- protected EditorLoader(Editor viewer)
+ protected EditorLoader(Editor viewer, SecurityContext ctx)
{
- if (viewer == null) throw new NullPointerException("No viewer.");
+ if (viewer == null) throw new NullPointerException("No viewer.");
+ if (ctx == null) throw new NullPointerException("No security context.");
this.viewer = viewer;
+ this.ctx = ctx;
registry = EditorAgent.getRegistry();
mhView = (MetadataHandlerView)
registry.getDataServicesView(MetadataHandlerView.class);
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/FileAnnotationLoader.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/FileAnnotationLoader.java
index c0dcd26192d..b9ea9e6ed20 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/FileAnnotationLoader.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/FileAnnotationLoader.java
@@ -29,6 +29,7 @@
//Application-internal dependencies
import org.openmicroscopy.shoola.agents.editor.browser.Browser;
import org.openmicroscopy.shoola.agents.editor.preview.AnnotationHandler;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.CallHandle;
import pojos.FileAnnotationData;
@@ -52,27 +53,29 @@ public class FileAnnotationLoader
{
/** Handle to the asynchronous call so that we can cancel it. */
- private CallHandle handle;
+ private CallHandle handle;
/** The id of the file annotation to load. */
- private long fileAnnotationID;
+ private long fileAnnotationID;
/**
* The handler of the annotation. Don't want this to be Editor since
* it would be tricky to handle which class requested the annotation.
*/
- private AnnotationHandler annotationHandler;
+ private AnnotationHandler annotationHandler;
/**
* Creates a new instance.
*
* @param viewer The Editor this data loader is for.
* Mustn't be null
.
+ * @param ctx The security context.
* @param fileAnnotationID The Id of the file annotation to load.
*/
- public FileAnnotationLoader(Browser viewer, long fileAnnotationID)
+ public FileAnnotationLoader(Browser viewer, SecurityContext ctx,
+ long fileAnnotationID)
{
- super(viewer);
+ super(viewer, ctx);
if (fileAnnotationID < 0)
throw new IllegalArgumentException("ID not valid.");
this.fileAnnotationID = fileAnnotationID;
@@ -94,7 +97,7 @@ public void setAnnotationHandler(AnnotationHandler handler)
*/
public void load()
{
- handle = mhView.loadAnnotation(fileAnnotationID, this);
+ handle = mhView.loadAnnotation(ctx, fileAnnotationID, this);
}
/**
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/FileLoader.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/FileLoader.java
index fc64d42bbb8..cc394439f15 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/FileLoader.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/FileLoader.java
@@ -35,6 +35,7 @@
import org.openmicroscopy.shoola.agents.editor.view.Editor;
import org.openmicroscopy.shoola.agents.treeviewer.browser.Browser;
import org.openmicroscopy.shoola.env.data.events.DSCallAdapter;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.CallHandle;
import org.openmicroscopy.shoola.env.log.LogMessage;
@@ -60,31 +61,32 @@ public class FileLoader
{
/** Handle to the asynchronous call so that we can cancel it. */
- private CallHandle handle;
+ private CallHandle handle;
/** The id of the file to load. */
- private long fileID;
+ private long fileID;
/** The size of the file to load. */
- private long fileSize;
+ private long fileSize;
/** Utility file where the raw data are loaded. */
- private File file;
+ private File file;
/**
* Creates a new instance.
*
* @param viewer The Editor this data loader is for.
* Mustn't be null
.
+ * @param ctx The security context.
* @param fileName The name of the file to edit.
* @param fileID The id of the file to load OR
* of the fileAnnotation if fileName is null
.
* @param fileSize The size of the file to load.
*/
- public FileLoader(Editor viewer, String fileName, long fileID,
- long fileSize)
+ public FileLoader(Editor viewer, SecurityContext ctx, String fileName,
+ long fileID, long fileSize)
{
- super(viewer);
+ super(viewer, ctx);
if (fileID < 0)
throw new IllegalArgumentException("ID not valid.");
this.fileID = fileID;
@@ -98,7 +100,7 @@ public FileLoader(Editor viewer, String fileName, long fileID,
*/
public void load()
{
- handle = mhView.loadFile(file, fileID, fileSize, this);
+ handle = mhView.loadFile(ctx, file, fileID, fileSize, this);
}
/**
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/FileSaver.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/FileSaver.java
index 6ad3efb582a..2a83fbed430 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/FileSaver.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/FileSaver.java
@@ -32,6 +32,7 @@
//Application-internal dependencies
import org.openmicroscopy.shoola.agents.editor.view.Editor;
import org.openmicroscopy.shoola.agents.treeviewer.browser.Browser;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.CallHandle;
import org.openmicroscopy.shoola.env.data.views.MetadataHandlerView;
@@ -58,45 +59,46 @@ public class FileSaver
{
/** Identifies that the file is of type protocol. */
- public static final int PROTOCOL = MetadataHandlerView.EDITOR_PROTOCOL;
+ public static final int PROTOCOL = MetadataHandlerView.EDITOR_PROTOCOL;
/** Identifies that the file is of type experiment. */
- public static final int EXPERIMENT =
+ public static final int EXPERIMENT =
MetadataHandlerView.EDITOR_EXPERIMENT;
/** Identifies that the file is of type other. */
- public static final int OTHER = MetadataHandlerView.OTHER;
+ public static final int OTHER = MetadataHandlerView.OTHER;
/** Handle to the asynchronous call so that we can cancel it. */
- private CallHandle handle;
+ private CallHandle handle;
/** Utility file where the raw data are loaded. */
- private File file;
+ private File file;
/** The fileAnnotation data. */
- private FileAnnotationData fileAnnotationData;
+ private FileAnnotationData fileAnnotationData;
/** One of the constants defined by this class. */
- private int index;
+ private int index;
/** The DataObject
to link the file annotation to. */
- private DataObject linkTo;
+ private DataObject linkTo;
/**
* Creates a new instance.
*
* @param viewer The Editor this data loader is for.
* Mustn't be null
.
+ * @param ctx The security context.
* @param file The file to save back to the server.
* @param data The id of the file if previously saved, or
* -1
if not previously saved.
* @param index One of the constants defined by this class.
* @param linkTo The
*/
- public FileSaver(Editor viewer, File file, FileAnnotationData data,
- int index, DataObject linkTo)
+ public FileSaver(Editor viewer, SecurityContext ctx, File file,
+ FileAnnotationData data, int index, DataObject linkTo)
{
- super(viewer);
+ super(viewer, ctx);
if (file == null)
throw new IllegalArgumentException("No file to save.");
if (data == null)
@@ -121,7 +123,8 @@ public FileSaver(Editor viewer, File file, FileAnnotationData data,
*/
public void load()
{
- handle = mhView.saveFile(fileAnnotationData, file, index, linkTo, this);
+ handle = mhView.saveFile(ctx, fileAnnotationData, file, index, linkTo,
+ this);
}
/**
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/IconManager.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/IconManager.java
index 010e3aef3f7..2d6b4d58fb8 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/IconManager.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/IconManager.java
@@ -332,11 +332,23 @@ public class IconManager
/** The Clear Values
icon */
public static final int CLEAR_VALUES_ICON = 91;
+ /** The 12x12 Private Group Drop Down
icon. */
+ public static final int PRIVATE_GROUP_DD_12 = 92;
+
+ /** The 12x12 Read Group Drop Down
icon. */
+ public static final int READ_GROUP_DD_12 = 93;
+
+ /** The 12x12 Read Link Group Drop Down
icon. */
+ public static final int READ_LINK_GROUP_DD_12 = 94;
+
+ /** The 12x12 Public Group Drop Down
icon. */
+ public static final int PUBLIC_GROUP_DD_12 = 95;
+
/**
* The maximum ID used for the icon IDs.
* Allows to correctly build arrays for direct indexing.
*/
- private static final int MAX_ID = 91;
+ private static final int MAX_ID = 95;
/** Paths of the icon files. */
@@ -442,6 +454,10 @@ public class IconManager
relPaths[ADD_STEP_NOTE_ICON] = "addStepNote.png";
relPaths[STEP_NOTE_ICON] = "stepNote.png";
relPaths[CLEAR_VALUES_ICON] = "nuvola_news_unsubscribe16.png";
+ relPaths[PRIVATE_GROUP_DD_12] = "nuvola_permission_private_dd12.png";
+ relPaths[READ_GROUP_DD_12] = "nuvola_permission_readOnly_dd12.png";
+ relPaths[READ_LINK_GROUP_DD_12] = "nuvola_permission_read_dd12.png";
+ relPaths[PUBLIC_GROUP_DD_12] = "nuvola_permission_public_dd12.png";
}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/actions/GroupSelectionAction.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/actions/GroupSelectionAction.java
new file mode 100644
index 00000000000..e2bcd816ba3
--- /dev/null
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/actions/GroupSelectionAction.java
@@ -0,0 +1,130 @@
+/*
+ * org.openmicroscopy.shoola.agents.editor.actions.GroupSelectionAction
+ *
+ *------------------------------------------------------------------------------
+ * Copyright (C) 2006-2012 University of Dundee & Open Microscopy Environment.
+ * All rights reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *------------------------------------------------------------------------------
+ */
+package org.openmicroscopy.shoola.agents.editor.actions;
+
+
+//Java imports
+import java.awt.event.ActionEvent;
+import javax.swing.Action;
+
+//Third-party libraries
+
+//Application-internal dependencies
+import org.openmicroscopy.shoola.agents.editor.EditorAgent;
+import org.openmicroscopy.shoola.agents.editor.view.Editor;
+import org.openmicroscopy.shoola.agents.treeviewer.IconManager;
+import org.openmicroscopy.shoola.env.data.model.AdminObject;
+import org.openmicroscopy.shoola.util.ui.UIUtilities;
+import pojos.GroupData;
+
+/**
+ * Selects the group out of the list of groups the user is member of
+ *
+ * @author Jean-Marie Burel
+ * j.burel@dundee.ac.uk
+ * @since Beta4.4
+ */
+public class GroupSelectionAction
+ extends EditorAction
+{
+
+ /** The group the logged in user is member of. */
+ private GroupData group;
+
+ /**
+ * Sets the icon and tool tip text according to the permissions of the
+ * group.
+ */
+ private void setPermissions()
+ {
+ int iconID = IconManager.PERSONAL;
+ int level =
+ EditorAgent.getRegistry().getAdminService().getPermissionLevel(
+ group);
+ String desc = "";
+ switch (level) {
+ case AdminObject.PERMISSIONS_PRIVATE:
+ desc = AdminObject.PERMISSIONS_PRIVATE_TEXT;
+ iconID = IconManager.PRIVATE_GROUP_DD_12;
+ break;
+ case AdminObject.PERMISSIONS_GROUP_READ:
+ desc = AdminObject.PERMISSIONS_GROUP_READ_TEXT;
+ iconID = IconManager.READ_GROUP_DD_12;
+ break;
+ case AdminObject.PERMISSIONS_GROUP_READ_LINK:
+ desc = AdminObject.PERMISSIONS_GROUP_READ_LINK_TEXT;
+ iconID = IconManager.READ_LINK_GROUP_DD_12;
+ break;
+ case AdminObject.PERMISSIONS_PUBLIC_READ:
+ desc = AdminObject.PERMISSIONS_PUBLIC_READ_TEXT;
+ iconID = IconManager.PUBLIC_GROUP_DD_12;
+ break;
+ case AdminObject.PERMISSIONS_PUBLIC_READ_WRITE:
+ desc = AdminObject.PERMISSIONS_PUBLIC_READ_WRITE_TEXT;
+ iconID = IconManager.PUBLIC_GROUP_DD_12;
+ }
+
+
+ setIcon(iconID);
+ putValue(Action.SHORT_DESCRIPTION, UIUtilities.formatToolTipText(desc));
+ }
+
+ /**
+ * Creates a new instance.
+ *
+ * @param model Reference to the Model. Mustn't be null
.
+ * @param group The group the logged in user is a member of.
+ */
+ public GroupSelectionAction(Editor model, GroupData group)
+ {
+ super(model);
+ if (group == null)
+ throw new IllegalArgumentException("No group specified.");
+ this.group = group;
+ putValue(Action.NAME, group.getName());
+ setPermissions();
+ }
+
+ /**
+ * Returns true
if the passed id corresponds to the group
+ * hosted by this component, false
otherwise.
+ *
+ * @param groupID The id to check.
+ * @return See above.
+ */
+ public boolean isSameGroup(long groupID)
+ {
+ return group.getId() == groupID;
+ }
+
+ /**
+ * Sets the default group for the currently logged in user.
+ * @see java.awt.event.ActionListener#actionPerformed(ActionEvent)
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ model.setUserGroup(group.getId());
+ }
+
+}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/actions/PersonalManagementAction.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/actions/PersonalManagementAction.java
new file mode 100644
index 00000000000..b055c5fb208
--- /dev/null
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/actions/PersonalManagementAction.java
@@ -0,0 +1,152 @@
+/*
+ * org.openmicroscopy.shoola.agents.editor.actions.PersonalManagementAction
+ *
+ *------------------------------------------------------------------------------
+ * Copyright (C) 2006-2012 University of Dundee & Open Microscopy Environment.
+ * All rights reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *------------------------------------------------------------------------------
+ */
+package org.openmicroscopy.shoola.agents.editor.actions;
+
+
+//Java imports
+import java.awt.Component;
+import java.awt.Point;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import javax.swing.Action;
+
+//Third-party libraries
+
+//Application-internal dependencies
+import org.openmicroscopy.shoola.agents.editor.EditorAgent;
+import org.openmicroscopy.shoola.agents.editor.IconManager;
+import org.openmicroscopy.shoola.agents.editor.view.Editor;
+import org.openmicroscopy.shoola.env.data.model.AdminObject;
+import org.openmicroscopy.shoola.util.ui.UIUtilities;
+import pojos.GroupData;
+
+/**
+ * Brings up the menu with available group.
+ *
+ * @author Jean-Marie Burel
+ * j.burel@dundee.ac.uk
+ * @since Beta4.4
+ */
+public class PersonalManagementAction
+ extends EditorAction
+ implements MouseListener
+{
+
+ /** The description of the action. */
+ private static final String DESCRIPTION = "Select your current group.";
+
+ /** The location of the mouse pressed. */
+ private Point point;
+
+ /**
+ * Creates a new instance.
+ *
+ * @param model Reference to the Model. Mustn't be null
.
+ */
+ public PersonalManagementAction(Editor model)
+ {
+ super(model);
+ setEnabled(true);
+ setPermissions();
+ }
+
+ /** Sets the name, description and the icon depending on the permissions. */
+ public void setPermissions()
+ {
+ GroupData group = model.getSelectedGroup();
+ String name = "";
+ String desc = DESCRIPTION;
+ int iconID = IconManager.UP_DOWN_9_12;
+ if (group != null) {
+ name = group.getName();
+ int level =
+ EditorAgent.getRegistry().getAdminService().getPermissionLevel(
+ group);
+ switch (level) {
+ case AdminObject.PERMISSIONS_PRIVATE:
+ desc = AdminObject.PERMISSIONS_PRIVATE_TEXT;
+ iconID = IconManager.PRIVATE_GROUP_DD_12;
+ break;
+ case AdminObject.PERMISSIONS_GROUP_READ:
+ desc = AdminObject.PERMISSIONS_GROUP_READ_TEXT;
+ iconID = IconManager.READ_GROUP_DD_12;
+ break;
+ case AdminObject.PERMISSIONS_GROUP_READ_LINK:
+ desc = AdminObject.PERMISSIONS_GROUP_READ_LINK_TEXT;
+ iconID = IconManager.READ_LINK_GROUP_DD_12;
+ break;
+ case AdminObject.PERMISSIONS_PUBLIC_READ:
+ desc = AdminObject.PERMISSIONS_PUBLIC_READ_TEXT;
+ iconID = IconManager.PUBLIC_GROUP_DD_12;
+ break;
+ case AdminObject.PERMISSIONS_PUBLIC_READ_WRITE:
+ desc = AdminObject.PERMISSIONS_PUBLIC_READ_WRITE_TEXT;
+ iconID = IconManager.PUBLIC_GROUP_DD_12;
+ }
+ }
+ putValue(Action.NAME, name);
+ setIcon(iconID);
+ putValue(Action.SHORT_DESCRIPTION, UIUtilities.formatToolTipText(desc));
+ }
+ /**
+ * Sets the location of the point where the mousePressed
+ * event occurred.
+ * @see MouseListener#mousePressed(MouseEvent)
+ */
+ public void mousePressed(MouseEvent me) { point = me.getPoint(); }
+
+ /**
+ * Brings up the menu.
+ * @see MouseListener#mouseReleased(MouseEvent)
+ */
+ public void mouseReleased(MouseEvent me)
+ {
+ Object source = me.getSource();
+ if (point == null) point = me.getPoint();
+ if (source instanceof Component && isEnabled())
+ model.showMenu(Editor.GROUP_MENU, (Component) source, point);
+ }
+
+ /**
+ * Required by {@link MouseListener} I/F but not actually needed in our
+ * case, no-operation implementation.
+ * @see MouseListener#mouseEntered(MouseEvent)
+ */
+ public void mouseEntered(MouseEvent e) {}
+
+ /**
+ * Required by {@link MouseListener} I/F but not actually needed in our
+ * case, no-operation implementation.
+ * @see MouseListener#mouseExited(MouseEvent)
+ */
+ public void mouseExited(MouseEvent e) {}
+
+ /**
+ * Required by {@link MouseListener} I/F but not actually needed in our
+ * case, no-operation implementation.
+ * @see MouseListener#mouseClicked(MouseEvent)
+ */
+ public void mouseClicked(MouseEvent e) {}
+
+}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/actions/RegisterAction.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/actions/RegisterAction.java
index 1a507fc0b73..685c16e38ef 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/actions/RegisterAction.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/actions/RegisterAction.java
@@ -36,9 +36,13 @@
import org.openmicroscopy.shoola.agents.editor.EditorAgent;
import org.openmicroscopy.shoola.agents.editor.IconManager;
import org.openmicroscopy.shoola.agents.events.editor.ShowEditorEvent;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.event.EventBus;
import org.openmicroscopy.shoola.util.ui.UIUtilities;
+import pojos.ExperimenterData;
+import pojos.GroupData;
+
/**
* Registers the agent.
*
@@ -54,7 +58,7 @@ public class RegisterAction
public static final String NAME = "Editor...";
/** The description of the action. */
- private static final String DESCRIPTION = "Open the Editor.";
+ public static final String DESCRIPTION = "Open the Editor.";
/**
* Creates a new instance.
@@ -71,9 +75,13 @@ public RegisterAction()
* Posts an event on the bus to open the editor.
* @see AbstractAction#actionPerformed(ActionEvent)
*/
- public void actionPerformed(ActionEvent evt) {
+ public void actionPerformed(ActionEvent evt)
+ {
+ ExperimenterData exp = EditorAgent.getUserDetails();
+ GroupData group = exp.getDefaultGroup();
+ if (group == null) return;
EventBus bus = EditorAgent.getRegistry().getEventBus();
- bus.post(new ShowEditorEvent());
+ bus.post(new ShowEditorEvent(new SecurityContext(group.getId())));
}
}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/browser/Browser.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/browser/Browser.java
index 71e82771a9f..9d6c27bcf98 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/browser/Browser.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/browser/Browser.java
@@ -31,6 +31,7 @@
//Third-party libraries
//Application-internal dependencies
+import org.openmicroscopy.shoola.agents.editor.preview.AnnotationHandler;
import org.openmicroscopy.shoola.util.ui.component.ObservableComponent;
@@ -191,4 +192,12 @@ public interface Browser
*/
public void deleteExperimentInfo();
+ /**
+ * Loads the file annotation.
+ *
+ * @param fileID The fileID you want the annotation for.
+ * @param handler The handler used when the annotation is returned.
+ */
+ void getFileAnnotation(long fileID, AnnotationHandler handler);
+
}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/browser/BrowserComponent.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/browser/BrowserComponent.java
index af3588f7b5a..335fad744d7 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/browser/BrowserComponent.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/browser/BrowserComponent.java
@@ -33,6 +33,7 @@
//Application-internal dependencies
+import org.openmicroscopy.shoola.agents.editor.preview.AnnotationHandler;
import org.openmicroscopy.shoola.util.ui.component.AbstractComponent;
/**
@@ -212,5 +213,14 @@ public void deleteExperimentInfo()
{
controller.deleteExperimentInfo(model.getTreeModel());
}
+
+ /**
+ * Implemented as specified by the {@link Browser} interface.
+ * @see Browser#getFileAnnotation(long, AnnotationHandler)
+ */
+ public void getFileAnnotation(long fileID, AnnotationHandler handler)
+ {
+ model.getFileAnnotation(fileID, handler);
+ }
}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/browser/BrowserControl.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/browser/BrowserControl.java
index 2cf6b1740c6..b1fff2b1345 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/browser/BrowserControl.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/browser/BrowserControl.java
@@ -652,9 +652,7 @@ public void removeFieldTable(IField field, JTree tree, TreeNode node)
public void getFileAnnotation(long fileID, AnnotationHandler handler)
{
if (handler == null) return;
- FileAnnotationLoader fal = new FileAnnotationLoader(model, fileID);
- fal.setAnnotationHandler(handler);
- fal.load();
+ model.getFileAnnotation(fileID, handler);
}
/**
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/browser/BrowserFactory.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/browser/BrowserFactory.java
index 090195ba9e7..a2466e0f5a5 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/browser/BrowserFactory.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/browser/BrowserFactory.java
@@ -29,6 +29,8 @@
//Application-internal dependencies
package org.openmicroscopy.shoola.agents.editor.browser;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
+
/**
* Factory to create {@link Browser} objects.
*
@@ -44,17 +46,18 @@ public class BrowserFactory
{
/**
- * Creates a new {@link Browser}, with a UI either for disply or editing
+ * Creates a new {@link Browser}, with a UI either for display or editing
* of the Tree data.
*
+ * @param ctx The security context.
* @param editingMode Either {@link Browser#FILE_LOCKED},
* {@link Browser#EDIT_EXPERIMENT}, or {@link Browser#EDIT_PROTOCOL}.
- *
* @return A browser component.
*/
- public static Browser createBrowser(int editingMode, int type)
+ public static Browser createBrowser(SecurityContext ctx,
+ int editingMode, int type)
{
- BrowserModel model = new BrowserModel(editingMode, type);
+ BrowserModel model = new BrowserModel(ctx, editingMode, type);
BrowserComponent component = new BrowserComponent(model);
model.initialize(component);
component.initialize();
@@ -64,19 +67,17 @@ public static Browser createBrowser(int editingMode, int type)
/**
* Creates a new {@link Browser}, with a UI either in the Display mode.
*
+ * @param ctx The security context.
* @param type Either {@link Browser#PROTOCOL} or {@link Browser#EXPERIMENT}.
* @return A browser component.
*
*/
- public static Browser createBrowser(int type)
+ public static Browser createBrowser(SecurityContext ctx, int type)
{
- int editingMode;
+ int editingMode = Browser.EDIT_PROTOCOL;
if (type == Browser.EXPERIMENT)
editingMode = Browser.EDIT_EXPERIMENT;
- else
- editingMode = Browser.EDIT_PROTOCOL;
-
- return createBrowser(editingMode, type);
+ return createBrowser(ctx, editingMode, type);
}
-
+
}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/browser/BrowserModel.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/browser/BrowserModel.java
index 8fc4cf6b9bd..fe90700bc9a 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/browser/BrowserModel.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/browser/BrowserModel.java
@@ -31,9 +31,12 @@
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreeNode;
+import org.openmicroscopy.shoola.agents.editor.FileAnnotationLoader;
import org.openmicroscopy.shoola.agents.editor.model.CPEimport;
import org.openmicroscopy.shoola.agents.editor.model.ExperimentInfo;
import org.openmicroscopy.shoola.agents.editor.model.IAttributes;
+import org.openmicroscopy.shoola.agents.editor.preview.AnnotationHandler;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
//Third-party libraries
@@ -77,16 +80,21 @@ class BrowserModel
/** The type of browser. */
private int type;
+ /** The security context.*/
+ private SecurityContext ctx;
+
/**
* Creates an instance.
*
+ * @param ctx The security context.
* @param state The editing mode of the browser.
* Either {@link Browser#EDIT_EXPERIMENT} or
* {@link Browser#EDIT_PROTOCOL}
* @param type
*/
- BrowserModel(int state, int type)
+ BrowserModel(SecurityContext ctx, int state, int type)
{
+ this.ctx = ctx;
setEditingMode(state);
this.savedState = Browser.TREE_SAVED;
this.type = type;
@@ -256,4 +264,18 @@ Date getLastSavedDate()
*/
int getType() { return type; }
+ /**
+ * Loads the file annotation.
+ *
+ * @param fileID The id of the file to load.
+ * @param handler The handler used when the annotation is returned.
+ */
+ void getFileAnnotation(long fileID, AnnotationHandler handler)
+ {
+ FileAnnotationLoader fal = new FileAnnotationLoader(component, ctx,
+ fileID);
+ fal.setAnnotationHandler(handler);
+ fal.load();
+ }
+
}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/browser/paramUIs/ProtocolLinkEditor.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/browser/paramUIs/ProtocolLinkEditor.java
index 0230d6b4236..bc3e3f6588b 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/browser/paramUIs/ProtocolLinkEditor.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/browser/paramUIs/ProtocolLinkEditor.java
@@ -315,11 +315,11 @@ public void actionPerformed(ActionEvent e) {
// if link to local file that exists, open in Editor.
if (f.exists())
EditorAgent.openLocalFile(f);
-
- }
- else if (fileID > 0) {
+ } else if (fileID > 0) {
+ /*TODO: review that work
EventBus bus = MetadataViewerAgent.getRegistry().getEventBus();
bus.post(new EditFileEvent(fileID));
+ */
}
}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/graphx/nuvola_permission_private_dd12.png b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/graphx/nuvola_permission_private_dd12.png
new file mode 100644
index 00000000000..4e28faa4ee5
Binary files /dev/null and b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/graphx/nuvola_permission_private_dd12.png differ
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/graphx/nuvola_permission_public_dd12.png b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/graphx/nuvola_permission_public_dd12.png
new file mode 100644
index 00000000000..10a631b1622
Binary files /dev/null and b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/graphx/nuvola_permission_public_dd12.png differ
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/graphx/nuvola_permission_readLink_dd12.png b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/graphx/nuvola_permission_readLink_dd12.png
new file mode 100644
index 00000000000..905c5754b61
Binary files /dev/null and b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/graphx/nuvola_permission_readLink_dd12.png differ
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/graphx/nuvola_permission_readOnly_dd12.png b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/graphx/nuvola_permission_readOnly_dd12.png
new file mode 100644
index 00000000000..8ad32dbfd53
Binary files /dev/null and b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/graphx/nuvola_permission_readOnly_dd12.png differ
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/graphx/nuvola_permission_read_dd12.png b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/graphx/nuvola_permission_read_dd12.png
new file mode 100644
index 00000000000..462fd95e1ad
Binary files /dev/null and b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/graphx/nuvola_permission_read_dd12.png differ
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/preview/EditorPreview.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/preview/EditorPreview.java
index b4c292adf1d..16c1a8ad853 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/preview/EditorPreview.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/preview/EditorPreview.java
@@ -150,7 +150,7 @@ public EditorPreview(long fileID, BrowserControl controller)
void loadPreviewData()
{
if (fileID != 0) {
- if (! EditorAgent.isServerAvailable()) {
+ if (!EditorAgent.isServerAvailable()) {
annotationDesc =
"File ID: " + fileID + " on server" +
"Can't show the preview of this file because " +
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/view/Editor.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/view/Editor.java
index 88ef82acf38..e5636f22537 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/view/Editor.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/view/Editor.java
@@ -24,9 +24,10 @@
//Java imports
+import java.awt.Component;
+import java.awt.Point;
import java.beans.PropertyChangeListener;
import java.io.File;
-
import javax.swing.JFrame;
//Third-party libraries
@@ -36,6 +37,7 @@
import org.openmicroscopy.shoola.agents.events.editor.ShowEditorEvent;
import org.openmicroscopy.shoola.util.ui.component.ObservableComponent;
import pojos.FileAnnotationData;
+import pojos.GroupData;
/**
* Defines the interface provided by the editor component.
@@ -85,6 +87,9 @@ public interface Editor
/** Flag to denote the Saving state. */
public static final int SAVING = 5;
+ /** Identifies the group menu. */
+ public static final int GROUP_MENU = 100;
+
/**
* Starts the data loading process when the current state is {@link #NEW}
* and puts the window on screen.
@@ -243,5 +248,30 @@ public interface Editor
* @return See above.
*/
public JFrame getUI();
+
+ /**
+ * Returns the group corresponding to the security context.
+ *
+ * @return See above.
+ */
+ public GroupData getSelectedGroup();
+ /**
+ * Brings up the menu on top of the specified component at
+ * the specified location.
+ *
+ * @param menuID The id of the menu.
+ * @param invoker The component that requested the pop-up menu.
+ * @param loc The point at which to display the menu, relative to the
+ * component
's coordinates.
+ */
+ public void showMenu(int menuID, Component c, Point p);
+
+ /**
+ * Sets the group to used if the file is saved back to the server.
+ *
+ * @param groupID The id of the group.
+ */
+ void setUserGroup(long groupID);
+
}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/view/EditorComponent.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/view/EditorComponent.java
index a06b16694b7..0c92df6380b 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/view/EditorComponent.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/view/EditorComponent.java
@@ -23,12 +23,16 @@
package org.openmicroscopy.shoola.agents.editor.view;
//Java imports
+import java.awt.Component;
+import java.awt.Point;
import java.beans.PropertyChangeListener;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
+import java.util.Iterator;
+import java.util.Set;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
@@ -42,11 +46,13 @@
import org.openmicroscopy.shoola.agents.editor.actions.SaveNewCmd;
import org.openmicroscopy.shoola.agents.editor.browser.Browser;
import org.openmicroscopy.shoola.env.data.events.ExitApplication;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.event.EventBus;
import org.openmicroscopy.shoola.env.ui.UserNotifier;
import org.openmicroscopy.shoola.util.ui.MessageBox;
import org.openmicroscopy.shoola.util.ui.component.AbstractComponent;
import pojos.FileAnnotationData;
+import pojos.GroupData;
/**
* Implements the {@link Editor} interface to provide the functionality
@@ -332,7 +338,8 @@ public void openLocalFile(File file) {
public void newBlankFile()
{
// gets a new editor
- Editor editor = EditorFactory.getNewBlankEditor();
+ Editor editor = EditorFactory.getNewBlankEditor(
+ model.getSecurityContext());
// primes the editor to open new file and activates the editor
if (editor != null) {
@@ -522,13 +529,14 @@ public void onFileSave(FileAnnotationData data)
{
UserNotifier un = EditorAgent.getRegistry().getUserNotifier();
String message =
- "An error occured while saving the file to the server.";
+ "An error occurred while saving the file to the server.";
if (data != null) {
long id = data.getId();
message = "The File has been saved to the server. \nID = " + id;
model.setFileAnnotationData(data);
model.getBrowser().setId(id);
}
+ view.setGroupInformation();
un.notifyInfo("File Saved", message);
model.setState(READY);
view.setTitle(model.getFileName());
@@ -585,6 +593,25 @@ public boolean isUserOwner()
{
return model.isUserOwner();
}
+
+ /**
+ * Implemented as specified by the {@link Editor} interface.
+ * @see Editor#isUserOwner()
+ */
+ public GroupData getSelectedGroup()
+ {
+ SecurityContext ctx = model.getSecurityContext();
+ if (ctx == null) return null;
+ Set groups = EditorAgent.getAvailableUserGroups();
+ Iterator i = groups.iterator();
+ GroupData g;
+ while (i.hasNext()) {
+ g = (GroupData) i.next();
+ if (g.getId() == ctx.getGroupID())
+ return g;
+ }
+ return null;
+ }
/**
* Implemented as specified by the {@link Editor} interface.
@@ -592,10 +619,37 @@ public boolean isUserOwner()
*/
public JFrame getUI() { return view; }
+ /**
+ * Implemented as specified by the {@link Editor} interface.
+ * @see Editor#showMenu(int, Component, Point)
+ */
+ public void showMenu(int menuID, Component c, Point p)
+ {
+ switch (menuID) {
+ case GROUP_MENU:
+ view.showMenu(menuID, c, p);
+ break;
+ }
+ }
+
+ /**
+ * Implemented as specified by the {@link Editor} interface.
+ * @see Editor#showMenu(int, Component, Point)
+ */
+ public void setUserGroup(long groupID)
+ {
+ SecurityContext ctx = model.getSecurityContext();
+ if (ctx.getGroupID() == groupID) return;
+ model.setSecurityContext(groupID);
+ view.setGroupInformation();
+ }
+
/**
* Overridden to return the name of the instance to save.
* @see #toString()
*/
public String toString() { return view.getTitle(); }
+
+
}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/view/EditorControl.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/view/EditorControl.java
index 0f92513aafc..c46354d6ce5 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/view/EditorControl.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/view/EditorControl.java
@@ -25,8 +25,13 @@
//Java imports
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
import java.util.Map;
+import java.util.Set;
+
import javax.swing.JMenu;
import javax.swing.WindowConstants;
import javax.swing.event.ChangeEvent;
@@ -39,15 +44,21 @@
//Third-party libraries
//Application-internal dependencies
+import org.openmicroscopy.shoola.agents.editor.EditorAgent;
import org.openmicroscopy.shoola.agents.editor.actions.CloseEditorAction;
import org.openmicroscopy.shoola.agents.editor.actions.EditorAction;
+import org.openmicroscopy.shoola.agents.editor.actions.GroupSelectionAction;
import org.openmicroscopy.shoola.agents.editor.actions.NewBlankFileAction;
import org.openmicroscopy.shoola.agents.editor.actions.OpenLocalFileAction;
import org.openmicroscopy.shoola.agents.editor.actions.OpenWwwFileAction;
+import org.openmicroscopy.shoola.agents.editor.actions.PersonalManagementAction;
import org.openmicroscopy.shoola.agents.editor.actions.SaveAsProtocolAction;
import org.openmicroscopy.shoola.agents.editor.actions.SaveFileLocallyAction;
import org.openmicroscopy.shoola.agents.editor.actions.SaveFileAction;
import org.openmicroscopy.shoola.agents.editor.actions.SaveFileServerAction;
+import org.openmicroscopy.shoola.agents.util.ViewerSorter;
+
+import pojos.GroupData;
/**
* The {@link Editor}'s controller.
@@ -90,6 +101,9 @@ class EditorControl
/** Identifies the SaveFileAsProtocol
Action. */
static final Integer SAVE_AS_PROTOCOL = Integer.valueOf(8);
+ /** Identifies the SaveFileAsProtocol
Action. */
+ static final Integer PERSONAL = Integer.valueOf(9);
+
/**
* Reference to the {@link Editor} component, which, in this context,
* is regarded as the Model.
@@ -113,6 +127,7 @@ private void createActions()
actionsMap.put(OPEN_WWW_FILE, new OpenWwwFileAction(model));
actionsMap.put(SAVE_FILE_SERVER, new SaveFileServerAction(model));
actionsMap.put(SAVE_AS_PROTOCOL, new SaveAsProtocolAction(model));
+ actionsMap.put(PERSONAL, new PersonalManagementAction(model));
}
/**
@@ -225,6 +240,26 @@ void initialize(EditorUI view)
*/
EditorAction getAction(Integer id) { return actionsMap.get(id); }
+ /**
+ * Returns the list of group the user is a member of.
+ *
+ * @return See above.
+ */
+ List getUserGroupAction()
+ {
+ List l = new ArrayList();
+ Set m = EditorAgent.getAvailableUserGroups();
+ if (m == null || m.size() == 0) return l;
+ ViewerSorter sorter = new ViewerSorter();
+ Iterator i = sorter.sort(m).iterator();
+ GroupData group;
+ while (i.hasNext()) {
+ group = (GroupData) i.next();
+ l.add(new GroupSelectionAction(model, group));
+ }
+ return l;
+ }
+
/**
* Reacts to state changes in the {@link Editor}.
* @see ChangeListener#stateChanged(ChangeEvent)
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/view/EditorFactory.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/view/EditorFactory.java
index 78849e06580..178c45a7b6b 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/view/EditorFactory.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/view/EditorFactory.java
@@ -40,6 +40,7 @@
import org.openmicroscopy.shoola.agents.editor.EditorAgent;
import org.openmicroscopy.shoola.agents.editor.actions.ActivationAction;
import org.openmicroscopy.shoola.env.data.events.ExitApplication;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.event.EventBus;
import org.openmicroscopy.shoola.env.ui.TaskBar;
@@ -77,40 +78,45 @@ public class EditorFactory
/**
* Returns the {@link Editor}.
*
+ * @param ctx The security context.
* @param fileAnnotation The annotation hosting the information about
* the file to edit.
* @return See above.
*/
- public static Editor getEditor(FileAnnotationData fileAnnotation)
+ public static Editor getEditor(SecurityContext ctx,
+ FileAnnotationData fileAnnotation)
{
- EditorModel model = new EditorModel(fileAnnotation);
+ EditorModel model = new EditorModel(ctx, fileAnnotation);
return singleton.getEditor(model);
}
/**
* Returns the {@link Editor}.
*
- * @param fileID The id of the file to edit.
+ * @param ctx The security context.
+ * @param fileID The id of the file to edit.
* @return See above.
*/
- public static Editor getEditor(long fileID)
+ public static Editor getEditor(SecurityContext ctx, long fileID)
{
- EditorModel model = new EditorModel(fileID);
+ EditorModel model = new EditorModel(ctx, fileID);
return singleton.getEditor(model);
}
/**
* Returns the {@link Editor} for the passed data object.
*
+ * @param ctx The security context.
* @param parent The data object that the file should be linked to.
* @param name The name of the editor file.
* @param type Either {@link Editor#PROTOCOL} or
* {@link Editor#EXPERIMENT}.
* @return See above.
*/
- public static Editor getEditor(DataObject parent, String name, int type)
+ public static Editor getEditor(SecurityContext ctx, DataObject parent,
+ String name, int type)
{
- EditorModel model = new EditorModel(parent, name, type);
+ EditorModel model = new EditorModel(ctx, parent, name, type);
Editor editor = singleton.getEditor(model);
if (editor != null) {
((EditorComponent) editor).setNewExperiment();
@@ -122,15 +128,15 @@ public static Editor getEditor(DataObject parent, String name, int type)
/**
* Returns the {@link Editor} created to display a particular file.
*
- *
- * @param file The file to open in Editor.
+ * @param ctx The security context.
+ * @param file The file to open in Editor.
* @return See above.
*/
- public static Editor getEditor(File file)
+ public static Editor getEditor(SecurityContext ctx, File file)
{
- if (file == null) return getEditor(); // just in case. Never used!
+ if (file == null) return getEditor(ctx); // just in case. Never used!
- EditorModel model = new EditorModel(file);
+ EditorModel model = new EditorModel(ctx, file);
// if a "blank" editor is open, with a "blank" model, this is returned
// or, if the model matches the model in an existing editor, return this,
@@ -146,13 +152,14 @@ public static Editor getEditor(File file)
* This provides the functionality for handling a "show editor", where
* it doesn't matter which editor/file you show.
*
+ * @param ctx The security context.
* @return See above.
*/
- public static Editor getEditor()
+ public static Editor getEditor(SecurityContext ctx)
{
EditorModel model;
if (singleton.editors.isEmpty())
- return getNewBlankEditor();
+ return getNewBlankEditor(ctx);
Editor e = singleton.editors.iterator().next();
if (e == null) return e;
model = ((EditorComponent) e).getModel();
@@ -184,12 +191,13 @@ public static void setCopiedData(Object copiedData)
* This has a similar functionality to getEditor
method,
* except this method always returns a new editor
* (never an existing editor).
- *
+ *
+ * @param ctx The security context.
* @return A new Editor, with a new EditorModel
*/
- public static Editor getNewBlankEditor()
+ public static Editor getNewBlankEditor(SecurityContext ctx)
{
- EditorModel model = new EditorModel();
+ EditorModel model = new EditorModel(ctx);
// this will return any existing editors with a 'blank' model, or
// create an editor with the blank model above, if none exist.
Editor editor = singleton.getEditor(model);
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/view/EditorModel.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/view/EditorModel.java
index 86954132e54..8567ce5201f 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/view/EditorModel.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/view/EditorModel.java
@@ -43,6 +43,7 @@
import org.openmicroscopy.shoola.agents.util.EditorUtil;
import org.openmicroscopy.shoola.env.config.Registry;
import org.openmicroscopy.shoola.env.data.OmeroMetadataService;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.log.LogMessage;
import org.openmicroscopy.shoola.env.ui.UserNotifier;
import org.openmicroscopy.shoola.util.file.IOUtil;
@@ -76,16 +77,16 @@ class EditorModel
{
/** Holds one of the state flags defined by {@link Editor}. */
- private int state;
+ private int state;
/** The name of the file to edit. */
- private String fileName;
+ private String fileName;
/** The annotation object hosting information about the file. */
- private FileAnnotationData fileAnnotation;
+ private FileAnnotationData fileAnnotation;
/** The id of the file to edit. Will not be set if editing local file */
- private long fileID;
+ private long fileID;
/**
* The ID of the annotation for the file on the server, as returned by
@@ -94,32 +95,35 @@ class EditorModel
* {@link #EditorModel(long)} constructor has been used, before
* {@link #setFileAnnotationData(FileAnnotationData)} has been called.
*/
- private long annotationID;
+ private long annotationID;
/** A string that defines the type of file we're editing. eg protocol */
- private String nameSpace;
+ private String nameSpace;
/** The file retrieved either from the DB or local machine. */
- private File fileToEdit;
+ private File fileToEdit;
/** The browser component */
- private Browser browser;
+ private Browser browser;
/** The DataObject
to link the editor file to. */
- private DataObject parent;
+ private DataObject parent;
/** Either {@link Editor#PROTOCOL} or {@link Editor#EXPERIMENT}. */
- private int type;
+ private int type;
/**
* Will either be a data loader or null
depending on the
* current state.
*/
- private EditorLoader currentLoader;
+ private EditorLoader currentLoader;
/** Reference to the component that embeds this model. */
- private Editor component;
+ private Editor component;
+ /** The security context.*/
+ private SecurityContext ctx;
+
/**
* Saves the {@link TreeModel} from the {@link Browser} as an XML file.
* Returns true
if the file can be parsed, false
@@ -140,25 +144,29 @@ private boolean saveFile(File file)
/**
* Creates a new instance and sets the state to {@link Editor#NEW}.
*
+ * @param ctx The security context.
* @param fileAnnotationData The annotation hosting the file to edit.
*/
- EditorModel(FileAnnotationData fileAnnotationData)
+ EditorModel(SecurityContext ctx, FileAnnotationData fileAnnotationData)
{
state = Editor.NEW;
if (fileAnnotationData == null)
throw new IllegalArgumentException("No file annotation specified.");
setFileAnnotationData(fileAnnotationData);
+ this.ctx = ctx;
type = Editor.PROTOCOL;
}
/**
* Creates a new instance and sets the state to {@link Editor#NEW}.
*
+ * @param ctx The security context.
* @param annotationID The id of the original file to edit.
*/
- EditorModel(long annotationID)
+ EditorModel(SecurityContext ctx, long annotationID)
{
state = Editor.NEW;
+ this.ctx = ctx;
this.annotationID = annotationID;
// this sets the fileID with the annotationID so that when
@@ -172,24 +180,29 @@ private boolean saveFile(File file)
* {@link #fileSize} and {@link #fileID} are not set.
* File is not opened. To do this, call {@link Editor#setFileToEdit(File)}
*
+ * @param ctx The security context.
* @param file The file to open. Sets the {@link #fileName} to the
* name of this file but does not open file.
*/
- EditorModel(File file)
+ EditorModel(SecurityContext ctx, File file)
{
if (file == null) throw new NullPointerException("No file.");
state = Editor.NEW;
+ this.ctx = ctx;
fileName = file.getName();
type = Editor.PROTOCOL;
}
/**
* Creates a new instance and sets the state to {@link Editor#NEW}.
- * The {@link #fileSize} and {@link #fileID} are not set.
+ * The {@link #fileSize} and {@link #fileID} are not set.
+ *
+ * @param ctx The security context.
*/
- EditorModel()
+ EditorModel(SecurityContext ctx)
{
state = Editor.NEW;
+ this.ctx = ctx;
fileName = EditorFactory.BLANK_MODEL;
type = Editor.PROTOCOL;
}
@@ -198,14 +211,16 @@ private boolean saveFile(File file)
* Creates a new instance and sets the state to {@link Editor#NEW}.
* The {@link #fileSize} and {@link #fileID} are not set.
*
+ * @param ctx The security context.
* @param parent The object to link the file to.
* @param name The name of the file.
* @param type Either {@link Editor#PROTOCOL} or
* {@link Editor#EXPERIMENT}.
*/
- EditorModel(DataObject parent, String name, int type)
+ EditorModel(SecurityContext ctx, DataObject parent, String name, int type)
{
state = Editor.NEW;
+ this.ctx = ctx;
if (name == null || name.length() == 0)
name = EditorFactory.BLANK_MODEL;
fileName = name;
@@ -225,7 +240,7 @@ private boolean saveFile(File file)
void initialize(Editor component)
{
this.component = component;
- browser = BrowserFactory.createBrowser(type);
+ browser = BrowserFactory.createBrowser(ctx, type);
}
/**
@@ -233,7 +248,7 @@ void initialize(Editor component)
*
* @return One of the flags defined by the {@link Editor} interface.
*/
- int getState() { return state; }
+ int getState() { return state; }
/**
* Sets the object in the {@link Editor#DISCARDED} state.
@@ -290,7 +305,7 @@ void fireFileLoading()
// fileID can be annotationID if fileName is null
// E.g. if EditorModel(long annotationID) was the constructor.
- currentLoader = new FileLoader(component, fileName, fileID, size);
+ currentLoader = new FileLoader(component, ctx, fileName, fileID, size);
currentLoader.load();
state = Editor.LOADING;
}
@@ -357,6 +372,9 @@ boolean setFileToEdit(File file)
"original file will erase the original XML format.");
// must avoid overwriting the original file...
// 'Save' won't work.
+ if (fileID > 0) { //try to read a file downloaded
+ file.delete();
+ }
fileToEdit = null;
setFileAnnotationData(null);
@@ -477,7 +495,7 @@ void fireFileSaving(File file, boolean asynch)
if (description != null) data.setDescription(description);
if (asynch) {
- currentLoader = new FileSaver(component, file, data, fileType,
+ currentLoader = new FileSaver(component, ctx, file, data, fileType,
linkTo);
currentLoader.load();
state = Editor.SAVING;
@@ -485,7 +503,7 @@ void fireFileSaving(File file, boolean asynch)
OmeroMetadataService svc =
EditorAgent.getRegistry().getMetadataService();
try {
- svc.archivedFile(fileAnnotation, file, fileType, linkTo);
+ svc.archivedFile(ctx, fileAnnotation, file, fileType, linkTo);
} catch (Exception e) {
LogMessage msg = new LogMessage();
msg.print("State: "+state);
@@ -605,5 +623,22 @@ boolean isUserOwner()
return EditorUtil.isUserOwner(fileAnnotation, userID);
}
+ /**
+ * Returns the security context.
+ *
+ * @return See above.
+ */
+ SecurityContext getSecurityContext() { return ctx; }
+ /**
+ * Sets the security context.
+ *
+ * @param groupId The id of the group.
+ */
+ void setSecurityContext(long groupId)
+ {
+ if (ctx.getGroupID() != groupId)
+ ctx = new SecurityContext(groupId);
+ }
+
}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/view/EditorToolBar.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/view/EditorToolBar.java
index 2b1944ae97a..2e324520a4d 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/view/EditorToolBar.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/view/EditorToolBar.java
@@ -24,18 +24,26 @@
//Java imports
+import java.awt.Color;
+import java.awt.FlowLayout;
+import java.util.Set;
+
import javax.swing.Action;
+import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JComponent;
+import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JToolBar;
-
-import org.openmicroscopy.shoola.agents.editor.uiComponents.CustomButton;
+import javax.swing.border.EmptyBorder;
//Third-party libraries
//Application-internal dependencies
+import org.openmicroscopy.shoola.agents.editor.EditorAgent;
+import org.openmicroscopy.shoola.agents.editor.actions.PersonalManagementAction;
+import org.openmicroscopy.shoola.agents.editor.uiComponents.CustomButton;
/**
* The tool bar of {@link Editor}.
@@ -62,9 +70,26 @@ class EditorToolBar
EditorControl.SAVE_FILE
};
+ /** The text indicating that the file is saved in the specified group.*/
+ static final String SAVED = "Saved in";
+
+ /** The text indicating to select the group where to select the group.*/
+ static final String SAVE = "Save to";
+
/** Reference to the Control. */
private EditorControl controller;
+ /** Reference to the View. */
+ private EditorUI view;
+
+ /**
+ * The label indicating where to save the file or where the file is saved.
+ */
+ private JLabel groupLabel;
+
+ /** The component used to display the name of the group.*/
+ private JButton groupButton;
+
/**
* Creates the bar.
*
@@ -83,13 +108,37 @@ private JToolBar createBar()
return bar;
}
+ /**
+ * Creates the management bar.
+ *
+ * @return See above.
+ */
+ private JPanel createManagementBar()
+ {
+ groupLabel = new JLabel();
+ PersonalManagementAction a = (PersonalManagementAction)
+ controller.getAction(EditorControl.PERSONAL);
+ groupButton = new JButton(a);
+ BorderFactory.createCompoundBorder(new EmptyBorder(2, 2, 2, 2),
+ BorderFactory.createLineBorder(Color.GRAY));
+ Set l = EditorAgent.getAvailableUserGroups();
+ if (l.size() > 1)
+ groupButton.addMouseListener(a);
+ JPanel bar = new JPanel();
+ bar.setLayout(new FlowLayout(FlowLayout.LEFT));
+ bar.add(groupLabel);
+ bar.add(groupButton);
+ setGroupInformation();
+ return bar;
+ }
+
/**
* Convenience method for getting an {@link Action} from the
* {@link #controller}, creating a {@link CustomButton} and adding
* it to the component;
*
- * @param actionId Action ID, e.g. {@link EditorControl#CLOSE_EDITOR}
- * @param comp The component to add the button.
+ * @param actionId Action ID, e.g. {@link EditorControl#CLOSE_EDITOR}
+ * @param comp The component to add the button.
*/
private void addAction(int actionId, JComponent comp)
{
@@ -97,7 +146,7 @@ private void addAction(int actionId, JComponent comp)
b.setText("");
comp.add(b);
}
-
+
/** Builds and lays out the UI. */
private void buildGUI()
{
@@ -105,6 +154,9 @@ private void buildGUI()
toolBars.setBorder(null);
toolBars.setLayout(new BoxLayout(toolBars, BoxLayout.X_AXIS));
toolBars.add(createBar());
+ Set l = EditorAgent.getAvailableUserGroups();
+ if (!view.isStandalone() && l.size() > 1)
+ toolBars.add(createManagementBar());
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
add(toolBars);
/*
@@ -131,15 +183,38 @@ private void buildGUI()
/**
* Creates a new instance.
*
- * @param controller Reference to the control.
- * Mustn't be null
.
+ * @param controller Reference to the control. Mustn't be null
.
+ * @param view Reference to the view. Mustn't be null
.
*/
- EditorToolBar(EditorControl controller)
+ EditorToolBar(EditorControl controller, EditorUI view)
{
if (controller == null)
throw new NullPointerException("No controller.");
+ if (view == null)
+ throw new NullPointerException("No view.");
this.controller = controller;
+ this.view = view;
buildGUI();
}
+ /**
+ * Sets the information about the group depending on the context and if the
+ * file has been saved or not.
+ */
+ void setGroupInformation()
+ {
+ if (view.isStandalone()) return;
+ if (groupLabel == null || groupButton == null) return;
+ long id = view.getFileID();
+ PersonalManagementAction a = (PersonalManagementAction)
+ controller.getAction(EditorControl.PERSONAL);
+ if (id <= 0) {
+ groupLabel.setText(SAVE);
+ a.setPermissions();
+ } else {
+ groupLabel.setText(SAVED);
+ groupButton.removeMouseListener(a);
+ }
+ }
+
}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/view/EditorUI.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/view/EditorUI.java
index 3771be027ec..f6e002c966d 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/view/EditorUI.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/editor/view/EditorUI.java
@@ -24,22 +24,32 @@
//Java imports
import java.awt.BorderLayout;
+import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
+import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import javax.swing.BorderFactory;
import javax.swing.Box;
+import javax.swing.ButtonGroup;
+import javax.swing.JCheckBoxMenuItem;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JTextPane;
import javax.swing.KeyStroke;
import javax.swing.SwingConstants;
+import javax.swing.border.BevelBorder;
import javax.swing.border.EmptyBorder;
//Third-party libraries
@@ -47,10 +57,14 @@
//Application-internal dependencies
import org.openmicroscopy.shoola.agents.editor.EditorAgent;
import org.openmicroscopy.shoola.agents.editor.actions.EditorAction;
+import org.openmicroscopy.shoola.agents.editor.actions.GroupSelectionAction;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.ui.TaskBar;
import org.openmicroscopy.shoola.env.ui.TopWindow;
import org.openmicroscopy.shoola.util.ui.UIUtilities;
+import pojos.ExperimenterData;
+
/**
* The {@link Editor}'s View.
*
@@ -86,7 +100,10 @@ class EditorUI
* A Panel to display in the center of this window if there is no file
* to show.
*/
- private JPanel splashScreen;
+ private JPanel splashScreen;
+
+ /** The menu displaying the available groups.*/
+ private JPopupMenu groupMenu;
/**
* Creates the file menu.
@@ -212,7 +229,7 @@ void initialize(EditorControl controller, EditorModel model)
if (model == null) throw new NullPointerException("No model.");
this.controller = controller;
this.model = model;
- toolBar = new EditorToolBar(controller);
+ toolBar = new EditorToolBar(controller, this);
statusBar = new EditorStatusBar();
setJMenuBar(createMenuBar());
buildGUI();
@@ -249,6 +266,24 @@ void displayFile(String contents)
repaint();
}
+ /**
+ * Returns true
if the editor is not connected to the server,
+ * false
otherwise.
+ *
+ * @return See above.
+ */
+ boolean isStandalone()
+ {
+ return model.getSecurityContext() == null;
+ }
+
+ /**
+ * Returns the id of the file saved on the server.
+ *
+ * @return See above.
+ */
+ long getFileID() { return model.getFileID(); }
+
/** Displays the browser by adding it to this UI. */
void displayFile()
{
@@ -262,6 +297,58 @@ void displayFile()
repaint();
}
+ /**
+ * Brings up the menu on top of the specified component at
+ * the specified location.
+ *
+ * @param menuID The id of the menu.
+ * @param invoker The component that requested the pop-up menu.
+ * @param loc The point at which to display the menu, relative to the
+ * component
's coordinates.
+ */
+ void showMenu(int menuID, Component c, Point p)
+ {
+ switch (menuID) {
+ case Editor.GROUP_MENU:
+ if (groupMenu == null) {
+ groupMenu = new JPopupMenu();
+ groupMenu.setBorder(
+ BorderFactory.createBevelBorder(BevelBorder.RAISED));
+ Set groups = EditorAgent.getAvailableUserGroups();
+ List l =
+ controller.getUserGroupAction();
+ Iterator i = l.iterator();
+ GroupSelectionAction a;
+ JCheckBoxMenuItem item;
+ ButtonGroup buttonGroup = new ButtonGroup();
+ SecurityContext ctx = model.getSecurityContext();
+ long gid = -1;
+ if (ctx != null) gid = ctx.getGroupID();
+ while (i.hasNext()) {
+ a = i.next();
+ item = new JCheckBoxMenuItem(a);
+ item.setEnabled(true);
+ item.setSelected(a.isSameGroup(gid));
+ item.setBorder(null);
+ buttonGroup.add(item);
+ groupMenu.add(item);
+ }
+ }
+ groupMenu.show(c, p.x, p.y);
+ break;
+
+ default:
+ break;
+ }
+
+ }
+
+ /**
+ * Sets the information about the group depending on the context and if the
+ * file has been saved or not.
+ */
+ void setGroupInformation() { toolBar.setGroupInformation(); }
+
/**
* Overrides the {@link #setOnScreen() setOnScreen} method.
* Does not make the window visible, since this only occurs after
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/events/editor/EditFileEvent.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/events/editor/EditFileEvent.java
index 434c0351b34..ac67a86d14d 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/events/editor/EditFileEvent.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/events/editor/EditFileEvent.java
@@ -28,6 +28,7 @@
//Third-party libraries
//Application-internal dependencies
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.event.RequestEvent;
import pojos.FileAnnotationData;
@@ -53,29 +54,37 @@ public class EditFileEvent
private FileAnnotationData fileAnnotation;
/** The id of the annotation to edit. */
- private long fileAnnotationID;
+ private long fileAnnotationID;
+
+ /** The security context.*/
+ private SecurityContext ctx;
/**
* Creates a new instance.
*
- * @param fileAnnotation The annotation hosting the information about
- * the file to edit.
+ * @param ctx The security context.
+ * @param fileAnnotation The annotation hosting the information about
+ * the file to edit.
*/
- public EditFileEvent(FileAnnotationData fileAnnotation)
+ public EditFileEvent(SecurityContext ctx,
+ FileAnnotationData fileAnnotation)
{
if (fileAnnotation == null)
throw new IllegalArgumentException("No file annotation.");
+ this.ctx = ctx;
this.fileAnnotation = fileAnnotation;
}
/**
* Creates a new instance.
*
+ * @param ctx The security context.
* @param fileAnnotationID The id of the annotation to edit.
*/
- public EditFileEvent(long fileAnnotationID)
+ public EditFileEvent(SecurityContext ctx, long fileAnnotationID)
{
this.fileAnnotationID = fileAnnotationID;
+ this.ctx = ctx;
}
/**
@@ -92,4 +101,11 @@ public EditFileEvent(long fileAnnotationID)
*/
public long getFileAnnotationID() { return fileAnnotationID; }
-}
+ /**
+ * Returns the security context.
+ *
+ * @return See above.
+ */
+ public SecurityContext getSecurityContext() { return ctx; }
+
+}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/events/editor/ShowEditorEvent.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/events/editor/ShowEditorEvent.java
index 3377b863d55..f9b5d77c978 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/events/editor/ShowEditorEvent.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/events/editor/ShowEditorEvent.java
@@ -28,6 +28,7 @@
//Third-party libraries
//Application-internal dependencies
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.event.RequestEvent;
import pojos.DataObject;
@@ -61,32 +62,42 @@ public class ShowEditorEvent
private DataObject parent;
/** The name of the file. */
- private String name;
+ private String name;
/** The type of editor file to create. */
- private int type;
+ private int type;
- /** Creates a new instance. */
- public ShowEditorEvent()
+ /** The security context.*/
+ private SecurityContext ctx;
+
+ /**
+ * Creates a new instance.
+ *
+ * @param ctx The security context.
+ */
+ public ShowEditorEvent(SecurityContext ctx)
{
type = PROTOCOL;
parent = null;
+ this.ctx = ctx;
}
/**
* Creates a new instance.
*
+ * @param ctx The security context.
* @param parent The data object the new experiment should be linked to.
* @param name The name to give to the experiment.
* @param type One of the constants defined by this class.
*/
- public ShowEditorEvent(DataObject parent, String name, int type)
+ public ShowEditorEvent(SecurityContext ctx, DataObject parent, String name,
+ int type)
{
this.parent = parent;
this.name = name;
- if (type == PROTOCOL || type == EXPERIMENT)
- this.type = type;
+ if (type == PROTOCOL || type == EXPERIMENT) this.type = type;
else this.type = PROTOCOL;
+ this.ctx = ctx;
}
/**
@@ -110,5 +121,11 @@ public ShowEditorEvent(DataObject parent, String name, int type)
*/
public int getType() { return type; }
+ /**
+ * Returns the security context.
+ *
+ * @return See above.
+ */
+ public SecurityContext getSecurityContext() { return ctx; }
}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/events/importer/LoadImporter.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/events/importer/LoadImporter.java
index 96d9a6944f8..e8bb714c1b6 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/events/importer/LoadImporter.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/events/importer/LoadImporter.java
@@ -24,7 +24,8 @@
//Java imports
-import java.util.Collection;
+import java.util.List;
+import java.util.Map;
//Third-party libraries
@@ -54,11 +55,14 @@ public class LoadImporter
private TreeImageDisplay selectedContainer;
/** The objects used for selection. */
- private Collection objects;
+ private Map>> objects;
/** The type of the import to handle. */
private int type;
+ /** The group context.*/
+ private long groupId;
+
/**
* Creates a new instance.
*
@@ -67,9 +71,24 @@ public class LoadImporter
public LoadImporter(TreeImageDisplay selectedContainer, int type)
{
this.selectedContainer = selectedContainer;
+ groupId = -1;
this.type = type;
}
+ /**
+ * Sets the identifier of the group.
+ *
+ * @param groupId The id of the group.
+ */
+ public void setGroup(long groupId) { this.groupId = groupId; }
+
+ /**
+ * Returns the id of the group.
+ *
+ * @return See above.
+ */
+ public long getGroup() { return groupId; }
+
/**
* Returns the container.
*
@@ -89,14 +108,17 @@ public LoadImporter(TreeImageDisplay selectedContainer, int type)
*
* @return See above.
*/
- public Collection getObjects() { return objects; }
+ public Map>> getObjects()
+ {
+ return objects;
+ }
/**
* Returns the top nodes.
*
* @param datasets The values to set.
*/
- public void setObjects(Collection objects)
+ public void setObjects(Map>> objects)
{
this.objects = objects;
}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/events/iviewer/MeasurementTool.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/events/iviewer/MeasurementTool.java
index 00a546b4e20..6647e9bcfad 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/events/iviewer/MeasurementTool.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/events/iviewer/MeasurementTool.java
@@ -32,6 +32,7 @@
//Third-party libraries
//Application-internal dependencies
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.event.RequestEvent;
import pojos.ChannelData;
@@ -103,24 +104,28 @@ public class MeasurementTool
/** The size along the Y-axis.*/
private int sizeY;
+ /** The security context.*/
+ private SecurityContext ctx;
+
/**
* Creates a new instance.
*
- * @param imageID The image ID.
- * @param pixels The pixels set the measurement tool is for.
- * @param name The name of the image.
- * @param defaultZ The currently selected z-section.
- * @param defaultT The currently selected timepoint.
- * @param activeChannels Collection of pairs
- * (channel's index, channel's color).
- * @param magnification The magnification factor.
- * @param bounds The bounds of the component posting the event.
- * @param channelData The channel metadata.
+ * @param ctx The security context.
+ * @param imageID The image ID.
+ * @param pixels The pixels set the measurement tool is for.
+ * @param name The name of the image.
+ * @param defaultZ The currently selected z-section.
+ * @param defaultT The currently selected timepoint.
+ * @param activeChannels Collection of pairs
+ * (channel's index, channel's color).
+ * @param magnification The magnification factor.
+ * @param bounds The bounds of the component posting the event.
+ * @param channelData The channel metadata.
*/
- public MeasurementTool(long imageID, PixelsData pixels, String name,
- int defaultZ, int defaultT, Map activeChannels,
- double magnification, Rectangle bounds,
- List channelData)
+ public MeasurementTool(SecurityContext ctx, long imageID, PixelsData pixels,
+ String name, int defaultZ, int defaultT, Map activeChannels,
+ double magnification, Rectangle bounds,
+ List channelData)
{
if (pixels == null)
throw new IllegalArgumentException("Pixels set not valid.");
@@ -128,6 +133,7 @@ public MeasurementTool(long imageID, PixelsData pixels, String name,
throw new IllegalArgumentException("Image ID not valid.");
if (channelData == null || channelData.size() == 0)
throw new IllegalArgumentException("Channel data not valid.");
+ this.ctx = ctx;
this.channelData = channelData;
this.pixels = pixels;
this.imageID = imageID;
@@ -317,4 +323,11 @@ public void setRenderedImage(BufferedImage renderedImage)
*/
public List getChannelData() { return channelData; }
+ /**
+ * Returns the security context.
+ *
+ * @return See above.
+ */
+ public SecurityContext getSecurityContext() { return ctx; }
+
}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/events/iviewer/ViewImage.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/events/iviewer/ViewImage.java
index 889fc5c4e0d..c4932251c1b 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/events/iviewer/ViewImage.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/events/iviewer/ViewImage.java
@@ -34,6 +34,7 @@
//Third-party libraries
//Application-internal dependencies
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.event.RequestEvent;
/**
@@ -56,27 +57,35 @@ public class ViewImage
{
/** The images to view. */
- private List images;
+ private List images;
/** The bounds of the component posting the event. */
- private Rectangle requesterBounds;
+ private Rectangle requesterBounds;
/**
* Flag indicating if the viewer should be opened as a separate window
* or not. The default value is true
.
*/
- private boolean separateWindow;
+ private boolean separateWindow;
+
+ /** The security context.*/
+ private SecurityContext ctx;
/**
* Creates a new instance.
*
- * @param image The id of the image to view.
- * @param bounds The bounds of the component posting the event.
+ * @param ctx The security context.
+ * @param image The id of the image to view.
+ * @param bounds The bounds of the component posting the event.
*/
- public ViewImage(ViewImageObject image, Rectangle bounds)
+ public ViewImage(SecurityContext ctx,
+ ViewImageObject image, Rectangle bounds)
{
if (image == null)
throw new IllegalArgumentException("Image not null.");
+ if (ctx == null)
+ throw new IllegalArgumentException("No security context.");
+ this.ctx = ctx;
images = new ArrayList();
images.add(image);
requesterBounds = bounds;
@@ -128,5 +137,12 @@ public void setSeparateWindow(boolean separateWindow)
{
this.separateWindow = separateWindow;
}
+
+ /**
+ * Returns the security context.
+ *
+ * @return See above.
+ */
+ public SecurityContext getSecurityContext() { return ctx; }
}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/events/measurement/MeasurementToolLoaded.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/events/measurement/MeasurementToolLoaded.java
index ece9e337b9d..f08699b022d 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/events/measurement/MeasurementToolLoaded.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/events/measurement/MeasurementToolLoaded.java
@@ -29,6 +29,7 @@
//Third-party libraries
//Application-internal dependencies
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.event.RequestEvent;
import org.openmicroscopy.shoola.env.event.ResponseEvent;
@@ -59,7 +60,10 @@ public class MeasurementToolLoaded
private JComponent view;
/** One of the constants defined by this class. */
- private int index;
+ private int index;
+
+ /** The security context.*/
+ private SecurityContext ctx;
/**
* Controls if the passed index is valid.
@@ -81,16 +85,19 @@ private void checkIndex(int i)
/**
* Creates a new instance.
*
- * @param act The original request.
- * @param view The component to add to the display.
+ * @param act The original request.
+ * @param ctx The security context.
+ * @param view The component to add to the display.
* @param index One of the constants defined by this class.
*/
- public MeasurementToolLoaded(RequestEvent act, JComponent view, int index)
+ public MeasurementToolLoaded(RequestEvent act, SecurityContext ctx,
+ JComponent view, int index)
{
super(act);
checkIndex(index);
this.index = index;
this.view = view;
+ this.ctx = ctx;
}
/**
@@ -107,4 +114,11 @@ public MeasurementToolLoaded(RequestEvent act, JComponent view, int index)
*/
public int getIndex() { return index; }
+ /**
+ * Returns the security context.
+ *
+ * @return See above.
+ */
+ public SecurityContext getSecurityContext() { return ctx; }
+
}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/events/measurement/SelectPlane.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/events/measurement/SelectPlane.java
index fc0546d968a..1b3737fe497 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/events/measurement/SelectPlane.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/events/measurement/SelectPlane.java
@@ -47,13 +47,13 @@ public class SelectPlane
{
/** The ID of the pixels set. */
- private long pixelsID;
+ private long pixelsID;
/** The currently selected z-section. */
- private int defaultZ;
+ private int defaultZ;
/** The currently selected timepoint. */
- private int defaultT;
+ private int defaultT;
/* The bounds of the ROI for big image.*/
private Rectangle bounds;
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/events/treeviewer/ExperimenterLoadedDataEvent.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/events/treeviewer/ExperimenterLoadedDataEvent.java
index 37d3cef62af..7e50a0c408c 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/events/treeviewer/ExperimenterLoadedDataEvent.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/events/treeviewer/ExperimenterLoadedDataEvent.java
@@ -46,14 +46,15 @@ public class ExperimenterLoadedDataEvent
{
/** Map hosting the data objects owned by users displayed.*/
- private Map> data;
+ private Map>> data;
/**
* Creates a new instance.
*
* @param data The data to store.
*/
- public ExperimenterLoadedDataEvent(Map> data)
+ public ExperimenterLoadedDataEvent(
+ Map>> data)
{
this.data = data;
}
@@ -63,6 +64,9 @@ public ExperimenterLoadedDataEvent(Map> data)
*
* @return See above.
*/
- public Map> getData() { return data; }
+ public Map>> getData()
+ {
+ return data;
+ }
}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/events/treeviewer/MoveToEvent.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/events/treeviewer/MoveToEvent.java
new file mode 100644
index 00000000000..5fb2eb2b65d
--- /dev/null
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/events/treeviewer/MoveToEvent.java
@@ -0,0 +1,80 @@
+/*
+ * org.openmicroscopy.shoola.agents.events.treeviewer.MoveToEvent
+ *
+ *------------------------------------------------------------------------------
+ * Copyright (C) 2006-2012 University of Dundee & Open Microscopy Environment.
+ * All rights reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *------------------------------------------------------------------------------
+ */
+package org.openmicroscopy.shoola.agents.events.treeviewer;
+
+
+//Java imports
+import java.util.List;
+
+//Third-party libraries
+
+//Application-internal dependencies
+import org.openmicroscopy.shoola.env.event.RequestEvent;
+import pojos.DataObject;
+import pojos.GroupData;
+
+/**
+ * Posts an event indicating to move the passed objects to the selectd group.
+ *
+ * @author Jean-Marie Burel
+ * j.burel@dundee.ac.uk
+ * @since Beta4.4
+ */
+public class MoveToEvent
+ extends RequestEvent
+{
+
+ /** The group to move the data to.*/
+ private GroupData group;
+
+ /** The objects to move.*/
+ private List objects;
+
+ /**
+ * Creates a new instance.
+ *
+ * @param group The group to move the data to.
+ * @param objects The objects to move.
+ */
+ public MoveToEvent(GroupData group, List objects)
+ {
+ this.objects = objects;
+ this.group = group;
+ }
+
+ /**
+ * Returns the group to move the data to.
+ *
+ * @return See above.
+ */
+ public GroupData getGroup() { return group; }
+
+ /**
+ * Returns the objects to move.
+ *
+ * @return See above.
+ */
+ public List getObjects() { return objects; }
+
+}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/fsimporter/DataImporterLoader.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/fsimporter/DataImporterLoader.java
index f7bface1cc6..38a026c2013 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/fsimporter/DataImporterLoader.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/fsimporter/DataImporterLoader.java
@@ -32,6 +32,7 @@
import org.openmicroscopy.shoola.env.config.Registry;
import org.openmicroscopy.shoola.env.data.events.DSCallAdapter;
import org.openmicroscopy.shoola.env.data.model.AdminObject;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.AdminView;
import org.openmicroscopy.shoola.env.data.views.DataManagerView;
import org.openmicroscopy.shoola.env.data.views.ImageDataView;
@@ -64,28 +65,31 @@ public abstract class DataImporterLoader
{
/** The Importer this data loader is for. */
- protected final Importer viewer;
+ protected final Importer viewer;
/** Convenience reference for subclasses. */
- protected final Registry registry;
+ protected final Registry registry;
/** Convenience reference for subclasses. */
- protected final ImageDataView ivView;
+ protected final ImageDataView ivView;
/** Convenience reference for subclasses. */
- protected final MetadataHandlerView mhView;
+ protected final MetadataHandlerView mhView;
/** Convenience reference for subclasses. */
- protected final AdminView adminView;
+ protected final AdminView adminView;
/** Convenience reference for subclasses. */
- protected final DataManagerView dmView;
+ protected final DataManagerView dmView;
/** The id of the user or -1
. */
- protected long userID;
+ protected long userID;
/** The id of the group or -1
. */
- protected long groupID;
+ protected long groupID;
+
+ /** The security context.*/
+ protected final SecurityContext ctx;
/**
* Helper method to return the ID of the currently logged in user.
@@ -117,11 +121,13 @@ void setIds()
*
* @param viewer The Importer this data loader is for.
* Mustn't be null
.
+ * @param ctx The security context.
*/
- protected DataImporterLoader(Importer viewer)
+ protected DataImporterLoader(Importer viewer, SecurityContext ctx)
{
if (viewer == null) throw new NullPointerException("No viewer.");
- this.viewer = viewer;
+ this.viewer = viewer;
+ this.ctx = ctx;
registry = ImporterAgent.getRegistry();
ivView = (ImageDataView)
registry.getDataServicesView(ImageDataView.class);
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/fsimporter/DataLoader.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/fsimporter/DataLoader.java
index 093ca5c82a3..86b35e70492 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/fsimporter/DataLoader.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/fsimporter/DataLoader.java
@@ -31,6 +31,7 @@
//Application-internal dependencies
import org.openmicroscopy.shoola.agents.fsimporter.view.Importer;
import org.openmicroscopy.shoola.agents.treeviewer.DataBrowserLoader;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.CallHandle;
import pojos.ProjectData;
import pojos.ScreenData;
@@ -65,14 +66,16 @@ public class DataLoader
/**
* Creates a new instance.
*
- * @param viewer The Importer this data loader is for.
- * Mustn't be null
.
- * @param rootType Either Project or Screen.
+ * @param viewer The Importer this data loader is for.
+ * Mustn't be null
.
+ * @param ctx The security context.
+ * @param rootType Either Project or Screen.
* @param refreshImport Flag indicating to refresh the on-going import.
*/
- public DataLoader(Importer viewer, Class rootType, boolean refreshImport)
+ public DataLoader(Importer viewer, SecurityContext ctx, Class rootType,
+ boolean refreshImport)
{
- super(viewer);
+ super(viewer, ctx);
if (!(ProjectData.class.equals(rootType) ||
ScreenData.class.equals(rootType)))
throw new IllegalArgumentException("Type not supported.");
@@ -86,7 +89,7 @@ public DataLoader(Importer viewer, Class rootType, boolean refreshImport)
*/
public void load()
{
- handle = dmView.loadContainerHierarchy(rootType, null, false,
+ handle = dmView.loadContainerHierarchy(ctx, rootType, null, false,
getCurrentUserID(), groupID, this);
}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/fsimporter/DataObjectCreator.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/fsimporter/DataObjectCreator.java
index eae4314b7ed..8b0eb6d67c4 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/fsimporter/DataObjectCreator.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/fsimporter/DataObjectCreator.java
@@ -32,6 +32,7 @@
//Application-internal dependencies
import org.openmicroscopy.shoola.agents.fsimporter.view.Importer;
import org.openmicroscopy.shoola.agents.treeviewer.DataBrowserLoader;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.CallHandle;
import pojos.DataObject;
@@ -65,16 +66,17 @@ public class DataObjectCreator
/**
* Creates a new instance.
*
- * @param viewer The Importer this data loader is for.
- * Mustn't be null
.
- * @param child The {@link DataObject} to handle.
- * @param parent The parent of the object to create,
- * null
if no parent.
+ * @param viewer The Importer this data loader is for.
+ * Mustn't be null
.
+ * @param ctx The security context.
+ * @param child The {@link DataObject} to handle.
+ * @param parent The parent of the object to create,
+ * null
if no parent.
*/
- public DataObjectCreator(Importer viewer, DataObject child,
- DataObject parent)
+ public DataObjectCreator(Importer viewer, SecurityContext ctx,
+ DataObject child, DataObject parent)
{
- super(viewer);
+ super(viewer, ctx);
if (child == null)
throw new IllegalArgumentException("No object to create.");
this.parent = parent;
@@ -87,7 +89,7 @@ public DataObjectCreator(Importer viewer, DataObject child,
*/
public void load()
{
- handle = dmView.createDataObject(child, parent, this);
+ handle = dmView.createDataObject(ctx, child, parent, this);
}
/**
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/fsimporter/DirectoryMonitor.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/fsimporter/DirectoryMonitor.java
index 5202529750d..f4d269542b8 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/fsimporter/DirectoryMonitor.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/fsimporter/DirectoryMonitor.java
@@ -31,6 +31,7 @@
//Application-internal dependencies
import org.openmicroscopy.shoola.agents.fsimporter.view.Importer;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.CallHandle;
import pojos.DataObject;
@@ -66,13 +67,14 @@ public class DirectoryMonitor
*
* @param viewer The Importer this data loader is for.
* Mustn't be null
.
+ * @param ctx The security context.
* @param directory The directory to monitor.
* @param container The container where to import the image to.
*/
- public DirectoryMonitor(Importer viewer, File directory,
- DataObject container)
+ public DirectoryMonitor(Importer viewer, SecurityContext ctx,
+ File directory, DataObject container)
{
- super(viewer);
+ super(viewer, ctx);
if (directory == null)
throw new IllegalArgumentException("No directory to monitor.");
this.directory = directory;
@@ -85,7 +87,7 @@ public DirectoryMonitor(Importer viewer, File directory,
*/
public void load()
{
- handle = ivView.monitorDirectory(directory, container,
+ handle = ivView.monitorDirectory(ctx, directory, container,
getCurrentUserID(), -1, this);
}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/fsimporter/DiskSpaceLoader.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/fsimporter/DiskSpaceLoader.java
index 77d488a37fc..88ff44488e8 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/fsimporter/DiskSpaceLoader.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/fsimporter/DiskSpaceLoader.java
@@ -32,6 +32,7 @@
import org.openmicroscopy.shoola.agents.fsimporter.view.Importer;
import org.openmicroscopy.shoola.agents.metadata.EditorLoader;
import org.openmicroscopy.shoola.env.data.model.DiskQuota;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.CallHandle;
import pojos.ExperimenterData;
@@ -59,10 +60,11 @@ public class DiskSpaceLoader
* Creates a new instance.
*
* @param viewer Reference to the viewer. Mustn't be null
.
+ * @param ctx The security context.
*/
- public DiskSpaceLoader(Importer viewer)
+ public DiskSpaceLoader(Importer viewer, SecurityContext ctx)
{
- super(viewer);
+ super(viewer, ctx);
}
/**
@@ -71,7 +73,7 @@ public DiskSpaceLoader(Importer viewer)
*/
public void load()
{
- handle = adminView.getDiskSpace(ExperimenterData.class,
+ handle = adminView.getDiskSpace(ctx, ExperimenterData.class,
getCurrentUserID(), this);
}
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/fsimporter/ImagesImporter.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/fsimporter/ImagesImporter.java
index cfde366b49e..9c3d206dcb2 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/fsimporter/ImagesImporter.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/fsimporter/ImagesImporter.java
@@ -39,6 +39,7 @@
import org.openmicroscopy.shoola.env.data.events.DSCallAdapter;
import org.openmicroscopy.shoola.env.data.events.DSCallFeedbackEvent;
import org.openmicroscopy.shoola.env.data.model.ImportableObject;
+import org.openmicroscopy.shoola.env.data.util.SecurityContext;
import org.openmicroscopy.shoola.env.data.views.CallHandle;
import org.openmicroscopy.shoola.env.log.LogMessage;
@@ -75,13 +76,14 @@ public class ImagesImporter
*
* @param viewer The Importer this data loader is for.
* Mustn't be null
.
+ * @param ctx The security context.
* @param context The context of the import.
* @param loaderID The identifier of the loader.
*/
- public ImagesImporter(Importer viewer, ImportableObject context,
- Integer loaderID)
+ public ImagesImporter(Importer viewer,
+ ImportableObject context, Integer loaderID)
{
- super(viewer);
+ super(viewer, null);
if (context == null || context.getFiles() == null ||
context.getFiles().size() == 0)
throw new IllegalArgumentException("No Files to import.");
diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/fsimporter/ImporterAgent.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/fsimporter/ImporterAgent.java
index 5c3876fa56a..c992b86bfc1 100644
--- a/components/insight/SRC/org/openmicroscopy/shoola/agents/fsimporter/ImporterAgent.java
+++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/fsimporter/ImporterAgent.java
@@ -39,6 +39,7 @@
//Application-internal dependencies
import org.openmicroscopy.shoola.agents.events.importer.LoadImporter;
import org.openmicroscopy.shoola.agents.events.treeviewer.BrowserSelectionEvent;
+import org.openmicroscopy.shoola.agents.events.treeviewer.ChangeUserGroupEvent;
import org.openmicroscopy.shoola.agents.events.treeviewer.ExperimenterLoadedDataEvent;
import org.openmicroscopy.shoola.agents.fsimporter.view.Importer;
import org.openmicroscopy.shoola.agents.fsimporter.view.ImporterFactory;
@@ -75,13 +76,16 @@ public class ImporterAgent
{
/** Reference to the registry. */
- private static Registry registry;
+ private static Registry registry;
/** The selected browser type.*/
private int browserType;
/** The objects displayed.*/
- private List objects;
+ private Map>> objects;
+
+ /** The group id if set.*/
+ private long groupId;
/**
* Helper method.
@@ -148,7 +152,8 @@ private int getDefaultBrowser()
private void handleLoadImporter(LoadImporter evt)
{
if (evt == null) return;
- Importer importer = ImporterFactory.getImporter();
+ long groupId = evt.getGroup();
+ Importer importer = ImporterFactory.getImporter(groupId);
if (importer != null) {
int t;
switch (evt.getType()) {
@@ -162,7 +167,12 @@ private void handleLoadImporter(LoadImporter evt)
t = browserType;
else t = getDefaultBrowser();
}
- importer.activate(t, evt.getSelectedContainer(), evt.getObjects());
+ //
+ //objects = evt.getObjects();
+ Map> data = objects.get(groupId);
+ List l = null;
+ if (data != null) l = data.get(getUserDetails().getId());
+ importer.activate(t, evt.getSelectedContainer(), l);
}
}
@@ -189,6 +199,26 @@ private void handleReconnectedEvent(ReconnectedEvent evt)
ImporterFactory.onReconnected();
}
+ /**
+ * Returns the containers if available for the specified group.
+ *
+ * @param groupId The id of the group.
+ */
+ private List