Search in sources :

Example 1 with RepositoryComparator

use of org.tigris.subversion.subclipse.core.repo.RepositoryComparator in project subclipse by subclipse.

the class CheckoutWizardLocationPage method refreshLocations.

public void refreshLocations() {
    ISVNRepositoryLocation[] locations = SVNUIPlugin.getPlugin().getRepositoryManager().getKnownRepositoryLocations(null);
    Arrays.sort(locations, new RepositoryComparator());
    AdaptableList input = new AdaptableList(locations);
    table.setInput(input);
    if (locations.length == 0) {
        newButton.setSelection(true);
        existingButton.setSelection(false);
        table.getTable().setEnabled(false);
        setPageComplete(true);
    } else {
        existingButton.setSelection(true);
        newButton.setSelection(false);
        table.getTable().setEnabled(true);
    }
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) AdaptableList(org.tigris.subversion.subclipse.ui.util.AdaptableList) RepositoryComparator(org.tigris.subversion.subclipse.core.repo.RepositoryComparator)

Example 2 with RepositoryComparator

use of org.tigris.subversion.subclipse.core.repo.RepositoryComparator in project subclipse by subclipse.

the class RepositorySelectionPage method createControl.

/**
 * Creates the UI part of the page.
 *
 * @param parent the parent of the created widgets
 */
public void createControl(Composite parent) {
    Composite composite = createComposite(parent, 1);
    // set F1 help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.SHARING_SELECT_REPOSITORY_PAGE);
    createWrappingLabel(composite, Policy.bind("RepositorySelectionPage.description"), 0, /* indent */
    1);
    useNewRepo = createRadioButton(composite, Policy.bind("RepositorySelectionPage.useNew"), // $NON-NLS-1$
    1);
    useExistingRepo = createRadioButton(composite, Policy.bind("RepositorySelectionPage.useExisting"), // $NON-NLS-1$
    1);
    table = createTable(composite, 1);
    table.setContentProvider(new WorkbenchContentProvider());
    table.setLabelProvider(new WorkbenchLabelProvider());
    table.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            result = (ISVNRepositoryLocation) ((IStructuredSelection) table.getSelection()).getFirstElement();
            settings.put(LAST_LOCATION, result.getLocation());
            setPageComplete(canFinish());
        }
    });
    SelectionListener selectionListener = new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            if (useNewRepo.getSelection()) {
                table.getTable().setEnabled(false);
                result = null;
            } else {
                table.getTable().setEnabled(true);
                result = (ISVNRepositoryLocation) ((IStructuredSelection) table.getSelection()).getFirstElement();
            }
            setPageComplete(canFinish());
        }
    };
    useNewRepo.addSelectionListener(selectionListener);
    useExistingRepo.addSelectionListener(selectionListener);
    setControl(composite);
    IRunnableWithProgress runnable = new IRunnableWithProgress() {

        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            locations = SVNUIPlugin.getPlugin().getRepositoryManager().getKnownRepositoryLocations(monitor);
        }
    };
    try {
        new ProgressMonitorDialog(getShell()).run(true, false, runnable);
    } catch (Exception e) {
        SVNUIPlugin.openError(getShell(), null, null, e, SVNUIPlugin.LOG_TEAM_EXCEPTIONS);
    }
    Arrays.sort(locations, new RepositoryComparator());
    AdaptableList input = new AdaptableList(locations);
    table.setInput(input);
    if (locations.length == 0) {
        useNewRepo.setSelection(true);
    } else {
        useExistingRepo.setSelection(true);
        int selectionIndex = 0;
        String lastLocation = settings.get(LAST_LOCATION);
        if (lastLocation != null) {
            for (int i = 0; i < locations.length; i++) {
                ISVNRepositoryLocation location = locations[i];
                if (lastLocation.equals(location.getLocation())) {
                    selectionIndex = i;
                    break;
                }
            }
        }
        table.setSelection(new StructuredSelection(locations[selectionIndex]));
        result = locations[selectionIndex];
    }
    setPageComplete(canFinish());
}
Also used : WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryComparator(org.tigris.subversion.subclipse.core.repo.RepositoryComparator) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) AdaptableList(org.tigris.subversion.subclipse.ui.util.AdaptableList) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 3 with RepositoryComparator

use of org.tigris.subversion.subclipse.core.repo.RepositoryComparator 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)3 RepositoryComparator (org.tigris.subversion.subclipse.core.repo.RepositoryComparator)3 AdaptableList (org.tigris.subversion.subclipse.ui.util.AdaptableList)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 SelectionListener (org.eclipse.swt.events.SelectionListener)1 Composite (org.eclipse.swt.widgets.Composite)1 WorkbenchContentProvider (org.eclipse.ui.model.WorkbenchContentProvider)1 WorkbenchLabelProvider (org.eclipse.ui.model.WorkbenchLabelProvider)1