Exemplo n.º 1
0
 private void checkCurrentFolder(Folder folder) {
   Preconditions.checkState(
       folder.equals(currentFolder),
       "You must have opened folder %s"
           + " before attempting to read from it (%s is currently open).",
       folder.getName(),
       (currentFolder == null ? "No folder" : currentFolder.getName()));
 }
Exemplo n.º 2
0
  @Test
  public void testConstructor1() {
    Folder folder = new Folder("Home", Visibility.PUBLIC, true);

    Assert.assertEquals("Home", folder.getName());
    Assert.assertEquals(Visibility.PUBLIC, folder.getVisibility());
    Assert.assertTrue(folder.getVisibilityInCascade());
  }
 @Override
 public Folder getFolder(String name) {
   Folder folder = mFolders.get(name);
   if (folder == null) {
     folder = new Pop3Folder(name);
     mFolders.put(folder.getName(), folder);
   }
   return folder;
 }
  public static void main(String[] args) throws Throwable {
    String mailbox = null;
    boolean DEBUG = false;

    for (int i = 0; i < args.length; i++) {
      if (args[i].equals("-debug")) {
        DEBUG = true;

      } else if (mailbox == null) {
        mailbox = args[i];

      } else {
        usage("Spurious command line: " + args);
      }
    }

    if (mailbox == null) {
      usage("Missing mailbox");
    }

    // Get a connection to the mail server
    Properties props = new Properties();
    Session session = Session.getDefaultInstance(props, null);
    session.setDebug(DEBUG);

    Provider[] providers = session.getProviders();
    for (int i = 0; i < providers.length; i++) {
      Provider provider = providers[i];
      out.println(provider);
    }

    Store store = session.getStore("imap");
    Folder folder = store.getFolder(mailbox);
    Message[] messages = folder.getMessages();
    out.println("Folder " + folder.getName() + " with " + messages.length + " messages");
    for (int i = 0; i < messages.length; i++) {
      Message message = messages[i];
      out.println("  " + i + ": " + message.getSubject());
    }

    out.println("");
  }
Exemplo n.º 5
0
    public View getView(int position, View convertView, ViewGroup parent) {
      View v = mInflater.inflate(R.layout.folder, parent, false);
      Folder folder = mFolders.get(position);
      TextView name = (TextView) v.findViewById(R.id.folder_name);

      Drawable drawable = null;
      if (folder.isParent) {
        name.setText("[..]");
        drawable = new FolderTransitionDrawable(mFolderUpLayers);
      } else {
        name.setText(folder.getName());
        if (folder.isDirectory()) {
          drawable = new FolderTransitionDrawable(mFolderLayers);
        } else {
          drawable = mFileDrawable;
        }
      }
      v.findViewById(R.id.folder_icon).setBackgroundDrawable(drawable);
      return v;
    }
Exemplo n.º 6
0
  private CompilationNode(final Folder folder, Children children, InstanceContent content) {
    super(children, new AbstractLookup(content));
    this.setDisplayName(folder.getName());

    if (folder instanceof Group) {
      content.add(
          new OpenCookie() {

            @Override
            public void open() {
              final List<InputGraph> graphs = ((Group) folder).getGraphs();
              if (graphs.isEmpty()) {
                JOptionPane.showMessageDialog(
                    null, "Cannot open compilation, because there was no snapshots recorded!");
              } else {
                Lookup.getDefault().lookup(GraphViewer.class).view(graphs.get(0));
              }
            }
          });
    }
    content.add(folder);
    folder.getChangedEvent().addListener(this);
  }
Exemplo n.º 7
0
  public void addFolder(Folder folder) {
    this.folders.put(folder.getName(), folder);

    this.updateRootFolderPath(folder.getName());
  }
Exemplo n.º 8
0
 @Test
 public void getNameTest() {
   folder.setName("Входящие");
   Assert.assertEquals("Входящие", folder.getName());
 }
Exemplo n.º 9
0
 public int compare(Folder o1, Folder o2) {
   return o1.getName().compareToIgnoreCase(o2.getName());
 }
Exemplo n.º 10
0
  /**
   * Method used to transfer the nodes of a LibrayNode based tree to a BaseTreeModel based tree of
   * Folder and Document objects for use in a GXT display
   *
   * @param node A LibraryNode object that was returned from the server
   * @return The equivalent BaseTreeModel node (Folder or Document) for display in a GXT Widget.
   */
  private BaseTreeModel parseLibraryNode(
      LibraryNode node, TreeModel parent, DrakeGeneticsServiceAsync drakeGeneticsService) {
    BaseTreeModel displayNode = null;

    if (node.isDocument()) {

      GWT.log(node.getDisplayName() + "--" + node.getFileName());
      final Document document = new Document(node.getDisplayName(), node.getFileName());
      if (parent != null) {
        document.setParent(parent);
      }

      // Add code here to actually fetch the document and add it to
      // the Document object
      List<String> path = new ArrayList<String>();
      path.add(document.getDocument());
      Folder fParent = (Folder) parent;
      if (!fParent.getName().equals("/Library/")) {
        path.add(fParent.getName());
        Folder curParent = (Folder) parent.getParent();
        while (curParent != null) {
          if (!curParent.getName().equals("/Library/")) path.add(curParent.getName());
          curParent = (Folder) curParent.getParent();
        }
      }
      Collections.reverse(path);
      GWT.log(path.toString());

      drakeGeneticsService.getPublication(
          path,
          new AsyncCallback<String>() {
            public void onSuccess(String documentUrl) {
              GWT.log(document.getName());
              GWT.log(" Node URL = " + documentUrl);
              document.setUrl(documentUrl);
              tree.repaint();
            }

            public void onFailure(Throwable caught) {
              getTreeModelFailed(caught);
            }
          });
      displayNode = document;

    } else if (node.isLeaf()) {
      displayNode = new Folder(node.getData());
      if (parent != null) {
        displayNode.setParent(parent);
      }

    } else {
      displayNode = new Folder(node.getData());
      if (parent != null) {
        displayNode.setParent(parent);
      }
      for (int i = 0; i < node.getChildCount(); i++) {
        displayNode.add(
            parseLibraryNode((LibraryNode) node.getChild(i), displayNode, drakeGeneticsService));
      }
    }

    return displayNode;
  }