/platform/platform-impl/src/com/intellij/openapi/vcs/readOnlyHandler/FileListRenderer.java

https://bitbucket.org/nbargnesi/idea · Java · 39 lines · 20 code · 3 blank · 16 comment · 2 complexity · 7b47de2e20dc7b9bf98d0c66031d9526 MD5 · raw file

  1. /*
  2. * Copyright 2000-2009 JetBrains s.r.o.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.intellij.openapi.vcs.readOnlyHandler;
  17. import com.intellij.ide.presentation.VirtualFilePresentation;
  18. import com.intellij.openapi.util.io.FileUtil;
  19. import com.intellij.openapi.vfs.VirtualFile;
  20. import com.intellij.ui.ColoredListCellRenderer;
  21. import com.intellij.ui.SimpleTextAttributes;
  22. import javax.swing.*;
  23. public class FileListRenderer extends ColoredListCellRenderer {
  24. protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
  25. // paint selection only as a focus rectangle
  26. mySelected = false;
  27. setBackground(null);
  28. VirtualFile vf = (VirtualFile) value;
  29. setIcon(VirtualFilePresentation.getIcon(vf));
  30. append(vf.getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
  31. VirtualFile parent = vf.getParent();
  32. if (parent != null) {
  33. append(" (" + FileUtil.toSystemDependentName(parent.getPath()) + ")", SimpleTextAttributes.GRAY_ATTRIBUTES);
  34. }
  35. }
  36. }