Package org.jdesktop.wonderland.common.cell

Examples of org.jdesktop.wonderland.common.cell.CellID


            Iterator<CellID> cellIDs = state.getRootCells();
            int count = 0;

            // load a cell
            while (cellIDs.hasNext() && (count < max)) {
                CellID cellID = cellIDs.next();

                // try to reload the cell
                boolean result = cells.reloadCell(cellID, UniverseService.this);

                // record the result
View Full Code Here


            // granted list
            for (ActionMap am : grants.values()) {
                // the resource is OK'd if the view action is granted. If
                // the action map is empty, it means permission was denied.
                if (am.isEmpty()) {
                    CellID id = ((CellIDResource) am.getResource()).getCellID();
                    cells.remove(id);
                }
            }

            // now send a load message with all the granted cells.
View Full Code Here

                    new LinkedHashMap<CellID, CellDescription>(cells);
            ViewCellCacheMO cache = viewCellCacheRef.get();

            // go through and look at each cell to see if its granted or denied
            for (ActionMap am : grants.values()) {
                CellID id = ((CellIDResource) am.getResource()).getCellID();
               
                // the resource is OK'd if the view action is granted
                if (am.size() == 0) {
                    // cell is removed -- keep on the unload list only
                    cells.remove(id);
                } else {
                    // cell is added -- keep on the load list only
                    unloadCells.remove(id);
                }
            }

            // go through the load list and remove any cells that are
            // already in the cache.
            for (Iterator<CellID> loadCells = cells.keySet().iterator();
                 loadCells.hasNext();)
            {
                CellID loadID = loadCells.next();

                // remove this id if it is already loaded
                if (cache.isLoaded(loadID)) {
                    loadCells.remove();
                }

                // remove this id from the unload list. This will take
                // care of any cells that don't have a security resource
                // and therefore were not checked above
                unloadCells.remove(loadID);
            }

            // now go through the unload list and remove any cells that
            // are already unloaded
            for (Iterator<CellID> unloads = unloadCells.keySet().iterator();
                 unloads.hasNext();)
            {
                CellID unloadID = unloads.next();

                // remove this id if it is already unloaded
                if (!cache.isLoaded(unloadID)) {
                    unloads.remove();
                }
View Full Code Here

    /**
     * Return a new Create cell message
     */
    public static CellHierarchyMessage newCreateCellMessage(CellMO cell, CellSessionProperties properties) {
        CellID parent=null;
       
        CellMO p = cell.getParent();
        if (p!=null) {
            parent = p.getCellID();
        }
View Full Code Here

   
    /**
     * Return a new LoadLocalAvatar cell message
     */
    public static CellHierarchyMessage newLoadLocalAvatarMessage(CellMO cell, CellSessionProperties properties) {
        CellID parent=null;
       
        CellMO p = cell.getParent();
        if (p!=null) {
            parent = p.getCellID();
        }
View Full Code Here

    /**
     * Return a new cell update message. Indicates that the content of the cell
     * has changed.
     */
    public static CellHierarchyMessage newConfigureCellMessage(CellMO cellMO, ClientCapabilities capabilities) {
        CellID parentID = null;
        if (cellMO.getParent() != null) {
            parentID = cellMO.getParent().getCellID();
        }
       
        /* Return a new CellHiearchyMessage class, with populated data fields */
 
View Full Code Here

        private void handleUpdateStateMessage(WonderlandClientSender sender,
                WonderlandClientID clientID,
                CellServerStateUpdateMessage message)
        {
            CellMO cellMO = getCell();
            CellID cellID = cellMO.getCellID();

            // Fetch the cell, and set its server state. Catch all exceptions
            // and report. This assumes that all components have been removed
            // from the server state object, since they are handled separately
            // below. The client needs to remove the component state objects
View Full Code Here

    public void exportResult(Map<CellID, CellExportResult> results) {
        int successCount = 0;
        int errorCount = 0;
       
        for (Map.Entry<CellID, CellExportResult> e : results.entrySet()) {
            CellID id = e.getKey();
            CellExportResult res = e.getValue();
           
            if (res.isSuccess()) {
                successCount++;
            } else {
View Full Code Here

                return;
            }

            // Find the parent cell (if any)
            CellMO parent = null;
            CellID parentCellID = ((CellCreateMessage)editMessage).getParentCellID();
            if (parentCellID != null) {
                parent = CellManagerMO.getCell(parentCellID);
            }

            /* Call the cell's setup method */
            try {
                cellMO.setServerState(setup);

                if (parent == null) {
                    WonderlandContext.getCellManager().insertCellInWorld(cellMO);
                } else {
                    parent.addChild(cellMO);
                }
                //everything worked okay. send response message
                sender.send(clientID, new CellCreatedMessage(editMessage.getMessageID(), cellMO.getCellID()));

            } catch (ClassCastException cce) {
                logger.log(Level.WARNING, "Error setting up new cell " +
                        cellMO.getName() + " of type " +
                        cellMO.getClass() + ", it does not implement " +
                        "BeanSetupMO.", cce);
                sender.send(clientID,
                        new ErrorMessage(editMessage.getMessageID(),cce));
                return;
            } catch (MultipleParentException excp) {
                logger.log(Level.WARNING, "Error adding new cell " + cellMO.getName()
                        + " of type " + cellMO.getClass() + ", has multiple parents", excp);
                sender.send(clientID,
                        new ErrorMessage(editMessage.getMessageID(), excp));
                return;
            }
        }
        else if (editMessage.getEditType() == EditType.DELETE_CELL) {
            // Find the cell object given the ID of the cell. If the ID is
            // invalid, we just log an error and return.
            CellID cellID = ((CellDeleteMessage)editMessage).getCellID();
            CellMO cellMO = CellManagerMO.getCell(cellID);
            if (cellMO == null) {
                logger.warning("No cell found to delete with cell id " + cellID);
                return;
            }

            // Find out the parent of the cell. This may be null if the cell is
            // at the world root. This determines from where to remove the cell
            CellMO parentMO = cellMO.getParent();
            if (parentMO != null) {
                parentMO.removeChild(cellMO);
            }
            else {
                CellManagerMO.getCellManager().removeCellFromWorld(cellMO);
            }
        }
        else if (editMessage.getEditType() == EditType.DUPLICATE_CELL) {
            // Find the cell object given the ID of the cell. If the ID is
            // invalid, we just log an error and return.
            CellID cellID = ((CellDuplicateMessage)editMessage).getCellID();
            CellMO cellMO = CellManagerMO.getCell(cellID);
            if (cellMO == null) {
                logger.warning("No cell found to duplicate with cell id " + cellID);
                sender.send(clientID, new ErrorMessage(editMessage.getMessageID(),
                        "No cell found to duplicate with cell id " + cellID));
                return;
            }
            CellMO parentCellMO = cellMO.getParent();

            // We need to fetch the current state of the cell from the cell we
            // wish to duplicate. We also need the name of the server-side cell
            // class
            CellServerState state = cellMO.getServerState(null);
            String className = state.getServerClassName();

            // Attempt to create the cell using the cell factory and the class
            // name of the server-side cell.
            CellMO newCellMO = CellMOFactory.loadCellMO(className);
            if (newCellMO == null) {
                /* Log a warning and move onto the next cell */
                logger.warning("Unable to duplicate cell MO: " + className);
                sender.send(clientID, new ErrorMessage(editMessage.getMessageID(),
                        "Unable to duplicate cell MO: " + className));
                return;
            }

            // We want to modify the position of the new cell slight, so we
            // offset the position by (1, 1, 1).
            PositionComponentServerState position = (PositionComponentServerState)state.getComponentServerState(PositionComponentServerState.class);
            if (position == null) {
                logger.warning("Unable to determine the position of the cell " +
                        "to duplicate with id " + cellID);
                sender.send(clientID, new ErrorMessage(editMessage.getMessageID(),
                        "Unable to determine the position of the cell " +
                        "to duplicate with id " + cellID));
                return;
            }
            Vector3f offset = new Vector3f(1, 0, 1);
            Vector3f origin = position.getTranslation();
            position.setTranslation(offset.add(origin));
            state.addComponentServerState(position);

            // Set the desired name of the cell contained within the message
            state.setName(((CellDuplicateMessage)editMessage).getCellName());
           
            // Set the state of the new cell and add it to the same parent as
            // the old cell. If the old parent cell is null, we just insert it
            // as root.
            newCellMO.setServerState(state);
            try {
                if (parentCellMO == null) {
                    WonderlandContext.getCellManager().insertCellInWorld(newCellMO);
                }
                else {
                    parentCellMO.addChild(newCellMO);
                }
                sender.send(clientID, new CellCreatedMessage(editMessage.getMessageID(), newCellMO.getCellID()));
            } catch (MultipleParentException excp) {
                logger.log(Level.WARNING, "Error duplicating cell " +
                        newCellMO.getName() + " of type " + newCellMO.getClass() +
                        ", has multiple parents", excp);
                sender.send(clientID, new ErrorMessage(editMessage.getMessageID(),
                        excp));
                return;
            }
        }
        else if (editMessage.getEditType() == EditType.REPARENT_CELL) {
            // Find the cell id to move and the new parent id
            CellID cellID = ((CellReparentMessage)editMessage).getCellID();
            CellID newParentID = ((CellReparentMessage)editMessage).getParentCellID();

            // Figure out the new local coordinates of the cell wrt the new
            // parent

            // Change the parent cell
View Full Code Here

            pendingCacheUpdates.add(new CacheUpdate(cell));
        }
    }

    void cellDestroyed(SpatialCell cell) {
        CellID cellID = ((SpatialCellImpl)cell).getCellID();
        removeViewUpdateListener(cellID, null);
    }
View Full Code Here

TOP

Related Classes of org.jdesktop.wonderland.common.cell.CellID

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.