use of org.eclipse.egit.gitflow.ui.internal.dialogs.FeatureBranchSelectionDialog in project egit by eclipse.
the class FeatureCheckoutHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final GitFlowRepository gfRepo = GitFlowHandlerUtil.getRepository(event);
if (gfRepo == null) {
return error(UIText.Handlers_noGitflowRepositoryFound);
}
Repository repository = gfRepo.getRepository();
final List<Ref> refs = gfRepo.getFeatureBranches();
FeatureBranchSelectionDialog dialog = new FeatureBranchSelectionDialog(HandlerUtil.getActiveShell(event), refs, UIText.FeatureCheckoutHandler_selectFeature, UIText.FeatureCheckoutHandler_localFeatures, Constants.R_HEADS + gfRepo.getConfig().getFeaturePrefix(), gfRepo);
if (dialog.open() != Window.OK) {
return null;
}
final Ref ref = dialog.getSelectedNode();
try {
String featureName = gfRepo.getFeatureBranchName(ref);
// TODO: consider using BranchOperationUI because checkout can take
// a long time on large repositories
FeatureCheckoutOperation checkoutOperation = new FeatureCheckoutOperation(gfRepo, featureName);
JobUtil.scheduleUserWorkspaceJob(checkoutOperation, UIText.FeatureCheckoutHandler_checkingOutFeature, JobFamilies.GITFLOW_FAMILY);
IJobManager jobMan = Job.getJobManager();
try {
jobMan.join(GITFLOW_FAMILY, null);
} catch (OperationCanceledException | InterruptedException e) {
return error(e.getMessage(), e);
}
CheckoutResult result = checkoutOperation.getResult();
if (!CheckoutResult.Status.OK.equals(result.getStatus())) {
Shell shell = HandlerUtil.getActiveShell(event);
if (!handleUncommittedFiles(gfRepo.getRepository(), shell, repository.getWorkTree().getName())) {
return Status.CANCEL_STATUS;
} else {
JobUtil.scheduleUserWorkspaceJob(checkoutOperation, UIText.FeatureCheckoutHandler_checkingOutFeature, JobFamilies.GITFLOW_FAMILY);
}
}
} catch (GitAPIException e) {
throw new RuntimeException(e);
}
return null;
}
use of org.eclipse.egit.gitflow.ui.internal.dialogs.FeatureBranchSelectionDialog 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;
}
Aggregations