Search in sources :

Example 1 with ConflictedProject

use of de.catma.project.conflict.ConflictedProject 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);
            }
        });
    }
}
Also used : IndexedProject(de.catma.indexer.IndexedProject) Project(de.catma.project.Project) ConflictedProject(de.catma.project.conflict.ConflictedProject) UI(com.vaadin.ui.UI) OpenProjectListener(de.catma.project.OpenProjectListener) ConflictedProject(de.catma.project.conflict.ConflictedProject) RouteToConflictedProjectEvent(de.catma.ui.events.routing.RouteToConflictedProjectEvent)

Example 2 with ConflictedProject

use of de.catma.project.conflict.ConflictedProject 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);
        }
    });
}
Also used : IndexedProject(de.catma.indexer.IndexedProject) Project(de.catma.project.Project) ConflictedProject(de.catma.project.conflict.ConflictedProject) UI(com.vaadin.ui.UI) OpenProjectListener(de.catma.project.OpenProjectListener) ConflictedProject(de.catma.project.conflict.ConflictedProject) RouteToConflictedProjectEvent(de.catma.ui.events.routing.RouteToConflictedProjectEvent)

Example 3 with ConflictedProject

use of de.catma.project.conflict.ConflictedProject 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);
        }
    });
}
Also used : IndexedProject(de.catma.indexer.IndexedProject) Project(de.catma.project.Project) ConflictedProject(de.catma.project.conflict.ConflictedProject) UI(com.vaadin.ui.UI) OpenProjectListener(de.catma.project.OpenProjectListener) ConflictedProject(de.catma.project.conflict.ConflictedProject) RouteToConflictedProjectEvent(de.catma.ui.events.routing.RouteToConflictedProjectEvent)

Example 4 with ConflictedProject

use of de.catma.project.conflict.ConflictedProject in project catma by forTEXT.

the class GitProjectManager method forkTagset.

@Override
public ForkStatus forkTagset(TagsetDefinition tagset, String sourceProjectId, ProjectReference targetProject) throws Exception {
    String targetProjectId = targetProject.getProjectId();
    String tagsetId = tagset.getUuid();
    cloneRootLocallyIfNotExists(targetProject, new OpenProjectListener() {

        @Override
        public void ready(Project project) {
        /**
         * not used *
         */
        }

        @Override
        public void conflictResolutionNeeded(ConflictedProject project) {
        /**
         * not used *
         */
        }

        @Override
        public void failure(Throwable t) {
        /**
         * not used *
         */
        }

        @Override
        public void progress(String msg, Object... params) {
            logger.info(String.format(msg, params));
        }
    });
    GitProjectHandler targetProjectHandler = new GitProjectHandler(this.user, targetProjectId, this.localGitRepositoryManager, this.remoteGitServerManager);
    targetProjectHandler.loadRolesPerResource();
    if (targetProjectHandler.hasConflicts()) {
        return ForkStatus.targetHasConflicts();
    } else if (targetProjectHandler.hasUncommittedChanges()) {
        return ForkStatus.targetNotClean();
    }
    ForkStatus forkStatus = remoteGitServerManager.forkResource(tagsetId, sourceProjectId, targetProjectId);
    if (forkStatus.isSuccess()) {
        targetProjectHandler.cloneAndAddTagset(tagset.getUuid(), tagset.getName(), String.format("Forked Tagset %1$s with ID %2$s from %3$s with ID %4$s", tagset.getName(), tagset.getUuid(), targetProject.getName(), targetProjectId));
    } else {
        return forkStatus;
    }
    return ForkStatus.success();
}
Also used : ForkStatus(de.catma.project.ForkStatus) Project(de.catma.project.Project) ConflictedProject(de.catma.project.conflict.ConflictedProject) OpenProjectListener(de.catma.project.OpenProjectListener) JsonObject(com.google.gson.JsonObject) ConflictedProject(de.catma.project.conflict.ConflictedProject)

Aggregations

OpenProjectListener (de.catma.project.OpenProjectListener)4 Project (de.catma.project.Project)4 ConflictedProject (de.catma.project.conflict.ConflictedProject)4 UI (com.vaadin.ui.UI)3 IndexedProject (de.catma.indexer.IndexedProject)3 RouteToConflictedProjectEvent (de.catma.ui.events.routing.RouteToConflictedProjectEvent)3 JsonObject (com.google.gson.JsonObject)1 ForkStatus (de.catma.project.ForkStatus)1