Community
Participate
Working Groups
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.
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.
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?
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.
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
Instead of overloading, I think setter methods would be preferable in this case.