Search in sources :

Example 1 with SVNProviderPlugin

use of org.tigris.subversion.subclipse.core.SVNProviderPlugin in project subclipse by subclipse.

the class RemoveRootAction method run.

public void run() {
    ISVNRepositoryLocation[] roots = getSelectedRemoteRoots();
    if (roots.length == 0)
        return;
    SVNProviderPlugin provider = SVNProviderPlugin.getPlugin();
    for (int i = 0; i < roots.length; i++) {
        try {
            // Check if any projects are shared with the repository
            IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
            final ArrayList shared = new ArrayList();
            for (int j = 0; j < projects.length; j++) {
                RepositoryProvider teamProvider = RepositoryProvider.getProvider(projects[j], SVNProviderPlugin.getTypeId());
                if (teamProvider != null) {
                    try {
                        SVNTeamProvider svnProvider = (SVNTeamProvider) teamProvider;
                        if (svnProvider.getSVNWorkspaceRoot().getRepository().equals(roots[i])) {
                            shared.add(projects[j]);
                        }
                    } catch (Exception e) {
                    // Don't let any exception prevent from
                    // continuing
                    }
                }
            }
            // This will notify the RepositoryManager of the removal
            if (!shared.isEmpty()) {
                final String location = roots[i].getLocation();
                shell.getDisplay().syncExec(new Runnable() {

                    public void run() {
                        DetailsDialogWithProjects dialog = new DetailsDialogWithProjects(shell, Policy.bind(// $NON-NLS-1$
                        "RemoteRootAction.Unable_to_Discard_Location_1"), Policy.bind("RemoteRootAction.Projects_in_the_local_workspace_are_shared_with__2", // $NON-NLS-1$
                        location), Policy.bind(// $NON-NLS-1$
                        "RemoteRootAction.The_projects_that_are_shared_with_the_above_repository_are__4"), (IProject[]) shared.toArray(new IProject[shared.size()]), false, SVNUIPlugin.getStandardDisplay().getSystemImage(SWT.ICON_ERROR));
                        dialog.open();
                    }
                });
            } else {
                provider.getRepositories().disposeRepository(roots[i]);
            }
        } catch (SVNException e) {
            SVNUIPlugin.openError(shell, null, null, e);
            SVNUIPlugin.log(e);
        }
    }
}
Also used : SVNProviderPlugin(org.tigris.subversion.subclipse.core.SVNProviderPlugin) ArrayList(java.util.ArrayList) SVNException(org.tigris.subversion.subclipse.core.SVNException) IProject(org.eclipse.core.resources.IProject) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) SVNTeamProvider(org.tigris.subversion.subclipse.core.SVNTeamProvider) DetailsDialogWithProjects(org.tigris.subversion.subclipse.ui.util.DetailsDialogWithProjects) RepositoryProvider(org.eclipse.team.core.RepositoryProvider)

Example 2 with SVNProviderPlugin

use of org.tigris.subversion.subclipse.core.SVNProviderPlugin in project subclipse by subclipse.

the class SvnWizardNewRepositoryPage method performFinish.

public boolean performFinish() {
    success = true;
    BusyIndicator.showWhile(Display.getDefault(), new Runnable() {

        public void run() {
            ISVNClientAdapter svnClient = null;
            try {
                SVNProviderPlugin provider = SVNProviderPlugin.getPlugin();
                String url = getUrl();
                if (provider.getRepositories().isKnownRepository(url, true)) {
                    MessageDialog.openError(getShell(), Policy.bind("NewRepositoryDialog.title"), // $NON-NLS-1$
                    Policy.bind("NewRepositoryDialog.alreadyExists"));
                    success = false;
                    return;
                }
                svnClient = SVNProviderPlugin.getPlugin().getSVNClient();
                File path = new File(folderText.getText().trim());
                if (!path.exists())
                    path.mkdirs();
                svnClient.createRepository(path, ISVNClientAdapter.REPOSITORY_FSTYPE_FSFS);
                if (connectionButton.getSelection()) {
                    Properties properties = new Properties();
                    // $NON-NLS-1$
                    properties.setProperty("url", url);
                    ISVNRepositoryLocation repository = provider.getRepositories().createRepository(properties);
                    provider.getRepositories().addOrUpdateRepository(repository);
                }
            } catch (Exception e) {
                MessageDialog.openError(getShell(), Policy.bind("NewRepositoryDialog.title"), // $NON-NLS-1$
                e.getLocalizedMessage());
                success = false;
            } finally {
                SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(svnClient);
            }
        }
    });
    return success;
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) SVNProviderPlugin(org.tigris.subversion.subclipse.core.SVNProviderPlugin) Properties(java.util.Properties) File(java.io.File) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 3 with SVNProviderPlugin

use of org.tigris.subversion.subclipse.core.SVNProviderPlugin in project subclipse by subclipse.

the class CheckoutWizard method createLocation.

private ISVNRepositoryLocation createLocation() {
    createLocationPage.finish(new NullProgressMonitor());
    Properties properties = createLocationPage.getProperties();
    if (repositorySourceProviderPage != null) {
        ISVNRepositorySourceProvider selectedRepositorySourceProvider = repositorySourceProviderPage.getSelectedRepositorySourceProvider();
        if (selectedRepositorySourceProvider != null) {
            SVNRepositoryProviderWizardPage wizardPage = wizardPageMap.get(selectedRepositorySourceProvider);
            if (wizardPage != null) {
                // $NON-NLS-1$
                properties.setProperty("url", wizardPage.getSelectedUrl());
            }
        }
    }
    String url = properties.getProperty("url");
    if (createdRepositoryUrls.contains(url)) {
        return null;
    }
    final ISVNRepositoryLocation[] root = new ISVNRepositoryLocation[1];
    SVNProviderPlugin provider = SVNProviderPlugin.getPlugin();
    try {
        root[0] = provider.getRepositories().createRepository(properties);
        // Validate the connection info.  This process also determines the rootURL
        try {
            new ProgressMonitorDialog(getShell()).run(true, true, new IRunnableWithProgress() {

                public void run(IProgressMonitor monitor) throws InvocationTargetException {
                    try {
                        root[0].validateConnection(monitor);
                    } catch (TeamException e) {
                        throw new InvocationTargetException(e);
                    }
                }
            });
            createdRepositoryUrls.add(url);
        } catch (InterruptedException e) {
            return null;
        } catch (InvocationTargetException e) {
            Throwable t = e.getTargetException();
            if (t instanceof TeamException) {
                throw (TeamException) t;
            }
        }
        provider.getRepositories().addOrUpdateRepository(root[0]);
    } catch (TeamException e) {
        if (root[0] == null) {
            // Exception creating the root, we cannot continue
            SVNUIPlugin.openError(getContainer().getShell(), Policy.bind("NewLocationWizard.exception"), null, // $NON-NLS-1$
            e);
            return null;
        } else {
            // Exception validating. We can continue if the user wishes.
            IStatus error = e.getStatus();
            if (error.isMultiStatus() && error.getChildren().length == 1) {
                error = error.getChildren()[0];
            }
            boolean keep = false;
            if (error.isMultiStatus()) {
                SVNUIPlugin.openError(getContainer().getShell(), Policy.bind("NewLocationWizard.validationFailedTitle"), null, // $NON-NLS-1$
                e);
            } else {
                keep = MessageDialog.openQuestion(getContainer().getShell(), // $NON-NLS-1$
                Policy.bind("NewLocationWizard.validationFailedTitle"), Policy.bind("NewLocationWizard.validationFailedText", // $NON-NLS-1$
                new Object[] { error.getMessage() }));
            }
            try {
                if (keep) {
                    provider.getRepositories().addOrUpdateRepository(root[0]);
                } else {
                    provider.getRepositories().disposeRepository(root[0]);
                }
            } catch (TeamException e1) {
                SVNUIPlugin.openError(getContainer().getShell(), Policy.bind("exception"), null, // $NON-NLS-1$
                e1);
                return null;
            }
            if (keep)
                return root[0];
        }
    }
    return root[0];
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) SVNProviderPlugin(org.tigris.subversion.subclipse.core.SVNProviderPlugin) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) Properties(java.util.Properties) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) ISVNRepositorySourceProvider(org.tigris.subversion.subclipse.ui.ISVNRepositorySourceProvider) TeamException(org.eclipse.team.core.TeamException) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor)

Example 4 with SVNProviderPlugin

use of org.tigris.subversion.subclipse.core.SVNProviderPlugin in project subclipse by subclipse.

the class Preferences method setSvnClientConfigDir.

/**
 * set the svn client config dir
 *
 * @param configDir
 */
private void setSvnClientConfigDir(String configDir) {
    if (SVNUIPlugin.getPlugin().passwordStoresConfiguredOnLinux() && !SVNUIPlugin.getPlugin().getDialogSettings().getBoolean(UnsupportedPasswordStoresDialog.SETTING_DO_NOT_SHOW_AGAIN)) {
        if (!SVNUIPlugin.TEST_MODE) {
            ISVNClientWrapper clientWrapper = Activator.getDefault().getClientWrapper("javahl");
            String version = null;
            if (clientWrapper != null) {
                version = clientWrapper.getVersionString();
            }
            boolean bugFixed = version != null && new SvnVersion(version).isNewerThanOrEqualTo(SvnVersion.VERSION_1_8_11);
            if (!bugFixed) {
                Display.getDefault().syncExec(new Runnable() {

                    public void run() {
                        UnsupportedPasswordStoresDialog dialog = new UnsupportedPasswordStoresDialog(Display.getDefault().getActiveShell());
                        if (dialog.open() == UnsupportedPasswordStoresDialog.OK) {
                            try {
                                SVNUIPlugin.getPlugin().clearPasswordStoresFromConfiguration(false);
                            } catch (Exception e) {
                                SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
                                MessageDialog.openError(Display.getDefault().getActiveShell(), Messages.Preferences_0, e.getMessage());
                            }
                        } else {
                            SVNUIPlugin.getPlugin().getDialogSettings().put(UnsupportedPasswordStoresDialog.SETTING_DO_NOT_SHOW_AGAIN, dialog.isDoNotShowAgain());
                        }
                    }
                });
            }
        }
    }
    SVNProviderPlugin plugin = SVNProviderPlugin.getPlugin();
    SVNClientManager svnClientManager = plugin.getSVNClientManager();
    if (configDir == null || "".equals(configDir)) {
        // $NON-NLS-1$
        svnClientManager.setConfigDir(null);
    } else {
        File configDirFile = new File(configDir);
        svnClientManager.setConfigDir(configDirFile);
    }
}
Also used : SVNProviderPlugin(org.tigris.subversion.subclipse.core.SVNProviderPlugin) UnsupportedPasswordStoresDialog(org.tigris.subversion.subclipse.ui.dialogs.UnsupportedPasswordStoresDialog) File(java.io.File) SVNClientManager(org.tigris.subversion.subclipse.core.SVNClientManager) ISVNClientWrapper(org.tigris.subversion.clientadapter.ISVNClientWrapper)

Example 5 with SVNProviderPlugin

use of org.tigris.subversion.subclipse.core.SVNProviderPlugin in project subclipse by subclipse.

the class Preferences method setSvnChangePathOnDemand.

/**
 * @param fetchChangePathOnDemand
 */
private void setSvnChangePathOnDemand(boolean fetchChangePathOnDemand) {
    SVNProviderPlugin plugin = SVNProviderPlugin.getPlugin();
    SVNClientManager svnClientManager = plugin.getSVNClientManager();
    svnClientManager.setFetchChangePathOnDemand(fetchChangePathOnDemand);
}
Also used : SVNProviderPlugin(org.tigris.subversion.subclipse.core.SVNProviderPlugin) SVNClientManager(org.tigris.subversion.subclipse.core.SVNClientManager)

Aggregations

SVNProviderPlugin (org.tigris.subversion.subclipse.core.SVNProviderPlugin)6 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)4 Properties (java.util.Properties)3 File (java.io.File)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IStatus (org.eclipse.core.runtime.IStatus)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)2 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)2 TeamException (org.eclipse.team.core.TeamException)2 SVNClientManager (org.tigris.subversion.subclipse.core.SVNClientManager)2 ISVNRepositorySourceProvider (org.tigris.subversion.subclipse.ui.ISVNRepositorySourceProvider)2 ArrayList (java.util.ArrayList)1 IProject (org.eclipse.core.resources.IProject)1 RepositoryProvider (org.eclipse.team.core.RepositoryProvider)1 ISVNClientWrapper (org.tigris.subversion.clientadapter.ISVNClientWrapper)1 SVNException (org.tigris.subversion.subclipse.core.SVNException)1 SVNTeamProvider (org.tigris.subversion.subclipse.core.SVNTeamProvider)1 UnsupportedPasswordStoresDialog (org.tigris.subversion.subclipse.ui.dialogs.UnsupportedPasswordStoresDialog)1