Package org.jdesktop.wonderland.modules.contentrepo.common

Examples of org.jdesktop.wonderland.modules.contentrepo.common.ContentCollection


        // Fetch the local content repository to store all avatar-related
        // configuration information.
        // XXX This should really be re-done for every primary session because
        // the login name can change.
        ContentCollection localContent = ContentRepositoryRegistry.getInstance().getLocalRepository();
        try {
            avatarCollection = (ContentCollection) localContent.getChild("avatars");
            if (avatarCollection == null) {
                avatarCollection = (ContentCollection) localContent.createChild("avatars", Type.COLLECTION);
            }
        } catch (ContentRepositoryException ex) {
            LOGGER.log(Level.SEVERE, null, ex);
        }
View Full Code Here


    public static List<XAppRegistryItem> getSystemXAppRegistryItemList() {
        // First fetch the content collection of the system-wide X Apps items.
        // Upon error, log an error and return an empty list. Then fetch the
        // items from this collection
        try {
            ContentCollection sysNode = getSystemXAppContentCollection();
            if (sysNode == null) {
                return new LinkedList<XAppRegistryItem>();
            }
            return getItemList(sysNode);
        } catch (ContentRepositoryException excp) {
View Full Code Here

    public static List<XAppRegistryItem> getUserXAppRegistryItemList() {
        // First fetch the content collection of the user-specific X Apps items.
        // Upon error, log an error and return an empty list. Then fetch the
        // items from this collection
        try {
            ContentCollection userNode = getUserXAppContentCollection();
            if (userNode == null) {
                return new LinkedList<XAppRegistryItem>();
            }
            return getItemList(userNode);
        } catch (ContentRepositoryException excp) {
View Full Code Here

    public static void addUserXAppRegistryItem(XAppRegistryItem item)
            throws ContentRepositoryException, JAXBException {

        // First fetch the content collection of the user-specific X Apps items
        // and look for the file <app name>.xml.
        ContentCollection userNode = getUserXAppContentCollection();
        String nodeName = item.getAppName() + ".xml";
        ContentNode appNode = userNode.getChild(nodeName);
        if (appNode == null) {
            appNode = userNode.createChild(nodeName, Type.RESOURCE);
        }
        ContentResource resource = (ContentResource)appNode;
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        Writer w = new OutputStreamWriter(os);
        item.encode(w);
View Full Code Here

    public static void removeUserXAppRegistryItem(XAppRegistryItem item)
            throws ContentRepositoryException {

        // First fetch the content collection of the user-specific X Apps items
        // and look for the file <app name>.xml.
        ContentCollection userNode = getUserXAppContentCollection();
        String nodeName = item.getAppName() + ".xml";
        ContentNode appNode = userNode.getChild(nodeName);
        if (appNode != null) {
            userNode.removeChild(nodeName);
        }
    }
View Full Code Here

     * @return The ContentConnection holding the system-wide X App items
     */
    private static ContentCollection getSystemXAppContentCollection()
            throws ContentRepositoryException {

        ContentCollection sysRoot = getSystemContentRepository();
        ContentCollection dir = (ContentCollection)sysRoot.getChild("x-apps");
        return dir;
    }
View Full Code Here

     * @return The ContentConnection holding the system-wide X App items
     */
    private static ContentCollection getUserXAppContentCollection()
            throws ContentRepositoryException {

        ContentCollection userRoot = getUserContentRepository();
        ContentCollection dir = (ContentCollection)userRoot.getChild("x-apps");
        if (dir == null) {
            dir = (ContentCollection)userRoot.createChild("x-apps", Type.COLLECTION);
        }
        return dir;
    }
View Full Code Here

       
        String uri = "";
        ContentRepositoryRegistry registry = ContentRepositoryRegistry.getInstance();
        ContentRepository repo = registry.getRepository(LoginManager.getPrimary());
        try {
            ContentCollection c = repo.getUserRoot();
            try {
                /*
                 * Remove file if it exists.
                 */
                ContentResource r = (ContentResource) c.removeChild(image.getName());
            } catch (Exception e) {
            }
           
            ContentResource r = (ContentResource) c.createChild(
                image.getName(), ContentNode.Type.RESOURCE);
            try {
               
                r.put(image);
               
View Full Code Here

    public static synchronized ContentCollection getBaseServerCollection(ServerSessionManager manager)
            throws ContentRepositoryException {

        ContentRepositoryRegistry reg = ContentRepositoryRegistry.getInstance();
        ContentRepository repository = reg.getRepository(manager);
        ContentCollection userDir = repository.getUserRoot(true);
        if (userDir == null) {
            logger.warning("Unable to find user content directory");
            throw new ContentRepositoryException("Unable to find user dir");
        }

        // Fetch the avatars/imi directory, creating each if necessary
        ContentCollection dir = (ContentCollection) userDir.getChild("avatars");
        if (dir == null) {
            dir = (ContentCollection) userDir.createChild("avatars", Type.COLLECTION);
        }
        return dir;
    }
View Full Code Here

        // default content repository.
        ContentRepositoryRegistry registry =
                ContentRepositoryRegistry.getInstance();
        ContentRepository repo = registry.getRepository(session);
        try {
            ContentCollection sysCollection = repo.getSystemRoot();
            ContentCollection userCollection =
                    (ContentCollection) repo.getRoot().getChild("users");
            jtree.addTreeRoot(BUNDLE.getString("System"), sysCollection);
            jtree.addTreeRoot(BUNDLE.getString("Users"), userCollection);
            factoryMap.put(sysCollection, new ContentRepoNodeURIFactory());
            factoryMap.put(userCollection, new ContentRepoNodeURIFactory());
        } catch (ContentRepositoryException excp) {
            logger.log(Level.WARNING, "Unable to create roots", excp);
        }

        // Formulate the "home" path as /Users/<login name>
        try {
            homePath = "/Users/" + repo.getUserRoot().getName();
        } catch (ContentRepositoryException excp) {
            logger.log(Level.WARNING, "Unable to find user's home", excp);
        }

        // Add the Module tree root, using a wrapper for the content repo to
        // present the modules properly
        try {
            ContentCollection moduleCollection =
                    new ModuleRootContentCollection(repo);
            jtree.addTreeRoot(BUNDLE.getString("Modules"), moduleCollection);
            factoryMap.put(moduleCollection, new ModuleNodeURIFactory());
        } catch (ContentRepositoryException excp) {
            logger.log(Level.WARNING, "Unable to create module root", excp);
        }

        // Create a new table to display a particular directory. We use an
        // AsynchronousJTable so that the entries are loaded asychronously in
        // case a network call is required to load the children.
        jtable = new AsynchronousJTable();
        JScrollPane tableScrollPane = new JScrollPane();
        tableScrollPane.setViewportView(jtable);
        tablePanel.add(tableScrollPane);

        // Listen for selections on the tree and update the right-hand table
        // with the children for the currently selected node.
        jtree.addAsyncTreeSelectionListener(new AsyncTreeSelectionListener() {
            public void treeSelectionChanged(ContentNode node) {
                treeSelectedNode = node;
                if (node == null) {
                    jtable.setContentCollection(null);
                } else if (node instanceof ContentCollection) {
                    jtable.setContentCollection((ContentCollection) node);
                }
            }
        });

        // Listen for when a new directory/file is selected in the list of
        // files in a content repository. Update the state of the buttons
        jtable.addAsyncTableSelectionListener(new AsyncTableSelectionListener() {

            public void tableSelectionChanged(
                    ContentNode node, boolean changeTo) {
                // If we select a node that isn't been selected then update
                // the table with the new selection.
                if (tableSelectedNode != node) {
                    tableSelectedNode = node;
                    changeTableSelection(node);
                }

                // If this selection was really a double-click to open a
                // directory, then update the tree selection too. We know that
                // the parent of the selected node in the table is the currently
                // selected node in the tree. We use this to form the path to
                // the newly selected node to expand
                if (changeTo == true) {
                    jtree.expandAndSelectChild(node.getName());
                }
            }
        });

        // When the Cancel button is pressed, fire off events to the listeners
        cancelButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                setVisible(false);
                dispose();
                for (ContentBrowserListener l : listenerSet) {
                    l.cancelAction();
                }
            }
        });

        // When the Ok button is pressed, fire off events to the listeners,
        // passing them the URI of the selected item
        okButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                setVisible(false);
                dispose();

                for (ContentBrowserListener l : listenerSet) {
                    // We need to get the URI of the selection. We first need a
                    // factory to generate the URI for us, based upon the root
                    // of the selected node. We ask the JTree for this.
                    ContentCollection c = jtree.getSelectedRootCollection();
                    if (c == null) {
                        logger.warning("Unable to find selected root");
                        l.cancelAction();
                    }
View Full Code Here

TOP

Related Classes of org.jdesktop.wonderland.modules.contentrepo.common.ContentCollection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.