Examples of CayenneModelerController


Examples of org.apache.cayenne.modeler.CayenneModelerController

            return;
        }

        boolean isNew = project.getConfigurationResource() == null;

        CayenneModelerController controller = getApplication().getFrameController();

        // close ... don't use OpenProjectAction close method as it will ask for save, we
        // don't want that here
        controller.projectClosedAction();

        File fileDirectory = new File(project
                .getConfigurationResource()
                .getURL()
                .getPath());
        // reopen existing
        if (!isNew && fileDirectory.isFile()) {
            OpenProjectAction openAction = controller
                    .getApplication()
                    .getActionManager()
                    .getAction(OpenProjectAction.class);
            openAction.openProject(fileDirectory);
        }
        // create new
        else if (!(project instanceof Project)) {
            throw new CayenneRuntimeException("Only ApplicationProjects are supported.");
        }
        else {
            controller.getApplication().getActionManager().getAction(
                    NewProjectAction.class).performAction(e);
        }

        application.getUndoManager().discardAllEdits();
    }
View Full Code Here

Examples of org.apache.cayenne.modeler.CayenneModelerController

                .getMenuShortcutKeyMask());
    }

    public void performAction(ActionEvent e) {

        CayenneModelerController controller = Application
                .getInstance()
                .getFrameController();
        // Save and close (if needed) currently open project.
        if (getCurrentProject() != null && !closeProject(true)) {
            return;
        }

        DataChannelDescriptor domain = new DataChannelDescriptor();

        String name = NamedObjectFactory.createName(DataChannelDescriptor.class, domain);

        domain.setName(name);

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

        controller.projectOpenedAction(project);

        // select default domain
        getProjectController().fireDomainDisplayEvent(
                new DomainDisplayEvent(this, domain));
    }
View Full Code Here

Examples of org.apache.cayenne.modeler.CayenneModelerController

                        "Can't Open Project",
                        JOptionPane.OK_OPTION);
                return;
            }

            CayenneModelerController controller = Application
                    .getInstance()
                    .getFrameController();
            controller.addToLastProjListAction(file.getAbsolutePath());

            URL url = file.toURL();
            Resource rootSource = new URLResource(url);

            ProjectUpgrader upgrader = getApplication().getInjector().getInstance(
                    ProjectUpgrader.class);
            UpgradeHandler handler = upgrader.getUpgradeHandler(rootSource);
            UpgradeMetaData md = handler.getUpgradeMetaData();

            if (UpgradeType.DOWNGRADE_NEEDED == md.getUpgradeType()) {
                JOptionPane
                        .showMessageDialog(
                                Application.getFrame(),
                                "Can't open project - it was created using a newer version of the Modeler",
                                "Can't Open Project",
                                JOptionPane.OK_OPTION);
                closeProject(false);
            }
            else if (UpgradeType.INTERMEDIATE_UPGRADE_NEEDED == md.getUpgradeType()) {
                JOptionPane
                        .showMessageDialog(Application.getFrame(),
                        // TODO: andrus 05/02/2010 - this message shows intermediate
                                // version of the project XML, not the Modeler code
                                // version that
                                // can be used for upgrade
                                "Can't upgrade project. Open the project in the Modeler v."
                                        + md.getIntermediateUpgradeVersion()
                                        + " to do an intermediate upgrade before you can upgrade to v."
                                        + md.getSupportedVersion(),
                                "Can't Upgrade Project",
                                JOptionPane.OK_OPTION);
                closeProject(false);
            }
            else if (UpgradeType.UPGRADE_NEEDED == md.getUpgradeType()) {
                if (processUpgrades(md)) {
                    // perform upgrade
                    logObj.info("Will upgrade project " + url.getPath());
                    Resource upgraded = handler.performUpgrade();
                    if (upgraded != null) {
                        Project project = openProjectResourse(upgraded, controller);

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

                        // if project file name changed
                        // need upgrade all
                        if (!file.getAbsolutePath().equals(
                                project.getConfigurationResource().getURL().getPath())) {
                            controller.changePathInLastProjListAction(file
                                    .getAbsolutePath(), project
                                    .getConfigurationResource()
                                    .getURL()
                                    .getPath());
                        }
View Full Code Here

Examples of org.apache.cayenne.modeler.CayenneModelerController

     * password fields depending on the option that was selected.
     */


    public void syncDataSourceAction() {
        CayenneModelerController mainController = getApplication().getFrameController();

        if (getNode() == null || getNode().getDataSourceDescriptor() == null) {
            return;
        }

        DataSourceInfo projectDSI = getNode().getDataSourceDescriptor();

        ProjectController parent = (ProjectController) getParent();
        String key = parent.getDataNodePreferences().getLocalDataSource();
        if (key == null) {
            mainController.updateStatus("No Local DataSource selected for node...");
            return;
        }

        DBConnectionInfo dataSource = (DBConnectionInfo) getApplication()
            .getCayenneProjectPreferences()
            .getDetailObject(DBConnectionInfo.class)
            .getObject(key);

        if (dataSource != null) {
            if (dataSource.copyTo(projectDSI)) {
                refreshView();
                super.nodeChangeProcessor.modelUpdated(null, null, null);
                mainController.updateStatus(null);
            }
            else {
                mainController.updateStatus("DataNode is up to date...");
            }
        }
        else {
            mainController.updateStatus("Invalid Local DataSource selected for node...");
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.