Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2016-04-02 19:17:02 -0400
committerMatthias Sohn2016-04-03 19:45:16 -0400
commit236f56cce34383388c3e3aa1fbc8c6c161ede465 (patch)
tree33c53384dd5aa6a7d1bec4060deb88a1b6fd2843
parentcefa50d70d345e6b0983348ff99edffc7da78ee7 (diff)
downloadegit-236f56cce34383388c3e3aa1fbc8c6c161ede465.tar.gz
egit-236f56cce34383388c3e3aa1fbc8c6c161ede465.tar.xz
egit-236f56cce34383388c3e3aa1fbc8c6c161ede465.zip
When running "Commit" action open staging view instead of commit dialog
Add a preference to allow switching back to the old behavior of the commit action to open the commit dialog. By default it now opens the staging view. After opening the staging view auto-select and set focus on unstaged files if there are any, otherwise set focus on the commit message. The commit dialog is still used by CleanupUncomittedChangesDialog. Bug: 490121 Change-Id: I604f31268f83ab11c3f3a869edf3c7121f0e6478 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CommitActionTest.java9
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CommitNonWSChangesTest.java10
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewRepoDeletionTest.java7
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java5
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/synchronize/AbstractSynchronizeViewTest.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/PluginPreferenceInitializer.java1
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java3
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitActionHandler.java64
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/CommittingPreferencePage.java5
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java8
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties1
12 files changed, 99 insertions, 20 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CommitActionTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CommitActionTest.java
index 984140399..7ff323e2b 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CommitActionTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CommitActionTest.java
@@ -35,6 +35,7 @@ import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -48,6 +49,8 @@ public class CommitActionTest extends LocalRepositoryTestCase {
@Before
public void setup() throws Exception {
+ Activator.getDefault().getPreferenceStore()
+ .setValue(UIPreferences.ALWAYS_USE_STAGING_VIEW, false);
repositoryFile = createProjectAndCommitToRepository();
Repository repo = lookupRepository(repositoryFile);
TestUtil.configureTestCommitterAsUser(repo);
@@ -59,6 +62,12 @@ public class CommitActionTest extends LocalRepositoryTestCase {
assertTrue(dotProject.delete());
}
+ @After
+ public void tearDown() {
+ Activator.getDefault().getPreferenceStore()
+ .setValue(UIPreferences.ALWAYS_USE_STAGING_VIEW, true);
+ }
+
@Test
public void testOpenCommitWithoutChanged() throws Exception {
NoFilesToCommitPopup popup = CommitDialogTester
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CommitNonWSChangesTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CommitNonWSChangesTest.java
index 8f79fda5e..91e13cae0 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CommitNonWSChangesTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CommitNonWSChangesTest.java
@@ -17,6 +17,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.JobFamilies;
+import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.common.LocalRepositoryTestCase;
import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.egit.ui.internal.repository.RepositoriesView;
@@ -29,6 +30,7 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarToggleButton;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -44,6 +46,8 @@ public class CommitNonWSChangesTest extends LocalRepositoryTestCase {
@Before
public void setup() throws Exception {
+ Activator.getDefault().getPreferenceStore()
+ .setValue(UIPreferences.ALWAYS_USE_STAGING_VIEW, false);
repositoryFile = createProjectAndCommitToRepository();
Activator.getDefault().getRepositoryUtil()
.addConfiguredRepository(repositoryFile);
@@ -51,6 +55,12 @@ public class CommitNonWSChangesTest extends LocalRepositoryTestCase {
.getRepositoryCache().lookupRepository(repositoryFile);
}
+ @After
+ public void tearDown() {
+ Activator.getDefault().getPreferenceStore()
+ .setValue(UIPreferences.ALWAYS_USE_STAGING_VIEW, true);
+ }
+
@Test
public void testCommitDeletedProject() throws Exception {
IProject project = ResourcesPlugin.getWorkspace().getRoot()
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewRepoDeletionTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewRepoDeletionTest.java
index 89a9fbf4c..b9cda2da9 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewRepoDeletionTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewRepoDeletionTest.java
@@ -32,6 +32,7 @@ import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.egit.core.internal.indexdiff.IndexDiffCache;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.JobFamilies;
+import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.internal.RepositoryCacheRule;
import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.egit.ui.test.ContextMenuHelper;
@@ -144,6 +145,9 @@ public class GitRepositoriesViewRepoDeletionTest extends
@Test
public void testRemoveRepositoryRemoveFromCachesBug483664()
throws Exception {
+ Activator.getDefault().getPreferenceStore()
+ .setValue(UIPreferences.ALWAYS_USE_STAGING_VIEW, false);
+
deleteAllProjects();
assertProjectExistence(PROJ1, false);
clearView();
@@ -264,6 +268,9 @@ public class GitRepositoriesViewRepoDeletionTest extends
configuredRepos.isEmpty());
assertEquals("Expected no cached repositories", "[]", results[0]);
assertEquals("Expected no IndexDiffCache entries", "[]", results[1]);
+
+ Activator.getDefault().getPreferenceStore()
+ .setValue(UIPreferences.ALWAYS_USE_STAGING_VIEW, true);
}
@Test
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java
index d47ecb4bc..719664899 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java
@@ -32,6 +32,7 @@ import org.eclipse.egit.core.internal.Utils;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.JobFamilies;
+import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.egit.ui.test.ContextMenuHelper;
import org.eclipse.egit.ui.test.TestUtil;
@@ -190,6 +191,8 @@ public class GitRepositoriesViewTest extends GitRepositoriesViewTestBase {
*/
@Test
public void testContextMenuRepository() throws Exception {
+ Activator.getDefault().getPreferenceStore()
+ .setValue(UIPreferences.ALWAYS_USE_STAGING_VIEW, false);
// We just check if the dialogs open, the actual commit and import projects
// is tested elsewhere
SWTBotTree tree = getOrOpenView().bot().tree();
@@ -202,6 +205,8 @@ public class GitRepositoriesViewTest extends GitRepositoriesViewTestBase {
myUtil.getPluginLocalizedValue("RepoViewImportProjects.label"),
NLS.bind(UIText.GitCreateProjectViaWizardWizard_WizardTitle,
repositoryFile));
+ Activator.getDefault().getPreferenceStore()
+ .setValue(UIPreferences.ALWAYS_USE_STAGING_VIEW, true);
}
/**
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/synchronize/AbstractSynchronizeViewTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/synchronize/AbstractSynchronizeViewTest.java
index b50a8a479..83a1f60b0 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/synchronize/AbstractSynchronizeViewTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/synchronize/AbstractSynchronizeViewTest.java
@@ -83,11 +83,15 @@ public abstract class AbstractSynchronizeViewTest extends
@Before
public void setupViews() {
+ Activator.getDefault().getPreferenceStore()
+ .setValue(UIPreferences.ALWAYS_USE_STAGING_VIEW, false);
TestUtil.showExplorerView();
}
@After
public void closeSynchronizeView() {
+ Activator.getDefault().getPreferenceStore()
+ .setValue(UIPreferences.ALWAYS_USE_STAGING_VIEW, true);
TestUtil.hideView(ISynchronizeView.VIEW_ID);
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/PluginPreferenceInitializer.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/PluginPreferenceInitializer.java
index 6dc1e80ab..ae8ab39eb 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/PluginPreferenceInitializer.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/PluginPreferenceInitializer.java
@@ -92,6 +92,7 @@ public class PluginPreferenceInitializer extends AbstractPreferenceInitializer {
store.setDefault(UIPreferences.FINDTOOLBAR_IGNORE_CASE, true);
store.setDefault(UIPreferences.FINDTOOLBAR_FIND_IN,
FindToolbar.PREFS_FINDIN_ALL);
+ store.setDefault(UIPreferences.ALWAYS_USE_STAGING_VIEW, true);
store.setDefault(UIPreferences.COMMIT_DIALOG_HARD_WRAP_MESSAGE, true);
store.setDefault(UIPreferences.COMMIT_DIALOG_WARN_ABOUT_MESSAGE_SECOND_LINE, true);
store.setDefault(UIPreferences.COMMIT_DIALOG_SIGNED_OFF_BY, false);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java
index 9ea9fa7fc..6486701c4 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java
@@ -67,6 +67,8 @@ public class UIPreferences {
/** */
public final static String COMMIT_DIALOG_HARD_WRAP_MESSAGE = "commit_dialog_hard_wrap_message"; //$NON-NLS-1$
/** */
+ public final static String ALWAYS_USE_STAGING_VIEW = "always_use_staging_view"; //$NON-NLS-1$
+ /** */
public final static String COMMIT_DIALOG_WARN_ABOUT_MESSAGE_SECOND_LINE = "commit_dialog_warn_about_message_second_line"; //$NON-NLS-1$
/** */
public final static String COMMIT_DIALOG_SIGNED_OFF_BY = "commit_dialog_signed_off_by"; //$NON-NLS-1$
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java
index 598afec4b..cadf297e0 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java
@@ -3207,6 +3207,9 @@ public class UIText extends NLS {
public static String CommittingPreferencePage_BlockCommitCombo;
/** */
+ public static String CommittingPreferencePage_AlwaysUseStagingView;
+
+ /** */
public static String DateFormatPreferencePage_title;
/** */
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitActionHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitActionHandler.java
index 56311c134..729e80518 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitActionHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitActionHandler.java
@@ -19,11 +19,16 @@ package org.eclipse.egit.ui.internal.actions;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IResource;
+import org.eclipse.egit.ui.Activator;
+import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.internal.commit.CommitUI;
import org.eclipse.egit.ui.internal.operations.GitScopeUtil;
+import org.eclipse.egit.ui.internal.staging.StagingView;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
/**
* Scan for modified resources in the same project as the selected resources.
@@ -32,27 +37,48 @@ public class CommitActionHandler extends RepositoryActionHandler {
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
- final Repository repo = getRepository(true, event);
- if (repo == null)
- return null;
- final Shell shell = getShell(event);
- IResource[] resourcesInScope;
- try {
- IResource[] selectedResources = getSelectedResources(event);
- if (selectedResources.length > 0) {
- IWorkbenchPart part = getPart(event);
- resourcesInScope = GitScopeUtil.getRelatedChanges(part,
- selectedResources);
- } else
- resourcesInScope = new IResource[0];
- } catch (InterruptedException e) {
- // ignore, we will not show the commit dialog in case the user
- // cancels the scope operation
+
+ final Repository repository = getRepository(true, event);
+ if (repository == null) {
return null;
}
- CommitUI commitUi = new CommitUI(shell, repo, resourcesInScope,
- false);
- commitUi.commit();
+ boolean useStagingView = Activator.getDefault().getPreferenceStore()
+ .getBoolean(UIPreferences.ALWAYS_USE_STAGING_VIEW);
+ if (useStagingView) {
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ StagingView view = (StagingView) PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage()
+ .showView(StagingView.VIEW_ID);
+ view.setFocus();
+ } catch (PartInitException e) {
+ Activator.logError(e.getMessage(), e);
+ }
+ }
+ });
+ } else {
+ final Shell shell = getShell(event);
+ IResource[] resourcesInScope;
+ try {
+ IResource[] selectedResources = getSelectedResources(event);
+ if (selectedResources.length > 0) {
+ IWorkbenchPart part = getPart(event);
+ resourcesInScope = GitScopeUtil.getRelatedChanges(part,
+ selectedResources);
+ } else
+ resourcesInScope = new IResource[0];
+ } catch (InterruptedException e) {
+ // ignore, we will not show the commit dialog in case the user
+ // cancels the scope operation
+ return null;
+ }
+ CommitUI commitUi = new CommitUI(shell, repository,
+ resourcesInScope, false);
+ commitUi.commit();
+ }
return null;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/CommittingPreferencePage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/CommittingPreferencePage.java
index f86601bcc..28d8e49e5 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/CommittingPreferencePage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/CommittingPreferencePage.java
@@ -64,6 +64,11 @@ public class CommittingPreferencePage extends FieldEditorPreferencePage
protected void createFieldEditors() {
Composite main = getFieldEditorParent();
+ BooleanFieldEditor useStagingView = new BooleanFieldEditor(
+ UIPreferences.ALWAYS_USE_STAGING_VIEW,
+ UIText.CommittingPreferencePage_AlwaysUseStagingView, main);
+ addField(useStagingView);
+
Group formattingGroup = new Group(main, SWT.SHADOW_ETCHED_IN);
formattingGroup.setText(UIText.CommittingPreferencePage_formatting);
GridDataFactory.fillDefaults().grab(true, false).span(3, 1)
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
index 6502c1ab8..0fbb21b44 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
@@ -3302,7 +3302,13 @@ public class StagingView extends ViewPart implements IShowInSource {
@Override
public void setFocus() {
- unstagedViewer.getControl().setFocus();
+ Tree tree = unstagedViewer.getTree();
+ if (tree.getItemCount() > 0) {
+ tree.setSelection(tree.getItems());
+ unstagedViewer.getControl().setFocus();
+ return;
+ }
+ commitMessageText.setFocus();
}
@Override
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
index 6ecd6b5b1..bc1cff5d0 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
@@ -1032,6 +1032,7 @@ CommittingPreferencePage_WarnBlock_Errors=Errors
CommittingPreferencePage_WarnBlock_WarningsAndErrors=Warnings and errors
CommittingPreferencePage_BlockCommit=Block commit button
CommittingPreferencePage_BlockCommitCombo=Block if there are:
+CommittingPreferencePage_AlwaysUseStagingView=Use Staging View to commit instead of Commit Dialog
DateFormatPreferencePage_title=Date Format
DateFormatPreferencePage_formatChooser_label=&Format:

Back to the top