Package org.jboss.dashboard.ui.resources

Examples of org.jboss.dashboard.ui.resources.GraphicElement


            if (!manager.getElementScopeDescriptor().isAllowedInstance())
                continue;//Ignore manager, as it does not define elements for panel instances
            GraphicElement[] elements = manager.getElements(panel.getWorkspace().getId(), null, panel.getInstanceId());
            if (elements != null) {
                for (int i = 0; i < elements.length; i++) {
                    GraphicElement element = elements[i];
                    GraphicElement elementClone = (GraphicElement) element.clone();
                    elementClone.setWorkspaceId(panelClone.getWorkspace().getId());
                    elementClone.setSectionId(null);
                    elementClone.setPanelId(panel.getInstanceId());
                    manager.createOrUpdate(elementClone);
                }
            }
        }
    }
View Full Code Here


    protected void createResource(CreateResult result, String workspaceId, Long sectionId, Long panelId, XMLNode node, Map attributes, boolean onStartup) throws Exception {
        String className = node.getAttributes().getProperty(ExportVisitor.RESOURCE_ATTR_CATEGORY);
        String id = node.getAttributes().getProperty(ExportVisitor.RESOURCE_ATTR_ID);
        byte[] rawContent = ((XMLNode) node.getChildren().get(0)).getContent();

        GraphicElement element = (GraphicElement) Class.forName(className).newInstance();

        if (element.getInstanceManager().getElement(id, workspaceId, sectionId, panelId) != null) {
            log.warn("Refusing to overwrite existing resource with id " + id);
            result.getWarnings().add("refusingOverwriteResource");
            result.getWarningArguments().add(new Object[]{element.getCategoryName(), id, workspaceId, sectionId, panelId});
        } else {
            element.setId(id);
            element.setWorkspaceId(workspaceId);
            element.setSectionId(sectionId);
            element.setPanelId(panelId);
            element.setZipFile(rawContent);
            element.getInstanceManager().createOrUpdate(element);
            if (workspaceId == null)
                result.setObjectCreated(element);
        }
    }
View Full Code Here

        GraphicElement[] layouts = UIServices.lookup().getLayoutsManager().getElements(getWorkspace().getId(), null, getInstanceId());
        GraphicElement[][] elements = {galleries, skins, envelopes, layouts};
        for (int i = 0; i < elements.length; i++) {
            GraphicElement[] elementsArray = elements[i];
            for (int j = 0; j < elementsArray.length; j++) {
                GraphicElement element = elementsArray[j];
                element.acceptVisit(visitor);
            }
        }

        return visitor.endVisit();
    }
View Full Code Here

    public GraphicElementScopeDescriptor getElementScopeDescriptor() {
        return GraphicElementScopeDescriptor.SECTION_SCOPED;
    }

    public GraphicElement getDefaultElement() {
        GraphicElement element = super.getDefaultElement();
        if (element == null) {
            try {
                element = createDefaultGallery();
            } catch (Exception e) {
                log.error("Error: ", e);
View Full Code Here

        deployBaseElements();
        if (elements != null) {
            new HibernateTxFragment() {
            protected void txFragment(Session session) throws Exception {
                for (Iterator iterator = elements.iterator(); iterator.hasNext();) {
                    GraphicElement graphicElement = (GraphicElement) iterator.next();
                    graphicElement.checkDeployment();
                    session.update(graphicElement);
                }
            }}.execute();
        }
    }
View Full Code Here

            protected void txFragment(Session session) throws Exception {
                FlushMode oldFlushMode = session.getFlushMode();
                session.setFlushMode(FlushMode.NEVER);
                List dbItems = session.createQuery("from " + classToHandle.getName() + " as element").list();
                for (int i = 0; i < dbItems.size(); i++) {
                    GraphicElement element = (GraphicElement) dbItems.get(i);
                    //element.deploy();
                    log.debug("Loaded db item " + element.getId());
                    elements.add(element);
                }
                session.setFlushMode(oldFlushMode);
            }
        };
View Full Code Here

    /**
     * Deploys an element (zip file). Deployment consists in creating or updating it in database
     */
    protected void deployZippedElement(File zipFile, String elementId) throws Exception {
        log.debug("Deploying " + classToHandleName + " " + zipFile);
        final GraphicElement existingElement = getElement(elementId, null, null, null);
        log.debug("Existing element with id " + elementId + " = " + existingElement);
        if (existingElement != null) {
            log.debug("Updating file " + zipFile + ". (Already deployed in db)");
            existingElement.setZipFile(zipFile);
            existingElement.setLastModified(new Date());
        } else {
            log.info("Deploying to database " + classToHandleName + " " + zipFile);
            Constructor c = classToHandle.getConstructor(new Class[]{String.class, File.class});
            final GraphicElement element = (GraphicElement) c.newInstance(new Object[]{elementId, zipFile});

            HibernateTxFragment txFragment = new HibernateTxFragment() {
                protected void txFragment(Session session) throws Exception {
                    element.setLastModified(new Date());
                    session.save(element);
                }
            };

            txFragment.execute();
View Full Code Here

     */
    public GraphicElement[] getElements(String workspaceId) {
        List l = new ArrayList();
        GraphicElement[] sortedElements = getElements();
        for (int i = 0; i < sortedElements.length; i++) {
            GraphicElement element = (GraphicElement) sortedElements[i];
            if (hasSameValue(element.getWorkspaceId(), workspaceId))
                l.add(element);
        }
        log.debug("Elements with workspace=" + workspaceId + ": " + l.size());
        return (GraphicElement[]) l.toArray(new GraphicElement[l.size()]);
    }
View Full Code Here

     */
    public GraphicElement[] getElements(String workspaceId, Long sectionId) {
        List l = new ArrayList();
        GraphicElement[] sortedElements = getElements(workspaceId);
        for (int i = 0; i < sortedElements.length; i++) {
            GraphicElement element = (GraphicElement) sortedElements[i];
            if (hasSameValue(element.getSectionId(), sectionId))
                l.add(element);
        }
        log.debug("Elements with workspace=" + workspaceId + ", section=" + sectionId + ": " + l.size());
        return (GraphicElement[]) l.toArray(new GraphicElement[l.size()]);
    }
View Full Code Here

     */
    public GraphicElement[] getElements(String workspaceId, Long sectionId, Long panelId) {
        List l = new ArrayList();
        GraphicElement[] sortedElements = getElements(workspaceId, sectionId);
        for (int i = 0; i < sortedElements.length; i++) {
            GraphicElement element = (GraphicElement) sortedElements[i];
            if (hasSameValue(element.getPanelId(), panelId))
                l.add(element);
        }
        log.debug("Elements with workspace=" + workspaceId + ", section=" + sectionId + ", panel=" + panelId + ": " + l.size());
        return (GraphicElement[]) l.toArray(new GraphicElement[l.size()]);
    }
View Full Code Here

TOP

Related Classes of org.jboss.dashboard.ui.resources.GraphicElement

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.