Package org.apache.cayenne.project

Examples of org.apache.cayenne.project.Project


    }

    private Project openProjectResourse(
            Resource resource,
            CayenneModelerController controller) {
        Project project = getApplication()
                .getInjector()
                .getInstance(ProjectLoader.class)
                .loadProject(resource);

        controller.projectOpenedAction(project);
View Full Code Here


        return "icon-save.gif";
    }

    @Override
    protected boolean saveAll() throws Exception {
        Project p = getCurrentProject();

        if (p == null || p.getConfigurationResource() == null) {
            return super.saveAll();
        }
        else {

            String oldPath = p.getConfigurationResource().getURL().getPath();

            getProjectController().getProjectWatcher().pauseWatching();

            ProjectSaver saver = getApplication().getInjector().getInstance(
                    ProjectSaver.class);
            saver.save(p);

            RenamedPreferences.removeOldPreferences();

            // if change DataChanelDescriptor name - as result change name of xml file
            // we will need change preferences path
            String[] path = oldPath.split("/");
            String[] newPath = p.getConfigurationResource().getURL().getPath().split("/");

            if (!path[path.length - 1].equals(newPath[newPath.length - 1])) {
                String newName = newPath[newPath.length - 1].replace(".xml", "");
                RenamedPreferences.copyPreferences(
                        newName,
                        getProjectController().getPreferenceForProject());
                RenamedPreferences.removeOldPreferences();
            }

            getApplication().getFrameController().changePathInLastProjListAction(
                    oldPath,
                    p.getConfigurationResource().getURL().getPath());
            Application.getFrame().fireRecentFileListChanged();

            /**
             * Reset the watcher now
             */
 
View Full Code Here

    public void reconfigure() {
        pauseWatching();

        removeAllFiles();

        Project project = mediator.getProject();

        if (project != null // project opened
                && project.getConfigurationResource() != null) // not new project
        {
            String projectPath = project.getConfigurationResource().getURL().getPath()
                    + File.separator;
            addFile(projectPath);

            Iterator<DataMap> it = ((DataChannelDescriptor) project.getRootNode())
                    .getDataMaps()
                    .iterator();
            while (it.hasNext()) {
                DataMap dm = it.next();
                addFile(dm.getConfigurationSource().getURL().getPath());
View Full Code Here

        URL url = getClass().getClassLoader().getResource(
                baseUrl + "/cayenne-" + testConfigName + ".xml");

        Resource rootSource = new URLResource(url);

        Project project = loader.loadProject(rootSource);
        assertNotNull(project);

        DataChannelDescriptor rootNode = (DataChannelDescriptor) project.getRootNode();
        assertNotNull(rootNode);
        assertSame(rootSource, rootNode.getConfigurationSource());
       
        assertNotNull(project.getConfigurationResource());
        assertEquals(project.getConfigurationResource(), rootSource);
    }
View Full Code Here

        nodes[0].getDataMapNames().add("B");
        nodes[0].getDataMapNames().add("A");

        rootNode.getNodeDescriptors().addAll(Arrays.asList(nodes));

        Project project = new Project(new ConfigurationTree<DataChannelDescriptor>(
                rootNode));

        saver.saveAs(project, new URLResource(testFolder.toURL()));

        File target = new File(testFolder, "cayenne-test.xml");
View Full Code Here

            }
        }

        // save in the new format
        for (DataChannelDescriptor descriptor : domains) {
            Project project = new Project(new ConfigurationTree<DataChannelDescriptor>(
                    descriptor));

            EntityResolver entityResolver = new EntityResolver(
                    ((DataChannelDescriptor) project.getRootNode()).getDataMaps());

            Iterator<DataMap> it = entityResolver.getDataMaps().iterator();
            while (it.hasNext()) {
                DataMap map = it.next();
                map.setNamespace(entityResolver);
View Full Code Here

        String baseUrl = getClass().getPackage().getName().replace('.', '/');
        URL url = getClass().getClassLoader().getResource(
                baseUrl + "/cayenne-" + testConfigName + ".xml");

        Resource source = new URLResource(url);
        Project project = injector.getInstance(ProjectLoader.class).loadProject(source);

        File outFile = setupTestDirectory("testSave");

        saver.saveAs(project, new URLResource(outFile.toURL()));
View Full Code Here

        String baseUrl = getClass().getPackage().getName().replace('.', '/');
        URL url = getClass().getClassLoader().getResource(
                baseUrl + "/cayenne-" + testConfigName + ".xml");

        Resource source = new URLResource(url);
        Project project = injector.getInstance(ProjectLoader.class).loadProject(source);

        File outFile = setupTestDirectory("testSaveAs_RecoverFromSaveError");
        assertEquals(0, outFile.list().length);

        try {
View Full Code Here

            public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor) {
                return null;
            }
        };

        Project project = new Project(new ConfigurationTree<ConfigurationNode>(object));
        assertSame(object, project.getRootNode());

        assertFalse(project.isModified());

        project.setModified(true);
        assertTrue(project.isModified());
    }
View Full Code Here

TOP

Related Classes of org.apache.cayenne.project.Project

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.