From bfc8aba7b4f124d465145c0245ec9d1f9df055a5 Mon Sep 17 00:00:00 2001 From: "Denis.Zhdanov" Date: Fri, 20 Jan 2012 20:25:57 +0400 Subject: [PATCH] IDEA-79964: Throwable at com.intellij.openapi.editor.impl.DocumentImpl.b 1. Refactored colors and fonts settings processing; 2. Added gradle colors and fonts settings page; 3. Gradle repackaging; --- .../ColorAndFontDescriptorsProvider.java | 60 ++++ .../options/colors/ColorSettingsPage.java | 30 +- .../intellij/openapi/roots/OrderEntry.java | 5 +- .../options/colors/ColorAndFontOptions.java | 36 ++- .../colors/ColorAndFontPanelFactory.java | 16 +- .../options/colors/ColorSettingsUtil.java | 15 +- .../colors/FileStatusColorsPageFactory.java | 7 +- .../options/colors/FontEditorPreview.java | 4 +- .../options/colors/PreviewPanel.java | 8 +- .../options/colors/SimpleEditorPreview.java | 5 +- .../highlighting/HighlightsExtractor.java | 5 +- .../diff/impl/settings/DiffPreviewPanel.java | 5 +- .../ide/util/treeView/NodeDescriptor.java | 7 +- .../ide/util/treeView/NodeRenderer.java | 25 +- .../src/META-INF/LangExtensionPoints.xml | 5 +- plugins/gradle/gradle.iml | 1 + .../resources/i18n/GradleBundle.properties | 10 +- plugins/gradle/src/META-INF/plugin.xml | 3 +- .../gradle/bootstrap/GradleBootstrap.java | 4 +- ...radleColorAndFontDescriptorsProvider.java} | 65 ++-- .../GradleColorAndFontPanelFactory.java | 29 ++ .../GradleColorAndFontPreviewPanel.java | 300 ++++++++++++++++++ .../gradle/config/GradleColorKeys.java | 30 -- .../gradle/config/GradleConfigurable.java | 4 +- .../GradleLibraryPresentationProvider.java | 3 +- .../gradle/config/GradleScriptType.java | 5 +- .../gradle/config/GradleTextAttributes.java | 72 +++++ .../gradle/config/GradleToolWindowPanel.java | 11 +- .../importing/GradleProjectImportBuilder.java | 4 +- .../GradleAdjustImportSettingsStep.java | 1 + .../adjust/GradleProjectStructureFactory.java | 22 +- .../GradleProjectStructureNodeDescriptor.java | 40 --- .../GradleProjectStructureChangesPanel.java | 74 ++++- .../plugins/gradle/ui/GradleIcons.java | 21 ++ .../GradleProjectStructureNode.java | 2 +- .../GradleProjectStructureNodeDescriptor.java | 42 +++ .../{util => ui}/MultiRowFlowPanel.java | 2 +- .../{util => ui}/RichTextActionProcessor.java | 3 +- .../{util => ui}/RichTextControlBuilder.java | 2 +- .../plugins/gradle/util/GradleConstants.java | 1 - .../plugins/gradle/util/GradleUtil.java | 3 +- 41 files changed, 759 insertions(+), 228 deletions(-) create mode 100644 platform/lang-api/src/com/intellij/openapi/options/colors/ColorAndFontDescriptorsProvider.java rename plugins/gradle/src/org/jetbrains/plugins/gradle/config/{GradleColorSettingsPage.java => GradleColorAndFontDescriptorsProvider.java} (59%) create mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorAndFontPanelFactory.java create mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorAndFontPreviewPanel.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorKeys.java create mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleTextAttributes.java delete mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/importing/wizard/adjust/GradleProjectStructureNodeDescriptor.java create mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/ui/GradleIcons.java rename plugins/gradle/src/org/jetbrains/plugins/gradle/{importing/wizard/adjust => ui}/GradleProjectStructureNode.java (89%) create mode 100644 plugins/gradle/src/org/jetbrains/plugins/gradle/ui/GradleProjectStructureNodeDescriptor.java rename plugins/gradle/src/org/jetbrains/plugins/gradle/{util => ui}/MultiRowFlowPanel.java (98%) rename plugins/gradle/src/org/jetbrains/plugins/gradle/{util => ui}/RichTextActionProcessor.java (93%) rename plugins/gradle/src/org/jetbrains/plugins/gradle/{util => ui}/RichTextControlBuilder.java (99%) diff --git a/platform/lang-api/src/com/intellij/openapi/options/colors/ColorAndFontDescriptorsProvider.java b/platform/lang-api/src/com/intellij/openapi/options/colors/ColorAndFontDescriptorsProvider.java new file mode 100644 index 000000000000..bec069803a1e --- /dev/null +++ b/platform/lang-api/src/com/intellij/openapi/options/colors/ColorAndFontDescriptorsProvider.java @@ -0,0 +1,60 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.options.colors; + +import com.intellij.openapi.editor.colors.TextAttributesKey; +import com.intellij.openapi.extensions.ExtensionPointName; +import org.jetbrains.annotations.NotNull; + +/** + * Defines interface for extending set of text/color descriptors operated by color schemes. + * + * @author Denis Zhdanov + * @since 1/19/12 1:10 PM + */ +public interface ColorAndFontDescriptorsProvider { + + ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.colorAndFontDescriptorProvider"); + + /** + * Returns the list of descriptors specifying the {@link TextAttributesKey} instances + * for which colors are specified in the page. For such attribute keys, the user can choose + * all highlighting attributes (font type, background color, foreground color, error stripe color and + * effects). + * + * @return the list of attribute descriptors. + */ + @NotNull + AttributesDescriptor[] getAttributeDescriptors(); + + /** + * Returns the list of descriptors specifying the {@link com.intellij.openapi.editor.colors.ColorKey} + * instances for which colors are specified in the page. For such color keys, the user can + * choose only the background or foreground color. + * + * @return the list of color descriptors. + */ + @NotNull + ColorDescriptor[] getColorDescriptors(); + + /** + * Returns the title of the page, shown as text in the dialog tab. + * + * @return the title of the custom page. + */ + @NotNull + String getDisplayName(); +} diff --git a/platform/lang-api/src/com/intellij/openapi/options/colors/ColorSettingsPage.java b/platform/lang-api/src/com/intellij/openapi/options/colors/ColorSettingsPage.java index 05c678dd0b98..9c5d11b6e673 100644 --- a/platform/lang-api/src/com/intellij/openapi/options/colors/ColorSettingsPage.java +++ b/platform/lang-api/src/com/intellij/openapi/options/colors/ColorSettingsPage.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,16 +28,9 @@ import java.util.Map; /** * Interface for a custom page shown in the "Colors and Fonts" settings dialog. */ -public interface ColorSettingsPage { +public interface ColorSettingsPage extends ColorAndFontDescriptorsProvider { ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.colorSettingsPage"); - /** - * Returns the title of the page, shown as text in the dialog tab. - * - * @return the title of the custom page. - */ - @NotNull String getDisplayName(); - /** * Returns the icon for the page, shown in the dialog tab. * @@ -45,25 +38,6 @@ public interface ColorSettingsPage { */ @Nullable Icon getIcon(); - /** - * Returns the list of descriptors specifying the {@link TextAttributesKey} instances - * for which colors are specified in the page. For such attribute keys, the user can choose - * all highlighting attributes (font type, background color, foreground color, error stripe color and - * effects). - * - * @return the list of attribute descriptors. - */ - @NotNull AttributesDescriptor[] getAttributeDescriptors(); - - /** - * Returns the list of descriptors specifying the {@link com.intellij.openapi.editor.colors.ColorKey} - * instances for which colors are specified in the page. For such color keys, the user can - * choose only the background or foreground color. - * - * @return the list of color descriptors. - */ - @NotNull ColorDescriptor[] getColorDescriptors(); - /** * Returns the syntax highlighter which is used to highlight the text shown in the preview * pane of the page. diff --git a/platform/lang-api/src/com/intellij/openapi/roots/OrderEntry.java b/platform/lang-api/src/com/intellij/openapi/roots/OrderEntry.java index 17842ae37f76..563a700fec9f 100644 --- a/platform/lang-api/src/com/intellij/openapi/roots/OrderEntry.java +++ b/platform/lang-api/src/com/intellij/openapi/roots/OrderEntry.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package com.intellij.openapi.roots; import com.intellij.openapi.module.Module; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents an entry in the classpath of a module (as shown in the "Order/Export" page @@ -88,5 +89,5 @@ public interface OrderEntry extends Synthetic, Comparable { * @param initialValue the default value to be returned by the visit process. * @return the value returned by the visitor. */ - R accept(RootPolicy policy, R initialValue); + R accept(RootPolicy policy, @Nullable R initialValue); } diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java b/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java index abf2bb5f4675..9f441d74e790 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,14 +37,12 @@ import com.intellij.openapi.editor.colors.impl.EditorColorsSchemeImpl; import com.intellij.openapi.editor.colors.impl.ReadOnlyColorsScheme; import com.intellij.openapi.editor.markup.EffectType; import com.intellij.openapi.editor.markup.TextAttributes; +import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.options.Configurable; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.options.ExternalizableScheme; import com.intellij.openapi.options.SearchableConfigurable; -import com.intellij.openapi.options.colors.AttributesDescriptor; -import com.intellij.openapi.options.colors.ColorDescriptor; -import com.intellij.openapi.options.colors.ColorSettingsPage; -import com.intellij.openapi.options.colors.ColorSettingsPages; +import com.intellij.openapi.options.colors.*; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.util.Comparing; @@ -329,16 +327,19 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract ColorSettingsPage[] pages = ColorSettingsPages.getInstance().getRegisteredPages(); for (final ColorSettingsPage page : pages) { result.add(new ColorAndFontPanelFactory() { - public NewColorAndFontPanel createPanel(ColorAndFontOptions options) { + @NotNull + public NewColorAndFontPanel createPanel(@NotNull ColorAndFontOptions options) { final SimpleEditorPreview preview = new SimpleEditorPreview(options, page); return NewColorAndFontPanel.create(preview, page.getDisplayName(), options, null, page); } + @NotNull public String getPanelDisplayName() { return page.getDisplayName(); } }); } + Collections.addAll(result, Extensions.getExtensions(ColorAndFontPanelFactory.EP_NAME)); result.add(new DiffColorsPageFactory()); result.add(new FileStatusColorsPageFactory()); result.add(new ScopeColorsPageFactory()); @@ -347,7 +348,8 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract } private static class FontConfigurableFactory implements ColorAndFontPanelFactory { - public NewColorAndFontPanel createPanel(ColorAndFontOptions options) { + @NotNull + public NewColorAndFontPanel createPanel(@NotNull ColorAndFontOptions options) { FontEditorPreview previewPanel = new FontEditorPreview(options, true); return new NewColorAndFontPanel(new SchemesPanel(options), new FontOptions(options), previewPanel, "Font", null, null){ @Override @@ -357,13 +359,15 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract }; } + @NotNull public String getPanelDisplayName() { return "Font"; } } private static class ConsoleFontConfigurableFactory implements ColorAndFontPanelFactory { - public NewColorAndFontPanel createPanel(ColorAndFontOptions options) { + @NotNull + public NewColorAndFontPanel createPanel(@NotNull ColorAndFontOptions options) { FontEditorPreview previewPanel = new FontEditorPreview(options, false) { @Override protected EditorColorsScheme updateOptionsScheme(EditorColorsScheme selectedScheme) { @@ -378,13 +382,15 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract }; } + @NotNull public String getPanelDisplayName() { return "Console Font"; } } private class DiffColorsPageFactory implements ColorAndFontPanelFactory { - public NewColorAndFontPanel createPanel(ColorAndFontOptions options) { + @NotNull + public NewColorAndFontPanel createPanel(@NotNull ColorAndFontOptions options) { final DiffOptionsPanel optionsPanel = new DiffOptionsPanel(options); SchemesPanel schemesPanel = new SchemesPanel(options); PreviewPanel previewPanel; @@ -409,6 +415,7 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract return new NewColorAndFontPanel(schemesPanel, optionsPanel, previewPanel, DIFF_GROUP, null, null); } + @NotNull public String getPanelDisplayName() { return DIFF_GROUP; } @@ -444,18 +451,21 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract for (ColorSettingsPage page : pages) { initDescriptions(page, descriptions, scheme); } + for (ColorAndFontDescriptorsProvider provider : Extensions.getExtensions(ColorAndFontDescriptorsProvider.EP_NAME)) { + initDescriptions(provider, descriptions, scheme); + } } - private static void initDescriptions(ColorSettingsPage page, + private static void initDescriptions(ColorAndFontDescriptorsProvider provider, ArrayList descriptions, MyColorScheme scheme) { - String group = page.getDisplayName(); - List attributeDescriptors = ColorSettingsUtil.getAllAttributeDescriptors(page); + String group = provider.getDisplayName(); + List attributeDescriptors = ColorSettingsUtil.getAllAttributeDescriptors(provider); for (AttributesDescriptor descriptor : attributeDescriptors) { addSchemedDescription(descriptions, descriptor.getDisplayName(), group, descriptor.getKey(), scheme, null, null); } - ColorDescriptor[] colorDescriptors = page.getColorDescriptors(); + ColorDescriptor[] colorDescriptors = provider.getColorDescriptors(); for (ColorDescriptor descriptor : colorDescriptors) { ColorKey back = descriptor.getKind() == ColorDescriptor.Kind.BACKGROUND ? descriptor.getKey() : null; ColorKey fore = descriptor.getKind() == ColorDescriptor.Kind.FOREGROUND ? descriptor.getKey() : null; diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontPanelFactory.java b/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontPanelFactory.java index 57984040c5b2..b3b156fe6391 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontPanelFactory.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontPanelFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,10 +16,22 @@ package com.intellij.application.options.colors; +import com.intellij.openapi.extensions.ExtensionPointName; +import com.intellij.openapi.options.colors.ColorSettingsPage; +import org.jetbrains.annotations.NotNull; + /** + * Generalises {@link ColorSettingsPage} in a way that allows to provide custom {@link PreviewPanel preview panel}. + * * @author yole */ public interface ColorAndFontPanelFactory { - NewColorAndFontPanel createPanel(ColorAndFontOptions options); + + ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.colorAndFontPanelFactory"); + + @NotNull + NewColorAndFontPanel createPanel(@NotNull ColorAndFontOptions options); + + @NotNull String getPanelDisplayName(); } diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/ColorSettingsUtil.java b/platform/lang-impl/src/com/intellij/application/options/colors/ColorSettingsUtil.java index aee77a51fbf7..e31c8518f7ca 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/ColorSettingsUtil.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/ColorSettingsUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import com.intellij.openapi.editor.colors.impl.EditorColorsManagerImpl; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.options.OptionsBundle; import com.intellij.openapi.options.colors.AttributesDescriptor; +import com.intellij.openapi.options.colors.ColorAndFontDescriptorsProvider; import com.intellij.openapi.options.colors.ColorSettingsPage; import com.intellij.util.containers.HashMap; @@ -51,21 +52,21 @@ public class ColorSettingsUtil { return displayText; } - public static List getAllAttributeDescriptors(ColorSettingsPage page) { + public static List getAllAttributeDescriptors(ColorAndFontDescriptorsProvider provider) { List result = new ArrayList(); - Collections.addAll(result, page.getAttributeDescriptors()); - if (isInspectionColorsPage(page)) { + Collections.addAll(result, provider.getAttributeDescriptors()); + if (isInspectionColorsPage(provider)) { addInspectionSeverityAttributes(result); } return result; } - private static boolean isInspectionColorsPage(ColorSettingsPage page) { + private static boolean isInspectionColorsPage(ColorAndFontDescriptorsProvider provider) { // the first registered page implementing InspectionColorSettingsPage // gets the inspection attribute descriptors added to its list - if (!(page instanceof InspectionColorSettingsPage)) return false; + if (!(provider instanceof InspectionColorSettingsPage)) return false; for(ColorSettingsPage settingsPage: Extensions.getExtensions(ColorSettingsPage.EP_NAME)) { - if (settingsPage == page) break; + if (settingsPage == provider) break; if (settingsPage instanceof InspectionColorSettingsPage) return false; } return true; diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/FileStatusColorsPageFactory.java b/platform/lang-impl/src/com/intellij/application/options/colors/FileStatusColorsPageFactory.java index 353c6746e31e..7cac47f8947b 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/FileStatusColorsPageFactory.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/FileStatusColorsPageFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,15 +18,18 @@ package com.intellij.application.options.colors; import com.intellij.openapi.vcs.FileStatus; import com.intellij.openapi.vcs.FileStatusFactory; +import org.jetbrains.annotations.NotNull; import java.util.Collection; import java.util.ArrayList; class FileStatusColorsPageFactory implements ColorAndFontPanelFactory { - public NewColorAndFontPanel createPanel(ColorAndFontOptions options) { + @NotNull + public NewColorAndFontPanel createPanel(@NotNull ColorAndFontOptions options) { return NewColorAndFontPanel.create(new PreviewPanel.Empty(), ColorAndFontOptions.FILE_STATUS_GROUP, options, collectFileTypes(), null); } + @NotNull public String getPanelDisplayName() { return ColorAndFontOptions.FILE_STATUS_GROUP; } diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/FontEditorPreview.java b/platform/lang-impl/src/com/intellij/application/options/colors/FontEditorPreview.java index b0a9d04a6d9f..4ff61929aba1 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/FontEditorPreview.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/FontEditorPreview.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -118,7 +118,7 @@ public class FontEditorPreview implements PreviewPanel{ public void blinkSelectedHighlightType(Object description) { } - public void addListener(final ColorAndFontSettingsListener listener) { + public void addListener(@NotNull final ColorAndFontSettingsListener listener) { myDispatcher.addListener(listener); } diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/PreviewPanel.java b/platform/lang-impl/src/com/intellij/application/options/colors/PreviewPanel.java index dccf002b915e..dc0379e63460 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/PreviewPanel.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/PreviewPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ package com.intellij.application.options.colors; +import org.jetbrains.annotations.NotNull; + import java.awt.*; public interface PreviewPanel { @@ -31,7 +33,7 @@ public interface PreviewPanel { public void updateView() { } - public void addListener(final ColorAndFontSettingsListener listener) { + public void addListener(@NotNull final ColorAndFontSettingsListener listener) { } @@ -48,5 +50,5 @@ public interface PreviewPanel { void updateView(); - void addListener(ColorAndFontSettingsListener listener); + void addListener(@NotNull ColorAndFontSettingsListener listener); } diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/SimpleEditorPreview.java b/platform/lang-impl/src/com/intellij/application/options/colors/SimpleEditorPreview.java index 975a8d5e1613..4de14c97e08d 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/SimpleEditorPreview.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/SimpleEditorPreview.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,6 +34,7 @@ import com.intellij.openapi.options.colors.EditorHighlightingProvidingColorSetti import com.intellij.psi.tree.IElementType; import com.intellij.util.Alarm; import com.intellij.util.EventDispatcher; +import org.jetbrains.annotations.NotNull; import javax.swing.*; import java.awt.*; @@ -296,7 +297,7 @@ public class SimpleEditorPreview implements PreviewPanel{ } - public void addListener(final ColorAndFontSettingsListener listener) { + public void addListener(@NotNull final ColorAndFontSettingsListener listener) { myDispatcher.addListener(listener); } diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/highlighting/HighlightsExtractor.java b/platform/lang-impl/src/com/intellij/application/options/colors/highlighting/HighlightsExtractor.java index db4b3b45b952..d80abf64a5b1 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/highlighting/HighlightsExtractor.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/highlighting/HighlightsExtractor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ package com.intellij.application.options.colors.highlighting; import com.intellij.openapi.editor.colors.TextAttributesKey; import com.intellij.util.containers.Stack; +import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.List; @@ -37,7 +38,7 @@ public class HighlightsExtractor { private boolean myIsOpeningTag; private static final HighlightData[] EMPTY_DATA = new HighlightData[0]; - public HighlightsExtractor(Map tags) { + public HighlightsExtractor(@Nullable Map tags) { myTags = tags; } diff --git a/platform/lang-impl/src/com/intellij/openapi/diff/impl/settings/DiffPreviewPanel.java b/platform/lang-impl/src/com/intellij/openapi/diff/impl/settings/DiffPreviewPanel.java index 9ac0b0f849fa..e274135f8133 100644 --- a/platform/lang-impl/src/com/intellij/openapi/diff/impl/settings/DiffPreviewPanel.java +++ b/platform/lang-impl/src/com/intellij/openapi/diff/impl/settings/DiffPreviewPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,6 +34,7 @@ import com.intellij.openapi.editor.ex.util.EditorUtil; import com.intellij.openapi.project.Project; import com.intellij.util.EventDispatcher; import com.intellij.util.diff.FilesTooBigForDiffException; +import org.jetbrains.annotations.NotNull; import javax.swing.*; import java.awt.*; @@ -130,7 +131,7 @@ public class DiffPreviewPanel implements PreviewPanel { public String getWindowTitle() { return DiffBundle.message("merge.color.options.dialog.title"); } } - public void addListener(final ColorAndFontSettingsListener listener) { + public void addListener(@NotNull final ColorAndFontSettingsListener listener) { myDispatcher.addListener(listener); } diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/NodeDescriptor.java b/platform/platform-api/src/com/intellij/ide/util/treeView/NodeDescriptor.java index 5fd80c07e8a9..e000520a3f22 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/NodeDescriptor.java +++ b/platform/platform-api/src/com/intellij/ide/util/treeView/NodeDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package com.intellij.ide.util.treeView; import com.intellij.openapi.project.Project; +import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; @@ -37,11 +38,12 @@ public abstract class NodeDescriptor { private boolean myWasDeclaredAlwaysLeaf; - public NodeDescriptor(Project project, NodeDescriptor parentDescriptor) { + public NodeDescriptor(@Nullable Project project, @Nullable NodeDescriptor parentDescriptor) { myProject = project; myParentDescriptor = parentDescriptor; } + @Nullable public NodeDescriptor getParentDescriptor() { return myParentDescriptor; } @@ -74,6 +76,7 @@ public abstract class NodeDescriptor { return myColor; } + @Nullable public final Project getProject() { return myProject; } diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/NodeRenderer.java b/platform/platform-api/src/com/intellij/ide/util/treeView/NodeRenderer.java index ccf6acb2968f..c510eb1b802c 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/NodeRenderer.java +++ b/platform/platform-api/src/com/intellij/ide/util/treeView/NodeRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,12 +19,14 @@ import com.intellij.ide.projectView.PresentationData; import com.intellij.navigation.ColoredItemPresentation; import com.intellij.navigation.ItemPresentation; import com.intellij.openapi.editor.colors.EditorColorsManager; +import com.intellij.openapi.editor.colors.EditorColorsScheme; import com.intellij.openapi.editor.colors.TextAttributesKey; import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.ui.ColoredTreeCellRenderer; import com.intellij.ui.SimpleTextAttributes; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.tree.DefaultMutableTreeNode; @@ -100,9 +102,14 @@ public class NodeRenderer extends ColoredTreeCellRenderer { public void doAppend(String fragment, boolean isSelected) { append(fragment); } - - protected static SimpleTextAttributes getSimpleTextAttributes(final PresentableNodeDescriptor node, final Color color) { - SimpleTextAttributes simpleTextAttributes = getSimpleTextAttributes(node.getPresentation()); + + @NotNull + protected EditorColorsScheme getColorsScheme() { + return EditorColorsManager.getInstance().getGlobalScheme(); + } + + protected SimpleTextAttributes getSimpleTextAttributes(final PresentableNodeDescriptor node, final Color color) { + SimpleTextAttributes simpleTextAttributes = getSimpleTextAttributes(node.getPresentation(), getColorsScheme()); if (color != null) { final TextAttributes textAttributes = simpleTextAttributes.toTextAttributes(); @@ -112,11 +119,17 @@ public class NodeRenderer extends ColoredTreeCellRenderer { return simpleTextAttributes; } - public static SimpleTextAttributes getSimpleTextAttributes(final ItemPresentation presentation) { + public static SimpleTextAttributes getSimpleTextAttributes(@Nullable final ItemPresentation presentation) { + return getSimpleTextAttributes(presentation, EditorColorsManager.getInstance().getGlobalScheme()); + } + + public static SimpleTextAttributes getSimpleTextAttributes(@Nullable final ItemPresentation presentation, + @NotNull EditorColorsScheme colorsScheme) + { if (presentation instanceof ColoredItemPresentation) { final TextAttributesKey textAttributesKey = ((ColoredItemPresentation) presentation).getTextAttributesKey(); if (textAttributesKey == null) return SimpleTextAttributes.REGULAR_ATTRIBUTES; - final TextAttributes textAttributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(textAttributesKey); + final TextAttributes textAttributes = colorsScheme.getAttributes(textAttributesKey); return textAttributes == null ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.fromTextAttributes(textAttributes); } return SimpleTextAttributes.REGULAR_ATTRIBUTES; diff --git a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml index 9f001e7a2620..cca38e9c553b 100644 --- a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml +++ b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml @@ -347,8 +347,9 @@ - + + + diff --git a/plugins/gradle/gradle.iml b/plugins/gradle/gradle.iml index a3452f1859a3..4239d57a2c9a 100644 --- a/plugins/gradle/gradle.iml +++ b/plugins/gradle/gradle.iml @@ -32,6 +32,7 @@ + diff --git a/plugins/gradle/resources/i18n/GradleBundle.properties b/plugins/gradle/resources/i18n/GradleBundle.properties index a4fbd505a67d..d0a8f4b5371f 100644 --- a/plugins/gradle/resources/i18n/GradleBundle.properties +++ b/plugins/gradle/resources/i18n/GradleBundle.properties @@ -50,6 +50,7 @@ gradle.sync.title.tab=Changes gradle.sync.change.type.gradle=Gradle local setting gradle.sync.change.type.intellij={0} local setting gradle.sync.change.type.conflict=Settings conflict +gradle.sync.change.type.unchanged=Unchanged setting gradle.sync.change.type.confirmed=Confirmed settings diff gradle.library.resolve.progress.text=Resolving gradle libraries @@ -64,4 +65,11 @@ gradle.home.setting.type.explicit.incorrect=Gradle location is incorrect gradle.toolwindow.text.no.linked.project=\nThere is no linked Gradle project\nYou may use {@action Gradle.LinkToProject} to add the one. gradle.action.link.project.text=Link gradle project -gradle.action.link.project.description=Allows to link any gradle project to the current IDE project \ No newline at end of file +gradle.action.link.project.description=Allows to link any gradle project to the current IDE project + +gradle.settings.color.text.sample.project.name=my-project +gradle.settings.color.text.sample.conflict.module.name=module-with-conflicting-setup +gradle.settings.color.text.sample.library.sync.name=library-with-same-setup +gradle.settings.color.text.sample.library.gradle.name=library-added-at-Gradle +gradle.settings.color.text.sample.library.intellij.name=library-added-at-{0} +gradle.settings.color.text.sample.library.confirmed.name=library-with-different-but-confirmed-setup diff --git a/plugins/gradle/src/META-INF/plugin.xml b/plugins/gradle/src/META-INF/plugin.xml index 66671b6de803..95070489bf94 100644 --- a/plugins/gradle/src/META-INF/plugin.xml +++ b/plugins/gradle/src/META-INF/plugin.xml @@ -32,7 +32,8 @@ - + + diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/bootstrap/GradleBootstrap.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/bootstrap/GradleBootstrap.java index 7c55748615a6..762c18a47488 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/bootstrap/GradleBootstrap.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/bootstrap/GradleBootstrap.java @@ -11,8 +11,8 @@ import com.intellij.ui.content.impl.ContentImpl; import org.jetbrains.annotations.NotNull; import org.jetbrains.plugins.gradle.sync.GradleProjectStructureChangesModel; import org.jetbrains.plugins.gradle.sync.GradleProjectStructureChangesPanel; +import org.jetbrains.plugins.gradle.ui.GradleIcons; import org.jetbrains.plugins.gradle.util.GradleBundle; -import org.jetbrains.plugins.gradle.util.GradleConstants; /** * // TODO den add doc @@ -48,7 +48,7 @@ public class GradleBootstrap extends AbstractProjectComponent { } final ToolWindowManagerEx manager = ToolWindowManagerEx.getInstanceEx(myProject); ToolWindow toolWindow = manager.registerToolWindow(GRADLE_TOOL_WINDOW_ID, false, ToolWindowAnchor.RIGHT); - toolWindow.setIcon(GradleConstants.GRADLE_ICON); + toolWindow.setIcon(GradleIcons.GRADLE_ICON); String syncTitle = GradleBundle.message("gradle.sync.title.tab"); final GradleProjectStructureChangesPanel projectStructureChanges = new GradleProjectStructureChangesPanel(myProject, myChangesModel); toolWindow.getContentManager().addContent(new ContentImpl(projectStructureChanges, syncTitle, true)); diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorSettingsPage.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorAndFontDescriptorsProvider.java similarity index 59% rename from plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorSettingsPage.java rename to plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorAndFontDescriptorsProvider.java index a1a345f4b648..c3316cfcf574 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorSettingsPage.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorAndFontDescriptorsProvider.java @@ -5,6 +5,7 @@ import com.intellij.openapi.editor.colors.TextAttributesKey; import com.intellij.openapi.fileTypes.PlainSyntaxHighlighter; import com.intellij.openapi.fileTypes.SyntaxHighlighter; import com.intellij.openapi.options.colors.AttributesDescriptor; +import com.intellij.openapi.options.colors.ColorAndFontDescriptorsProvider; import com.intellij.openapi.options.colors.ColorDescriptor; import com.intellij.openapi.options.colors.ColorSettingsPage; import org.jetbrains.annotations.NotNull; @@ -22,68 +23,46 @@ import java.util.Map; * @author Denis Zhdanov * @since 1/18/12 4:15 PM */ -public class GradleColorSettingsPage implements ColorSettingsPage { +public class GradleColorAndFontDescriptorsProvider implements ColorAndFontDescriptorsProvider { - private static final ColorDescriptor[] DESCRIPTORS = { - new ColorDescriptor( - GradleBundle.message("gradle.sync.change.type.gradle"), - GradleColorKeys.GRADLE_LOCAL_CHANGE, - ColorDescriptor.Kind.FOREGROUND - ), - new ColorDescriptor( - GradleBundle.message("gradle.sync.change.type.intellij", ApplicationNamesInfo.getInstance().getProductName()), - GradleColorKeys.GRADLE_INTELLIJ_LOCAL_CHANGE, - ColorDescriptor.Kind.FOREGROUND - ), - new ColorDescriptor( + private static final AttributesDescriptor[] DESCRIPTORS = { + new AttributesDescriptor( GradleBundle.message("gradle.sync.change.type.conflict"), - GradleColorKeys.GRADLE_CHANGE_CONFLICT, - ColorDescriptor.Kind.FOREGROUND + GradleTextAttributes.GRADLE_CHANGE_CONFLICT ), - new ColorDescriptor( + new AttributesDescriptor( + GradleBundle.message("gradle.sync.change.type.gradle"), + GradleTextAttributes.GRADLE_LOCAL_CHANGE + ), + new AttributesDescriptor( + GradleBundle.message("gradle.sync.change.type.intellij", ApplicationNamesInfo.getInstance().getProductName()), + GradleTextAttributes.GRADLE_INTELLIJ_LOCAL_CHANGE + ), + new AttributesDescriptor( GradleBundle.message("gradle.sync.change.type.confirmed"), - GradleColorKeys.GRADLE_CONFIRMED_CONFLICT, - ColorDescriptor.Kind.FOREGROUND + GradleTextAttributes.GRADLE_CONFIRMED_CONFLICT + ), + new AttributesDescriptor( + GradleBundle.message("gradle.sync.change.type.unchanged"), + GradleTextAttributes.GRADLE_NO_CHANGE ) }; - + @NotNull @Override public String getDisplayName() { return GradleBundle.message("gradle.name"); } - @Override - public Icon getIcon() { - return GradleIcons.GRADLE_ICON; - } - @NotNull @Override public AttributesDescriptor[] getAttributeDescriptors() { - return new AttributesDescriptor[0]; - } - - @NotNull - @Override - public ColorDescriptor[] getColorDescriptors() { return DESCRIPTORS; } @NotNull @Override - public SyntaxHighlighter getHighlighter() { - return new PlainSyntaxHighlighter(); - } - - @NotNull - @Override - public String getDemoText() { - return ""; - } - - @Override - public Map getAdditionalHighlightingTagToDescriptorMap() { - return null; + public ColorDescriptor[] getColorDescriptors() { + return new ColorDescriptor[0]; } } diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorAndFontPanelFactory.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorAndFontPanelFactory.java new file mode 100644 index 000000000000..bad0df5d10f8 --- /dev/null +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorAndFontPanelFactory.java @@ -0,0 +1,29 @@ +package org.jetbrains.plugins.gradle.config; + +import com.intellij.application.options.colors.*; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.plugins.gradle.util.GradleBundle; + +/** + * @author Denis Zhdanov + * @since 1/19/12 11:32 AM + */ +public class GradleColorAndFontPanelFactory implements ColorAndFontPanelFactory { + + @NotNull + @Override + public NewColorAndFontPanel createPanel(@NotNull ColorAndFontOptions options) { + SchemesPanel schemesPanel = new SchemesPanel(options); + final ColorAndFontDescriptionPanel descriptionPanel = new ColorAndFontDescriptionPanel(); + final OptionsPanel optionsPanel = new OptionsPanelImpl(descriptionPanel, options, schemesPanel, GradleBundle.message("gradle.name")); + GradleColorAndFontPreviewPanel previewPanel = new GradleColorAndFontPreviewPanel(options); + // TODO den check what listeners do we need here. + return new NewColorAndFontPanel(schemesPanel, optionsPanel, previewPanel, GradleBundle.message("gradle.name"), null, null); + } + + @NotNull + @Override + public String getPanelDisplayName() { + return GradleBundle.message("gradle.name"); + } +} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorAndFontPreviewPanel.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorAndFontPreviewPanel.java new file mode 100644 index 000000000000..d755bf0c07e2 --- /dev/null +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorAndFontPreviewPanel.java @@ -0,0 +1,300 @@ +package org.jetbrains.plugins.gradle.config; + +import com.intellij.application.options.colors.ColorAndFontOptions; +import com.intellij.application.options.colors.ColorAndFontSettingsListener; +import com.intellij.application.options.colors.EditorSchemeAttributeDescriptor; +import com.intellij.application.options.colors.PreviewPanel; +import com.intellij.ide.projectView.PresentationData; +import com.intellij.ide.util.treeView.NodeRenderer; +import com.intellij.openapi.application.ApplicationNamesInfo; +import com.intellij.openapi.editor.colors.EditorColorsScheme; +import com.intellij.openapi.editor.colors.TextAttributesKey; +import com.intellij.openapi.util.Pair; +import com.intellij.openapi.util.Ref; +import com.intellij.ui.treeStructure.Tree; +import com.intellij.util.containers.hash.HashMap; +import org.jdesktop.swingx.JXPanel; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.plugins.gradle.ui.GradleIcons; +import org.jetbrains.plugins.gradle.ui.GradleProjectStructureNodeDescriptor; +import org.jetbrains.plugins.gradle.util.GradleBundle; + +import javax.swing.*; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CopyOnWriteArrayList; + +/** + * @author Denis Zhdanov + * @since 1/19/12 11:59 AM + */ +public class GradleColorAndFontPreviewPanel implements PreviewPanel { + + private static final int SELECTED_NODE_REFRESH_INTERVAL_MILLIS = 100; + private static final float BLINK_ALPHA_INCREMENT = 0.1f; + + private final Map myNodes = new HashMap(); + + private final List myListeners = new CopyOnWriteArrayList(); + private final JPanel myContent = new JPanel(new GridBagLayout()); + private final JXPanel myNodeRenderPanel = new JXPanel(new BorderLayout()); + private final Ref myAllowTreeExpansion = new Ref(true); + + private final Tree myTree; + private final DefaultTreeModel myTreeModel; + + private Timer myTimer; + private ColorAndFontOptions myOptions; + private TreeNode mySelectedNode; + private float mySelectedNodeAlpha; + private boolean mySelectedNodePainted; + + public GradleColorAndFontPreviewPanel(@NotNull ColorAndFontOptions options) { + myOptions = options; + final Pair pair = init(); + myTree = pair.first; + myTreeModel = pair.second; + } + + private Pair init() { + myContent.removeAll(); + String projectName = GradleBundle.message("gradle.settings.color.text.sample.project.name"); + DefaultMutableTreeNode root = createNode(projectName, GradleIcons.PROJECT_ICON, null); + + String moduleName = GradleBundle.message("gradle.settings.color.text.sample.conflict.module.name"); + DefaultMutableTreeNode module = createNode(moduleName, GradleIcons.MODULE_ICON, GradleTextAttributes.GRADLE_CHANGE_CONFLICT); + + String gradleLibraryName = GradleBundle.message("gradle.settings.color.text.sample.library.gradle.name"); + DefaultMutableTreeNode gradleLibrary = createNode(gradleLibraryName, GradleIcons.LIB_ICON, GradleTextAttributes.GRADLE_LOCAL_CHANGE); + + String intellijLibraryName = GradleBundle.message("gradle.settings.color.text.sample.library.intellij.name", + ApplicationNamesInfo.getInstance().getProductName()); + DefaultMutableTreeNode intellijLibrary = createNode( + intellijLibraryName, GradleIcons.LIB_ICON, GradleTextAttributes.GRADLE_INTELLIJ_LOCAL_CHANGE + ); + + String confirmedLibraryName = GradleBundle.message("gradle.settings.color.text.sample.library.confirmed.name"); + DefaultMutableTreeNode confirmedLibrary = createNode( + confirmedLibraryName, GradleIcons.LIB_ICON, GradleTextAttributes.GRADLE_CONFIRMED_CONFLICT + ); + + String syncLibraryName = GradleBundle.message("gradle.settings.color.text.sample.library.sync.name"); + DefaultMutableTreeNode syncLibrary = createNode(syncLibraryName, GradleIcons.LIB_ICON, GradleTextAttributes.GRADLE_NO_CHANGE); + + module.add(gradleLibrary); + module.add(intellijLibrary); + module.add(confirmedLibrary); + module.add(syncLibrary); + root.add(module); + + DefaultTreeModel treeModel = new DefaultTreeModel(root); + Tree tree = buildTree(treeModel, module); + + GridBagConstraints constraints = new GridBagConstraints(); + constraints.fill = GridBagConstraints.BOTH; + constraints.weightx = constraints.weighty = 1; + myContent.add(tree, constraints); + return new Pair(tree, treeModel); + } + + private Tree buildTree(@NotNull TreeModel model, DefaultMutableTreeNode ... nodesToExpand) { + final Tree tree = new Tree(model) { + @Override + protected void setExpandedState(TreePath path, boolean state) { + if (myAllowTreeExpansion.get()) { + super.setExpandedState(path, state); + } + // Ignore the expansion change events otherwise + } + }; + + // Configure expansion + for (DefaultMutableTreeNode node : nodesToExpand) { + tree.expandPath(new TreePath(node.getPath())); + } + myAllowTreeExpansion.set(false); + + // Configure selection. + tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); + tree.addTreeSelectionListener(new TreeSelectionListener() { + + private boolean myIgnore; + + @Override + public void valueChanged(TreeSelectionEvent e) { + if (myIgnore) { + return; + } + final TreePath path = e.getNewLeadSelectionPath(); + if (path == null) { + clearSelection(); + return; + } + final Object component = path.getLastPathComponent(); + for (Map.Entry entry : myNodes.entrySet()) { + if (entry.getValue().equals(component)) { + for (ColorAndFontSettingsListener listener : myListeners) { + listener.selectionInPreviewChanged(entry.getKey().getExternalName()); + clearSelection(); + } + return; + } + } + clearSelection(); + } + + private void clearSelection() { + // Don't show selection at the 'preview' node. + myIgnore = true; + try { + tree.getSelectionModel().clearSelection(); + } + finally { + myIgnore = false; + } + } + }); + + // Bind rendering to the target colors scheme. + final NodeRenderer delegate = new NodeRenderer() { + @NotNull + @Override + protected EditorColorsScheme getColorsScheme() { + return myOptions.getSelectedScheme(); + } + }; + myNodeRenderPanel.setBackground(tree.getBackground()); + myNodeRenderPanel.setPaintBorderInsets(false); + tree.setCellRenderer(new TreeCellRenderer() { + @Override + public Component getTreeCellRendererComponent(JTree tree, + Object value, + boolean selected, + boolean expanded, + boolean leaf, + int row, + boolean hasFocus) + { + final Component component = delegate.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); + myNodeRenderPanel.removeAll(); + myNodeRenderPanel.add(component); + if (value == mySelectedNode) { + myNodeRenderPanel.setAlpha(roundAlpha(mySelectedNodeAlpha)); + mySelectedNodePainted = true; + } + else { + myNodeRenderPanel.setAlpha(roundAlpha(1.1f - mySelectedNodeAlpha)); + } + return myNodeRenderPanel; + } + }); + return tree; + } + + @Override + public void blinkSelectedHighlightType(Object selected) { + if (!(selected instanceof EditorSchemeAttributeDescriptor)) { + return; + } + final String type = ((EditorSchemeAttributeDescriptor)selected).getType(); + for (Map.Entry entry : myNodes.entrySet()) { + if (entry.getKey().getExternalName().equals(type)) { + blink(entry.getValue()); + return; + } + } + } + + private void blink(@NotNull TreeNode node) { + if (myTimer != null) { + myTimer.stop(); + } + mySelectedNode = node; + mySelectedNodeAlpha = 0.5f; + myTimer = new Timer(SELECTED_NODE_REFRESH_INTERVAL_MILLIS, new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (mySelectedNodeAlpha > 1) { + mySelectedNodeAlpha = 1; + myTimer.stop(); + repaintTree(); + return; + } + if (!mySelectedNodePainted) { + return; + } + mySelectedNodePainted = false; + mySelectedNodeAlpha += BLINK_ALPHA_INCREMENT; + repaintTree(); + } + }); + myTimer.start(); + } + + @Override + public void disposeUIResources() { + myListeners.clear(); + myNodes.clear(); + myContent.removeAll(); + myNodeRenderPanel.removeAll(); + } + + @Override + public Component getPanel() { + return myContent; + } + + @Override + public void updateView() { + repaintTree(); + } + + private void repaintTree() { + // TODO den implement + myTreeModel.reload(); + myAllowTreeExpansion.set(true); + try { + for (DefaultMutableTreeNode node : myNodes.values()) { + myTree.expandPath(new TreePath(node.getPath())); + } + } + finally { + myAllowTreeExpansion.set(false); + } + } + + @Override + public void addListener(@NotNull ColorAndFontSettingsListener listener) { + myListeners.add(listener); + } + + private DefaultMutableTreeNode createNode(@NotNull String text, @NotNull Icon icon, @Nullable TextAttributesKey textAttributesKey) { + final GradleProjectStructureNodeDescriptor descriptor = new GradleProjectStructureNodeDescriptor(text, text, icon); + DefaultMutableTreeNode result = new DefaultMutableTreeNode(descriptor); + if (textAttributesKey != null) { + final PresentationData presentation = descriptor.getPresentation(); + presentation.setAttributesKey(textAttributesKey); + myNodes.put(textAttributesKey, result); + } + return result; + } + + private static float roundAlpha(float alpha) { + if (alpha < 0) { + return 0; + } + else if (alpha > 1) { + return 1; + } + else { + return alpha; + } + } +} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorKeys.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorKeys.java deleted file mode 100644 index fde14fdf4579..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleColorKeys.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.jetbrains.plugins.gradle.config; - -import com.intellij.openapi.editor.colors.ColorKey; -import com.intellij.ui.Gray; - -import java.awt.*; - -/** - * Holds keys to the colors used at gradle-specific processing. - *

- * Thread-safe. - * - * @author Denis Zhdanov - * @since 1/18/12 4:19 PM - */ -public class GradleColorKeys { - - /** - * References color to use for indication of particular change that exists only at the gradle side. - *

- * Example: particular dependency is added at the gradle side but not at intellij. - */ - public static final ColorKey GRADLE_LOCAL_CHANGE = ColorKey.createColorKey("GRADLE_LOCAL_CHANGE", new Color(130, 184, 22)); - public static final ColorKey GRADLE_INTELLIJ_LOCAL_CHANGE = ColorKey.createColorKey("GRADLE_INTELLIJ_LOCAL_CHANGE", new Color(16, 102, 248)); - public static final ColorKey GRADLE_CHANGE_CONFLICT = ColorKey.createColorKey("GRADLE_CHANGE_CONFLICT", new Color(255, 187, 255)); - public static final ColorKey GRADLE_CONFIRMED_CONFLICT = ColorKey.createColorKey("GRADLE_CONFIRMED_CONFLICT", Gray._208); - - private GradleColorKeys() { - } -} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleConfigurable.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleConfigurable.java index f81f236ce37f..f21de8c75b8c 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleConfigurable.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleConfigurable.java @@ -29,8 +29,8 @@ import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.plugins.gradle.ui.GradleIcons; import org.jetbrains.plugins.gradle.util.GradleBundle; -import org.jetbrains.plugins.gradle.util.GradleConstants; import org.jetbrains.plugins.gradle.util.GradleLibraryManager; import org.jetbrains.plugins.gradle.util.GradleUtil; @@ -251,7 +251,7 @@ public class GradleConfigurable implements SearchableConfigurable, Configurable. } public Icon getIcon() { - return GradleConstants.GRADLE_ICON; + return GradleIcons.GRADLE_ICON; } @NotNull diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleLibraryPresentationProvider.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleLibraryPresentationProvider.java index 8c619f848120..5cd1ebef6282 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleLibraryPresentationProvider.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleLibraryPresentationProvider.java @@ -24,6 +24,7 @@ import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.plugins.gradle.ui.GradleIcons; import org.jetbrains.plugins.gradle.util.GradleConstants; import org.jetbrains.plugins.gradle.util.GradleLibraryManager; import org.jetbrains.plugins.groovy.config.GroovyLibraryPresentationProviderBase; @@ -48,7 +49,7 @@ public class GradleLibraryPresentationProvider extends GroovyLibraryPresentation @NotNull @Override public Icon getIcon() { - return GradleConstants.GRADLE_ICON; + return GradleIcons.GRADLE_ICON; } @Nls diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleScriptType.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleScriptType.java index 459bfc00d258..d7def8e54110 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleScriptType.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleScriptType.java @@ -38,6 +38,7 @@ import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.NonClasspathDirectoryScope; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.plugins.gradle.ui.GradleIcons; import org.jetbrains.plugins.gradle.util.GradleConstants; import org.jetbrains.plugins.gradle.util.GradleLibraryManager; import org.jetbrains.plugins.groovy.config.GroovyConfigUtils; @@ -77,7 +78,7 @@ public class GradleScriptType extends GroovyScriptType { @NotNull @Override public Icon getScriptIcon() { - return GradleConstants.GRADLE_ICON; + return GradleIcons.GRADLE_ICON; } @Override @@ -161,7 +162,7 @@ public class GradleScriptType extends GroovyScriptType { int result = Messages.showOkCancelDialog( "Gradle is not configured. Do you want to configure it?", "Configure Gradle SDK", - GradleConstants.GRADLE_ICON + GradleIcons.GRADLE_ICON ); if (result == 0) { ShowSettingsUtil.getInstance().editConfigurable(project, new GradleConfigurable(project)); diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleTextAttributes.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleTextAttributes.java new file mode 100644 index 000000000000..cc449b9fd629 --- /dev/null +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleTextAttributes.java @@ -0,0 +1,72 @@ +package org.jetbrains.plugins.gradle.config; + +import com.intellij.openapi.editor.colors.TextAttributesKey; +import com.intellij.openapi.editor.markup.TextAttributes; +import com.intellij.ui.Gray; + +import java.awt.*; + +/** + * Holds keys to the colors used at gradle-specific processing. + *

+ * Thread-safe. + * + * @author Denis Zhdanov + * @since 1/18/12 4:19 PM + */ +public class GradleTextAttributes { + + /** + * References color to use for indication of particular change that exists only at the gradle side. + *

+ * Example: particular dependency is added at the gradle side but not at the intellij. + */ + public static final TextAttributesKey GRADLE_LOCAL_CHANGE = TextAttributesKey.createTextAttributesKey( + "GRADLE_LOCAL_CHANGE", + new TextAttributes(new Color(130, 184, 22), null, null, null, Font.PLAIN) + ); + + /** + * References color to use for indication of particular change that exists only at the intellij side. + *

+ * Example: particular dependency is added at the intellij side but not at the gradle. + */ + public static final TextAttributesKey GRADLE_INTELLIJ_LOCAL_CHANGE = TextAttributesKey.createTextAttributesKey( + "GRADLE_INTELLIJ_LOCAL_CHANGE", + new TextAttributes(new Color(16, 102, 248), null, null, null, Font.PLAIN) + ); + + /** + * References color to use for indication that particular setting has different values at the gradle and intellij. + *

+ * Example: particular module is renamed at the intellij, i.e. 'module.name' property has different (conflicting) + * values at the gradle and the intellij. + */ + public static final TextAttributesKey GRADLE_CHANGE_CONFLICT = TextAttributesKey.createTextAttributesKey( + "GRADLE_CHANGE_CONFLICT", + new TextAttributes(new Color(238, 0, 0), null, null, null, Font.PLAIN) + ); + + /** + * References color to use for indication that particular setting has the same values at the gradle and intellij. + */ + public static final TextAttributesKey GRADLE_NO_CHANGE = TextAttributesKey.createTextAttributesKey( + "GRADLE_NO_CHANGE", + new TextAttributes(Color.BLACK, null, null, null, Font.PLAIN) + ); + + /** + * References color to use for indication that particular change should be ignored during the gradle and intellij project structures + * comparison. + *

+ * Example: particular dummy module specific to the local environment is added at the intellij side but we don't want to propagate + * that to the gradle side and don't want to see it during the project structures comparison. + */ + public static final TextAttributesKey GRADLE_CONFIRMED_CONFLICT = TextAttributesKey.createTextAttributesKey( + "GRADLE_CONFIRMED_CONFLICT", + new TextAttributes(Gray._140, null, null, null, Font.PLAIN) + ); + + private GradleTextAttributes() { + } +} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleToolWindowPanel.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleToolWindowPanel.java index 70b1ccd93c89..063cb6eee62b 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleToolWindowPanel.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleToolWindowPanel.java @@ -10,7 +10,7 @@ import com.intellij.util.messages.MessageBusConnection; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.gradle.util.GradleBundle; -import org.jetbrains.plugins.gradle.util.RichTextControlBuilder; +import org.jetbrains.plugins.gradle.ui.RichTextControlBuilder; import javax.swing.*; import java.awt.*; @@ -85,13 +85,18 @@ public abstract class GradleToolWindowPanel extends SimpleToolWindowPanel { updateContent(); } - + + @NotNull + public Project getProject() { + return myProject; + } + /** * @return GUI control to be displayed at the current tab */ @NotNull protected abstract JComponent buildContent(); - + /** * Callback for asking content control to update its state. */ diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/GradleProjectImportBuilder.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/GradleProjectImportBuilder.java index 1b418fc9c4c4..9c7a99224f4a 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/GradleProjectImportBuilder.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/GradleProjectImportBuilder.java @@ -32,8 +32,8 @@ import org.jetbrains.plugins.gradle.notification.*; import org.jetbrains.plugins.gradle.remote.GradleApiException; import org.jetbrains.plugins.gradle.remote.GradleApiFacadeManager; import org.jetbrains.plugins.gradle.remote.GradleProjectResolver; +import org.jetbrains.plugins.gradle.ui.GradleIcons; import org.jetbrains.plugins.gradle.util.GradleBundle; -import org.jetbrains.plugins.gradle.util.GradleConstants; import org.jetbrains.plugins.gradle.util.GradleLog; import javax.swing.*; @@ -70,7 +70,7 @@ public class GradleProjectImportBuilder extends ProjectImportBuilder GradleProjectStructureNodeDescriptor buildDescriptor(@NotNull T entity) { - final Ref result = new Ref(); + final Ref> result = new Ref>(); entity.invite(new GradleEntityVisitor() { @Override public void visit(@NotNull GradleProject project) { - result.set(new GradleProjectStructureNodeDescriptor(project, project.getName(), PROJECT_ICON)); + result.set(new GradleProjectStructureNodeDescriptor(project, project.getName(), GradleIcons.PROJECT_ICON)); } @Override public void visit(@NotNull GradleModule module) { - result.set(new GradleProjectStructureNodeDescriptor(module, module.getName(), MODULE_ICON)); + result.set(new GradleProjectStructureNodeDescriptor(module, module.getName(), GradleIcons.MODULE_ICON)); } @Override public void visit(@NotNull GradleContentRoot contentRoot) { - result.set(new GradleProjectStructureNodeDescriptor( + result.set(new GradleProjectStructureNodeDescriptor( contentRoot, - GradleBundle.message("gradle.import.structure.tree.node.content.root"), CONTENT_ROOT_ICON + GradleBundle.message("gradle.import.structure.tree.node.content.root"), GradleIcons.CONTENT_ROOT_ICON )); } @Override public void visit(@NotNull GradleLibrary library) { - result.set(new GradleProjectStructureNodeDescriptor(library, library.getName(), LIB_ICON)); + result.set(new GradleProjectStructureNodeDescriptor(library, library.getName(), GradleIcons.LIB_ICON)); } @Override diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/wizard/adjust/GradleProjectStructureNodeDescriptor.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/wizard/adjust/GradleProjectStructureNodeDescriptor.java deleted file mode 100644 index a68adf732978..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/wizard/adjust/GradleProjectStructureNodeDescriptor.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.jetbrains.plugins.gradle.importing.wizard.adjust; - -import com.intellij.ide.util.treeView.NodeDescriptor; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.plugins.gradle.model.GradleEntity; - -import javax.swing.*; - -/** - * Descriptor for the node of 'project structure view' derived from gradle. - * - * @author Denis Zhdanov - * @since 8/12/11 2:47 PM - */ -public class GradleProjectStructureNodeDescriptor extends NodeDescriptor { - - private final GradleEntity myData; - - @SuppressWarnings("NullableProblems") - GradleProjectStructureNodeDescriptor(@NotNull GradleEntity data, @NotNull String text, @NotNull Icon icon) { - super(null, null); - myData = data; - myOpenIcon = myClosedIcon = icon; - myName = text; - } - - @Override - public boolean update() { - return true; - } - - @Override - public GradleEntity getElement() { - return myData; - } - - public void setName(@NotNull String name) { - myName = name; - } -} \ No newline at end of file diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/GradleProjectStructureChangesPanel.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/GradleProjectStructureChangesPanel.java index 50d999a531c9..e7234965e23a 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/GradleProjectStructureChangesPanel.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/GradleProjectStructureChangesPanel.java @@ -1,12 +1,24 @@ package org.jetbrains.plugins.gradle.sync; +import com.intellij.openapi.module.Module; +import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.project.Project; -import com.intellij.ui.treeStructure.SimpleTree; +import com.intellij.openapi.roots.LibraryOrderEntry; +import com.intellij.openapi.roots.ModuleRootManager; +import com.intellij.openapi.roots.OrderEntry; +import com.intellij.openapi.roots.RootPolicy; +import com.intellij.ui.treeStructure.Tree; import org.jetbrains.annotations.NotNull; import org.jetbrains.plugins.gradle.config.GradleToolWindowPanel; +import org.jetbrains.plugins.gradle.ui.GradleIcons; +import org.jetbrains.plugins.gradle.ui.GradleProjectStructureNodeDescriptor; import org.jetbrains.plugins.gradle.util.GradleConstants; import javax.swing.*; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreeCellRenderer; +import java.awt.*; /** * // TODO den add doc @@ -15,24 +27,72 @@ import javax.swing.*; * @since 11/3/11 3:58 PM */ public class GradleProjectStructureChangesPanel extends GradleToolWindowPanel { + + private JPanel myContent; - private final GradleProjectStructureChangesModel myModel; + private final GradleProjectStructureChangesModel myDataModel; public GradleProjectStructureChangesPanel(@NotNull Project project, @NotNull GradleProjectStructureChangesModel model) { super(project, GradleConstants.TOOL_WINDOW_TOOLBAR_PLACE); - myModel = model; + myDataModel = model; + init(); } + private void init() { + JPanel content = new JPanel(new GridBagLayout()); + DefaultMutableTreeNode root = new DefaultMutableTreeNode(buildDescriptor(getProject())); + final Module[] modules = ModuleManager.getInstance(getProject()).getModules(); + RootPolicy policy = new RootPolicy() { + @Override + public LibraryOrderEntry visitLibraryOrderEntry(LibraryOrderEntry libraryOrderEntry, LibraryOrderEntry value) { + return libraryOrderEntry; + } + }; + for (Module module : modules) { + final DefaultMutableTreeNode moduleNode = new DefaultMutableTreeNode(buildDescriptor(module)); + final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module); + for (OrderEntry orderEntry : moduleRootManager.getOrderEntries()) { + final LibraryOrderEntry library = orderEntry.accept(policy, null); + if (library != null) { + moduleNode.add(new DefaultMutableTreeNode(buildDescriptor(library))); + } + } + root.add(moduleNode); + } + DefaultTreeModel treeModel = new DefaultTreeModel(root); + Tree tree = new Tree(treeModel); + + GridBagConstraints constraints = new GridBagConstraints(); + constraints.fill = GridBagConstraints.BOTH; + constraints.weightx = constraints.weighty = 1; + content.add(tree, constraints); + myContent = content; + } + @NotNull @Override protected JComponent buildContent() { - // TODO den implement - return new SimpleTree(); - //return new JLabel("project-structure-change-content"); + if (myContent == null) { + init(); + } + return myContent; } @Override protected void updateContent() { - // TODO den implement + // TODO den implement + int i = 1; + } + + public static GradleProjectStructureNodeDescriptor buildDescriptor(@NotNull Project project) { + return new GradleProjectStructureNodeDescriptor(project, project.getName(), GradleIcons.PROJECT_ICON); + } + + public static GradleProjectStructureNodeDescriptor buildDescriptor(@NotNull Module module) { + return new GradleProjectStructureNodeDescriptor(module, module.getName(), GradleIcons.MODULE_ICON); + } + + public static GradleProjectStructureNodeDescriptor buildDescriptor(@NotNull LibraryOrderEntry library) { + return new GradleProjectStructureNodeDescriptor(library, library.getPresentableName(), GradleIcons.LIB_ICON); } } diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/GradleIcons.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/GradleIcons.java new file mode 100644 index 000000000000..a267350fd019 --- /dev/null +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/GradleIcons.java @@ -0,0 +1,21 @@ +package org.jetbrains.plugins.gradle.ui; + +import com.intellij.openapi.util.IconLoader; + +import javax.swing.*; + +/** + * @author Denis Zhdanov + * @since 1/18/12 1:16 PM + */ +public class GradleIcons { + + public static final Icon GRADLE_ICON = IconLoader.getIcon("/icons/gradle.png"); + public static final Icon LIB_ICON = IconLoader.getIcon("/nodes/ppLib.png"); + public static final Icon PROJECT_ICON = IconLoader.getIcon("/nodes/ideaProject.png"); + public static final Icon MODULE_ICON = IconLoader.getIcon("/nodes/ModuleOpen.png"); + public static final Icon CONTENT_ROOT_ICON = IconLoader.getIcon("/modules/addContentEntry.png"); + + private GradleIcons() { + } +} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/wizard/adjust/GradleProjectStructureNode.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/GradleProjectStructureNode.java similarity index 89% rename from plugins/gradle/src/org/jetbrains/plugins/gradle/importing/wizard/adjust/GradleProjectStructureNode.java rename to plugins/gradle/src/org/jetbrains/plugins/gradle/ui/GradleProjectStructureNode.java index c12b8ffd7515..06e7285d2861 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/importing/wizard/adjust/GradleProjectStructureNode.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/GradleProjectStructureNode.java @@ -1,4 +1,4 @@ -package org.jetbrains.plugins.gradle.importing.wizard.adjust; +package org.jetbrains.plugins.gradle.ui; import org.jetbrains.annotations.NotNull; diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/GradleProjectStructureNodeDescriptor.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/GradleProjectStructureNodeDescriptor.java new file mode 100644 index 000000000000..8f6fc72bea16 --- /dev/null +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/GradleProjectStructureNodeDescriptor.java @@ -0,0 +1,42 @@ +package org.jetbrains.plugins.gradle.ui; + +import com.intellij.ide.projectView.PresentationData; +import com.intellij.ide.util.treeView.PresentableNodeDescriptor; +import org.jetbrains.annotations.NotNull; + +import javax.swing.*; +import java.awt.*; + +/** + * Descriptor for the node of 'project structure view' derived from gradle. + * + * @author Denis Zhdanov + * @since 8/12/11 2:47 PM + * @param target element type + */ +public class GradleProjectStructureNodeDescriptor extends PresentableNodeDescriptor { + + private final T myData; + + @SuppressWarnings("NullableProblems") + public GradleProjectStructureNodeDescriptor(@NotNull T data, @NotNull String text, @NotNull Icon icon) { + super(null, null); + myData = data; + myOpenIcon = myClosedIcon = icon; + myName = text; + } + + @Override + protected void update(@NotNull PresentationData presentation) { + presentation.setForcedTextForeground(Color.RED); + } + + @Override + public T getElement() { + return myData; + } + + public void setName(@NotNull String name) { + myName = name; + } +} \ No newline at end of file diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/util/MultiRowFlowPanel.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/MultiRowFlowPanel.java similarity index 98% rename from plugins/gradle/src/org/jetbrains/plugins/gradle/util/MultiRowFlowPanel.java rename to plugins/gradle/src/org/jetbrains/plugins/gradle/ui/MultiRowFlowPanel.java index 07bf9232e8e8..75e84552fbfa 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/util/MultiRowFlowPanel.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/MultiRowFlowPanel.java @@ -1,4 +1,4 @@ -package org.jetbrains.plugins.gradle.util; +package org.jetbrains.plugins.gradle.ui; import org.intellij.lang.annotations.JdkConstants; diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/util/RichTextActionProcessor.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/RichTextActionProcessor.java similarity index 93% rename from plugins/gradle/src/org/jetbrains/plugins/gradle/util/RichTextActionProcessor.java rename to plugins/gradle/src/org/jetbrains/plugins/gradle/ui/RichTextActionProcessor.java index 458a05122433..0fee03b51d73 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/util/RichTextActionProcessor.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/RichTextActionProcessor.java @@ -1,4 +1,4 @@ -package org.jetbrains.plugins.gradle.util; +package org.jetbrains.plugins.gradle.ui; import com.intellij.openapi.actionSystem.ActionManager; import com.intellij.openapi.actionSystem.AnAction; @@ -6,6 +6,7 @@ import com.intellij.openapi.actionSystem.Presentation; import com.intellij.openapi.actionSystem.ex.ActionButtonLook; import com.intellij.openapi.actionSystem.impl.ActionButton; import org.jetbrains.annotations.NotNull; +import org.jetbrains.plugins.gradle.util.GradleConstants; import javax.swing.*; import java.awt.*; diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/util/RichTextControlBuilder.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/RichTextControlBuilder.java similarity index 99% rename from plugins/gradle/src/org/jetbrains/plugins/gradle/util/RichTextControlBuilder.java rename to plugins/gradle/src/org/jetbrains/plugins/gradle/ui/RichTextControlBuilder.java index 59d05c747cb1..cc3371b08d91 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/util/RichTextControlBuilder.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/RichTextControlBuilder.java @@ -1,4 +1,4 @@ -package org.jetbrains.plugins.gradle.util; +package org.jetbrains.plugins.gradle.ui; import com.intellij.openapi.util.text.StringUtil; import org.jetbrains.annotations.NotNull; diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleConstants.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleConstants.java index f6684687fccd..49f441744592 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleConstants.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleConstants.java @@ -13,7 +13,6 @@ import javax.swing.*; */ public class GradleConstants { - public static final Icon GRADLE_ICON = IconLoader.getIcon("/icons/gradle.png"); @NonNls public static final String EXTENSION = "gradle"; @NonNls public static final String DEFAULT_SCRIPT_NAME = "build.gradle"; @NonNls public static final String TOOL_WINDOW_TOOLBAR_PLACE = "GRADLE_SYNC_CHANGES_TOOLBAR"; diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleUtil.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleUtil.java index f00fcc29df84..a285e2a27325 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleUtil.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleUtil.java @@ -11,6 +11,7 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.awt.RelativePoint; import com.intellij.util.PathUtil; import org.jetbrains.annotations.NotNull; +import org.jetbrains.plugins.gradle.ui.GradleIcons; import javax.swing.*; import java.awt.*; @@ -54,7 +55,7 @@ public class GradleUtil { *

* Note: we want to fall back to the standard {@link FileTypeDescriptor} when dedicated gradle file type * is introduced (it's processed as groovy file at the moment). We use open project descriptor here in order to show - * custom gradle icon at the file chooser ({@link GradleConstants#GRADLE_ICON}, is used at the file chooser dialog via + * custom gradle icon at the file chooser ({@link GradleIcons#GRADLE_ICON}, is used at the file chooser dialog via * the dedicated gradle project open processor). */ public static FileChooserDescriptor getFileChooserDescriptor() {