Search in sources :

Example 1 with AppTag

use of org.cytoscape.app.internal.net.WebQuerier.AppTag in project cytoscape-impl by cytoscape.

the class InstallAppsPanel method buildTagsTree.

private void buildTagsTree() {
    WebQuerier webQuerier = appManager.getWebQuerier();
    // Get all available apps and tags
    Set<WebApp> availableApps = webQuerier.getAllApps();
    Set<WebQuerier.AppTag> availableTags = webQuerier.getAllTags();
    if (availableApps == null || availableTags == null)
        return;
    List<WebQuerier.AppTag> sortedTags = new LinkedList<WebQuerier.AppTag>(availableTags);
    Collections.sort(sortedTags, new Comparator<WebQuerier.AppTag>() {

        @Override
        public int compare(AppTag tag, AppTag other) {
            return other.getCount() - tag.getCount();
        }
    });
    DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");
    DefaultMutableTreeNode allAppsTreeNode = new DefaultMutableTreeNode("all apps" + " (" + availableApps.size() + ")");
    root.add(allAppsTreeNode);
    DefaultMutableTreeNode collectionsTreeNode = new DefaultMutableTreeNode("collections (0)");
    DefaultMutableTreeNode appsByTagTreeNode = new DefaultMutableTreeNode("apps by tag");
    for (final WebQuerier.AppTag appTag : sortedTags) {
        if (appTag.getName().equals("collections"))
            collectionsTreeNode.setUserObject(appTag);
        else
            appsByTagTreeNode.add(new DefaultMutableTreeNode(appTag));
    }
    root.add(collectionsTreeNode);
    root.add(appsByTagTreeNode);
    tagsTree.setModel(new DefaultTreeModel(root));
    // tagsTree.expandRow(2);
    currentSelectedAppTag = null;
    hasTagTreeBeenPopulated = true;
}
Also used : AppTag(org.cytoscape.app.internal.net.WebQuerier.AppTag) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) AppTag(org.cytoscape.app.internal.net.WebQuerier.AppTag) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) WebQuerier(org.cytoscape.app.internal.net.WebQuerier) LinkedList(java.util.LinkedList) WebApp(org.cytoscape.app.internal.net.WebApp)

Aggregations

LinkedList (java.util.LinkedList)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)1 WebApp (org.cytoscape.app.internal.net.WebApp)1 WebQuerier (org.cytoscape.app.internal.net.WebQuerier)1 AppTag (org.cytoscape.app.internal.net.WebQuerier.AppTag)1