Search in sources :

Example 1 with FeatureListOperation

use of org.eclipse.egit.gitflow.op.FeatureListOperation in project egit by eclipse.

the class FeatureTrackHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final GitFlowRepository gfRepo = GitFlowHandlerUtil.getRepository(event);
    if (gfRepo == null) {
        return error(UIText.Handlers_noGitflowRepositoryFound);
    }
    final List<Ref> refs = new ArrayList<Ref>();
    Shell activeShell = HandlerUtil.getActiveShell(event);
    int timeout = Activator.getDefault().getPreferenceStore().getInt(UIPreferences.REMOTE_CONNECTION_TIMEOUT);
    FeatureListOperation featureListOperation = new FeatureListOperation(gfRepo, timeout);
    JobUtil.scheduleUserWorkspaceJob(featureListOperation, UIText.FeatureTrackHandler_fetchingRemoteFeatures, GITFLOW_FAMILY);
    IJobManager jobMan = Job.getJobManager();
    try {
        jobMan.join(GITFLOW_FAMILY, null);
    } catch (OperationCanceledException | InterruptedException e) {
        return error(e.getMessage(), e);
    }
    List<Ref> remoteFeatures = featureListOperation.getResult();
    if (remoteFeatures.isEmpty()) {
        MessageDialog.openInformation(activeShell, UIText.FeatureTrackHandler_noRemoteFeatures, UIText.FeatureTrackHandler_noRemoteFeaturesFoundOnTheConfiguredRemote);
    }
    refs.addAll(remoteFeatures);
    FeatureBranchSelectionDialog dialog = new FeatureBranchSelectionDialog(HandlerUtil.getActiveShell(event), refs, UIText.FeatureCheckoutHandler_selectFeature, UIText.FeatureTrackHandler_remoteFeatures, R_REMOTES + DEFAULT_REMOTE_NAME + SEP + gfRepo.getConfig().getFeaturePrefix(), gfRepo);
    if (dialog.open() != Window.OK) {
        return Status.CANCEL_STATUS;
    }
    Ref ref = dialog.getSelectedNode();
    FeatureTrackOperation featureTrackOperation = new FeatureTrackOperation(gfRepo, ref, timeout);
    JobUtil.scheduleUserWorkspaceJob(featureTrackOperation, UIText.FeatureTrackHandler_trackingFeature, GITFLOW_FAMILY);
    return null;
}
Also used : FeatureBranchSelectionDialog(org.eclipse.egit.gitflow.ui.internal.dialogs.FeatureBranchSelectionDialog) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) ArrayList(java.util.ArrayList) IJobManager(org.eclipse.core.runtime.jobs.IJobManager) FeatureTrackOperation(org.eclipse.egit.gitflow.op.FeatureTrackOperation) Ref(org.eclipse.jgit.lib.Ref) Shell(org.eclipse.swt.widgets.Shell) FeatureListOperation(org.eclipse.egit.gitflow.op.FeatureListOperation) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository)

Aggregations

ArrayList (java.util.ArrayList)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 IJobManager (org.eclipse.core.runtime.jobs.IJobManager)1 GitFlowRepository (org.eclipse.egit.gitflow.GitFlowRepository)1 FeatureListOperation (org.eclipse.egit.gitflow.op.FeatureListOperation)1 FeatureTrackOperation (org.eclipse.egit.gitflow.op.FeatureTrackOperation)1 FeatureBranchSelectionDialog (org.eclipse.egit.gitflow.ui.internal.dialogs.FeatureBranchSelectionDialog)1 Ref (org.eclipse.jgit.lib.Ref)1 Shell (org.eclipse.swt.widgets.Shell)1