Search in sources :

Example 61 with ISVNRemoteResource

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

the class SVNHistoryPage method getCreateTagFromRevisionChangedPathAction.

private IAction getCreateTagFromRevisionChangedPathAction() {
    if (createTagFromRevisionChangedPathAction == null) {
        createTagFromRevisionChangedPathAction = new // $NON-NLS-1$
        Action() {

            public void run() {
                SVNRevision selectedRevision = null;
                ISelection selection = changePathsViewer.getSelection();
                if (!(selection instanceof IStructuredSelection))
                    return;
                IStructuredSelection sel = (IStructuredSelection) selection;
                ISVNRemoteResource remoteResource = null;
                if (sel.getFirstElement() instanceof LogEntryChangePath) {
                    try {
                        remoteResource = ((LogEntryChangePath) sel.getFirstElement()).getRemoteResource();
                        selectedRevision = remoteResource.getRevision();
                    } catch (SVNException e) {
                    }
                } else if (sel.getFirstElement() instanceof HistoryFolder) {
                    HistoryFolder historyFolder = (HistoryFolder) sel.getFirstElement();
                    Object[] children = historyFolder.getChildren();
                    if (children != null && children.length > 0 && children[0] instanceof LogEntryChangePath) {
                        LogEntryChangePath changePath = (LogEntryChangePath) children[0];
                        try {
                            remoteResource = changePath.getRemoteResource().getRepository().getRemoteFolder(historyFolder.getPath());
                            selectedRevision = getSelectedRevision();
                        } catch (SVNException e) {
                        }
                    }
                }
                if (remoteResource == null)
                    return;
                ISVNRemoteResource[] remoteResources = { remoteResource };
                BranchTagWizard wizard = new BranchTagWizard(remoteResources);
                wizard.setRevisionNumber(Long.parseLong(selectedRevision.toString()));
                WizardDialog dialog = new ClosableWizardDialog(getSite().getShell(), wizard);
                if (dialog.open() == WizardDialog.OK) {
                    final SVNUrl sourceUrl = wizard.getUrl();
                    final SVNUrl destinationUrl = wizard.getToUrl();
                    final String message = wizard.getComment();
                    final SVNRevision revision = wizard.getRevision();
                    final boolean makeParents = wizard.isMakeParents();
                    try {
                        BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {

                            public void run() {
                                ISVNClientAdapter client = null;
                                try {
                                    client = SVNProviderPlugin.getPlugin().getSVNClientManager().getSVNClient();
                                    client.copy(sourceUrl, destinationUrl, message, revision, makeParents);
                                    SVNUIPlugin.getPlugin().getRepositoryManager().resourceCreated(null, null);
                                } catch (Exception e) {
                                    MessageDialog.openError(getSite().getShell(), Policy.bind("HistoryView.createTagFromRevision"), // $NON-NLS-1$
                                    e.getMessage());
                                } finally {
                                    SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
                                }
                            }
                        });
                    } catch (Exception e) {
                        MessageDialog.openError(getSite().getShell(), Policy.bind("HistoryView.createTagFromRevision"), // $NON-NLS-1$
                        e.getMessage());
                    }
                }
            // SvnWizardBranchTagPage branchTagPage = new
            // SvnWizardBranchTagPage(remoteResource);
            // 
            // branchTagPage.setRevisionNumber(Long.parseLong(selectedRevision.toString()));
            // SvnWizard wizard = new SvnWizard(branchTagPage);
            // SvnWizardDialog dialog = new SvnWizardDialog(getSite().getShell(),
            // wizard);
            // wizard.setParentDialog(dialog);
            // if (!(dialog.open() == SvnWizardDialog.OK)) return;
            // final SVNUrl sourceUrl = branchTagPage.getUrl();
            // final SVNUrl destinationUrl = branchTagPage.getToUrl();
            // final String message = branchTagPage.getComment();
            // final SVNRevision revision = branchTagPage.getRevision();
            // final boolean makeParents = branchTagPage.isMakeParents();
            // try {
            // BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
            // public void run() {
            // try {
            // ISVNClientAdapter client =
            // SVNProviderPlugin.getPlugin().getSVNClientManager().createSVNClient();
            // client.copy(sourceUrl, destinationUrl, message, revision,
            // makeParents);
            // } catch(Exception e) {
            // MessageDialog.openError(getSite().getShell(),
            // Policy.bind("HistoryView.createTagFromRevision"), e
            // .getMessage());
            // }
            // }
            // });
            // } catch(Exception e) {
            // MessageDialog.openError(getSite().getShell(),
            // Policy.bind("HistoryView.createTagFromRevision"), e
            // .getMessage());
            // }
            }
        };
    }
    ISelection selection = changePathsViewer.getSelection();
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection sel = (IStructuredSelection) selection;
        SVNRevision selectedRevision = null;
        if (sel.size() == 1) {
            // ISVNRemoteResource remoteResource = null;
            if (sel.getFirstElement() instanceof LogEntryChangePath && ((LogEntryChangePath) sel.getFirstElement()).getAction() != 'D') {
                // try {
                // remoteResource = ((LogEntryChangePath)sel.getFirstElement()).getRemoteResource();
                selectedRevision = ((LogEntryChangePath) sel.getFirstElement()).getRevision();
            // selectedRevision = remoteResource.getRevision();
            // } catch (SVNException e) {}
            } else if (sel.getFirstElement() instanceof HistoryFolder) {
                HistoryFolder historyFolder = (HistoryFolder) sel.getFirstElement();
                Object[] children = historyFolder.getChildren();
                if (children != null && children.length > 0 && children[0] instanceof LogEntryChangePath) {
                    selectedRevision = getSelectedRevision();
                }
            }
            createTagFromRevisionChangedPathAction.setEnabled(selectedRevision != null);
            if (selectedRevision == null) {
                createTagFromRevisionChangedPathAction.setText(Policy.bind("HistoryView.createTagFromRevision", // $NON-NLS-1$ //$NON-NLS-2$
                "" + ((LogEntryChangePath) sel.getFirstElement()).getRevision()));
            } else {
                createTagFromRevisionChangedPathAction.setText(Policy.bind("HistoryView.createTagFromRevision", // $NON-NLS-1$ //$NON-NLS-2$
                "" + selectedRevision));
            }
        }
    }
    createTagFromRevisionChangedPathAction.setImageDescriptor(SVNUIPlugin.getPlugin().getImageDescriptor(ISVNUIConstants.IMG_MENU_BRANCHTAG));
    return createTagFromRevisionChangedPathAction;
}
Also used : LogEntryChangePath(org.tigris.subversion.subclipse.core.history.LogEntryChangePath) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) SVNException(org.tigris.subversion.subclipse.core.SVNException) CoreException(org.eclipse.core.runtime.CoreException) SVNException(org.tigris.subversion.subclipse.core.SVNException) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) ParseException(java.text.ParseException) BranchTagWizard(org.tigris.subversion.subclipse.ui.wizards.BranchTagWizard) IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) ISelection(org.eclipse.jface.viewers.ISelection) ClosableWizardDialog(org.tigris.subversion.subclipse.ui.wizards.ClosableWizardDialog) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) WizardDialog(org.eclipse.jface.wizard.WizardDialog) ClosableWizardDialog(org.tigris.subversion.subclipse.ui.wizards.ClosableWizardDialog) SvnWizardDialog(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardDialog) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 62 with ISVNRemoteResource

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

the class SVNHistoryPage method createText.

/**
 * Create the TextViewer for the logEntry comments
 */
protected void createText(Composite parent) {
    // this.textViewer = new TextViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI |
    // SWT.READ_ONLY);
    SourceViewer result = new SourceViewer(parent, null, null, true, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.READ_ONLY);
    result.getTextWidget().setIndent(2);
    result.configure(new TextSourceViewerConfiguration(EditorsUI.getPreferenceStore()) {

        public Map getHyperlinkDetectorTargets(ISourceViewer sourceViewer) {
            return Collections.singletonMap(// $NON-NLS-1$
            "org.eclipse.ui.DefaultTextEditor.Subclipse", new IAdaptable() {

                public Object getAdapter(Class adapter) {
                    if (adapter == IResource.class && getInput() instanceof IResource) {
                        return getInput();
                    } else if (adapter == ISVNRemoteResource.class && getInput() instanceof ISVNRemoteResource) {
                        return getInput();
                    }
                    return Platform.getAdapterManager().getAdapter(SVNHistoryPage.this, adapter);
                }
            });
        }

        public int getHyperlinkStateMask(ISourceViewer sourceViewer) {
            return SWT.NONE;
        }

        public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
            IHyperlinkDetector[] detectors = super.getHyperlinkDetectors(sourceViewer);
            IHyperlinkDetector[] newDetectors;
            if (detectors == null) {
                newDetectors = new IHyperlinkDetector[1];
            } else {
                newDetectors = new IHyperlinkDetector[detectors.length + 1];
                System.arraycopy(detectors, 0, newDetectors, 0, detectors.length);
            }
            newDetectors[newDetectors.length - 1] = new IHyperlinkDetector() {

                public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) {
                    if (linkList == null || !linkList.isLinkAt(region.getOffset())) {
                        return null;
                    }
                    final String linkUrl = linkList.getLinkAt(region.getOffset());
                    final int[] linkRange = linkList.getLinkRange(region.getOffset());
                    return new IHyperlink[] { new IHyperlink() {

                        public IRegion getHyperlinkRegion() {
                            return new Region(linkRange[0], linkRange[1]);
                        }

                        public void open() {
                            try {
                                URL url = new URL(linkUrl);
                                PlatformUI.getWorkbench().getBrowserSupport().createBrowser("Subclipse").openURL(// $NON-NLS-1$
                                url);
                            } catch (Exception e1) {
                                Program.launch(linkUrl);
                            }
                        }

                        public String getHyperlinkText() {
                            return null;
                        }

                        public String getTypeLabel() {
                            return null;
                        }
                    } };
                }
            };
            return newDetectors;
        }
    });
    this.textViewer = result;
    this.textViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            copyAction.update();
        }
    });
    Font font = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getFontRegistry().get(ISVNUIConstants.SVN_COMMENT_FONT);
    if (font != null) {
        this.textViewer.getTextWidget().setFont(font);
    }
    // Create actions for the text editor (copy and select all)
    copyAction = new TextViewerAction(this.textViewer, ITextOperationTarget.COPY);
    // $NON-NLS-1$
    copyAction.setText(Policy.bind("HistoryView.copy"));
    selectAllAction = new TextViewerAction(this.textViewer, ITextOperationTarget.SELECT_ALL);
    // $NON-NLS-1$
    selectAllAction.setText(Policy.bind("HistoryView.selectAll"));
    IHistoryPageSite parentSite = getHistoryPageSite();
    IPageSite pageSite = parentSite.getWorkbenchPageSite();
    IActionBars actionBars = pageSite.getActionBars();
    actionBars.setGlobalActionHandler(ITextEditorActionConstants.COPY, copyAction);
    actionBars.setGlobalActionHandler(ITextEditorActionConstants.SELECT_ALL, selectAllAction);
    actionBars.updateActionBars();
    // Contribute actions to popup menu for the comments area
    {
        MenuManager menuMgr = new MenuManager();
        menuMgr.setRemoveAllWhenShown(true);
        menuMgr.addMenuListener(new IMenuListener() {

            public void menuAboutToShow(IMenuManager menuMgr) {
                menuMgr.add(copyAction);
                menuMgr.add(selectAllAction);
            }
        });
        StyledText text = this.textViewer.getTextWidget();
        Menu menu = menuMgr.createContextMenu(text);
        text.setMenu(menu);
    }
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) SourceViewer(org.eclipse.jface.text.source.SourceViewer) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) IPageSite(org.eclipse.ui.part.IPageSite) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IHistoryPageSite(org.eclipse.team.ui.history.IHistoryPageSite) IRegion(org.eclipse.jface.text.IRegion) URL(java.net.URL) Font(org.eclipse.swt.graphics.Font) Menu(org.eclipse.swt.widgets.Menu) IActionBars(org.eclipse.ui.IActionBars) TextSourceViewerConfiguration(org.eclipse.ui.editors.text.TextSourceViewerConfiguration) StyledText(org.eclipse.swt.custom.StyledText) IHyperlinkDetector(org.eclipse.jface.text.hyperlink.IHyperlinkDetector) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) TextViewerAction(org.tigris.subversion.subclipse.ui.console.TextViewerAction) CoreException(org.eclipse.core.runtime.CoreException) SVNException(org.tigris.subversion.subclipse.core.SVNException) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) ParseException(java.text.ParseException) IMenuListener(org.eclipse.jface.action.IMenuListener) ITextViewer(org.eclipse.jface.text.ITextViewer) IHyperlink(org.eclipse.jface.text.hyperlink.IHyperlink) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Region(org.eclipse.jface.text.Region) IRegion(org.eclipse.jface.text.IRegion) IMenuManager(org.eclipse.jface.action.IMenuManager) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) Map(java.util.Map) IResource(org.eclipse.core.resources.IResource)

Example 63 with ISVNRemoteResource

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

the class SVNHistoryPageSource method canShowHistoryFor.

public boolean canShowHistoryFor(Object object) {
    if (object instanceof IResource) {
        IResource resource = (IResource) object;
        ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
        if (localResource != null) {
            try {
                if (!localResource.isManaged()) {
                    return false;
                }
                if (localResource.isAdded() && !localResource.getStatus().isCopied()) {
                    return false;
                }
            } catch (Exception e) {
                SVNUIPlugin.log(Status.ERROR, e.getMessage(), e);
            }
        }
    }
    return (object instanceof IResource && ((IResource) object).getType() != IResource.ROOT) || (object instanceof ISVNRemoteResource);
}
Also used : ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IResource(org.eclipse.core.resources.IResource)

Example 64 with ISVNRemoteResource

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

the class ComparePropertiesDialog method createDialogArea.

protected Control createDialogArea(Composite parent) {
    // $NON-NLS-1$
    getShell().setText(Policy.bind("ComparePropertiesDialog.1"));
    Composite composite = new Composite(parent, SWT.NULL);
    composite.setLayout(new GridLayout());
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    Group fromGroup = new Group(composite, SWT.NULL);
    // $NON-NLS-1$
    fromGroup.setText(Policy.bind("ShowDifferencesAsUnifiedDiffDialog.compareFrom"));
    GridLayout fromLayout = new GridLayout();
    fromLayout.numColumns = 3;
    fromGroup.setLayout(fromLayout);
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
    fromGroup.setLayoutData(data);
    fromWorkingCopyButton = new Button(fromGroup, SWT.RADIO);
    // $NON-NLS-1$
    fromWorkingCopyButton.setText(Policy.bind("ComparePropertiesDialog.2"));
    fromWorkingCopyText = new Text(fromGroup, SWT.BORDER | SWT.READ_ONLY);
    data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
    data.widthHint = 600;
    fromWorkingCopyText.setLayoutData(data);
    fromWorkingCopyBrowseButton = new Button(fromGroup, SWT.PUSH);
    // $NON-NLS-1$
    fromWorkingCopyBrowseButton.setText(Policy.bind("ComparePropertiesDialog.3"));
    fromRepositoryButton = new Button(fromGroup, SWT.RADIO);
    // $NON-NLS-1$
    fromRepositoryButton.setText(Policy.bind("ComparePropertiesDialog.4"));
    fromRepositoryText = new Text(fromGroup, SWT.BORDER);
    data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
    data.widthHint = 600;
    fromRepositoryText.setLayoutData(data);
    fromRepositoryBrowseButton = new Button(fromGroup, SWT.PUSH);
    // $NON-NLS-1$
    fromRepositoryBrowseButton.setText(Policy.bind("ComparePropertiesDialog.3"));
    fromHeadButton = new Button(fromGroup, SWT.CHECK);
    data = new GridData();
    data.horizontalSpan = 3;
    fromHeadButton.setLayoutData(data);
    // $NON-NLS-1$
    fromHeadButton.setText(Policy.bind("ComparePropertiesDialog.6"));
    fromHeadButton.setSelection(true);
    Composite fromRevisionGroup = new Composite(fromGroup, SWT.NONE);
    GridLayout fromRevisionLayout = new GridLayout();
    fromRevisionLayout.numColumns = 3;
    fromRevisionLayout.marginHeight = 0;
    fromRevisionLayout.marginWidth = 0;
    fromRevisionGroup.setLayout(fromRevisionLayout);
    data = new GridData();
    data.horizontalSpan = 3;
    fromRevisionGroup.setLayoutData(data);
    fromRevisionLabel = new Label(fromRevisionGroup, SWT.NONE);
    // $NON-NLS-1$
    fromRevisionLabel.setText(Policy.bind("ComparePropertiesDialog.7"));
    fromRevisionLabel.setEnabled(false);
    fromRevisionText = new Text(fromRevisionGroup, SWT.BORDER);
    data = new GridData();
    data.widthHint = 40;
    fromRevisionText.setLayoutData(data);
    fromRevisionText.setEnabled(false);
    fromRevisionBrowseButton = new Button(fromRevisionGroup, SWT.PUSH);
    // $NON-NLS-1$
    fromRevisionBrowseButton.setText(Policy.bind("ComparePropertiesDialog.3"));
    fromRevisionBrowseButton.setEnabled(false);
    Group toGroup = new Group(composite, SWT.NULL);
    // $NON-NLS-1$
    toGroup.setText(Policy.bind("ShowDifferencesAsUnifiedDiffDialog.compareTo"));
    GridLayout toLayout = new GridLayout();
    toLayout.numColumns = 3;
    toGroup.setLayout(toLayout);
    data = new GridData(SWT.FILL, SWT.FILL, true, false);
    toGroup.setLayoutData(data);
    toWorkingCopyButton = new Button(toGroup, SWT.RADIO);
    // $NON-NLS-1$
    toWorkingCopyButton.setText(Policy.bind("ComparePropertiesDialog.2"));
    toWorkingCopyText = new Text(toGroup, SWT.BORDER | SWT.READ_ONLY);
    data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
    data.widthHint = 600;
    toWorkingCopyText.setLayoutData(data);
    toWorkingCopyBrowseButton = new Button(toGroup, SWT.PUSH);
    // $NON-NLS-1$
    toWorkingCopyBrowseButton.setText(Policy.bind("ComparePropertiesDialog.3"));
    toRepositoryButton = new Button(toGroup, SWT.RADIO);
    // $NON-NLS-1$
    toRepositoryButton.setText(Policy.bind("ComparePropertiesDialog.4"));
    toRepositoryText = new Text(toGroup, SWT.BORDER);
    data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
    data.widthHint = 600;
    toRepositoryText.setLayoutData(data);
    toRepositoryBrowseButton = new Button(toGroup, SWT.PUSH);
    // $NON-NLS-1$
    toRepositoryBrowseButton.setText(Policy.bind("ComparePropertiesDialog.3"));
    toHeadButton = new Button(toGroup, SWT.CHECK);
    data = new GridData();
    data.horizontalSpan = 3;
    toHeadButton.setLayoutData(data);
    // $NON-NLS-1$
    toHeadButton.setText(Policy.bind("ComparePropertiesDialog.6"));
    toHeadButton.setSelection(true);
    Composite toRevisionGroup = new Composite(toGroup, SWT.NONE);
    GridLayout toRevisionLayout = new GridLayout();
    toRevisionLayout.numColumns = 3;
    toRevisionLayout.marginHeight = 0;
    toRevisionLayout.marginWidth = 0;
    toRevisionGroup.setLayout(toRevisionLayout);
    data = new GridData();
    data.horizontalSpan = 3;
    toRevisionGroup.setLayoutData(data);
    toRevisionLabel = new Label(toRevisionGroup, SWT.NONE);
    // $NON-NLS-1$
    toRevisionLabel.setText(Policy.bind("ComparePropertiesDialog.7"));
    toRevisionLabel.setEnabled(false);
    toRevisionText = new Text(toRevisionGroup, SWT.BORDER);
    data = new GridData();
    data.widthHint = 40;
    toRevisionText.setLayoutData(data);
    toRevisionText.setEnabled(false);
    toRevisionBrowseButton = new Button(toRevisionGroup, SWT.PUSH);
    // $NON-NLS-1$
    toRevisionBrowseButton.setText(Policy.bind("ComparePropertiesDialog.3"));
    toRevisionBrowseButton.setEnabled(false);
    recursiveButton = new Button(composite, SWT.CHECK);
    // $NON-NLS-1$
    recursiveButton.setText(Policy.bind("ComparePropertiesDialog.16"));
    if (left != null) {
        if (left instanceof PropertyCompareLocalResourceNode) {
            fromWorkingCopyText.setText(((PropertyCompareLocalResourceNode) left).getResource().getFullPath().toString());
            fromWorkingCopyButton.setSelection(true);
            fromRepositoryText.setEnabled(false);
            fromRepositoryBrowseButton.setEnabled(false);
            fromHeadButton.setEnabled(false);
            fromLocalResource = ((PropertyCompareLocalResourceNode) left).getResource();
        } else if (left instanceof PropertyCompareRemoteResourceNode) {
            fromRepositoryText.setText(((PropertyCompareRemoteResourceNode) left).getRemoteResource().getUrl().toString());
            fromRepositoryButton.setSelection(true);
            fromWorkingCopyText.setEnabled(false);
            fromWorkingCopyBrowseButton.setEnabled(false);
            fromHeadButton.setEnabled(true);
        }
    }
    if (right == null) {
        right = left;
    }
    if (right != null) {
        if (right instanceof PropertyCompareLocalResourceNode) {
            toWorkingCopyText.setText(((PropertyCompareLocalResourceNode) right).getResource().getFullPath().toString());
            toWorkingCopyButton.setSelection(true);
            toRepositoryText.setEnabled(false);
            toRepositoryBrowseButton.setEnabled(false);
            toHeadButton.setEnabled(false);
            repository = SVNWorkspaceRoot.getSVNResourceFor(((PropertyCompareLocalResourceNode) right).getResource()).getRepository();
            toLocalResource = ((PropertyCompareLocalResourceNode) right).getResource();
        } else if (right instanceof PropertyCompareRemoteResourceNode) {
            toRepositoryText.setText(((PropertyCompareRemoteResourceNode) right).getRemoteResource().getUrl().toString());
            toRepositoryButton.setSelection(true);
            toWorkingCopyText.setEnabled(false);
            toWorkingCopyBrowseButton.setEnabled(false);
            toHeadButton.setEnabled(true);
            repository = ((PropertyCompareRemoteResourceNode) right).getRemoteResource().getRepository();
        }
    }
    ModifyListener modifyListener = new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            okButton.setEnabled(canFinish());
        }
    };
    fromWorkingCopyText.addModifyListener(modifyListener);
    fromRepositoryText.addModifyListener(modifyListener);
    fromRevisionText.addModifyListener(modifyListener);
    toWorkingCopyText.addModifyListener(modifyListener);
    toRepositoryText.addModifyListener(modifyListener);
    toRevisionText.addModifyListener(modifyListener);
    SelectionListener selectionListener = new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            if (e.getSource() == fromWorkingCopyBrowseButton || e.getSource() == toWorkingCopyBrowseButton) {
                ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new BaseWorkbenchContentProvider());
                // $NON-NLS-1$
                dialog.setTitle(Policy.bind("ComparePropertiesDialog.1"));
                // $NON-NLS-1$
                dialog.setMessage(Policy.bind("ComparePropertiesDialog.18"));
                dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
                if (dialog.open() != ElementTreeSelectionDialog.CANCEL) {
                    Object result = dialog.getFirstResult();
                    if (result instanceof IResource) {
                        if (e.getSource() == fromWorkingCopyBrowseButton) {
                            fromWorkingCopyText.setText(((IResource) result).getFullPath().toString());
                            fromLocalResource = (IResource) result;
                        } else {
                            toWorkingCopyText.setText(((IResource) result).getFullPath().toString());
                            toLocalResource = (IResource) result;
                        }
                    }
                }
            } else if (e.getSource() == fromRepositoryBrowseButton || e.getSource() == toRepositoryBrowseButton) {
                ChooseUrlDialog dialog = new ChooseUrlDialog(getShell(), null);
                dialog.setRepositoryLocation(repository);
                if (dialog.open() != ChooseUrlDialog.CANCEL) {
                    String url = dialog.getUrl();
                    if (url != null) {
                        if (e.getSource() == fromRepositoryBrowseButton) {
                            fromRepositoryText.setText(url);
                        } else {
                            toRepositoryText.setText(url);
                        }
                    }
                }
            } else if (e.getSource() == fromRevisionBrowseButton || e.getSource() == toRevisionBrowseButton) {
                try {
                    SVNUrl url = null;
                    if (e.getSource() == fromRevisionBrowseButton) {
                        url = new SVNUrl(fromRepositoryText.getText().trim());
                    } else {
                        url = new SVNUrl(toRepositoryText.getText().trim());
                    }
                    ISVNRemoteResource remoteResource = repository.getRemoteFile(url);
                    HistoryDialog dialog = new HistoryDialog(getShell(), remoteResource);
                    if (dialog.open() != HistoryDialog.CANCEL) {
                        ILogEntry[] selectedEntries = dialog.getSelectedLogEntries();
                        if (selectedEntries.length > 0) {
                            if (e.getSource() == fromRevisionBrowseButton) {
                                fromRevisionText.setText(Long.toString(selectedEntries[selectedEntries.length - 1].getRevision().getNumber()));
                            } else {
                                toRevisionText.setText(Long.toString(selectedEntries[selectedEntries.length - 1].getRevision().getNumber()));
                            }
                        }
                    }
                } catch (Exception exc) {
                    MessageDialog.openError(getShell(), Policy.bind("ComparePropertiesDialog.1"), // $NON-NLS-1$
                    exc.getMessage());
                }
            }
            setEnablement();
            okButton.setEnabled(canFinish());
        }
    };
    fromWorkingCopyButton.addSelectionListener(selectionListener);
    fromWorkingCopyBrowseButton.addSelectionListener(selectionListener);
    fromRepositoryButton.addSelectionListener(selectionListener);
    fromRepositoryBrowseButton.addSelectionListener(selectionListener);
    fromHeadButton.addSelectionListener(selectionListener);
    fromRevisionBrowseButton.addSelectionListener(selectionListener);
    toWorkingCopyButton.addSelectionListener(selectionListener);
    toWorkingCopyBrowseButton.addSelectionListener(selectionListener);
    toRepositoryButton.addSelectionListener(selectionListener);
    toRepositoryBrowseButton.addSelectionListener(selectionListener);
    toHeadButton.addSelectionListener(selectionListener);
    toRevisionBrowseButton.addSelectionListener(selectionListener);
    return composite;
}
Also used : PropertyCompareLocalResourceNode(org.tigris.subversion.subclipse.ui.compare.PropertyCompareLocalResourceNode) Group(org.eclipse.swt.widgets.Group) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) ModifyListener(org.eclipse.swt.events.ModifyListener) ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) Label(org.eclipse.swt.widgets.Label) PropertyCompareRemoteResourceNode(org.tigris.subversion.subclipse.ui.compare.PropertyCompareRemoteResourceNode) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) BaseWorkbenchContentProvider(org.eclipse.ui.model.BaseWorkbenchContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Composite(org.eclipse.swt.widgets.Composite) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) ElementTreeSelectionDialog(org.eclipse.ui.dialogs.ElementTreeSelectionDialog) GridData(org.eclipse.swt.layout.GridData) IResource(org.eclipse.core.resources.IResource) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 65 with ISVNRemoteResource

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

the class DifferencesDialog method compare.

private void compare() {
    if (fromResource instanceof ISVNRemoteResource && toResource != null && toResource instanceof ISVNRemoteResource) {
        SVNUrl fromUrl = null;
        SVNUrl toUrl = null;
        SVNRevision fromRevision;
        SVNRevision toRevision;
        if (fromHeadButton.getSelection())
            fromRevision = SVNRevision.HEAD;
        else {
            int fromRevisionInt = Integer.parseInt(fromRevisionText.getText().trim());
            long fromRevisionLong = fromRevisionInt;
            fromRevision = new SVNRevision.Number(fromRevisionLong);
        }
        if (toHeadButton.getSelection())
            toRevision = SVNRevision.HEAD;
        else {
            int toRevisionInt = Integer.parseInt(toRevisionText.getText().trim());
            long toRevisionLong = toRevisionInt;
            toRevision = new SVNRevision.Number(toRevisionLong);
        }
        try {
            fromUrl = new SVNUrl(fromUrlText.getText().trim());
            toUrl = new SVNUrl(toUrlText.getText().trim());
        } catch (Exception e) {
            MessageDialog.openError(getShell(), Policy.bind("DifferencesDialog.compare"), e.getMessage());
            success = false;
            return;
        }
        ISVNRemoteResource resource1 = null;
        SVNRevision.Number lastChangedRevision1 = null;
        ISVNRemoteResource resource2 = null;
        SVNRevision.Number lastChangedRevision2 = null;
        if (fromRevision instanceof SVNRevision.Number) {
            lastChangedRevision1 = (SVNRevision.Number) fromRevision;
        } else {
            lastChangedRevision1 = ((ISVNRemoteResource) remoteResources[0]).getLastChangedRevision();
        }
        if (fromResource.isFolder()) {
            resource1 = new RemoteFolder(null, fromResource.getRepository(), fromUrl, fromRevision, lastChangedRevision1, null, null);
            if (!fromUrl.equals(fromResource.getUrl())) {
                try {
                    resource1.members(null);
                } catch (TeamException e) {
                    resource1 = new RemoteFile(null, fromResource.getRepository(), fromUrl, fromRevision, lastChangedRevision1, null, null);
                }
            }
        } else {
            resource1 = new RemoteFile(null, fromResource.getRepository(), fromUrl, fromRevision, lastChangedRevision1, null, null);
            if (!fromUrl.equals(fromResource.getUrl())) {
                IStorage storage = null;
                try {
                    storage = resource1.getStorage(null);
                } catch (TeamException e) {
                }
                if (storage == null) {
                    resource1 = new RemoteFolder(null, fromResource.getRepository(), fromUrl, fromRevision, lastChangedRevision1, null, null);
                }
            }
        }
        if (fromRevision instanceof SVNRevision.Number) {
            if (usePegRevision && resource1 instanceof RemoteResource) {
                ((RemoteResource) resource1).setPegRevision(fromRevision);
            }
        }
        if (toRevision instanceof SVNRevision.Number) {
            lastChangedRevision2 = (SVNRevision.Number) toRevision;
        } else {
            lastChangedRevision2 = ((ISVNRemoteResource) remoteResources[1]).getLastChangedRevision();
        }
        if (toResource.isFolder()) {
            resource2 = new RemoteFolder(null, toResource.getRepository(), toUrl, toRevision, lastChangedRevision2, null, null);
            if (!toUrl.equals(toResource.getUrl())) {
                try {
                    resource2.members(null);
                } catch (TeamException e) {
                    resource2 = new RemoteFile(null, toResource.getRepository(), toUrl, toRevision, lastChangedRevision2, null, null);
                }
            }
        } else {
            resource2 = new RemoteFile(null, toResource.getRepository(), toUrl, toRevision, lastChangedRevision2, null, null);
            if (!toUrl.equals(toResource.getUrl())) {
                IStorage storage = null;
                try {
                    storage = resource2.getStorage(null);
                } catch (TeamException e) {
                }
                if (storage == null) {
                    resource2 = new RemoteFolder(null, toResource.getRepository(), toUrl, toRevision, lastChangedRevision2, null, null);
                }
            }
        }
        if (toRevision instanceof SVNRevision.Number) {
            if (usePegRevision && resource2 instanceof RemoteResource) {
                ((RemoteResource) resource2).setPegRevision(toRevision);
            }
        }
        ISVNRemoteResource[] remotes = { resource1, resource2 };
        CompareRemoteResourcesAction compareAction = new CompareRemoteResourcesAction();
        compareAction.setLocalResource(localResource);
        compareAction.setRemoteResources(remotes);
        compareAction.setPegRevisions(pegRevisions);
        compareAction.setLocalResources(remoteResources);
        try {
            compareAction.execute(null);
        } catch (InvocationTargetException e) {
            SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
        } catch (InterruptedException e) {
            SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
        }
    }
}
Also used : RemoteResource(org.tigris.subversion.subclipse.core.resources.RemoteResource) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) CompareRemoteResourcesAction(org.tigris.subversion.subclipse.ui.actions.CompareRemoteResourcesAction) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) RemoteFolder(org.tigris.subversion.subclipse.core.resources.RemoteFolder) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) IStorage(org.eclipse.core.resources.IStorage) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) RemoteFile(org.tigris.subversion.subclipse.core.resources.RemoteFile)

Aggregations

ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)69 SVNException (org.tigris.subversion.subclipse.core.SVNException)23 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)21 InvocationTargetException (java.lang.reflect.InvocationTargetException)16 TeamException (org.eclipse.team.core.TeamException)16 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)16 IResource (org.eclipse.core.resources.IResource)15 ILogEntry (org.tigris.subversion.subclipse.core.history.ILogEntry)14 ArrayList (java.util.ArrayList)12 ParseException (java.text.ParseException)11 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)10 CoreException (org.eclipse.core.runtime.CoreException)9 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)9 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)9 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)8 MalformedURLException (java.net.MalformedURLException)7 ISVNRemoteFolder (org.tigris.subversion.subclipse.core.ISVNRemoteFolder)7 RemoteFile (org.tigris.subversion.subclipse.core.resources.RemoteFile)7 HistoryDialog (org.tigris.subversion.subclipse.ui.dialogs.HistoryDialog)6 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)6