use of de.catma.project.OpenProjectListener in project catma by forTEXT.
the class ProjectView method reloadProject.
/**
* @param projectReference
*/
public void reloadProject(ProjectReference projectReference) {
if (this.project == null) {
setProjectReference(projectReference);
} else {
setEnabled(false);
setProgressBarVisible(true);
final UI ui = UI.getCurrent();
this.project.open(new OpenProjectListener() {
@Override
public void progress(String msg, Object... params) {
ui.access(() -> {
if (params != null) {
progressBar.setCaption(String.format(msg, params));
} else {
progressBar.setCaption(msg);
}
ui.push();
});
}
@Override
public void ready(Project project) {
setProgressBarVisible(false);
ProjectView.this.project = project;
ProjectView.this.project.addPropertyChangeListener(RepositoryChangeEvent.exceptionOccurred, projectExceptionListener);
ProjectView.this.project.getTagManager().addPropertyChangeListener(TagManagerEvent.tagsetDefinitionChanged, tagsetChangeListener);
ProjectView.this.project.addPropertyChangeListener(RepositoryChangeEvent.tagReferencesChanged, tagReferencesChangedListener);
setEnabled(true);
reloadAll();
checkForUnsynchronizedCommits();
}
@Override
public void conflictResolutionNeeded(ConflictedProject conflictedProject) {
setProgressBarVisible(false);
setEnabled(true);
eventBus.post(new RouteToConflictedProjectEvent(conflictedProject));
}
@Override
public void failure(Throwable t) {
setProgressBarVisible(false);
setEnabled(true);
errorHandler.showAndLogError("error opening project", t);
}
});
}
}
use of de.catma.project.OpenProjectListener in project catma by forTEXT.
the class ProjectView method synchronizeProject.
private void synchronizeProject() throws Exception {
setProgressBarVisible(true);
final UI ui = UI.getCurrent();
project.synchronizeWithRemote(new OpenProjectListener() {
@Override
public void progress(String msg, Object... params) {
ui.access(() -> {
if (params != null) {
progressBar.setCaption(String.format(msg, params));
} else {
progressBar.setCaption(msg);
}
ui.push();
});
}
@Override
public void ready(Project project) {
setProgressBarVisible(false);
reloadAll();
setEnabled(true);
Notification.show("Info", "Your Project has been synchronized!", Type.HUMANIZED_MESSAGE);
checkForUnsynchronizedCommits();
}
@Override
public void conflictResolutionNeeded(ConflictedProject conflictedProject) {
setProgressBarVisible(false);
setEnabled(true);
eventBus.post(new RouteToConflictedProjectEvent(conflictedProject));
}
@Override
public void failure(Throwable t) {
setProgressBarVisible(false);
setEnabled(true);
errorHandler.showAndLogError("error opening project", t);
}
});
}
use of de.catma.project.OpenProjectListener in project catma by forTEXT.
the class GraphWorktreeProject method synchronizeWithRemote.
@Override
public void synchronizeWithRemote(OpenProjectListener openProjectListener) throws Exception {
if (hasUncommittedChanges()) {
throw new IllegalStateException("There are uncommitted changes that need to be committed first!");
}
for (TagsetDefinition tagset : getTagsets()) {
gitProjectHandler.synchronizeTagsetWithRemote(tagset.getUuid());
}
for (SourceDocument document : getSourceDocuments()) {
gitProjectHandler.synchronizeSourceDocumentWithRemote(document.getUuid());
for (AnnotationCollectionReference collectionReference : document.getUserMarkupCollectionRefs()) {
gitProjectHandler.synchronizeCollectionWithRemote(collectionReference.getId());
}
}
gitProjectHandler.synchronizeWithRemote();
if (gitProjectHandler.hasConflicts()) {
gitProjectHandler.initAndUpdateSubmodules();
openProjectListener.conflictResolutionNeeded(new GitConflictedProject(projectReference, gitProjectHandler, documentId -> getSourceDocumentURI(documentId)));
} else {
boolean forceGraphReload = gitProjectHandler.loadRolesPerResource();
gitProjectHandler.initAndUpdateSubmodules();
gitProjectHandler.removeStaleSubmoduleDirectories();
gitProjectHandler.ensureDevBranches();
rootRevisionHash = gitProjectHandler.getRootRevisionHash();
ProgressListener progressListener = new ProgressListener() {
@Override
public void setProgress(String value, Object... args) {
openProjectListener.progress(value, args);
}
};
graphProjectHandler.ensureProjectRevisionIsLoaded(new ExecutionListener<TagManager>() {
@Override
public void error(Throwable t) {
openProjectListener.failure(t);
}
@Override
public void done(TagManager result) {
tagManager.load(result.getTagLibrary());
openProjectListener.ready(GraphWorktreeProject.this);
}
}, progressListener, rootRevisionHash, tagManager, () -> gitProjectHandler.getTagsets(), () -> gitProjectHandler.getDocuments(), (tagLibrary) -> gitProjectHandler.getCollections(tagLibrary, progressListener), forceGraphReload, backgroundService);
}
}
use of de.catma.project.OpenProjectListener in project catma by forTEXT.
the class ProjectView method initProject.
/**
* @param projectReference
*/
private void initProject(ProjectReference projectReference) {
setEnabled(false);
setProgressBarVisible(true);
final UI ui = UI.getCurrent();
projectManager.openProject(tagManager, projectReference, new OpenProjectListener() {
@Override
public void progress(String msg, Object... params) {
ui.access(() -> {
if (params != null) {
progressBar.setCaption(String.format(msg, params));
} else {
progressBar.setCaption(msg);
}
ui.push();
});
}
@Override
public void ready(Project project) {
setProgressBarVisible(false);
ProjectView.this.project = project;
ProjectView.this.project.addPropertyChangeListener(RepositoryChangeEvent.exceptionOccurred, projectExceptionListener);
ProjectView.this.project.getTagManager().addPropertyChangeListener(TagManagerEvent.tagsetDefinitionChanged, tagsetChangeListener);
ProjectView.this.project.addPropertyChangeListener(RepositoryChangeEvent.tagReferencesChanged, tagReferencesChangedListener);
setEnabled(true);
reloadAll();
checkForUnsynchronizedCommits();
}
@Override
public void conflictResolutionNeeded(ConflictedProject conflictedProject) {
setProgressBarVisible(false);
setEnabled(true);
eventBus.post(new RouteToConflictedProjectEvent(conflictedProject));
}
@Override
public void failure(Throwable t) {
setProgressBarVisible(false);
setEnabled(true);
errorHandler.showAndLogError("error opening project", t);
}
});
}
use of de.catma.project.OpenProjectListener in project catma by forTEXT.
the class GraphWorktreeProject method open.
@Override
public void open(OpenProjectListener openProjectListener) {
try {
logger.info(String.format("Opening Project %1$s with ID %2$s", projectReference.getName(), projectReference.getProjectId()));
this.rootRevisionHash = gitProjectHandler.getRootRevisionHash();
logger.info(String.format("Revision Hash for Project %1$s is %2$s", projectReference.getProjectId(), this.rootRevisionHash));
this.gitProjectHandler.loadRolesPerResource();
logger.info(String.format("Checking for conflicts in Project %1$s", projectReference.getProjectId()));
if (gitProjectHandler.hasConflicts()) {
gitProjectHandler.initAndUpdateSubmodules();
openProjectListener.conflictResolutionNeeded(new GitConflictedProject(projectReference, gitProjectHandler, documentId -> getSourceDocumentURI(documentId)));
} else {
gitProjectHandler.initAndUpdateSubmodules();
gitProjectHandler.removeStaleSubmoduleDirectories();
gitProjectHandler.ensureDevBranches();
gitProjectHandler.verifyCollections();
ProgressListener progressListener = new ProgressListener() {
@Override
public void setProgress(String value, Object... args) {
logger.info(String.format(value, args));
openProjectListener.progress(value, args);
}
};
graphProjectHandler.ensureProjectRevisionIsLoaded(new ExecutionListener<TagManager>() {
@Override
public void error(Throwable t) {
openProjectListener.failure(t);
}
@Override
public void done(TagManager result) {
logger.info(String.format("Loading Tag library for Project %1$s", projectReference.getProjectId()));
tagManager.load(result.getTagLibrary());
initTagManagerListeners();
logger.info(String.format("Project %1$s is loaded.", projectReference.getProjectId()));
openProjectListener.ready(GraphWorktreeProject.this);
}
}, progressListener, rootRevisionHash, tagManager, () -> gitProjectHandler.getTagsets(), () -> gitProjectHandler.getDocuments(), (tagLibrary) -> gitProjectHandler.getCollections(tagLibrary, progressListener), // forceGraphReload
false, backgroundService);
}
} catch (Exception e) {
openProjectListener.failure(e);
}
}
Aggregations