Search in sources :

Example 16 with SVNURL

use of org.tmatesoft.svn.core.SVNURL in project intellij-community by JetBrains.

the class RepositoryBrowserDialog method createBrowserComponent.

public JComponent createBrowserComponent(final boolean toolWindow) {
    JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    GridBagConstraints gc = new GridBagConstraints();
    gc.gridx = 0;
    gc.gridwidth = 1;
    gc.gridy = 0;
    gc.gridheight = 1;
    gc.gridx = 0;
    gc.gridwidth = 2;
    gc.gridy += 1;
    gc.gridheight = 1;
    gc.weightx = 1;
    gc.weighty = 1;
    gc.fill = GridBagConstraints.BOTH;
    gc.anchor = GridBagConstraints.WEST;
    panel.add(getRepositoryBrowser(), gc);
    gc.gridy += 1;
    gc.weighty = 0;
    gc.fill = GridBagConstraints.HORIZONTAL;
    panel.add(new JLabel(), gc);
    Collection<String> urls = SvnApplicationSettings.getInstance().getCheckoutURLs();
    ArrayList<SVNURL> svnURLs = new ArrayList<>();
    for (final String url : urls) {
        try {
            svnURLs.add(SVNURL.parseURIEncoded(url));
        } catch (SVNException e) {
        //
        }
    }
    getRepositoryBrowser().setRepositoryURLs(svnURLs.toArray(new SVNURL[svnURLs.size()]), myShowFiles);
    getRepositoryBrowser().getRepositoryTree().addMouseListener(new PopupHandler() {

        @Override
        public void invokePopup(Component comp, int x, int y) {
            JTree tree = getRepositoryBrowser().getRepositoryTree();
            int row = tree.getRowForLocation(x, y);
            if (row >= 0) {
                tree.setSelectionRow(row);
            }
            JPopupMenu popupMenu = createPopup(toolWindow);
            if (popupMenu != null) {
                popupMenu.show(comp, x, y);
            }
        }
    });
    return panel;
}
Also used : PopupHandler(com.intellij.ui.PopupHandler) SVNURL(org.tmatesoft.svn.core.SVNURL) ArrayList(java.util.ArrayList) SVNException(org.tmatesoft.svn.core.SVNException)

Example 17 with SVNURL

use of org.tmatesoft.svn.core.SVNURL in project intellij-community by JetBrains.

the class ElementWithBranchComparer method resolveElementUrl.

@Nullable
protected SVNURL resolveElementUrl() throws SVNException {
    final SvnFileUrlMapping urlMapping = myVcs.getSvnFileUrlMapping();
    final File file = virtualToIoFile(myVirtualFile);
    final SVNURL fileUrl = urlMapping.getUrlForFile(file);
    if (fileUrl == null) {
        return null;
    }
    final String fileUrlString = fileUrl.toString();
    final RootUrlInfo rootMixed = urlMapping.getWcRootForUrl(fileUrlString);
    if (rootMixed == null) {
        return null;
    }
    final SVNURL thisBranchForUrl = SvnUtil.getBranchForUrl(myVcs, rootMixed.getVirtualFile(), fileUrlString);
    if (thisBranchForUrl == null) {
        return null;
    }
    final String relativePath = SVNPathUtil.getRelativePath(thisBranchForUrl.toString(), fileUrlString);
    return SVNURL.parseURIEncoded(SVNPathUtil.append(myBranchUrl, relativePath));
}
Also used : SVNURL(org.tmatesoft.svn.core.SVNURL) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) Nullable(org.jetbrains.annotations.Nullable)

Example 18 with SVNURL

use of org.tmatesoft.svn.core.SVNURL in project intellij-community by JetBrains.

the class SetPropertyDialog method fillPropertyNames.

private void fillPropertyNames(File[] files) {
    final Collection<String> names = new TreeSet<>();
    if (files.length == 1) {
        File file = files[0];
        try {
            PropertyConsumer handler = new PropertyConsumer() {

                public void handleProperty(File path, PropertyData property) {
                    String name = property.getName();
                    if (name != null) {
                        names.add(name);
                    }
                }

                public void handleProperty(SVNURL url, PropertyData property) {
                }

                public void handleProperty(long revision, PropertyData property) {
                }
            };
            PropertyClient client = myVCS.getFactory(file).createPropertyClient();
            client.list(SvnTarget.fromFile(file, SVNRevision.WORKING), SVNRevision.WORKING, Depth.EMPTY, handler);
        } catch (VcsException e) {
            LOG.info(e);
        }
    }
    fillProperties(names);
    for (final String name : names) {
        myPropertyNameBox.addItem(name);
    }
}
Also used : PropertyClient(org.jetbrains.idea.svn.properties.PropertyClient) PropertyConsumer(org.jetbrains.idea.svn.properties.PropertyConsumer) PropertyData(org.jetbrains.idea.svn.properties.PropertyData) TreeSet(java.util.TreeSet) SVNURL(org.tmatesoft.svn.core.SVNURL) VcsException(com.intellij.openapi.vcs.VcsException) File(java.io.File)

Example 19 with SVNURL

use of org.tmatesoft.svn.core.SVNURL in project intellij-community by JetBrains.

the class SvnAuthenticationTest method testSavedAndRead.

public void testSavedAndRead() throws Exception {
    final TestListener listener = new TestListener(mySynchObject);
    myAuthenticationManager.addListener(listener);
    final SavedOnceListener savedOnceListener = new SavedOnceListener();
    myAuthenticationManager.addListener(savedOnceListener);
    final SVNURL url = SVNURL.parseURIEncoded("http://some.host.com/repo");
    final SVNException[] exception = new SVNException[1];
    final boolean[] result = { false };
    synchronousBackground(() -> {
        try {
            listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
            listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
            if (SystemInfo.isWindows) {
                listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.save));
            } else {
                listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.without_pasword_save));
            }
            commonScheme(url, false, null);
            Assert.assertEquals(3, listener.getCnt());
            //long start = System.currentTimeMillis();
            //waitListenerStep(start, listener, 3);
            listener.reset();
            if (!SystemInfo.isWindows)
                savedOnceListener.reset();
            SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
            listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
            if (!SystemInfo.isWindows) {
                listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
                listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.without_pasword_save));
            }
            commonScheme(url, false, null);
            //start = System.currentTimeMillis();
            //waitListenerStep(start, listener, 4);
            Assert.assertEquals(SystemInfo.isWindows ? 1 : 3, listener.getCnt());
        } catch (SVNException e) {
            exception[0] = e;
        }
        result[0] = true;
    });
    Assert.assertTrue(result[0]);
    Assert.assertEquals(SystemInfo.isWindows ? 0 : 2, myTestInteraction.getNumPlaintextPrompt());
    Assert.assertEquals(0, myTestInteraction.getNumAuthWarn());
    Assert.assertEquals(0, myTestInteraction.getNumPasswordsWarn());
    Assert.assertEquals(0, myTestInteraction.getNumSSLPlaintextPrompt());
    Assert.assertEquals(0, myTestInteraction.getNumSSLWarn());
    Assert.assertEquals(SystemInfo.isWindows ? 1 : 3, listener.getCnt());
    listener.assertForAwt();
    savedOnceListener.assertForAwt();
    savedOnceListener.assertSaved(url, ISVNAuthenticationManager.PASSWORD);
    if (exception[0] != null) {
        throw exception[0];
    }
}
Also used : SVNURL(org.tmatesoft.svn.core.SVNURL) SVNException(org.tmatesoft.svn.core.SVNException)

Example 20 with SVNURL

use of org.tmatesoft.svn.core.SVNURL in project intellij-community by JetBrains.

the class SvnAuthenticationTest method testWhenNotSaved.

public void testWhenNotSaved() throws Exception {
    final TestListener listener = new TestListener(mySynchObject);
    myAuthenticationManager.addListener(listener);
    final SavedOnceListener savedOnceListener = new SavedOnceListener();
    myAuthenticationManager.addListener(savedOnceListener);
    myInteractiveProvider.setSaveData(false);
    final SVNURL url = SVNURL.parseURIEncoded("http://some.host.com/repo");
    final SVNException[] exception = new SVNException[1];
    final Boolean[] result = new Boolean[1];
    synchronousBackground(() -> {
        try {
            listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
            listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
            commonScheme(url, false, null);
            //long start = System.currentTimeMillis();
            //waitListenerStep(start, listener, 2);
            Assert.assertEquals(2, listener.getCnt());
            savedOnceListener.assertNotSaved(url, ISVNAuthenticationManager.PASSWORD);
            // cause is not cleared though
            savedOnceListener.reset();
            SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
            listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
            listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
            commonScheme(url, false, null);
            Assert.assertEquals(4, listener.getCnt());
        //start = System.currentTimeMillis();
        //waitListenerStep(start, listener, 4);
        } catch (SVNException e) {
            exception[0] = e;
        }
        result[0] = true;
    });
    Assert.assertTrue(result[0]);
    myTestInteraction.assertNothing();
    Assert.assertEquals(4, listener.getCnt());
    listener.assertForAwt();
    savedOnceListener.assertForAwt();
    savedOnceListener.assertNotSaved(url, ISVNAuthenticationManager.PASSWORD);
    if (exception[0] != null) {
        throw exception[0];
    }
}
Also used : SVNURL(org.tmatesoft.svn.core.SVNURL) SVNException(org.tmatesoft.svn.core.SVNException)

Aggregations

SVNURL (org.tmatesoft.svn.core.SVNURL)93 SVNException (org.tmatesoft.svn.core.SVNException)37 File (java.io.File)31 SVNConfigFile (org.tmatesoft.svn.core.internal.wc.SVNConfigFile)15 VirtualFile (com.intellij.openapi.vfs.VirtualFile)13 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)8 VcsException (com.intellij.openapi.vcs.VcsException)7 Nullable (org.jetbrains.annotations.Nullable)7 SVNRevision (org.tmatesoft.svn.core.wc.SVNRevision)7 SvnTarget (org.tmatesoft.svn.core.wc2.SvnTarget)7 ArrayList (java.util.ArrayList)6 NotNull (org.jetbrains.annotations.NotNull)6 Info (org.jetbrains.idea.svn.info.Info)6 SvnBindException (org.jetbrains.idea.svn.commandLine.SvnBindException)5 FilePath (com.intellij.openapi.vcs.FilePath)4 SvnVcs (org.jetbrains.idea.svn.SvnVcs)3 SvnAuthenticationManager (org.jetbrains.idea.svn.auth.SvnAuthenticationManager)3 SVNDirEntry (org.tmatesoft.svn.core.SVNDirEntry)3 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)2 Project (com.intellij.openapi.project.Project)2