Search in sources :

Example 1 with BranchTagWizard

use of org.tigris.subversion.subclipse.ui.wizards.BranchTagWizard in project subclipse by subclipse.

the class BranchTagAction method run.

public void run() {
    BranchTagWizard wizard;
    final IResource resource = ((RevisionGraphEditorInput) editor.getEditorInput()).getResource();
    ISVNRemoteResource remoteResource = ((RevisionGraphEditorInput) editor.getEditorInput()).getRemoteResource();
    if (resource == null) {
        ISVNRemoteResource[] resources = { remoteResource };
        wizard = new BranchTagWizard(resources);
    } else {
        IResource[] resources = { resource };
        wizard = new BranchTagWizard(resources);
    }
    wizard.setRevisionNumber(node.getRevision());
    WizardDialog dialog = new ClosableWizardDialog(Display.getDefault().getActiveShell(), 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();
        final SVNUrl[] sourceUrls = wizard.getUrls();
        final boolean createOnServer = wizard.isCreateOnServer();
        final Alias newAlias = wizard.getNewAlias();
        final boolean switchAfter = wizard.isSwitchAfterBranchTag();
        try {
            BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {

                public void run() {
                    ISVNClientAdapter client = null;
                    try {
                        if (resource == null) {
                            client = SVNProviderPlugin.getPlugin().getSVNClientManager().getSVNClient();
                            client.copy(sourceUrl, destinationUrl, message, revision, makeParents);
                        } else {
                            IResource[] resources = { resource };
                            BranchTagOperation branchTagOperation = new BranchTagOperation(editor.getEditorSite().getPart(), resources, sourceUrls, destinationUrl, createOnServer, revision, message);
                            branchTagOperation.setMakeParents(makeParents);
                            branchTagOperation.setNewAlias(newAlias);
                            branchTagOperation.switchAfterTagBranchOperation(switchAfter);
                            branchTagOperation.run();
                        }
                    } catch (Exception e) {
                        MessageDialog.openError(Display.getDefault().getActiveShell(), Policy.bind("HistoryView.createTagFromRevision"), e.getMessage());
                    } finally {
                        SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
                    }
                }
            });
        } catch (Exception e) {
            MessageDialog.openError(Display.getDefault().getActiveShell(), Policy.bind("HistoryView.createTagFromRevision"), e.getMessage());
        }
    }
}
Also used : SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) RevisionGraphEditorInput(org.tigris.subversion.subclipse.graph.editors.RevisionGraphEditorInput) BranchTagWizard(org.tigris.subversion.subclipse.ui.wizards.BranchTagWizard) Alias(org.tigris.subversion.subclipse.core.history.Alias) BranchTagOperation(org.tigris.subversion.subclipse.ui.operations.BranchTagOperation) ClosableWizardDialog(org.tigris.subversion.subclipse.ui.wizards.ClosableWizardDialog) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) ClosableWizardDialog(org.tigris.subversion.subclipse.ui.wizards.ClosableWizardDialog) WizardDialog(org.eclipse.jface.wizard.WizardDialog) IResource(org.eclipse.core.resources.IResource) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 2 with BranchTagWizard

use of org.tigris.subversion.subclipse.ui.wizards.BranchTagWizard in project subclipse by subclipse.

the class RepositoryBranchTagAction method execute.

protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
    ISVNRemoteResource[] resources = getSelectedRemoteResources();
    BranchTagWizard wizard = new BranchTagWizard(resources);
    WizardDialog dialog = // $NON-NLS-1$
    new SizePersistedWizardDialog(getShell(), wizard, "BranchTag");
    if (dialog.open() == WizardDialog.OK) {
        SVNUrl[] sourceUrls = wizard.getUrls();
        SVNUrl destinationUrl = wizard.getToUrl();
        String message = wizard.getComment();
        SVNRevision revision = wizard.getRevision();
        boolean makeParents = wizard.isMakeParents();
        ISVNClientAdapter client = null;
        try {
            ISVNRepositoryLocation repository = SVNProviderPlugin.getPlugin().getRepository(sourceUrls[0].toString());
            if (repository != null)
                client = repository.getSVNClient();
            if (client == null)
                client = SVNProviderPlugin.getPlugin().getSVNClientManager().getSVNClient();
            RepositoryBranchTagOperation branchTagOperation = new RepositoryBranchTagOperation(getTargetPart(), client, sourceUrls, destinationUrl, revision, message, makeParents);
            branchTagOperation.setMultipleTransactions(wizard.isSameStructure());
            branchTagOperation.run();
        } catch (Exception e) {
            MessageDialog.openError(getShell(), Policy.bind("BranchTagDialog.title"), e.getMessage());
        } finally {
        // BranchTagCommand will dispose.
        // SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
        }
    }
}
Also used : SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) RepositoryBranchTagOperation(org.tigris.subversion.subclipse.ui.operations.RepositoryBranchTagOperation) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) BranchTagWizard(org.tigris.subversion.subclipse.ui.wizards.BranchTagWizard) SizePersistedWizardDialog(org.tigris.subversion.subclipse.ui.wizards.SizePersistedWizardDialog) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) WizardDialog(org.eclipse.jface.wizard.WizardDialog) SizePersistedWizardDialog(org.tigris.subversion.subclipse.ui.wizards.SizePersistedWizardDialog) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 3 with BranchTagWizard

use of org.tigris.subversion.subclipse.ui.wizards.BranchTagWizard in project subclipse by subclipse.

the class BranchTagAction method execute.

protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
    if (action != null && !action.isEnabled()) {
        action.setEnabled(true);
    } else {
        IResource[] resources = getSelectedResources();
        BranchTagWizard wizard = new BranchTagWizard(resources);
        SizePersistedWizardDialog dialog = // $NON-NLS-1$
        new SizePersistedWizardDialog(getShell(), wizard, "BranchTag");
        wizard.setParentDialog(dialog);
        if (dialog.open() == WizardDialog.OK) {
            SVNUrl[] sourceUrls = wizard.getUrls();
            SVNUrl destinationUrl = wizard.getToUrl();
            String message = wizard.getComment();
            boolean createOnServer = wizard.isCreateOnServer();
            BranchTagOperation branchTagOperation = new BranchTagOperation(getTargetPart(), getSelectedResources(), sourceUrls, destinationUrl, createOnServer, wizard.getRevision(), message);
            branchTagOperation.setMakeParents(wizard.isMakeParents());
            branchTagOperation.setMultipleTransactions(wizard.isSameStructure());
            branchTagOperation.setNewAlias(wizard.getNewAlias());
            branchTagOperation.switchAfterTagBranchOperation(wizard.isSwitchAfterBranchTag());
            branchTagOperation.setSvnExternals(wizard.getSvnExternals());
            branchTagOperation.run();
        }
    }
}
Also used : BranchTagWizard(org.tigris.subversion.subclipse.ui.wizards.BranchTagWizard) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) BranchTagOperation(org.tigris.subversion.subclipse.ui.operations.BranchTagOperation) SizePersistedWizardDialog(org.tigris.subversion.subclipse.ui.wizards.SizePersistedWizardDialog) IResource(org.eclipse.core.resources.IResource)

Example 4 with BranchTagWizard

use of org.tigris.subversion.subclipse.ui.wizards.BranchTagWizard 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 5 with BranchTagWizard

use of org.tigris.subversion.subclipse.ui.wizards.BranchTagWizard in project subclipse by subclipse.

the class SVNHistoryPage method getCreateTagFromRevisionAction.

// get create tag from revision action (context menu)
private IAction getCreateTagFromRevisionAction() {
    if (createTagFromRevisionAction == null) {
        createTagFromRevisionAction = new Action() {

            public void run() {
                ISelection selection = getSelection();
                if (!(selection instanceof IStructuredSelection))
                    return;
                ILogEntry currentSelection = getLogEntry((IStructuredSelection) selection);
                BranchTagWizard wizard;
                if (resource == null) {
                    ISVNRemoteResource[] remoteResources = { historyTableProvider.getRemoteResource() };
                    wizard = new BranchTagWizard(remoteResources);
                } else {
                    IResource[] resources = { resource };
                    wizard = new BranchTagWizard(resources);
                }
                wizard.setRevisionNumber(currentSelection.getRevision().getNumber());
                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();
                    boolean createOnServer = wizard.isCreateOnServer();
                    IResource[] resources = { resource };
                    try {
                        if (resource == null) {
                            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);
                                    }
                                }
                            });
                        } else {
                            BranchTagOperation branchTagOperation = new BranchTagOperation(getSite().getPage().getActivePart(), resources, new SVNUrl[] { sourceUrl }, destinationUrl, createOnServer, wizard.getRevision(), message);
                            branchTagOperation.setMakeParents(makeParents);
                            branchTagOperation.setNewAlias(wizard.getNewAlias());
                            branchTagOperation.run();
                        }
                    } catch (Exception e) {
                        MessageDialog.openError(getSite().getShell(), Policy.bind("HistoryView.createTagFromRevision"), // $NON-NLS-1$
                        e.getMessage());
                    }
                }
            }
        };
    }
    ISelection selection = getSelection();
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection ss = (IStructuredSelection) selection;
        if (ss.size() == 1) {
            ILogEntry currentSelection = getLogEntry(ss);
            createTagFromRevisionAction.setText(Policy.bind("HistoryView.createTagFromRevision", // $NON-NLS-1$ //$NON-NLS-2$
            "" + currentSelection.getRevision().getNumber()));
        }
    }
    createTagFromRevisionAction.setImageDescriptor(SVNUIPlugin.getPlugin().getImageDescriptor(ISVNUIConstants.IMG_MENU_BRANCHTAG));
    return createTagFromRevisionAction;
}
Also used : CompareRemoteResourcesAction(org.tigris.subversion.subclipse.ui.actions.CompareRemoteResourcesAction) ExportRemoteFolderAction(org.tigris.subversion.subclipse.ui.actions.ExportRemoteFolderAction) ShowDifferencesAsUnifiedDiffAction(org.tigris.subversion.subclipse.ui.actions.ShowDifferencesAsUnifiedDiffAction) TextViewerAction(org.tigris.subversion.subclipse.ui.console.TextViewerAction) ShowAnnotationAction(org.tigris.subversion.subclipse.ui.actions.ShowAnnotationAction) ShowHistoryAction(org.tigris.subversion.subclipse.ui.actions.ShowHistoryAction) WorkspaceAction(org.tigris.subversion.subclipse.ui.actions.WorkspaceAction) IAction(org.eclipse.jface.action.IAction) OpenRemoteFileAction(org.tigris.subversion.subclipse.ui.actions.OpenRemoteFileAction) GenerateChangeLogAction(org.tigris.subversion.subclipse.ui.actions.GenerateChangeLogAction) Action(org.eclipse.jface.action.Action) ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) 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) BranchTagOperation(org.tigris.subversion.subclipse.ui.operations.BranchTagOperation) 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)

Aggregations

BranchTagWizard (org.tigris.subversion.subclipse.ui.wizards.BranchTagWizard)5 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)5 WizardDialog (org.eclipse.jface.wizard.WizardDialog)4 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)4 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 TeamException (org.eclipse.team.core.TeamException)3 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)3 BranchTagOperation (org.tigris.subversion.subclipse.ui.operations.BranchTagOperation)3 ClosableWizardDialog (org.tigris.subversion.subclipse.ui.wizards.ClosableWizardDialog)3 ParseException (java.text.ParseException)2 IResource (org.eclipse.core.resources.IResource)2 IWorkspaceRunnable (org.eclipse.core.resources.IWorkspaceRunnable)2 CoreException (org.eclipse.core.runtime.CoreException)2 ISelection (org.eclipse.jface.viewers.ISelection)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 PartInitException (org.eclipse.ui.PartInitException)2 SVNException (org.tigris.subversion.subclipse.core.SVNException)2 SizePersistedWizardDialog (org.tigris.subversion.subclipse.ui.wizards.SizePersistedWizardDialog)2 SvnWizardDialog (org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardDialog)2