Search in sources :

Example 1 with DirectoryEntry

use of org.jetbrains.idea.svn.browse.DirectoryEntry in project intellij-community by JetBrains.

the class RepositoryBrowserDialog method doCheckout.

protected void doCheckout(@Nullable final CheckoutProvider.Listener listener, final RepositoryTreeNode selectedNode) {
    if (selectedNode == null) {
        return;
    }
    SVNURL url = selectedNode.getURL();
    String relativePath = "";
    final DirectoryEntry entry = selectedNode.getSVNDirEntry();
    if (entry != null) {
        if (entry.getRepositoryRoot() != null) {
            if (!entry.getRepositoryRoot().equals(url)) {
                relativePath = SVNPathUtil.getRelativePath(entry.getRepositoryRoot().toString(), url.toDecodedString());
            }
        } else {
            relativePath = entry.getRelativePath();
        }
    } else {
        relativePath = url.getPath();
    }
    File dir = selectFile(SvnBundle.message("svn.checkout.destination.directory.title"), SvnBundle.message("svn.checkout.destination.directory.description"));
    if (dir == null) {
        return;
    }
    Project p = myProject;
    CheckoutOptionsDialog dialog = new CheckoutOptionsDialog(p, url, dir, SvnUtil.getVirtualFile(dir.getAbsolutePath()), relativePath);
    dialog.show();
    dir = dialog.getTarget();
    if (dialog.isOK() && dir != null) {
        final SVNRevision revision;
        try {
            revision = dialog.getRevision();
        } catch (ConfigurationException e) {
            Messages.showErrorDialog(SvnBundle.message("message.text.cannot.checkout", e.getMessage()), SvnBundle.message("message.title.check.out"));
            return;
        }
        SvnCheckoutProvider.doCheckout(myProject, dir, url.toString(), revision, dialog.getDepth(), dialog.isIgnoreExternals(), listener);
    }
}
Also used : Project(com.intellij.openapi.project.Project) ConfigurationException(com.intellij.openapi.options.ConfigurationException) SVNURL(org.tmatesoft.svn.core.SVNURL) DirectoryEntry(org.jetbrains.idea.svn.browse.DirectoryEntry) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) VirtualFile(com.intellij.openapi.vfs.VirtualFile)

Example 2 with DirectoryEntry

use of org.jetbrains.idea.svn.browse.DirectoryEntry in project intellij-community by JetBrains.

the class SvnRepositoryTreeCellRenderer method customizeCellRenderer.

public void customizeCellRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    setIcon(null);
    if (value instanceof RepositoryTreeNode) {
        RepositoryTreeNode node = (RepositoryTreeNode) value;
        if (node.getSVNDirEntry() == null) {
            append(node.getURL().toString(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
            setIcon(PlatformIcons.DIRECTORY_CLOSED_ICON);
        } else {
            String name = node.getSVNDirEntry().getName();
            append(name, node.isCached() ? SimpleTextAttributes.GRAY_ITALIC_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES);
            if (myIsShowDetails) {
                DirectoryEntry entry = node.getSVNDirEntry();
                append(" " + entry.getRevision(), SimpleTextAttributes.GRAY_ATTRIBUTES);
                if (entry.getAuthor() != null) {
                    append(" " + entry.getAuthor(), SimpleTextAttributes.GRAYED_BOLD_ATTRIBUTES);
                }
                if (entry.getDate() != null) {
                    append(" " + DateFormatUtil.formatPrettyDateTime(entry.getDate()), SimpleTextAttributes.GRAY_ATTRIBUTES);
                }
            }
            setIcon(node.getSVNDirEntry().isFile() ? FileTypeManager.getInstance().getFileTypeByFileName(name).getIcon() : PlatformIcons.DIRECTORY_CLOSED_ICON);
        }
    } else if (value instanceof SimpleTextNode) {
        SimpleTextNode node = (SimpleTextNode) value;
        append(node.getText(), node.isError() ? SimpleTextAttributes.ERROR_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES);
    }
}
Also used : DirectoryEntry(org.jetbrains.idea.svn.browse.DirectoryEntry)

Example 3 with DirectoryEntry

use of org.jetbrains.idea.svn.browse.DirectoryEntry in project intellij-community by JetBrains.

the class RepositoryBrowserComponent method getSelectedVcsFile.

@Nullable
public VirtualFile getSelectedVcsFile() {
    final RepositoryTreeNode node = getSelectedNode();
    if (node == null)
        return null;
    DirectoryEntry entry = node.getSVNDirEntry();
    if (entry == null || !entry.isFile()) {
        return null;
    }
    String name = entry.getName();
    FileTypeManager manager = FileTypeManager.getInstance();
    if (entry.getName().lastIndexOf('.') > 0 && !manager.getFileTypeByFileName(name).isBinary()) {
        SVNURL url = node.getURL();
        final SvnFileRevision revision = new SvnFileRevision(myVCS, SVNRevision.UNDEFINED, SVNRevision.HEAD, url.toString(), entry.getAuthor(), entry.getDate(), null, null);
        return new VcsVirtualFile(node.getSVNDirEntry().getName(), revision, VcsFileSystem.getInstance());
    } else {
        return null;
    }
}
Also used : VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile) SvnFileRevision(org.jetbrains.idea.svn.history.SvnFileRevision) SVNURL(org.tmatesoft.svn.core.SVNURL) FileTypeManager(com.intellij.openapi.fileTypes.FileTypeManager) DirectoryEntry(org.jetbrains.idea.svn.browse.DirectoryEntry) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with DirectoryEntry

use of org.jetbrains.idea.svn.browse.DirectoryEntry in project intellij-community by JetBrains.

the class RepositoryTreeNode method setChildren.

public void setChildren(@NotNull List<DirectoryEntry> children, @NotNull NodeLoadState state) {
    final List<TreeNode> nodes = new ArrayList<>();
    for (final DirectoryEntry entry : children) {
        if (!myModel.isShowFiles() && !entry.isDirectory()) {
            continue;
        }
        nodes.add(new RepositoryTreeNode(myModel, this, entry.getUrl(), entry, state));
    }
    myChildrenLoadState = state;
    myChildren.clear();
    myChildren.addAll(nodes);
    myModel.reload(this);
}
Also used : TreeNode(javax.swing.tree.TreeNode) ArrayList(java.util.ArrayList) DirectoryEntry(org.jetbrains.idea.svn.browse.DirectoryEntry)

Example 5 with DirectoryEntry

use of org.jetbrains.idea.svn.browse.DirectoryEntry in project intellij-community by JetBrains.

the class SyntheticWorker method removeSelf.

public void removeSelf() {
    final String parentUrl;
    try {
        parentUrl = myUrl.removePathTail().toString();
    } catch (SVNException e) {
        return;
    }
    final List<DirectoryEntry> children = myCache.getChildren(parentUrl);
    if (children == null) {
        return;
    }
    for (Iterator<DirectoryEntry> iterator = children.iterator(); iterator.hasNext(); ) {
        final DirectoryEntry entry = iterator.next();
        if (myUrl.equals(entry.getUrl())) {
            iterator.remove();
        }
    }
    myCache.put(parentUrl, children);
}
Also used : SVNException(org.tmatesoft.svn.core.SVNException) DirectoryEntry(org.jetbrains.idea.svn.browse.DirectoryEntry)

Aggregations

DirectoryEntry (org.jetbrains.idea.svn.browse.DirectoryEntry)5 SVNURL (org.tmatesoft.svn.core.SVNURL)2 FileTypeManager (com.intellij.openapi.fileTypes.FileTypeManager)1 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1 Project (com.intellij.openapi.project.Project)1 VcsVirtualFile (com.intellij.openapi.vcs.vfs.VcsVirtualFile)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 ArrayList (java.util.ArrayList)1 TreeNode (javax.swing.tree.TreeNode)1 Nullable (org.jetbrains.annotations.Nullable)1 SvnFileRevision (org.jetbrains.idea.svn.history.SvnFileRevision)1 SVNException (org.tmatesoft.svn.core.SVNException)1 SVNRevision (org.tmatesoft.svn.core.wc.SVNRevision)1