Search in sources :

Example 21 with ISVNLocalResource

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

the class SvnWizardCommitPage method addResourcesArea.

private void addResourcesArea(Composite composite) {
    // get the toolbar actions from any contributing plug-in
    final SVNPluginAction[] toolbarActions = SVNUIPlugin.getCommitDialogToolBarActions();
    final SVNPluginAction[] alternateCompareActions = SVNUIPlugin.getCommitDialogCompareActions();
    ResourceSelectionTree.IToolbarControlCreator toolbarControlCreator = new ResourceSelectionTree.IToolbarControlCreator() {

        public void createToolbarControls(ToolBarManager toolbarManager) {
            toolbarManager.add(new // $NON-NLS-1$
            ControlContribution(// $NON-NLS-1$
            "ignoreUnversioned") {

                protected Control createControl(Composite parent) {
                    includeUnversionedButton = new Button(parent, SWT.CHECK);
                    includeUnversionedButton.setText(// $NON-NLS-1$
                    Policy.bind("CommitDialog.includeUnversioned"));
                    includeUnversionedButton.setSelection(includeUnversioned);
                    includeUnversionedButton.addSelectionListener(new SelectionListener() {

                        public void widgetSelected(SelectionEvent e) {
                            includeUnversioned = includeUnversionedButton.getSelection();
                            includeUnversionedAction.setChecked(includeUnversioned);
                            toggleIncludeUnversioned();
                        }

                        public void widgetDefaultSelected(SelectionEvent e) {
                        }
                    });
                    return includeUnversionedButton;
                }
            });
            toolbarManager.add(new ControlContribution("keepLocks") {

                protected Control createControl(Composite parent) {
                    keepLocksButton = new Button(parent, SWT.CHECK);
                    // $NON-NLS-1$
                    keepLocksButton.setText(Policy.bind("CommitDialog.keepLocks"));
                    keepLocksButton.addSelectionListener(new SelectionListener() {

                        public void widgetSelected(SelectionEvent e) {
                            keepLocks = keepLocksButton.getSelection();
                            keepLocksAction.setChecked(keepLocksButton.getSelection());
                        }

                        public void widgetDefaultSelected(SelectionEvent e) {
                        }
                    });
                    return keepLocksButton;
                }
            });
            toolbarManager.add(new Separator());
            toolbarManager.add(new ControlContribution("showCompare") {

                protected Control createControl(Composite parent) {
                    showCompareButton = new Button(parent, SWT.TOGGLE | SWT.FLAT);
                    showCompareButton.setImage(// $NON-NLS-1$
                    SVNUIPlugin.getImage(ISVNUIConstants.IMG_SYNCPANE));
                    showCompareButton.setToolTipText(Policy.bind("CommitDialog.showCompare"));
                    showCompareButton.setSelection(showCompare);
                    showCompareButton.addSelectionListener(new SelectionListener() {

                        public void widgetSelected(SelectionEvent e) {
                            showComparePane(!showCompare);
                            if (showCompare) {
                                IStructuredSelection selection = (IStructuredSelection) resourceSelectionTree.getTreeViewer().getSelection();
                                if (!selection.isEmpty()) {
                                    Object sel0 = selection.getFirstElement();
                                    if (sel0 instanceof IFile) {
                                        final ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor((IFile) sel0);
                                        try {
                                            // compare dialog
                                            if (alternateCompareActions.length > 0) {
                                                StructuredSelection localResourceSelection = new StructuredSelection(localResource);
                                                for (int i = 0; i < alternateCompareActions.length; i++) {
                                                    // make sure the selection is up to date
                                                    alternateCompareActions[i].selectionChanged(localResourceSelection);
                                                    alternateCompareActions[i].run();
                                                }
                                            } else {
                                                setCompareInput(new SVNLocalCompareInput(localResource, SVNRevision.BASE, true));
                                            }
                                        } catch (Exception e1) {
                                        }
                                    }
                                }
                            }
                        }

                        public void widgetDefaultSelected(SelectionEvent e) {
                        }
                    });
                    return showCompareButton;
                }
            });
            // add any contributing actions from the extension point
            if (toolbarActions.length > 0) {
                toolbarManager.add(new Separator());
                for (int i = 0; i < toolbarActions.length; i++) {
                    SVNPluginAction action = toolbarActions[i];
                    toolbarManager.add(action);
                }
            }
        }

        public int getControlCount() {
            return 1;
        }
    };
    resourceSelectionTree = new ResourceSelectionTree(composite, SWT.NONE, Policy.bind("GenerateSVNDiff.Changes"), ResourceSelectionTree.dedupeResources(resourcesToCommit), statusMap, null, true, toolbarControlCreator, // $NON-NLS-1$
    syncInfoSet);
    if (!resourceSelectionTree.showIncludeUnversionedButton())
        includeUnversionedButton.setVisible(false);
    resourceSelectionTree.setCustomOptions(getCustomOptions());
    resourceSelectionTree.setRemoveFromViewValidator(new ResourceSelectionTree.IRemoveFromViewValidator() {

        public boolean canRemove(ArrayList resourceList, IStructuredSelection selection) {
            return removalOk(resourceList, selection);
        }

        public String getErrorMessage() {
            return removalError;
        // return Policy.bind("CommitDialog.unselectedPropChangeChildren"); //$NON-NLS-1$
        }
    });
    resourceSelectionTree.getTreeViewer().getTree().addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            selectedResources = resourceSelectionTree.getSelectedResources();
            // need to update the toolbar actions too - but we use the tree viewer's selection
            IStructuredSelection selection = (IStructuredSelection) resourceSelectionTree.getTreeViewer().getSelection();
            if (toolbarActions.length > 0) {
                for (int i = 0; i < toolbarActions.length; i++) {
                    SVNPluginAction action = toolbarActions[i];
                    action.selectionChanged(selection);
                }
            }
            if (showCompare) {
                Object sel0 = selection.getFirstElement();
                if (sel0 instanceof IFile) {
                    final ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor((IFile) sel0);
                    try {
                        // then call those actions instead of showing the default compare dialog
                        if (alternateCompareActions.length > 0) {
                            StructuredSelection localResourceSelection = new StructuredSelection(localResource);
                            for (int i = 0; i < alternateCompareActions.length; i++) {
                                // make sure the selection is up to date
                                alternateCompareActions[i].selectionChanged(localResourceSelection);
                                alternateCompareActions[i].run();
                            }
                        } else {
                            setCompareInput(new SVNLocalCompareInput(localResource, SVNRevision.BASE, true));
                        }
                    } catch (Exception e1) {
                    }
                }
            }
        }
    });
    ((CheckboxTreeViewer) resourceSelectionTree.getTreeViewer()).addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            selectedResources = resourceSelectionTree.getSelectedResources();
        }
    });
    resourceSelectionTree.getTreeViewer().addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection sel = (IStructuredSelection) event.getSelection();
            Object sel0 = sel.getFirstElement();
            if (sel0 instanceof IFile) {
                final ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor((IFile) sel0);
                try {
                    // then call those actions instead of showing the default compare dialog
                    if (alternateCompareActions.length > 0) {
                        StructuredSelection selection = new StructuredSelection(localResource);
                        for (int i = 0; i < alternateCompareActions.length; i++) {
                            // make sure the selection is up to date
                            alternateCompareActions[i].selectionChanged(selection);
                            alternateCompareActions[i].run();
                        }
                    } else {
                        setCompareInput(new SVNLocalCompareInput(localResource, SVNRevision.BASE, true));
                        showComparePane(true);
                        showCompareButton.setSelection(true);
                    }
                } catch (Exception e1) {
                }
            }
        }
    });
    if (!includeUnversioned) {
        resourceSelectionTree.removeUnversioned();
    }
    selectedResources = resourceSelectionTree.getSelectedResources();
    setPageComplete(canFinish());
}
Also used : IFile(org.eclipse.core.resources.IFile) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ArrayList(java.util.ArrayList) ControlContribution(org.eclipse.jface.action.ControlContribution) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) ToolBarManager(org.eclipse.jface.action.ToolBarManager) Control(org.eclipse.swt.widgets.Control) ResourceSelectionTree(org.tigris.subversion.subclipse.ui.util.ResourceSelectionTree) Button(org.eclipse.swt.widgets.Button) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SVNLocalCompareInput(org.tigris.subversion.subclipse.ui.compare.SVNLocalCompareInput) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SVNException(org.tigris.subversion.subclipse.core.SVNException) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) SVNPluginAction(org.tigris.subversion.subclipse.ui.actions.SVNPluginAction) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) Separator(org.eclipse.jface.action.Separator) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 22 with ISVNLocalResource

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

the class SvnWizardRevertPage method createControls.

public void createControls(Composite outerContainer) {
    Composite composite = new Composite(outerContainer, SWT.NULL);
    GridLayout layout = new GridLayout(1, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    ResourceSelectionTree.IToolbarControlCreator toolbarControlCreator = new ResourceSelectionTree.IToolbarControlCreator() {

        public void createToolbarControls(ToolBarManager toolbarManager) {
            toolbarManager.add(new // $NON-NLS-1$
            ControlContribution(// $NON-NLS-1$
            "ignoreUnversioned") {

                protected Control createControl(Composite parent) {
                    includeUnversionedButton = new Button(parent, SWT.CHECK);
                    includeUnversionedButton.setText(// $NON-NLS-1$
                    Policy.bind("CommitDialog.includeUnversioned"));
                    includeUnversionedButton.setSelection(includeUnversioned);
                    includeUnversionedButton.addSelectionListener(new SelectionListener() {

                        public void widgetSelected(SelectionEvent e) {
                            includeUnversioned = includeUnversionedButton.getSelection();
                            if (!includeUnversioned) {
                                resourceSelectionTree.removeUnversioned();
                            } else {
                                resourceSelectionTree.addUnversioned();
                            }
                            selectedResources = resourceSelectionTree.getSelectedResources();
                            setPageComplete(canFinish());
                            if (!fromSyncView)
                                updatePreference(includeUnversioned);
                        }

                        public void widgetDefaultSelected(SelectionEvent e) {
                        }
                    });
                    return includeUnversionedButton;
                }
            });
        }

        public int getControlCount() {
            return 1;
        }
    };
    IResource[] dedupedResourcesToRevert = ResourceSelectionTree.dedupeResources(resourcesToRevert);
    if (dedupedResourcesToRevert.length != resourcesToRevert.length) {
        resourceRemoved = true;
    }
    resourceSelectionTree = new ResourceSelectionTree(composite, SWT.NONE, Policy.bind("GenerateSVNDiff.Changes"), dedupedResourcesToRevert, statusMap, null, true, toolbarControlCreator, // $NON-NLS-1$
    null);
    if (!resourceSelectionTree.showIncludeUnversionedButton())
        includeUnversionedButton.setVisible(false);
    // resourceSelectionTree.getTreeViewer().setAllChecked(true);
    resourceSelectionTree.getTreeViewer().addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            selectedResources = resourceSelectionTree.getSelectedResources();
        }
    });
    ((CheckboxTreeViewer) resourceSelectionTree.getTreeViewer()).addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            selectedResources = resourceSelectionTree.getSelectedResources();
        }
    });
    resourceSelectionTree.getTreeViewer().addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection sel = (IStructuredSelection) event.getSelection();
            Object sel0 = sel.getFirstElement();
            if (sel0 instanceof IFile) {
                final ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor((IFile) sel0);
                try {
                    new CompareDialog(getShell(), new SVNLocalCompareInput(localResource, SVNRevision.BASE, true)).open();
                } catch (Exception e1) {
                }
            }
        }
    });
    if (!includeUnversioned) {
        resourceSelectionTree.removeUnversioned();
    }
    resourceSelectionTree.getTreeViewer().getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    // Composite composite_1 = new Composite(composite, SWT.NONE);
    // composite_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
    // composite_1.setLayout(new GridLayout());
    selectedResources = resourceSelectionTree.getSelectedResources();
    setPageComplete(canFinish());
    PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.REVERT_DIALOG);
}
Also used : IFile(org.eclipse.core.resources.IFile) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) ToolBarManager(org.eclipse.jface.action.ToolBarManager) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) ResourceSelectionTree(org.tigris.subversion.subclipse.ui.util.ResourceSelectionTree) Button(org.eclipse.swt.widgets.Button) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SVNLocalCompareInput(org.tigris.subversion.subclipse.ui.compare.SVNLocalCompareInput) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) CompareDialog(org.tigris.subversion.subclipse.ui.dialogs.CompareDialog) GridData(org.eclipse.swt.layout.GridData) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) IResource(org.eclipse.core.resources.IResource) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 23 with ISVNLocalResource

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

the class BranchTagWizardRepositoryPage method createControl.

public void createControl(Composite parent) {
    resources = ((BranchTagWizard) getWizard()).getResources();
    remoteResources = ((BranchTagWizard) getWizard()).getRemoteResources();
    Composite outerContainer = new Composite(parent, SWT.NONE);
    GridLayout outerLayout = new GridLayout();
    outerLayout.numColumns = 1;
    outerLayout.marginHeight = 0;
    outerLayout.marginWidth = 0;
    outerContainer.setLayout(outerLayout);
    outerContainer.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
    Group repositoryGroup = new Group(outerContainer, SWT.NULL);
    // $NON-NLS-1$
    repositoryGroup.setText(Policy.bind("BranchTagDialog.repository"));
    repositoryGroup.setLayout(new GridLayout());
    GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
    repositoryGroup.setLayoutData(data);
    if (multipleSelections()) {
        ArrayList urlArray = new ArrayList();
        if (resources == null) {
            for (int i = 0; i < remoteResources.length; i++) {
                urlArray.add(remoteResources[i].getUrl());
            }
        } else {
            for (int i = 0; i < resources.length; i++) {
                ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
                try {
                    SVNUrl url = svnResource.getStatus().getUrl();
                    if (url != null) {
                        urlArray.add(url);
                    }
                } catch (SVNException e1) {
                }
            }
        }
        urls = new SVNUrl[urlArray.size()];
        urlArray.toArray(urls);
    } else {
        if (resources == null) {
            urls = new SVNUrl[1];
            urls[0] = remoteResources[0].getUrl();
        } else {
            svnResources = new ISVNLocalResource[1];
            svnResources[0] = SVNWorkspaceRoot.getSVNResourceFor(resources[0]);
            try {
                urls = new SVNUrl[1];
                urls[0] = svnResources[0].getStatus().getUrl();
            } catch (SVNException e1) {
            }
        }
    }
    Label toUrlLabel = new Label(repositoryGroup, SWT.NONE);
    // $NON-NLS-1$
    toUrlLabel.setText(Policy.bind("BranchTagDialog.toUrl"));
    Composite urlComposite = new Composite(repositoryGroup, SWT.NULL);
    GridLayout urlLayout = new GridLayout();
    urlLayout.numColumns = 2;
    urlLayout.marginWidth = 0;
    urlLayout.marginHeight = 0;
    urlComposite.setLayout(urlLayout);
    data = new GridData(SWT.FILL, SWT.FILL, true, false);
    urlComposite.setLayoutData(data);
    toUrlCombo = new UrlCombo(urlComposite, SWT.NONE);
    toUrlCombo.init(resources == null ? "repositoryBrowser" : // $NON-NLS-1$
    resources[0].getProject().getName());
    toUrlCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    toUrlCombo.setText(getCommonRoot());
    toUrlCombo.getCombo().addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            setPageComplete(canFinish());
        }
    });
    Button browseButton = new Button(urlComposite, SWT.PUSH);
    // $NON-NLS-1$
    browseButton.setText(Policy.bind("SwitchDialog.browse"));
    browseButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            IResource resource = null;
            if (resources != null && resources.length > 0)
                resource = resources[0];
            ChooseUrlDialog dialog = new ChooseUrlDialog(getShell(), resource);
            if ((dialog.open() == ChooseUrlDialog.OK) && (dialog.getUrl() != null)) {
                toUrlCombo.setText(dialog.getUrl());
            }
        }
    });
    makeParentsButton = new Button(urlComposite, SWT.CHECK);
    // $NON-NLS-1$
    makeParentsButton.setText(Policy.bind("BranchTagDialog.makeParents"));
    data = new GridData();
    data.horizontalSpan = 2;
    makeParentsButton.setLayoutData(data);
    makeParentsButton.setSelection(// $NON-NLS-1$
    settings.getBoolean("BranchTagDialog.makeParents"));
    makeParentsButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            settings.put("BranchTagDialog.makeParents", // $NON-NLS-1$
            makeParentsButton.getSelection());
        }
    });
    if (multipleSelections() && !sameParents()) {
        sameStructureButton = new Button(urlComposite, SWT.CHECK);
        // $NON-NLS-1$
        sameStructureButton.setText(Policy.bind("BranchTagDialog.sameStructure"));
        data = new GridData();
        data.horizontalSpan = 2;
        sameStructureButton.setLayoutData(data);
        sameStructureButton.setSelection(// $NON-NLS-1$
        settings.getBoolean("BranchTagDialog.sameStructure"));
        sameStructureButton.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                settings.put("BranchTagDialog.sameStructure", // $NON-NLS-1$
                sameStructureButton.getSelection());
                viewer.refresh();
            }
        });
    }
    // Label label = new Label(outerContainer, SWT.NONE);
    // label.setText(Policy.bind("BranchTagDialog.resources"));
    table = new Table(outerContainer, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    // table.setLinesVisible(false);
    table.setHeaderVisible(true);
    data = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
    data.heightHint = 75;
    table.setLayoutData(data);
    TableLayout tableLayout = new TableLayout();
    table.setLayout(tableLayout);
    viewer = new TableViewer(table);
    viewer.setContentProvider(new BranchContentProvider());
    ILabelDecorator decorator = PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator();
    viewer.setLabelProvider(new TableDecoratingLabelProvider(new BranchLabelProvider(), decorator));
    for (int i = 0; i < columnHeaders.length; i++) {
        tableLayout.addColumnData(columnLayouts[i]);
        TableColumn tc = new TableColumn(table, SWT.NONE, i);
        tc.setResizable(columnLayouts[i].resizable);
        tc.setText(columnHeaders[i]);
    }
    viewer.setInput(this);
    toUrlCombo.getCombo().addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            viewer.refresh();
        }
    });
    toUrlCombo.getCombo().setFocus();
    setPageComplete(canFinish());
    setControl(outerContainer);
}
Also used : Group(org.eclipse.swt.widgets.Group) ModifyListener(org.eclipse.swt.events.ModifyListener) UrlCombo(org.tigris.subversion.subclipse.ui.util.UrlCombo) ArrayList(java.util.ArrayList) Label(org.eclipse.swt.widgets.Label) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) ChooseUrlDialog(org.tigris.subversion.subclipse.ui.dialogs.ChooseUrlDialog) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableLayout(org.eclipse.jface.viewers.TableLayout) ILabelDecorator(org.eclipse.jface.viewers.ILabelDecorator) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableColumn(org.eclipse.swt.widgets.TableColumn) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer) IResource(org.eclipse.core.resources.IResource)

Example 24 with ISVNLocalResource

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

the class BranchTagWizardRepositoryPage method getCommonRoot.

public String getCommonRoot() {
    if (commonRoot != null)
        return commonRoot;
    ArrayList urlList = new ArrayList();
    if (resources == null) {
        for (int i = 0; i < remoteResources.length; i++) {
            urlList.add(remoteResources[i].getUrl().toString());
        }
    } else {
        for (int i = 0; i < resources.length; i++) {
            ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
            try {
                String anUrl = svnResource.getStatus().getUrlString();
                if (anUrl != null)
                    urlList.add(anUrl);
            } catch (SVNException e1) {
            }
        }
    }
    String[] urlStrings = new String[urlList.size()];
    urlList.toArray(urlStrings);
    if (urlStrings.length == 0)
        return null;
    String urlString = urlStrings[0];
    tag1: for (int i = 0; i < urlString.length(); i++) {
        String partialPath = urlString.substring(0, i + 1);
        if (partialPath.endsWith("/")) {
            for (int j = 1; j < urlStrings.length; j++) {
                if (!urlStrings[j].startsWith(partialPath))
                    break tag1;
            }
            commonRoot = partialPath.substring(0, i);
        }
    }
    if (resources == null) {
        branchResources = new BranchResource[remoteResources.length];
        for (int i = 0; i < remoteResources.length; i++) {
            branchResources[i] = new BranchResource(remoteResources[i], urlStrings[i].substring(commonRoot.length() + 1));
        }
    } else {
        branchResources = new BranchResource[resources.length];
        for (int i = 0; i < resources.length; i++) {
            branchResources[i] = new BranchResource(resources[i], urlStrings[i].substring(commonRoot.length() + 1));
        }
    }
    if (urlStrings.length == 1) {
        return urlString;
    }
    return commonRoot;
}
Also used : ArrayList(java.util.ArrayList) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource)

Example 25 with ISVNLocalResource

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

the class ShowHistorySynchronizeAction method getSubscriberOperation.

protected SynchronizeModelOperation getSubscriberOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) {
    ISynchronizeModelElement element = (ISynchronizeModelElement) getStructuredSelection().getFirstElement();
    IResource resource = element.getResource();
    if (!resource.exists()) {
        try {
            ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
            return new ShowHistorySynchronizeOperation(configuration, elements, svnResource.getLatestRemoteResource());
        } catch (SVNException e) {
            SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
        }
    }
    return new ShowHistorySynchronizeOperation(configuration, elements, resource);
}
Also used : ISynchronizeModelElement(org.eclipse.team.ui.synchronize.ISynchronizeModelElement) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IResource(org.eclipse.core.resources.IResource)

Aggregations

ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)120 IResource (org.eclipse.core.resources.IResource)77 SVNException (org.tigris.subversion.subclipse.core.SVNException)76 ArrayList (java.util.ArrayList)39 CoreException (org.eclipse.core.runtime.CoreException)24 Iterator (java.util.Iterator)20 IFile (org.eclipse.core.resources.IFile)20 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)20 InvocationTargetException (java.lang.reflect.InvocationTargetException)18 List (java.util.List)18 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)18 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)17 LocalResourceStatus (org.tigris.subversion.subclipse.core.resources.LocalResourceStatus)17 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)17 File (java.io.File)16 TeamException (org.eclipse.team.core.TeamException)16 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)15 ISynchronizeModelElement (org.eclipse.team.ui.synchronize.ISynchronizeModelElement)14 IContainer (org.eclipse.core.resources.IContainer)13 SyncInfo (org.eclipse.team.core.synchronize.SyncInfo)11