Search in sources :

Example 56 with ISVNRepositoryLocation

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

the class NewLocationWizard method performFinish.

/*
   * @see IWizard#performFinish
   */
public boolean performFinish() {
    mainPage.finish(new NullProgressMonitor());
    Properties properties = mainPage.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());
            }
        }
    }
    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);
                    }
                }
            });
        } catch (InterruptedException e) {
            return false;
        } 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 false;
        } 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 false;
            }
            return keep;
        }
    }
    return true;
}
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 57 with ISVNRepositoryLocation

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

the class RemoveRootAction method getSelectedRemoteRoots.

/**
 * Returns the selected remote files
 */
protected ISVNRepositoryLocation[] getSelectedRemoteRoots() {
    ArrayList resources = null;
    if (selection != null && !selection.isEmpty()) {
        resources = new ArrayList();
        Iterator elements = selection.iterator();
        while (elements.hasNext()) {
            Object next = SVNAction.getAdapter(elements.next(), ISVNRepositoryLocation.class);
            if (next instanceof ISVNRepositoryLocation) {
                resources.add(next);
            }
        }
    }
    if (resources != null && !resources.isEmpty()) {
        ISVNRepositoryLocation[] result = new ISVNRepositoryLocation[resources.size()];
        resources.toArray(result);
        return result;
    }
    return new ISVNRepositoryLocation[0];
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Example 58 with ISVNRepositoryLocation

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

the class RepositoriesView method contributeActions.

/**
 * Contribute actions to the view
 */
protected void contributeActions() {
    final Shell shell = getShell();
    // Create actions
    // New Repository (popup)
    newAction = new Action(// $NON-NLS-1$
    Policy.bind("RepositoriesView.new"), SVNUIPlugin.getPlugin().getImageDescriptor(// $NON-NLS-1$
    ISVNUIConstants.IMG_NEWLOCATION)) {

        public void run() {
            if (!WorkspacePathValidator.validateWorkspacePath())
                return;
            NewLocationWizard wizard = new NewLocationWizard();
            WizardDialog dialog = new ClosableWizardDialog(shell, wizard);
            dialog.open();
        }
    };
    PlatformUI.getWorkbench().getHelpSystem().setHelp(newAction, IHelpContextIds.NEW_REPOSITORY_LOCATION_ACTION);
    // Properties
    propertiesAction = new PropertyDialogAction(new SameShellProvider(shell), getViewer());
    getViewSite().getActionBars().setGlobalActionHandler(ActionFactory.PROPERTIES.getId(), propertiesAction);
    IStructuredSelection selection = (IStructuredSelection) getViewer().getSelection();
    if (selection.size() == 1 && selection.getFirstElement() instanceof ISVNRepositoryLocation) {
        propertiesAction.setEnabled(true);
    } else {
        propertiesAction.setEnabled(false);
    }
    getViewer().addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection ss = (IStructuredSelection) event.getSelection();
            boolean enabled = ss.size() == 1 && ss.getFirstElement() instanceof ISVNRepositoryLocation;
            propertiesAction.setEnabled(enabled);
        }
    });
    // Remove Root
    removeRootAction = new RemoveRootAction(treeViewer.getControl().getShell());
    removeRootAction.selectionChanged((IStructuredSelection) null);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(removeRootAction, IHelpContextIds.REMOVE_REPOSITORY_LOCATION_ACTION);
    IActionBars bars = getViewSite().getActionBars();
    bars.setGlobalActionHandler(ActionFactory.DELETE.getId(), removeRootAction);
    // Refresh action (toolbar)
    SVNUIPlugin plugin = SVNUIPlugin.getPlugin();
    refreshAction = new Action(Policy.bind("RepositoriesView.refresh"), SVNUIPlugin.getPlugin().getImageDescriptor(// $NON-NLS-1$
    ISVNUIConstants.IMG_REFRESH_ENABLED)) {

        public void run() {
            refreshViewer(null, true);
        }
    };
    // $NON-NLS-1$
    refreshAction.setToolTipText(Policy.bind("RepositoriesView.refreshTooltip"));
    refreshAction.setDisabledImageDescriptor(plugin.getImageDescriptor(ISVNUIConstants.IMG_REFRESH_DISABLED));
    refreshAction.setHoverImageDescriptor(plugin.getImageDescriptor(ISVNUIConstants.IMG_REFRESH));
    getViewSite().getActionBars().setGlobalActionHandler(ActionFactory.REFRESH.getId(), refreshAction);
    refreshPopupAction = new Action(Policy.bind("RepositoriesView.refreshPopup"), SVNUIPlugin.getPlugin().getImageDescriptor(// $NON-NLS-1$
    ISVNUIConstants.IMG_REFRESH)) {

        public void run() {
            refreshViewerNode();
        }
    };
    // Collapse action
    collapseAllAction = new Action(Policy.bind("RepositoriesView.collapseAll"), SVNUIPlugin.getPlugin().getImageDescriptor(// $NON-NLS-1$
    ISVNUIConstants.IMG_COLLAPSE_ALL_ENABLED)) {

        public void run() {
            collapseAll();
        }
    };
    collapseAllAction.setToolTipText(// $NON-NLS-1$
    Policy.bind("RepositoriesView.collapseAllTooltip"));
    collapseAllAction.setHoverImageDescriptor(plugin.getImageDescriptor(ISVNUIConstants.IMG_COLLAPSE_ALL));
    // Create the popup menu
    MenuManager menuMgr = new MenuManager();
    Tree tree = treeViewer.getTree();
    Menu menu = menuMgr.createContextMenu(tree);
    menuMgr.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            addWorkbenchActions(manager);
        }
    });
    menuMgr.setRemoveAllWhenShown(true);
    tree.setMenu(menu);
    getSite().registerContextMenu(menuMgr, treeViewer);
    // Create the local tool bar
    IToolBarManager tbm = bars.getToolBarManager();
    drillPart.addNavigationActions(tbm);
    tbm.add(refreshAction);
    tbm.add(new Separator());
    tbm.add(collapseAllAction);
    tbm.update(false);
    // Create the open action for double clicks
    openAction = new OpenRemoteFileAction();
    bars.updateActionBars();
    IActionBars actionBars = getViewSite().getActionBars();
    IMenuManager actionBarsMenu = actionBars.getMenuManager();
    Action newRepositoryAction = new // $NON-NLS-1$
    Action(// $NON-NLS-1$
    Policy.bind("RepositoriesView.newRepository")) {

        public void run() {
            SvnWizardNewRepositoryPage newRepositoryPage = new SvnWizardNewRepositoryPage();
            SvnWizard wizard = new SvnWizard(newRepositoryPage);
            SvnWizardDialog dialog = new SvnWizardDialog(getShell(), wizard);
            if (dialog.open() == SvnWizardDialog.OK)
                refreshViewer(null, false);
        }
    };
    actionBarsMenu.add(newRepositoryAction);
}
Also used : OpenRemoteFileAction(org.tigris.subversion.subclipse.ui.actions.OpenRemoteFileAction) PropertyDialogAction(org.eclipse.ui.dialogs.PropertyDialogAction) SVNAction(org.tigris.subversion.subclipse.ui.actions.SVNAction) Action(org.eclipse.jface.action.Action) SvnWizardDialog(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardDialog) SvnWizard(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizard) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) NewLocationWizard(org.tigris.subversion.subclipse.ui.wizards.NewLocationWizard) PropertyDialogAction(org.eclipse.ui.dialogs.PropertyDialogAction) Shell(org.eclipse.swt.widgets.Shell) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) Tree(org.eclipse.swt.widgets.Tree) OpenRemoteFileAction(org.tigris.subversion.subclipse.ui.actions.OpenRemoteFileAction) SvnWizardNewRepositoryPage(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardNewRepositoryPage) ClosableWizardDialog(org.tigris.subversion.subclipse.ui.wizards.ClosableWizardDialog) Menu(org.eclipse.swt.widgets.Menu) IActionBars(org.eclipse.ui.IActionBars) SameShellProvider(org.eclipse.jface.window.SameShellProvider) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) IMenuListener(org.eclipse.jface.action.IMenuListener) SVNUIPlugin(org.tigris.subversion.subclipse.ui.SVNUIPlugin) IToolBarManager(org.eclipse.jface.action.IToolBarManager) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) WizardDialog(org.eclipse.jface.wizard.WizardDialog) ClosableWizardDialog(org.tigris.subversion.subclipse.ui.wizards.ClosableWizardDialog) SvnWizardDialog(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardDialog) Separator(org.eclipse.jface.action.Separator)

Example 59 with ISVNRepositoryLocation

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

the class RepositoriesView method addWorkbenchActions.

// contributeActions
/**
 * @see
 *     org.tigris.subversion.subclipse.ui.repo.RemoteViewPart#addWorkbenchActions(org.eclipse.jface.action.IMenuManager)
 */
protected void addWorkbenchActions(IMenuManager manager) {
    // New actions go next
    MenuManager sub = new MenuManager(Policy.bind("RepositoriesView.newSubmenu"), // $NON-NLS-1$
    IWorkbenchActionConstants.GROUP_ADD);
    sub.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
    manager.add(sub);
    IStructuredSelection selection = (IStructuredSelection) getViewer().getSelection();
    // File actions go first (view file)
    manager.add(new Separator(IWorkbenchActionConstants.GROUP_FILE));
    if (selection.size() == 1 && selection.getFirstElement() instanceof ISVNRemoteFile) {
        ISVNRemoteFile file = (ISVNRemoteFile) selection.getFirstElement();
        MenuManager submenu = // $NON-NLS-1$
        new MenuManager(Policy.bind("TreeConflictsView.openWith"));
        IWorkbench workbench = SVNUIPlugin.getPlugin().getWorkbench();
        IEditorRegistry registry = workbench.getEditorRegistry();
        IEditorDescriptor[] descriptors = registry.getEditors(file.getName());
        for (IEditorDescriptor descriptor : descriptors) {
            submenu.add(new OpenWithAction(file, descriptor));
        }
        manager.add(submenu);
    }
    // Misc additions
    // $NON-NLS-1$
    manager.add(new Separator("historyGroup"));
    // $NON-NLS-1$
    manager.add(new Separator("checkoutGroup"));
    // $NON-NLS-1$
    manager.add(new Separator("exportImportGroup"));
    // $NON-NLS-1$
    manager.add(new Separator("miscGroup"));
    manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
    manager.add(refreshPopupAction);
    removeRootAction.selectionChanged(selection);
    if (removeRootAction.isEnabled()) {
        manager.add(removeRootAction);
    }
    if (selection.size() == 1 && selection.getFirstElement() instanceof ISVNRepositoryLocation) {
        manager.add(new Separator());
        manager.add(propertiesAction);
    }
    sub.add(newAction);
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile) IEditorDescriptor(org.eclipse.ui.IEditorDescriptor) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Separator(org.eclipse.jface.action.Separator) IEditorRegistry(org.eclipse.ui.IEditorRegistry)

Example 60 with ISVNRepositoryLocation

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

the class AllRootsElement method internalGetChildren.

public Object[] internalGetChildren(Object o, IProgressMonitor monitor) {
    ISVNRepositoryLocation[] locations = SVNUIPlugin.getPlugin().getRepositoryManager().getKnownRepositoryLocations(null);
    Arrays.sort(locations, new RepositoryComparator());
    return locations;
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) RepositoryComparator(org.tigris.subversion.subclipse.core.repo.RepositoryComparator)

Aggregations

ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)69 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)20 InvocationTargetException (java.lang.reflect.InvocationTargetException)18 IResource (org.eclipse.core.resources.IResource)15 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)15 TeamException (org.eclipse.team.core.TeamException)14 ArrayList (java.util.ArrayList)13 SVNException (org.tigris.subversion.subclipse.core.SVNException)13 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)13 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)12 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)11 File (java.io.File)10 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)9 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)8 LocalResourceStatus (org.tigris.subversion.subclipse.core.resources.LocalResourceStatus)8 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)8 Iterator (java.util.Iterator)7 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)7 ISVNRemoteFolder (org.tigris.subversion.subclipse.core.ISVNRemoteFolder)7 List (java.util.List)6