Search in sources :

Example 1 with CommitToTagsWarningDialog

use of org.tigris.subversion.subclipse.ui.dialogs.CommitToTagsWarningDialog in project subclipse by subclipse.

the class CommitSynchronizeOperation method confirmCommit.

private boolean confirmCommit(SyncInfoSet set) {
    commit = false;
    IResource[] modified = set.getResources();
    List conflictFiles = new ArrayList();
    List filteredModified = new ArrayList();
    boolean switched = false;
    for (int i = 0; i < modified.length; i++) {
        IResource resource = modified[i];
        filteredModified.add(resource);
        if (!(resource instanceof IContainer)) {
            ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
            try {
                if (svnResource.isManaged() && svnResource.getStatus().isTextConflicted()) {
                    IFile conflictNewFile = (IFile) File2Resource.getResource(svnResource.getStatus().getConflictNew());
                    if (conflictNewFile != null)
                        conflictFiles.add(conflictNewFile);
                    IFile conflictOldFile = (IFile) File2Resource.getResource(svnResource.getStatus().getConflictOld());
                    if (conflictOldFile != null)
                        conflictFiles.add(conflictOldFile);
                    IFile conflictWorkingFile = (IFile) File2Resource.getResource(svnResource.getStatus().getConflictWorking());
                    if (conflictWorkingFile != null)
                        conflictFiles.add(conflictWorkingFile);
                }
                if (svnResource.getStatus().isSwitched()) {
                    url = svnResource.getStatus().getUrlString();
                    switched = true;
                }
            } catch (SVNException e) {
            }
        }
    }
    if (switched && modified.length > 1) {
        url = null;
    }
    if (conflictFiles.size() > 0) {
        Iterator iter = conflictFiles.iterator();
        while (iter.hasNext()) {
            IFile conflictFile = (IFile) iter.next();
            filteredModified.remove(conflictFile);
        }
        modified = new IResource[filteredModified.size()];
        filteredModified.toArray(modified);
    }
    if (modified.length > 0) {
        try {
            IPreferenceStore preferenceStore = SVNUIPlugin.getPlugin().getPreferenceStore();
            boolean commitToTagsPathWithoutWarning = preferenceStore.getBoolean(ISVNUIConstants.PREF_COMMIT_TO_TAGS_PATH_WITHOUT_WARNING);
            if (!commitToTagsPathWithoutWarning && onTagPath(modified)) {
                commit = true;
                getShell().getDisplay().syncExec(new Runnable() {

                    public void run() {
                        CommitToTagsWarningDialog dialog = new CommitToTagsWarningDialog(getShell());
                        commit = dialog.open() == CommitToTagsWarningDialog.OK;
                    }
                });
                if (!commit) {
                    return false;
                }
            }
            ProjectProperties projectProperties = ProjectProperties.getProjectProperties(modified[0]);
            SvnWizardCommitPage commitPage = new SvnWizardCommitPage(modified, url, projectProperties, new HashMap(), changeSet, true);
            if (proposedComment == null || proposedComment.length() == 0)
                commitPage.setComment(getProposedComment(modified));
            else
                commitPage.setComment(proposedComment);
            commitPage.setSyncInfoSet(set);
            SvnWizard wizard = new SvnWizard(commitPage);
            final SvnWizardDialog dialog = new SvnWizardDialog(getShell(), wizard);
            wizard.setParentDialog(dialog);
            getShell().getDisplay().syncExec(new Runnable() {

                public void run() {
                    commit = (dialog.open() == SvnWizardDialog.OK);
                }
            });
            if (commit) {
                resourcesToCommit = commitPage.getSelectedResources();
                keepLocks = commitPage.isKeepLocks();
            }
            commitComment = commitPage.getComment();
        } catch (SVNException e) {
            if (!e.operationInterrupted()) {
                SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
            }
        }
    }
    return commit;
}
Also used : IFile(org.eclipse.core.resources.IFile) HashMap(java.util.HashMap) SvnWizardDialog(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardDialog) ArrayList(java.util.ArrayList) SvnWizardCommitPage(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardCommitPage) SvnWizard(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizard) SVNException(org.tigris.subversion.subclipse.core.SVNException) ProjectProperties(org.tigris.subversion.subclipse.ui.settings.ProjectProperties) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) CommitToTagsWarningDialog(org.tigris.subversion.subclipse.ui.dialogs.CommitToTagsWarningDialog) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) IContainer(org.eclipse.core.resources.IContainer) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) IResource(org.eclipse.core.resources.IResource)

Example 2 with CommitToTagsWarningDialog

use of org.tigris.subversion.subclipse.ui.dialogs.CommitToTagsWarningDialog in project subclipse by subclipse.

the class CommitAction method confirmCommit.

/**
 * prompt commit of selected resources.
 *
 * @throws SVNException
 */
protected boolean confirmCommit(IResource[] modifiedResources, ProjectProperties projectProperties) throws SVNException {
    IPreferenceStore preferenceStore = SVNUIPlugin.getPlugin().getPreferenceStore();
    boolean commitToTagsPathWithoutWarning = preferenceStore.getBoolean(ISVNUIConstants.PREF_COMMIT_TO_TAGS_PATH_WITHOUT_WARNING);
    if (!commitToTagsPathWithoutWarning && onTagPath(modifiedResources)) {
        // Warning - working copy appears to be on a tag path.
        CommitToTagsWarningDialog dialog = new CommitToTagsWarningDialog(getShell());
        if (dialog.open() != CommitToTagsWarningDialog.OK) {
            return false;
        }
    }
    int highestProblemSeverity = getHighestProblemSeverity(modifiedResources);
    switch(highestProblemSeverity) {
        case IMarker.SEVERITY_WARNING:
            String allowCommitsWithWarnings = preferenceStore.getString(ISVNUIConstants.PREF_ALLOW_COMMIT_WITH_WARNINGS);
            if (MessageDialogWithToggle.PROMPT.equals(allowCommitsWithWarnings) || MessageDialogWithToggle.NEVER.equals(allowCommitsWithWarnings)) {
                MessageDialogWithToggle warningDialog = MessageDialogWithToggle.openYesNoQuestion(shell, Policy.bind("CommitWizard.commitResources"), Policy.bind("CommitWizard.warningMarkers"), Policy.bind("CommitWizard.warningQuestion"), false, preferenceStore, ISVNUIConstants.PREF_ALLOW_COMMIT_WITH_WARNINGS);
                if (IDialogConstants.YES_ID != warningDialog.getReturnCode()) {
                    return false;
                }
            }
            break;
        case IMarker.SEVERITY_ERROR:
            String allowCommitsWithErrors = preferenceStore.getString(ISVNUIConstants.PREF_ALLOW_COMMIT_WITH_ERRORS);
            if (MessageDialogWithToggle.PROMPT.equals(allowCommitsWithErrors) || MessageDialogWithToggle.NEVER.equals(allowCommitsWithErrors)) {
                MessageDialogWithToggle errorDialog = MessageDialogWithToggle.openYesNoQuestion(shell, Policy.bind("CommitWizard.commitResources"), Policy.bind("CommitWizard.errorMarkers"), Policy.bind("CommitWizard.errorQuestion"), false, preferenceStore, ISVNUIConstants.PREF_ALLOW_COMMIT_WITH_ERRORS);
                if (IDialogConstants.YES_ID != errorDialog.getReturnCode()) {
                    return false;
                }
            }
            break;
    }
    SvnWizardCommitPage commitPage = new SvnWizardCommitPage(modifiedResources, url, projectProperties, statusMap, null, false);
    // commitPage.setSharing(sharing);
    SvnWizard wizard = new SvnWizard(commitPage);
    SvnWizardDialog dialog = new SvnWizardDialog(getShell(), wizard);
    if (proposedComment == null || proposedComment.length() == 0) {
        commitPage.setComment(getProposedComment(modifiedResources));
    } else {
        commitPage.setComment(proposedComment);
    }
    wizard.setParentDialog(dialog);
    boolean commitOK = (dialog.open() == SvnWizardDialog.OK);
    url = null;
    commitComment = commitPage.getComment();
    resourcesToCommit = commitPage.getSelectedResources();
    keepLocks = commitPage.isKeepLocks();
    return commitOK;
}
Also used : SvnWizardDialog(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardDialog) SvnWizardCommitPage(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardCommitPage) SvnWizard(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizard) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) CommitToTagsWarningDialog(org.tigris.subversion.subclipse.ui.dialogs.CommitToTagsWarningDialog)

Aggregations

IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)2 CommitToTagsWarningDialog (org.tigris.subversion.subclipse.ui.dialogs.CommitToTagsWarningDialog)2 SvnWizard (org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizard)2 SvnWizardCommitPage (org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardCommitPage)2 SvnWizardDialog (org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardDialog)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 IContainer (org.eclipse.core.resources.IContainer)1 IFile (org.eclipse.core.resources.IFile)1 IResource (org.eclipse.core.resources.IResource)1 MessageDialogWithToggle (org.eclipse.jface.dialogs.MessageDialogWithToggle)1 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)1 SVNException (org.tigris.subversion.subclipse.core.SVNException)1 ProjectProperties (org.tigris.subversion.subclipse.ui.settings.ProjectProperties)1