Search in sources :

Example 1 with MergeFileAssociation

use of org.tigris.subversion.subclipse.ui.conflicts.MergeFileAssociation in project subclipse by subclipse.

the class SVNUIPlugin method getMergeFileAssociations.

public MergeFileAssociation[] getMergeFileAssociations() throws BackingStoreException {
    ArrayList associations = new ArrayList();
    String[] childrenNames = MergeFileAssociation.getParentPreferences().childrenNames();
    for (int i = 0; i < childrenNames.length; i++) {
        org.osgi.service.prefs.Preferences node = MergeFileAssociation.getParentPreferences().node(childrenNames[i]);
        MergeFileAssociation association = new MergeFileAssociation();
        association.setFileType(childrenNames[i]);
        // $NON-NLS-1$,  //$NON-NLS-1$
        association.setMergeProgram(node.get("mergeProgram", ""));
        // $NON-NLS-1$,  //$NON-NLS-1$
        association.setParameters(node.get("parameters", ""));
        association.setType(node.getInt("type", MergeFileAssociation.BUILT_IN));
        associations.add(association);
    }
    MergeFileAssociation[] associationArray = new MergeFileAssociation[associations.size()];
    associations.toArray(associationArray);
    Arrays.sort(associationArray);
    return associationArray;
}
Also used : ArrayList(java.util.ArrayList) MergeFileAssociation(org.tigris.subversion.subclipse.ui.conflicts.MergeFileAssociation)

Example 2 with MergeFileAssociation

use of org.tigris.subversion.subclipse.ui.conflicts.MergeFileAssociation in project subclipse by subclipse.

the class EditConflictsAction method execute.

/*
   * (non-Javadoc)
   *
   * @see org.tigris.subversion.subclipse.ui.actions.SVNAction#execute(org.eclipse.jface.action.IAction)
   */
protected void execute(final IAction action) throws InvocationTargetException, InterruptedException {
    IFile resource;
    if (selectedResource == null)
        resource = (IFile) getSelectedResources()[0];
    else
        resource = selectedResource;
    ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
    try {
        IFile conflictNewFile = (IFile) File2Resource.getResource(svnResource.getStatus().getConflictNew());
        IFile conflictOldFile = (IFile) File2Resource.getResource(svnResource.getStatus().getConflictOld());
        IFile conflictWorkingFile = (IFile) File2Resource.getResource(svnResource.getStatus().getConflictWorking());
        if (conflictWorkingFile == null) {
            conflictWorkingFile = resource;
        }
        MergeFileAssociation mergeFileAssociation = null;
        try {
            mergeFileAssociation = SVNUIPlugin.getPlugin().getMergeFileAssociation(resource.getName());
        } catch (BackingStoreException e) {
            mergeFileAssociation = new MergeFileAssociation();
        }
        if (mergeFileAssociation.getType() == MergeFileAssociation.BUILT_IN) {
            editConflictsInternal(resource, conflictOldFile, conflictWorkingFile, conflictNewFile);
        } else if (mergeFileAssociation.getType() == MergeFileAssociation.DEFAULT_EXTERNAL) {
            IPreferenceStore preferenceStore = SVNUIPlugin.getPlugin().getPreferenceStore();
            String mergeProgramLocation = preferenceStore.getString(ISVNUIConstants.PREF_MERGE_PROGRAM_LOCATION);
            String mergeProgramParameters = preferenceStore.getString(ISVNUIConstants.PREF_MERGE_PROGRAM_PARAMETERS);
            editConflictsExternal(resource, conflictOldFile, conflictWorkingFile, conflictNewFile, mergeProgramLocation, mergeProgramParameters);
        } else {
            editConflictsExternal(resource, conflictOldFile, conflictWorkingFile, conflictNewFile, mergeFileAssociation.getMergeProgram(), mergeFileAssociation.getParameters());
        }
    } catch (Exception e) {
        exception = e;
    }
    if (exception != null) {
        throw new InvocationTargetException(exception);
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) BackingStoreException(org.osgi.service.prefs.BackingStoreException) MergeFileAssociation(org.tigris.subversion.subclipse.ui.conflicts.MergeFileAssociation) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IOException(java.io.IOException) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) SVNException(org.tigris.subversion.subclipse.core.SVNException) BackingStoreException(org.osgi.service.prefs.BackingStoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 3 with MergeFileAssociation

use of org.tigris.subversion.subclipse.ui.conflicts.MergeFileAssociation in project subclipse by subclipse.

the class SVNUIPlugin method getMergeFileAssociation.

public MergeFileAssociation getMergeFileAssociation(String fileName) throws BackingStoreException {
    MergeFileAssociation[] mergeFileAssociations = getMergeFileAssociations();
    for (int i = 0; i < mergeFileAssociations.length; i++) {
        if (mergeFileAssociations[i].getFileType().equals(fileName))
            return mergeFileAssociations[i];
    }
    for (int i = 0; i < mergeFileAssociations.length; i++) {
        if (mergeFileAssociations[i].matches(fileName))
            return mergeFileAssociations[i];
    }
    MergeFileAssociation mergeFileAssociation = new MergeFileAssociation();
    IPreferenceStore preferenceStore = getPreferenceStore();
    if (preferenceStore.getBoolean(ISVNUIConstants.PREF_MERGE_USE_EXTERNAL))
        mergeFileAssociation.setType(MergeFileAssociation.DEFAULT_EXTERNAL);
    else
        mergeFileAssociation.setType(MergeFileAssociation.BUILT_IN);
    return mergeFileAssociation;
}
Also used : MergeFileAssociation(org.tigris.subversion.subclipse.ui.conflicts.MergeFileAssociation) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Aggregations

MergeFileAssociation (org.tigris.subversion.subclipse.ui.conflicts.MergeFileAssociation)3 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)2 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 IFile (org.eclipse.core.resources.IFile)1 CoreException (org.eclipse.core.runtime.CoreException)1 BackingStoreException (org.osgi.service.prefs.BackingStoreException)1 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)1 SVNException (org.tigris.subversion.subclipse.core.SVNException)1