/**
  * Returns the compression quality related to the passed level.
  *
  * @param compressionLevel The level to handle.
  * @return See above.
  */
 static final float getCompressionQuality(int compressionLevel) {
   Float value;
   switch (compressionLevel) {
     default:
     case RenderingControl.UNCOMPRESSED:
     case RenderingControl.MEDIUM:
       value = (Float) registry.lookup(LookupNames.COMPRESSIOM_MEDIUM_QUALITY);
       return value.floatValue();
     case RenderingControl.LOW:
       value = (Float) registry.lookup(LookupNames.COMPRESSIOM_LOW_QUALITY);
       return value.floatValue();
   }
 }
示例#2
0
  /** Opens the file. */
  private void openFile() {
    if (!(data instanceof FileAnnotationData)) return;

    FileAnnotationData fa = (FileAnnotationData) data;
    Registry reg = MetadataViewerAgent.getRegistry();
    UserNotifier un = reg.getUserNotifier();
    OriginalFile f = (OriginalFile) fa.getContent();
    Environment env = (Environment) reg.lookup(LookupNames.ENV);
    DownloadAndLaunchActivityParam activity;
    final long dataId = fa.getId();
    final File dir =
        new File(env.getOmeroFilesHome() + File.separatorChar + "file annotation " + dataId);
    if (!dir.exists()) {
      dir.mkdir();
    }
    if (f != null && f.isLoaded()) {
      activity = new DownloadAndLaunchActivityParam(f, dir, null);
    } else {
      activity =
          new DownloadAndLaunchActivityParam(
              dataId, DownloadAndLaunchActivityParam.FILE_ANNOTATION, dir, null);
    }
    un.notifyActivity(model.getSecurityContext(), activity);
    return;
  }
  /**
   * Creates a new {@link CacheService}.
   *
   * @param container Reference to the container.
   * @return See above.
   */
  public static CacheService makeNew(Container container) {
    // NB: this can't be called outside of container b/c agents have no refs
    // to the singleton container. So we can be sure this method is going to
    // create services just once.
    if (container == null) return null;
    // If caching is off, then we return the no-op adapter.
    Registry reg = container.getRegistry();
    Boolean isCachingOn = (Boolean) reg.lookup(LookupNames.CACHE_ON);
    if (!isCachingOn.booleanValue()) return makeNoOpCache();

    // Ok we have to cache, so try and read the config file.
    InputStream config = loadConfig(container.getConfigFileRelative(CACHE_CONFIG_FILE));
    if (config == null) return makeNoOpCache();

    // We have a config file, set up ehcache.
    CacheService cache = new CacheServiceImpl(config, container.getRegistry().getLogger());
    try {
      config.close();
    } catch (Exception e) {
    }
    return cache;
  }
  /**
   * Checks if the rendering controls are still active. Shuts the inactive ones.
   *
   * @param context Reference to the registry. To ensure that agents cannot call the method. It must
   *     be a reference to the container's registry.
   */
  public static void checkRenderingControls(Registry context) {
    // TODO Auto-generated method stub
    if (!(context.equals(registry)))
      throw new IllegalArgumentException("Not allow to access method.");
    RenderingControlProxy proxy;
    Entry<Long, RenderingControl> e;
    Iterator<Entry<Long, RenderingControl>> i = singleton.rndSvcProxies.entrySet().iterator();
    Long value = (Long) context.lookup(LookupNames.RE_TIMEOUT);

    long timeout = 60000; // 1min
    if (value != null && value.longValue() > timeout) timeout = value.longValue();

    Logger logger = context.getLogger();
    while (i.hasNext()) {
      e = i.next();
      proxy = (RenderingControlProxy) e.getValue();
      if (!proxy.isProxyActive(timeout)) {
        if (!proxy.shutDown(true))
          logger.info(singleton, "Rendering Engine shut down: PixelsID " + e.getKey());
      }
    }
  }
示例#5
0
  /**
   * Builds the UI component hosting the UI component used to modify the password.
   *
   * @return See above.
   */
  private JPanel buildPasswordPanel() {
    JPanel content = new JPanel();
    content.setBackground(UIUtilities.BACKGROUND_COLOR);
    Registry reg = MetadataViewerAgent.getRegistry();
    String ldap = (String) reg.lookup(LookupNames.USER_AUTHENTICATION);
    if (ldap != null && ldap.length() > 0) {
      content.setBorder(BorderFactory.createTitledBorder("LDAP Authentication"));
      content.setLayout(new FlowLayout(FlowLayout.LEFT));
      content.add(new JLabel(ldap));
      return content;
    }
    content.setBorder(BorderFactory.createTitledBorder("Change Password"));

    content.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(0, 2, 2, 0);
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last
    c.fill = GridBagConstraints.NONE; // reset to default
    c.weightx = 0.0;
    if (MetadataViewerAgent.isAdministrator()) {
      content.add(UIUtilities.setTextFont(PASSWORD_NEW), c);
      c.gridx++;
      c.gridwidth = GridBagConstraints.REMAINDER; // end row
      c.fill = GridBagConstraints.HORIZONTAL;
      c.weightx = 1.0;
      content.add(passwordNew, c);
    } else {
      content.add(UIUtilities.setTextFont(PASSWORD_OLD), c);
      c.gridx++;
      c.gridwidth = GridBagConstraints.REMAINDER; // end row
      c.fill = GridBagConstraints.HORIZONTAL;
      c.weightx = 1.0;
      content.add(oldPassword, c);
      c.gridy++;
      c.gridx = 0;
      c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last
      c.fill = GridBagConstraints.NONE; // reset to default
      c.weightx = 0.0;
      content.add(UIUtilities.setTextFont(PASSWORD_NEW), c);
      c.gridx++;
      c.gridwidth = GridBagConstraints.REMAINDER; // end row
      c.fill = GridBagConstraints.HORIZONTAL;
      c.weightx = 1.0;
      content.add(passwordNew, c);
      c.gridy++;
      c.gridx = 0;
      c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last
      c.fill = GridBagConstraints.NONE; // reset to default
      c.weightx = 0.0;
      content.add(UIUtilities.setTextFont(PASSWORD_CONFIRMATION), c);
      c.gridx++;
      c.gridwidth = GridBagConstraints.REMAINDER; // end row
      c.fill = GridBagConstraints.HORIZONTAL;
      c.weightx = 1.0;
      content.add(passwordConfirm, c);
      c.gridy++;
      c.gridx = 0;
    }

    JPanel p = new JPanel();
    p.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(content);
    JPanel buttonPanel = UIUtilities.buildComponentPanel(passwordButton);
    buttonPanel.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.add(buttonPanel);
    return p;
  }
示例#6
0
 /**
  * Returns an implementation of {@link ExecMonitor} that works as an adapter to notify the
  * specified <code>observer</code> of execution events. Specifically, the returned adapter will
  * notify the <code>observer</code> of the tree's execution progress and of the eventual outcome
  * of the computation.
  *
  * @param observer The adaptee.
  * @return The adapter.
  * @see BatchCallMonitor
  */
 protected ExecMonitor getMonitor(AgentEventListener observer) {
   MonitorFactory mf = (MonitorFactory) context.lookup(LookupNames.MONITOR_FACTORY);
   return mf.makeNew(this, observer);
 }
示例#7
0
 /**
  * Returns a concrete {@link CmdProcessor} to {@link #exec(AgentEventListener) execute} the call
  * tree.
  *
  * @return See above.
  */
 protected CmdProcessor getProcessor() {
   return (CmdProcessor) context.lookup(LookupNames.CMD_PROCESSOR);
 }