Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 9dd4b8cf4cc6192edafc7e20b344cb2962d6ba5d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
 * Copyright (c) 2015 Eike Stepper (Berlin, Germany) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Eike Stepper - initial API and implementation
 */
package org.eclipse.emf.cdo.explorer.ui.checkouts.actions;

import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout;
import org.eclipse.emf.cdo.explorer.repositories.CDORepository;
import org.eclipse.emf.cdo.ui.Support;
import org.eclipse.emf.cdo.ui.compare.CDOCompareEditorUtil;

/**
 * @author Eike Stepper
 */
public class MergeFromActionProvider extends AbstractBranchPointActionProvider
{
  private static final String ID = MergeFromActionProvider.class.getName();

  public MergeFromActionProvider()
  {
    super(ID, "Merge From");
  }

  @Override
  protected boolean createSubMenu(CDOCheckout checkout)
  {
    return super.createSubMenu(checkout) && !checkout.isReadOnly();
  }

  @Override
  protected String getHistorizedBranchPointToolTip(boolean allowTimeStamp)
  {
    return allowTimeStamp ? "Merge from this branch point" : "Merge from this branch";
  }

  @Override
  protected String getOtherBranchPointToolTip(boolean allowTimeStamp)
  {
    return allowTimeStamp ? "Select a branch point and merge from it" : "Select a branch and merge from it";
  }

  @Override
  protected String getCommitBranchPointToolTip()
  {
    return "Select a commit and merge from it";
  }

  @Override
  protected String getOtherCheckoutToolTip()
  {
    return "Merge from the branch point of this checkout";
  }

  @Override
  protected void execute(CDOCheckout checkout, CDOBranchPoint branchPoint) throws Exception
  {
    mergeFrom(checkout, branchPoint);
  }

  public static void mergeFrom(CDOCheckout checkout, CDOBranchPoint branchPoint)
  {
    if (Support.COMPARE.isAvailable())
    {
      CDORepository repository = checkout.getRepository();
      CDOBranchPoint left = branchPoint;
      CDOBranchPoint right = checkout.getBranchPoint();
      CDOCompareEditorUtil.openEditor(repository, repository, left, right, null, true);
    }
  }
}

Back to the top