@Override public void selectionChanged(@NotNull FileEditorManagerEvent fileEditorManagerEvent) { final Project project = fileEditorManagerEvent.getManager().getProject(); final FileEditorManagerEx manager = FileEditorManagerEx.getInstanceEx(project); final FileColorManager fileColorManager = FileColorManager.getInstance(project); final HighlighterSettingsConfig highlighterSettingsConfig = HighlighterSettingsConfig.getInstance(project); final VirtualFile oldFile = fileEditorManagerEvent.getOldFile(); final VirtualFile newFile = fileEditorManagerEvent.getNewFile(); for (EditorWindow editorWindow : manager.getWindows()) { setUnfocusedTabWithColorManagerDefaultColor(fileColorManager, oldFile, editorWindow); setFocusedTabHighlighterColor(highlighterSettingsConfig, newFile, editorWindow); } }
@Nullable @Override public Color getEditorTabColor(@NotNull Project project, @NotNull VirtualFile virtualFile) { final FileEditorManagerEx fileEditorManagerEx = FileEditorManagerEx.getInstanceEx(project); FileColorManager fileColorManager = FileColorManager.getInstance(project); HighlighterSettingsConfig highlighterSettingsConfig = HighlighterSettingsConfig.getInstance(project); EditorWindow activeWindow = fileEditorManagerEx.getCurrentWindow(); if (activeWindow != null) { final EditorWithProviderComposite selectedEditor = activeWindow.getSelectedEditor(); if (selectedEditor != null && selectedEditor.getFile() != null && selectedEditor.getFile().equals(virtualFile)) { return highlighterSettingsConfig.buildHighlightColor(); } } return fileColorManager.getFileColor(virtualFile); }
@NotNull @Override public Collection<BooleanOptionDescription> getOptions(@Nullable Project project) { if (project != null) { FileColorManager manager = FileColorManager.getInstance(project); if (manager != null) { BooleanOptionDescription enabled = new Option(manager, "File Colors enabled", "isEnabled", "setEnabled"); return !enabled.isOptionEnabled() ? Collections.singletonList(enabled) : Collections.unmodifiableCollection(Arrays.asList( enabled, new Option(manager, "Use File Colors in Editor Tabs", "isEnabledForTabs", "setEnabledForTabs"), new Option(manager, "Use File Colors in Project View", "isEnabledForProjectView", "setEnabledForProjectView"))); } } return Collections.emptyList(); }
public FileColorConfigurationEditDialog(@NotNull final FileColorManager manager, @Nullable final FileColorConfiguration configuration) { super(true); setTitle(configuration == null ? "Add Color Label" : "Edit Color Label"); setResizable(false); myManager = manager; myConfiguration = configuration; myColorSelectionComponent = new ColorSelectionComponent(); myColorSelectionComponent.initDefault(manager, configuration == null ? null : configuration.getColorName()); myColorSelectionComponent.setChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { updateOKButton(); } }); init(); updateCustomButton(); if (myConfiguration != null && !StringUtil.isEmpty(myConfiguration.getScopeName())) { myScopeComboBox.setSelectedItem(myConfiguration.getScopeName()); } updateOKButton(); }
private Color getBackgroundColor(boolean isSelected, Usage usage) { Color fileBgColor = null; if (isSelected) { fileBgColor = UIUtil.getListSelectionBackground(); } else { VirtualFile virtualFile = usage instanceof UsageInFile ? ((UsageInFile)usage).getFile() : null; if (virtualFile != null) { Project project = myUsageView.getProject(); PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile); if (psiFile != null && psiFile.isValid()) { final Color color = FileColorManager.getInstance(project).getRendererBackground(psiFile); if (color != null) fileBgColor = color; } } } return fileBgColor; }
protected static Color getBackgroundColor(@Nullable Object value) { if (value instanceof PsiElement || value instanceof DataProvider) { final PsiElement psiElement = value instanceof PsiElement ? (PsiElement)value : CommonDataKeys.PSI_ELEMENT.getData((DataProvider) value); if (psiElement != null && psiElement.isValid()) { final FileColorManager fileColorManager = FileColorManager.getInstance(psiElement.getProject()); final Color fileColor = fileColorManager.getRendererBackground(psiElement.getContainingFile()); if (fileColor != null) { return fileColor; } } } return UIUtil.getListBackground(); }
private void addDisabledFileColors(Project project) { final FileColorManager manager = FileColorManager.getInstance(project); manager.addScopeColor(NonProjectFilesScope.NAME, MTOceanicTheme.DISABLED, false); manager.addScopeColor(NonProjectFilesScope.NAME, MTDarkerTheme.DISABLED, false); manager.addScopeColor(NonProjectFilesScope.NAME, MTLighterTheme.DISABLED, false); manager.addScopeColor(NonProjectFilesScope.NAME, MTPalenightTheme.DISABLED, false); Notify.show(project, "", MaterialThemeBundle.message("mt.fileColorsInstalled"), NotificationType.INFORMATION, new NotificationListener.Adapter() { @Override protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) { ApplicationManager.getApplication().invokeLater(() -> ShowSettingsUtil.getInstance().showSettingsDialog( project, "File Colors"), ModalityState.NON_MODAL); } }); }
public FileColorConfigurationEditDialog(@NotNull final FileColorManager manager, @Nullable final FileColorConfiguration configuration) { super(true); setTitle(configuration == null ? "Add color label" : "Edit color label"); setResizable(false); myManager = manager; myConfiguration = configuration; myColorSelectionComponent = new ColorSelectionComponent(); myColorSelectionComponent.initDefault(manager, configuration == null ? null : configuration.getColorName()); myColorSelectionComponent.setChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { updateOKButton(); } }); init(); updateCustomButton(); if (myConfiguration != null && !StringUtil.isEmpty(myConfiguration.getScopeName())) { myScopeComboBox.setSelectedItem(myConfiguration.getScopeName()); } updateOKButton(); }
protected static Color getBackgroundColor(@Nullable Object value) { if (value instanceof PsiElement || value instanceof DataProvider) { final PsiElement psiElement = value instanceof PsiElement ? (PsiElement)value : LangDataKeys.PSI_ELEMENT.getData((DataProvider) value); if (psiElement != null) { final FileColorManager fileColorManager = FileColorManager.getInstance(psiElement.getProject()); final Color fileColor = fileColorManager.getRendererBackground(psiElement.getContainingFile()); if (fileColor != null) { return fileColor; } } } return UIUtil.getListBackground(); }
private Color getBackgroundColor(boolean isSelected, Usage usage) { Color fileBgColor = null; if (isSelected) { fileBgColor = UIUtil.getListSelectionBackground(); } else { VirtualFile virtualFile = usage instanceof UsageInFile ? ((UsageInFile) usage).getFile() : null; if (virtualFile != null) { Project project = myUsageView.getProject(); PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile); if (psiFile != null && psiFile.isValid()) { final Color color = FileColorManager.getInstance(project).getRendererBackground(psiFile); if (color != null) fileBgColor = color; } } } return fileBgColor; }
public FileColorConfigurationEditDialog(@Nonnull final FileColorManager manager, @Nullable final FileColorConfiguration configuration) { super(true); setTitle(configuration == null ? "Add color label" : "Edit color label"); setResizable(false); myManager = manager; myConfiguration = configuration; init(); updateCustomButton(); if (myConfiguration != null && !StringUtil.isEmpty(myConfiguration.getScopeName())) { myScopeComboBox.setSelectedItem(myConfiguration.getScopeName()); } updateOKButton(); }
@Override public JComponent createComponent() { if (myPanel == null) { myPanel = new FileColorsConfigurablePanel((FileColorManagerImpl) FileColorManager.getInstance(myProject)); } return myPanel; }
public void initDefault(@NotNull FileColorManager manager, @Nullable String selectedColorName) { for (String name : manager.getColorNames()) { addColorButton(name, ObjectUtils.assertNotNull(manager.getColor(name))); } addCustomColorButton(); setSelectedColor(selectedColorName); }
public FileColorSettingsTable(@NotNull final FileColorManager manager, @NotNull final List<FileColorConfiguration> configurations) { super(new ModelAdapter(manager, copy(configurations))); myManager = manager; setStriped(true); myOriginal = configurations; setAutoResizeMode(AUTO_RESIZE_LAST_COLUMN); final TableColumnModel columnModel = getColumnModel(); final TableColumn nameColumn = columnModel.getColumn(NAME_COLUMN); nameColumn.setCellRenderer(new ScopeNameRenderer()); final TableColumn colorColumn = columnModel.getColumn(COLOR_COLUMN); colorColumn.setCellRenderer(new ColorCellRenderer(manager)); }
@Nullable public static <T> Color getColorForObject(T object, Project project, @NotNull Function<T, PsiElement> converter) { Color color = null; final PsiElement psi = converter.fun(object); if (psi != null) { if (!psi.isValid()) return null; final VirtualFile file = PsiUtilCore.getVirtualFile(psi); if (file != null) { color = FileColorManager.getInstance(project).getFileColor(file); } else if (psi instanceof PsiDirectory) { color = FileColorManager.getInstance(project).getFileColor(((PsiDirectory)psi).getVirtualFile()); } else if (psi instanceof PsiDirectoryContainer) { final PsiDirectory[] dirs = ((PsiDirectoryContainer)psi).getDirectories(); for (PsiDirectory dir : dirs) { Color c = FileColorManager.getInstance(project).getFileColor(dir.getVirtualFile()); if (c != null && color == null) { color = c; } else if (c != null) { color = null; break; } } } } return color == null ? null : ColorUtil.softer(color); }
@Nullable @Override public Color getEditorTabColor(@NotNull Project project, @NotNull VirtualFile file) { if (JSGraphQLSchemaLanguageProjectService.isProjectSchemaFile(file)) { FileColorManager colorManager = FileColorManager.getInstance(project); if (colorManager.isEnabledForTabs()) { return colorManager.getScopeColor(NonProjectFilesScope.NAME); } } return null; }
@Override public Color getEditorTabColor(@NotNull final Project project, @NotNull final VirtualFile virtualFile) { final FileColorManager colorManager = FileColorManager.getInstance(project); if (colorManager.isEnabledForTabs()) { final Color fileColor = colorManager.getFileColor(virtualFile); return fileColor != null ? fileColor : getDefaultTabColor(); } return getDefaultTabColor(); }
/** * At start, check if Material Theme File Colors are added, otherwise add them * Note: If the scope has changed somehow (by changing the name or the color), it will add a duplicate. */ private void addDisabledFileColors() { final FileColorManager manager = FileColorManager.getInstance(myProject); manager.addScopeColor(NonProjectFilesScope.NAME, MTOceanicTheme.DISABLED, false); manager.addScopeColor(NonProjectFilesScope.NAME, MTDarkerTheme.DISABLED, false); manager.addScopeColor(NonProjectFilesScope.NAME, MTLighterTheme.DISABLED, false); manager.addScopeColor(NonProjectFilesScope.NAME, MTPalenightTheme.DISABLED, false); }
@Override @Nullable public Color getEditorTabColor(Project project, VirtualFile file) { final FileColorManager colorManager = FileColorManagerImpl.getInstance(project); final PsiFile psiFile = PsiManager.getInstance(project).findFile(file); return psiFile != null && colorManager.isEnabledForTabs() ? colorManager.getFileColor(psiFile) : null; }
public FileColorSettingsTable(@Nonnull final FileColorManager manager, @Nonnull final List<FileColorConfiguration> configurations) { super(new ModelAdapter(manager, copy(configurations))); myManager = manager; setStriped(true); myOriginal = configurations; setAutoResizeMode(AUTO_RESIZE_LAST_COLUMN); final TableColumnModel columnModel = getColumnModel(); final TableColumn nameColumn = columnModel.getColumn(NAME_COLUMN); nameColumn.setCellRenderer(new ScopeNameRenderer()); final TableColumn colorColumn = columnModel.getColumn(COLOR_COLUMN); colorColumn.setCellRenderer(new ColorCellRenderer(manager)); }
@Nullable public static <T> Color getColorForObject(T object, Project project, @Nonnull Function<T, PsiElement> converter) { Color color = null; final PsiElement psi = converter.fun(object); if (psi != null) { if (!psi.isValid()) return null; final VirtualFile file = PsiUtilCore.getVirtualFile(psi); if (file != null) { color = FileColorManager.getInstance(project).getFileColor(file); } else if (psi instanceof PsiDirectory) { color = FileColorManager.getInstance(project).getFileColor(((PsiDirectory)psi).getVirtualFile()); } else if (psi instanceof PsiDirectoryContainer) { final PsiDirectory[] dirs = ((PsiDirectoryContainer)psi).getDirectories(); for (PsiDirectory dir : dirs) { Color c = FileColorManager.getInstance(project).getFileColor(dir.getVirtualFile()); if (c != null && color == null) { color = c; } else if (c != null) { color = null; break; } } } } return color == null ? null : ColorUtil.softer(color); }
private void setUnfocusedTabWithColorManagerDefaultColor(@NotNull FileColorManager fileColorManager, VirtualFile file, EditorWindow editorWindow) { if (null != file) { setTabColor(fileColorManager.getFileColor(file), file, editorWindow); } }
public XDebuggerFrameListRenderer(Project project) { myColorsManager = FileColorManager.getInstance(project); }
public Option(FileColorManager manager, String option, String getter, String setter) { super(option, "reference.settings.ide.settings.file-colors", getter, setter); myManager = manager; }
@Override @Nullable public Color getEditorTabColor(@NotNull Project project, @NotNull VirtualFile file) { FileColorManager colorManager = FileColorManager.getInstance(project); return colorManager.isEnabledForTabs() ? colorManager.getFileColor(file) : null; }
@Override public Element getState() { return ((FileColorManagerImpl)FileColorManager.getInstance(myProject)).getState(true); }
@Override public void loadState(Element state) { ((FileColorManagerImpl)FileColorManager.getInstance(myProject)).loadState(state, true); }
private ModelAdapter(FileColorManager manager, final List<FileColorConfiguration> configurations) { myManager = manager; myConfigurations = configurations; }
private ColorCellRenderer(final FileColorManager manager) { myManager = manager; }
public XDebuggerFrameListRenderer(Project project) { myPsiManager = PsiManager.getInstance(project); myColorsManager = FileColorManager.getInstance(project); }
@Override @Nullable public Color getEditorTabColor(Project project, VirtualFile file) { FileColorManager colorManager = FileColorManager.getInstance(project); return colorManager.isEnabledForTabs() ? colorManager.getFileColor(file) : null; }