Esempio n. 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);
  }
Esempio n. 2
0
 /**
  * Sets the action enabled depending on the state of the {@link Browser}.
  *
  * @see TreeViewerAction#onBrowserStateChange(Browser)
  */
 protected void onBrowserStateChange(Browser browser) {
   if (browser == null) return;
   switch (browser.getState()) {
     case Browser.LOADING_DATA:
     case Browser.LOADING_LEAVES:
     case Browser.COUNTING_ITEMS:
       setEnabled(false);
       break;
     default:
       onDisplayChange(browser.getLastSelectedDisplay());
   }
 }
 /**
  * Sets the action enabled depending on the selected type.
  *
  * @see TreeViewerAction#onDisplayChange(TreeImageDisplay)
  */
 protected void onDisplayChange(TreeImageDisplay selectedDisplay) {
   if (nodeType == GROUP || nodeType == EXPERIMENTER) {
     setEnabled(TreeViewerAgent.isAdministrator());
     return;
   }
   if (nodeType != EXPERIMENTER) {
     if (selectedDisplay != null) {
       Object ho = selectedDisplay.getUserObject();
       if (ho instanceof ExperimenterData) {
         ExperimenterData data = (ExperimenterData) ho;
         long id = TreeViewerAgent.getUserDetails().getId();
         setEnabled(data.getId() == id);
         return;
       }
       /*
           		switch (nodeType) {
       	case TAG:
       		if (ho instanceof TagAnnotationData) {
       			TagAnnotationData tag = (TagAnnotationData) ho;
       			String ns = tag.getNameSpace();
       			if (TagAnnotationData.INSIGHT_TAGSET_NS.equals(ns)) {
       				setEnabled(model.isUserOwner(ho));
       			} else setEnabled(false);
       		}
       		//setEnabled(model.isUserOwner(ho));
       		break;
       	case DATASET:
       		if (ho instanceof DatasetData) {
       			setEnabled(false);
       		} else
       			setEnabled(model.isUserOwner(ho));
       		break;
       	default:
       		setEnabled(true);
       }
       */
       setEnabled(true);
     }
   } else {
     Browser browser = model.getSelectedBrowser();
     if (browser == null || selectedDisplay == null) {
       setEnabled(false);
       return;
     }
     Object ho = selectedDisplay.getUserObject();
     if (ho instanceof GroupData) {
       TreeImageDisplay[] selected = browser.getSelectedDisplays();
       setEnabled(selected.length == 1);
     } else setEnabled(false);
   }
 }
  /**
   * Sets the action enabled depending on the browser's type and the currently selected node. Sets
   * the name of the action depending on the <code>DataObject</code> hosted by the currently
   * selected node.
   *
   * @see TreeViewerAction#onDisplayChange(TreeImageDisplay)
   */
  protected void onDisplayChange(TreeImageDisplay selectedDisplay) {
    if (selectedDisplay == null) {
      setEnabled(false);
      return;
    }
    Browser b = model.getSelectedBrowser();

    if (b != null && b.getSelectedDisplays().length > 1) {
      setEnabled(false);
      return;
    }
    Object ho = selectedDisplay.getUserObject();
    setEnabled(ho instanceof ExperimenterData);
  }
Esempio n. 5
0
 /**
  * Enables the action if the browser is not ready.
  *
  * @see TreeViewerAction#onBrowserStateChange(Browser)
  */
 protected void onBrowserStateChange(Browser browser) {
   if (model.isImporting()) {
     setEnabled(false);
     return;
   }
   if (browser != null) setEnabled(browser.getState() == Browser.READY);
 }
 /**
  * Sets the action enabled depending on the state of the {@link Browser}.
  *
  * @see TreeViewerAction#onBrowserStateChange(Browser)
  */
 protected void onBrowserStateChange(Browser browser) {
   if (browser == null) {
     setEnabled(false);
     return;
   }
   switch (browser.getState()) {
     case Browser.LOADING_DATA:
     case Browser.LOADING_LEAVES:
     case Browser.COUNTING_ITEMS:
       setEnabled(false);
       break;
     default:
       if (browser.getBrowserType() != Browser.ADMIN_EXPLORER) setEnabled(true);
       else onDisplayChange(browser.getLastSelectedDisplay());
   }
 }
  /**
   * Creates a {@link CreateCmd} command to execute the action.
   *
   * @see java.awt.event.ActionListener#actionPerformed(ActionEvent)
   */
  public void actionPerformed(ActionEvent e) {
    if (nodeType == -1) return;
    boolean withParent = false;

    Browser browser = model.getSelectedBrowser();
    if (browser != null) {
      int n = browser.getSelectedDisplays().length;
      if (n == 1) {
        TreeImageDisplay node = browser.getLastSelectedDisplay();
        Object uo = node.getUserObject();
        switch (nodeType) {
          case DATASET:
            if (uo instanceof ProjectData) withParent = model.isUserOwner(uo);
            break;
          case EXPERIMENTER:
            if (uo instanceof ExperimenterData) withParent = false; // true;
            break;
          case TAG:
            if (uo instanceof TagAnnotationData) {
              TagAnnotationData tag = (TagAnnotationData) uo;
              String ns = tag.getNameSpace();
              if (ns != null && TagAnnotationData.INSIGHT_TAGSET_NS.equals(ns)) ;
              withParent = model.isUserOwner(tag);
            }
            /*
            if (fromTopMenu) withParent = false;
            else {
            	if (uo instanceof TagAnnotationData) {
            		TagAnnotationData tag = (TagAnnotationData) uo;
            		String ns = tag.getNameSpace();
            		if (ns != null &&
            			TagAnnotationData.INSIGHT_TAGSET_NS.equals(
            						ns));
            			withParent = model.isUserOwner(tag);
            	}
            }
            */
        }
      }
    }
    CreateCmd cmd = new CreateCmd(model, nodeType);
    cmd.setWithParent(withParent);
    cmd.execute();
  }
 /**
  * Reloads the experimenter's data.
  *
  * @see java.awt.event.ActionListener#actionPerformed(ActionEvent)
  */
 public void actionPerformed(ActionEvent e) {
   Browser b = model.getSelectedBrowser();
   if (b != null) b.refreshExperimenterData();
 }