use of gen.core.project.RepositoryMapping 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"));
}
use of gen.core.project.RepositoryMapping 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();
}
Aggregations