toolwindow resize for docked windows
[fedora-idea.git] / platform / platform-impl / src / com / intellij / ide / actions / QuickChangeColorSchemeAction.java
blob566d5883e48c9d8085d6c044e3229878f9cd6a03
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package com.intellij.ide.actions;
18 import com.intellij.openapi.actionSystem.*;
19 import com.intellij.openapi.editor.Editor;
20 import com.intellij.openapi.editor.EditorFactory;
21 import com.intellij.openapi.editor.colors.EditorColorsManager;
22 import com.intellij.openapi.editor.colors.EditorColorsScheme;
23 import com.intellij.openapi.editor.colors.impl.EditorColorsManagerImpl;
24 import com.intellij.openapi.editor.colors.impl.EditorColorsSchemeImpl;
25 import com.intellij.openapi.editor.ex.EditorEx;
26 import com.intellij.openapi.options.SharedScheme;
27 import com.intellij.openapi.project.Project;
29 import java.util.Collection;
31 /**
32 * @author max
34 public class QuickChangeColorSchemeAction extends QuickSwitchSchemeAction {
35 protected void fillActions(Project project, DefaultActionGroup group, DataContext dataContext) {
36 final EditorColorsScheme[] schemes = EditorColorsManager.getInstance().getAllSchemes();
37 EditorColorsScheme current = EditorColorsManager.getInstance().getGlobalScheme();
38 for (final EditorColorsScheme scheme : schemes) {
39 addScheme(group, current, scheme, false);
43 Collection<SharedScheme<EditorColorsSchemeImpl>> sharedSchemes = ((EditorColorsManagerImpl)EditorColorsManager.getInstance()).getSchemesManager().loadSharedSchemes();
45 if (!sharedSchemes.isEmpty()) {
46 group.add(Separator.getInstance());
48 for (SharedScheme<EditorColorsSchemeImpl> sharedScheme : sharedSchemes) {
49 addScheme(group, current, sharedScheme.getScheme(), true);
55 private void addScheme(final DefaultActionGroup group, final EditorColorsScheme current, final EditorColorsScheme scheme, final boolean addScheme) {
56 group.add(new AnAction(scheme.getName(), "", scheme == current ? ourCurrentAction : ourNotCurrentAction) {
57 public void actionPerformed(AnActionEvent e) {
58 if (addScheme) {
59 EditorColorsManager.getInstance().addColorsScheme(scheme);
61 EditorColorsManager.getInstance().setGlobalScheme(scheme);
62 Editor[] editors = EditorFactory.getInstance().getAllEditors();
63 for (Editor editor : editors) {
64 ((EditorEx)editor).reinitSettings();
67 });
70 protected boolean isEnabled() {
71 return EditorColorsManager.getInstance().getAllSchemes().length > 1 || ((EditorColorsManagerImpl)EditorColorsManager.getInstance()).getSchemesManager().isImportAvailable();