Bug 447236 - CommitDialog ability to force preselection of untracked files
Summary: CommitDialog ability to force preselection of untracked files
Status: NEW
Alias: None
Product: EGit
Classification: Technology
Component: UI (show other bugs)
Version: 3.4   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-15 04:26 EDT by Johannes Dorn CLA
Modified: 2015-01-06 03:35 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Dorn CLA 2014-10-15 04:26:28 EDT
When i open a commit dialog with CommitUI, i give it an array of preselected IResources. However, untracked files are not selected unless the COMMIT_DIALOG_INCLUDE_UNTRACKED preference is set.

The relevant code is in CommitDialog:

 final boolean includeUntracked = getPreferenceStore().getBoolean(
    UIPreferences.COMMIT_DIALOG_INCLUDE_UNTRACKED);
    for (CommitItem item : items) {
       if (!preselectAll && !preselectedFiles.contains(item.path))
           continue;
       if (item.status == Status.ASSUME_UNCHANGED)
           continue;
       if (!includeUntracked && item.status == Status.UNTRACKED)
           continue;
       filesViewer.setChecked(item, true);
 }

I would like to be able to force that selection even if the preference is disabled. Maybe this should even be the default.
If the caller explicitly asked to have the resource preselected, than imo this should happen regardless of preferences.
Comment 1 Matthias Sohn CLA 2014-10-15 04:45:27 EDT
this looks wrong. I would add another parameter to the CommitUI constructor

public CommitUI(Shell shell, Repository repo,
			IResource[] selectedResources, boolean preselectAll, boolean selectUntrackedResources)

so that this can be controlled explicitly. The relevant callers in EGit should then feed this new parameter based on the preference setting.

Note that these classes are internal so they can change any time.
Comment 2 Johannes Dorn CLA 2014-10-15 05:04:51 EDT
I find the constructor is already confusing. Its parameters are an array and a boolean. If the boolean is true, the array is ignored. If we add a third boolean, it becomes more confusing. For my use case, it would be very helpful to be able to disallow selection changes, which would require an additional (boolean) parameter.

Maybe overloading the constructor would help. Possibly like this:

 public CommitUI(Shell shell, Repository repo,
			boolean preselectAll, boolean selectUntrackedResources)

 public CommitUI(Shell shell, Repository repo,
			IResource[] selectedResources, boolean selectUntrackedResources, boolean allowSelectionChange)

Or have public setter methods for these options.


Is there some public API to open this CommitDialog?
If not, do you have plans for that?
Comment 3 Johannes Dorn CLA 2014-10-15 05:18:10 EDT
Looking at this further, i would actually want to be able to control pretty much the entire dialog programmatically. In our use case we want to set the commit message, which the user may edit further and we would want to preselect the "Add signed-off-by" button.

So much for my small ;) wishlist for a public commit dialog API.
Comment 4 Matthias Sohn CLA 2014-10-15 08:25:53 EDT
You are right, overloading may help to fix this mess. Feel free to contribute the necessary changes, but keep the existing CommitDialog behavior in EGit working
Comment 5 Robin Stocker CLA 2015-01-06 03:35:55 EST
Instead of overloading, I think setter methods would be preferable in this case.