@Override protected String getContainerText(PsiElement element, String name) { if (element instanceof PsiFileSystemItem) { PsiFileSystemItem parent = ((PsiFileSystemItem)element).getParent(); final PsiDirectory psiDirectory = parent instanceof PsiDirectory ? (PsiDirectory)parent : null; VirtualFile virtualFile = psiDirectory == null ? null : psiDirectory.getVirtualFile(); if (virtualFile == null) return null; final String relativePath = getRelativePath(virtualFile, element.getProject()); if (relativePath == null) return "( " + File.separator + " )"; int width = myList.getWidth(); if (width == 0) width += 800; String path = FilePathSplittingPolicy.SPLIT_BY_SEPARATOR.getOptimalTextForComponent(name, new File(relativePath), this, width - myRightComponentWidth - 16 - 10); return "(" + path + ")"; } return getSymbolContainerText(name, element); }
public void testSplitByLetter() { myPolicy = FilePathSplittingPolicy.SPLIT_BY_LETTER; @NonNls String[] expectedStrings = { "t", "xt", "txt", ".txt", "e.txt", "le.txt", "ile.txt", "file.txt", ".file.txt", "..file.txt", "...file.txt", "c...file.txt", "c.../file.txt", "c:.../file.txt", "c:...4/file.txt", "c:/...4/file.txt", "c:/...r4/file.txt", "c:/d...r4/file.txt", "c:/d...ir4/file.txt", "c:/di...ir4/file.txt", "c:/di...dir4/file.txt", "c:/dir...dir4/file.txt", "c:/dir.../dir4/file.txt", "c:/dir1.../dir4/file.txt", "c:/dir1/...3/dir4/file.txt", "c:/dir1/...r3/dir4/file.txt", "c:/dir1/d...r3/dir4/file.txt", "c:/dir1/d...ir3/dir4/file.txt", "c:/dir1/di...ir3/dir4/file.txt", "c:/dir1/dir2/dir3/dir4/file.txt" }; for (String expectedString : expectedStrings) { doTest(expectedString, expectedString.length()); } }
public void testPerformance() { myPolicy = FilePathSplittingPolicy.SPLIT_BY_SEPARATOR; PlatformTestUtil.startPerformanceTest("FileNameSplitting performance", 70, new ThrowableRunnable() { @Override public void run() throws Exception { for (int i = 0; i < 100; i++) { for (int j = 0; j < FILE.getPath().length(); j++) myPolicy.getPresentableName(FILE, j); } } }).cpuBound().assertTiming(); }
protected String createMessage(Collection modifiedFiles) { if (modifiedFiles.size() == 1) { VirtualFile virtualFile = ((VirtualFile)modifiedFiles.iterator().next()); return VcsBundle.message("message.text.file.locally.modified", FilePathSplittingPolicy.SPLIT_BY_LETTER.getPresentableName(new File(virtualFile.getPath()), 40)); } else { return VcsBundle.message("message.text.several.files.locally.modified"); } }
@Override protected String getContainerText(PsiFileSystemItem element, String name) { PsiFileSystemItem parent = element.getParent(); final PsiDirectory psiDirectory = parent instanceof PsiDirectory ? (PsiDirectory)parent : null; if (psiDirectory == null) return null; final VirtualFile virtualFile = psiDirectory.getVirtualFile(); final String relativePath = getRelativePath(virtualFile, element.getProject()); if (relativePath == null) return "( " + File.separator + " )"; String path = FilePathSplittingPolicy.SPLIT_BY_SEPARATOR.getOptimalTextForComponent(name + " ", new File(relativePath), this, myMaxWidth); return "(" + path + ")"; }
public void componentResized(ComponentEvent e) { final String optimalTextForComponent = FilePathSplittingPolicy.SPLIT_BY_SEPARATOR.getOptimalTextForComponent(myFile, myLabelToClip, myComponentToWatch.getWidth()); myLabelToClip.setText(optimalTextForComponent); }
public void testSplitByFileSeparator(){ myPolicy = FilePathSplittingPolicy.SPLIT_BY_SEPARATOR; @NonNls String[] expectedStrings = { "...", "...", "...", "...", "...", "...", "...", "file.txt", "file.txt", "file.txt", "...file.txt", "...file.txt", "c:...file.txt", "c:.../file.txt", "c:/.../file.txt", "c:/.../file.txt", "c:/.../file.txt", "c:/.../file.txt", "c:/...dir4/file.txt", "c:/...dir4/file.txt", "c:/...dir4/file.txt", "c:/...dir4/file.txt", "c:/dir1...dir4/file.txt", "c:/dir1.../dir4/file.txt", "c:/dir1/.../dir4/file.txt", "c:/dir1/.../dir4/file.txt", "c:/dir1/.../dir4/file.txt", "c:/dir1/.../dir4/file.txt", "c:/dir1/...dir3/dir4/file.txt", "c:/dir1/...dir3/dir4/file.txt", "c:/dir1/dir2/dir3/dir4/file.txt" }; for (int i = 0; i < expectedStrings.length; i++) { int count = i + 1; String expectedString = expectedStrings[i]; assertTrue(expectedString, expectedString.length() <= count || i < 3); doTest(expectedString, count); } }
public GotoTestDataAction(String filePath, Project project, Icon icon) { super("Go to " + FilePathSplittingPolicy.SPLIT_BY_SEPARATOR.getPresentableName(new File(filePath), 50), null, icon); myFilePath = filePath; myProject = project; }