Search in sources :

Example 6 with RepositoryDefinition

use of gen.core.project.RepositoryDefinition in project omegat by omegat-org.

the class RemoteRepositoryProvider method initializeRepositories.

/**
 * Initialize repositories instances.
 */
protected void initializeRepositories() throws Exception {
    for (RepositoryDefinition r : repositoriesDefinitions) {
        IRemoteRepository2 repo = RemoteRepositoryFactory.create(r.getType());
        repo.init(r, getRepositoryDir(r), teamSettings);
        repositories.add(repo);
    }
}
Also used : RepositoryDefinition(gen.core.project.RepositoryDefinition)

Example 7 with RepositoryDefinition

use of gen.core.project.RepositoryDefinition in project omegat by omegat-org.

the class ConvertProject26to37team method convert.

private static void convert(File projectRootFolder) throws Exception {
    ProjectProperties props = ProjectFileStorage.loadProjectProperties(projectRootFolder);
    String version;
    String url;
    RepositoryDefinition def = new RepositoryDefinition();
    if (isSVNDirectory(projectRootFolder)) {
        url = getSVNUrl(projectRootFolder);
        def.setType("svn");
        version = getSVNTmxVersion(projectRootFolder);
    } else {
        url = getGITUrl(projectRootFolder);
        def.setType("git");
        version = getGITTmxVersion(projectRootFolder);
    }
    if (url == null) {
        throw new Exception("Repository URL not defined");
    }
    def.setUrl(url);
    saveVersion(projectRootFolder, "omegat/project_save.tmx", version);
    // map full project
    RepositoryMapping map = new RepositoryMapping();
    map.setLocal("");
    map.setRepository("");
    def.getMapping().add(map);
    props.setRepositories(new ArrayList<RepositoryDefinition>());
    props.getRepositories().add(def);
    ProjectFileStorage.writeProjectFile(props);
    // all data saved - remove old repository
    FileUtils.deleteDirectory(new File(projectRootFolder, ".svn"));
    FileUtils.deleteDirectory(new File(projectRootFolder, ".git"));
}
Also used : RepositoryDefinition(gen.core.project.RepositoryDefinition) RepositoryMapping(gen.core.project.RepositoryMapping) ProjectProperties(org.omegat.core.data.ProjectProperties) File(java.io.File) IOException(java.io.IOException)

Example 8 with RepositoryDefinition

use of gen.core.project.RepositoryDefinition in project omegat by omegat-org.

the class ProjectUICommands method projectTeamCreate.

public static void projectTeamCreate() {
    UIThreadsUtil.mustBeSwingThread();
    if (Core.getProject().isProjectLoaded()) {
        return;
    }
    new SwingWorker<Void, Void>() {

        File projectRoot;

        protected Void doInBackground() throws Exception {
            Core.getMainWindow().showStatusMessageRB(null);
            final NewTeamProject dialog = new NewTeamProject(Core.getMainWindow().getApplicationFrame());
            dialog.setVisible(true);
            if (!dialog.ok) {
                Core.getMainWindow().showStatusMessageRB("TEAM_CANCELLED");
                return null;
            }
            IMainWindow mainWindow = Core.getMainWindow();
            Cursor hourglassCursor = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
            Cursor oldCursor = mainWindow.getCursor();
            mainWindow.setCursor(hourglassCursor);
            Core.getMainWindow().showStatusMessageRB("CT_DOWNLOADING_PROJECT");
            // retrieve omegat.project
            projectRoot = new File(dialog.getSaveLocation());
            List<RepositoryDefinition> repos = new ArrayList<RepositoryDefinition>();
            RepositoryDefinition repo = new RepositoryDefinition();
            repos.add(repo);
            repo.setType(dialog.getRepoType());
            repo.setUrl(dialog.getRepoUrl());
            RepositoryMapping mapping = new RepositoryMapping();
            mapping.setLocal("");
            mapping.setRepository("");
            repo.getMapping().add(mapping);
            RemoteRepositoryProvider remoteRepositoryProvider = new RemoteRepositoryProvider(projectRoot, repos);
            remoteRepositoryProvider.switchAllToLatest();
            for (String file : new String[] { OConsts.FILE_PROJECT, OConsts.DEFAULT_INTERNAL + '/' + FilterMaster.FILE_FILTERS, OConsts.DEFAULT_INTERNAL + '/' + SRX.CONF_SENTSEG }) {
                remoteRepositoryProvider.copyFilesFromRepoToProject(file);
            }
            ProjectProperties props = ProjectFileStorage.loadProjectProperties(projectRoot);
            if (props.getRepositories() == null) {
                // We assume it's a 3.6 style project with no repository mapping,
                // so we add root repository mapping
                props.setRepositories(repos);
            }
            // We write in all cases, because we might have added default excludes, for instance
            ProjectFileStorage.writeProjectFile(props);
            // String projectFileURL = dialog.txtRepositoryOrProjectFileURL.getText();
            // File localDirectory = new File(dialog.txtDirectory.getText());
            // try {
            // localDirectory.mkdirs();
            // byte[] projectFile = WikiGet.getURLasByteArray(projectFileURL);
            // FileUtils.writeByteArrayToFile(new File(localDirectory, OConsts.FILE_PROJECT), projectFile);
            // } catch (Exception ex) {
            // ex.printStackTrace();
            // Core.getMainWindow().displayErrorRB(ex, "TEAM_CHECKOUT_ERROR");
            // mainWindow.setCursor(oldCursor);
            // return null;
            // }
            // projectOpen(localDirectory);
            mainWindow.setCursor(oldCursor);
            return null;
        }

        @Override
        protected void done() {
            Core.getMainWindow().showProgressMessage(" ");
            try {
                get();
                if (projectRoot != null) {
                    // don't ask open if user cancelled previous dialog
                    SwingUtilities.invokeLater(() -> {
                        Core.getEditor().requestFocus();
                        projectOpen(projectRoot);
                    });
                }
            } catch (Exception ex) {
                Log.logErrorRB(ex, "PP_ERROR_UNABLE_TO_DOWNLOAD_TEAM_PROJECT");
                Core.getMainWindow().displayErrorRB(ex, "PP_ERROR_UNABLE_TO_DOWNLOAD_TEAM_PROJECT");
            }
        }
    }.execute();
}
Also used : RemoteRepositoryProvider(org.omegat.core.team2.RemoteRepositoryProvider) NewTeamProject(org.omegat.gui.dialogs.NewTeamProject) ProjectProperties(org.omegat.core.data.ProjectProperties) Cursor(java.awt.Cursor) KnownException(org.omegat.core.KnownException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) RepositoryDefinition(gen.core.project.RepositoryDefinition) RepositoryMapping(gen.core.project.RepositoryMapping) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File)

Aggregations

RepositoryDefinition (gen.core.project.RepositoryDefinition)8 RepositoryMapping (gen.core.project.RepositoryMapping)6 File (java.io.File)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 ProjectProperties (org.omegat.core.data.ProjectProperties)2 Cursor (java.awt.Cursor)1 List (java.util.List)1 ExecutionException (java.util.concurrent.ExecutionException)1 Before (org.junit.Before)1 KnownException (org.omegat.core.KnownException)1 RemoteRepositoryProvider (org.omegat.core.team2.RemoteRepositoryProvider)1 NewTeamProject (org.omegat.gui.dialogs.NewTeamProject)1