Search in sources :

Example 1 with ISynchronizeParticipant

use of org.eclipse.team.ui.synchronize.ISynchronizeParticipant in project egit by eclipse.

the class GitModelSynchronize method fireSynchronizeAction.

private static void fireSynchronizeAction(final IWorkbenchWindow window, final GitSynchronizeDataSet gsdSet, final ResourceMapping[] mappings) {
    final GitResourceVariantTreeSubscriber subscriber = new GitResourceVariantTreeSubscriber(gsdSet);
    Job syncJob = new WorkspaceJob(UIText.GitModelSynchronize_fetchGitDataJobName) {

        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor) {
            subscriber.init(monitor);
            return Status.OK_STATUS;
        }

        @Override
        public boolean belongsTo(Object family) {
            if (JobFamilies.SYNCHRONIZE_READ_DATA.equals(family))
                return true;
            return super.belongsTo(family);
        }
    };
    syncJob.addJobChangeListener(new JobChangeAdapter() {

        @Override
        public void done(IJobChangeEvent event) {
            RemoteResourceMappingContext remoteContext = new GitSubscriberResourceMappingContext(subscriber, gsdSet);
            SubscriberScopeManager manager = new SubscriberScopeManager(subscriber.getName(), mappings, subscriber, remoteContext, true);
            GitSubscriberMergeContext context = new GitSubscriberMergeContext(subscriber, manager, gsdSet);
            final GitModelSynchronizeParticipant participant = new GitModelSynchronizeParticipant(context);
            TeamUI.getSynchronizeManager().addSynchronizeParticipants(new ISynchronizeParticipant[] { participant });
            IWorkbenchPart activePart = null;
            if (window != null)
                activePart = window.getActivePage().getActivePart();
            participant.run(activePart);
        }
    });
    syncJob.setUser(true);
    syncJob.schedule();
}
Also used : GitSubscriberResourceMappingContext(org.eclipse.egit.core.synchronize.GitSubscriberResourceMappingContext) SubscriberScopeManager(org.eclipse.team.core.subscribers.SubscriberScopeManager) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) GitResourceVariantTreeSubscriber(org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber) RemoteResourceMappingContext(org.eclipse.core.resources.mapping.RemoteResourceMappingContext) Job(org.eclipse.core.runtime.jobs.Job) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) ISynchronizeParticipant(org.eclipse.team.ui.synchronize.ISynchronizeParticipant) GitSubscriberMergeContext(org.eclipse.egit.core.synchronize.GitSubscriberMergeContext)

Aggregations

WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)1 RemoteResourceMappingContext (org.eclipse.core.resources.mapping.RemoteResourceMappingContext)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)1 Job (org.eclipse.core.runtime.jobs.Job)1 JobChangeAdapter (org.eclipse.core.runtime.jobs.JobChangeAdapter)1 GitResourceVariantTreeSubscriber (org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber)1 GitSubscriberMergeContext (org.eclipse.egit.core.synchronize.GitSubscriberMergeContext)1 GitSubscriberResourceMappingContext (org.eclipse.egit.core.synchronize.GitSubscriberResourceMappingContext)1 SubscriberScopeManager (org.eclipse.team.core.subscribers.SubscriberScopeManager)1 ISynchronizeParticipant (org.eclipse.team.ui.synchronize.ISynchronizeParticipant)1 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)1