Пример #1
0
  /**
   * Sets the action enabled depending on the selected type.
   *
   * @see TreeViewerAction#onDisplayChange(TreeImageDisplay)
   */
  protected void onDisplayChange(TreeImageDisplay selectedDisplay) {
    if (selectedDisplay == null) {
      setEnabled(false);
      return;
    }
    Browser browser = model.getSelectedBrowser();
    if (browser == null) {
      setEnabled(false);
      return;
    }
    Object ho = selectedDisplay.getUserObject();

    if (ho instanceof DatasetData
        || ho instanceof ProjectData
        || ho instanceof ImageData
        || ho instanceof ScreenData
        || ho instanceof PlateData) {
      if (model.canAnnotate(ho)) {
        List selected = browser.getSelectedDataObjects();
        if (selected == null) setEnabled(false);
        else {
          List<Long> ids = new ArrayList<Long>();
          Iterator i = selected.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);
  }
Пример #2
0
 /**
  * Sets the action enabled depending on the currently selected display
  *
  * @see DataBrowserAction#onDisplayChange(ImageDisplay)
  */
 protected void onDisplayChange(ImageDisplay node) {
   if (node == null) {
     setEnabled(false);
     return;
   }
   Object ho = node.getHierarchyObject();
   if (ho instanceof ImageData
       || ho instanceof DatasetData
       || ho instanceof ProjectData
       || ho instanceof ScreenData
       || ho instanceof PlateData) {
     if (model.canAnnotate(ho)) {
       Collection l = model.getBrowser().getSelectedDataObjects();
       List<Long> ids = new ArrayList<Long>();
       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);
 }
 /**
  * Sets the object of reference.
  *
  * @param refObject The value to set.
  * @param ctx The security context.
  */
 void setRootObject(Object refObject, SecurityContext ctx) {
   this.refObject = refObject;
   this.ctx = ctx;
   if (ctx == null && refObject instanceof DataObject) {
     DataObject data = (DataObject) refObject;
     if (data.getId() >= 0) this.ctx = new SecurityContext(data.getGroupId());
   }
   browser.setRootObject(refObject);
   editor.setRootObject(refObject);
   data = null;
   if (!(refObject instanceof WellSampleData) && parentData != null) {
     parentData = null;
   }
   parentRefObject = null;
   viewedBy = null;
 }
 /**
  * Creates a new context if <code>null</code>.
  *
  * @param ho The node to handle.
  * @return See above.
  */
 private SecurityContext retrieveContext(DataObject ho) {
   if (ctx != null) return ctx;
   return new SecurityContext(ho.getGroupId());
 }