mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-02 00:57:59 +07:00
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;
This commit is contained in:
+60
@@ -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<ColorAndFontDescriptorsProvider> 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();
|
||||
}
|
||||
@@ -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<ColorSettingsPage> 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.
|
||||
|
||||
@@ -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<OrderEntry> {
|
||||
* @param initialValue the default value to be returned by the visit process.
|
||||
* @return the value returned by the visitor.
|
||||
*/
|
||||
<R> R accept(RootPolicy<R> policy, R initialValue);
|
||||
<R> R accept(RootPolicy<R> policy, @Nullable R initialValue);
|
||||
}
|
||||
|
||||
+23
-13
@@ -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<EditorSchemeAttributeDescriptor> descriptions,
|
||||
MyColorScheme scheme) {
|
||||
String group = page.getDisplayName();
|
||||
List<AttributesDescriptor> attributeDescriptors = ColorSettingsUtil.getAllAttributeDescriptors(page);
|
||||
String group = provider.getDisplayName();
|
||||
List<AttributesDescriptor> 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;
|
||||
|
||||
+14
-2
@@ -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<ColorAndFontPanelFactory> EP_NAME = ExtensionPointName.create("com.intellij.colorAndFontPanelFactory");
|
||||
|
||||
@NotNull
|
||||
NewColorAndFontPanel createPanel(@NotNull ColorAndFontOptions options);
|
||||
|
||||
@NotNull
|
||||
String getPanelDisplayName();
|
||||
}
|
||||
|
||||
+8
-7
@@ -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<AttributesDescriptor> getAllAttributeDescriptors(ColorSettingsPage page) {
|
||||
public static List<AttributesDescriptor> getAllAttributeDescriptors(ColorAndFontDescriptorsProvider provider) {
|
||||
List<AttributesDescriptor> result = new ArrayList<AttributesDescriptor>();
|
||||
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;
|
||||
|
||||
+5
-2
@@ -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;
|
||||
}
|
||||
|
||||
+2
-2
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
+3
-2
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -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<String, TextAttributesKey> tags) {
|
||||
public HighlightsExtractor(@Nullable Map<String, TextAttributesKey> tags) {
|
||||
myTags = tags;
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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<E> {
|
||||
|
||||
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<E> {
|
||||
return myColor;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public final Project getProject() {
|
||||
return myProject;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -347,8 +347,9 @@
|
||||
|
||||
<extensionPoint name="scopeParserExtension" interface="com.intellij.psi.search.scope.packageSet.PackageSetParserExtension"/>
|
||||
<extensionPoint name="referenceProviderType" beanClass="com.intellij.util.KeyedLazyInstanceEP"/>
|
||||
<extensionPoint name="colorSettingsPage"
|
||||
interface="com.intellij.openapi.options.colors.ColorSettingsPage"/>
|
||||
<extensionPoint name="colorSettingsPage" interface="com.intellij.openapi.options.colors.ColorSettingsPage"/>
|
||||
<extensionPoint name="colorAndFontPanelFactory" interface="com.intellij.application.options.colors.ColorAndFontPanelFactory"/>
|
||||
<extensionPoint name="colorAndFontDescriptorProvider" interface="com.intellij.openapi.options.colors.ColorAndFontDescriptorsProvider"/>
|
||||
|
||||
<extensionPoint name="codeInsight.parameterInfo" beanClass="com.intellij.lang.LanguageExtensionPoint"/>
|
||||
<extensionPoint name="editorOptionsProvider" beanClass="com.intellij.application.options.editor.EditorOptionsProviderEP"/>
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
<orderEntry type="library" name="JUnit4" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Mocks" level="project" />
|
||||
<orderEntry type="module" module-name="testFramework" scope="TEST" />
|
||||
<orderEntry type="library" name="swingx" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
@@ -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
|
||||
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
|
||||
|
||||
@@ -32,7 +32,8 @@
|
||||
<library.presentationProvider implementation="org.jetbrains.plugins.gradle.config.GradleLibraryPresentationProvider" order="last"/>
|
||||
<java.elementFinder implementation="org.jetbrains.plugins.gradle.config.GradleClassFinder"/>
|
||||
<projectOpenProcessor implementation="org.jetbrains.plugins.gradle.importing.GradleProjectOpenProcessor"/>
|
||||
<colorSettingsPage implementation="org.jetbrains.plugins.gradle.config.GradleColorSettingsPage"/>
|
||||
<colorAndFontPanelFactory implementation="org.jetbrains.plugins.gradle.config.GradleColorAndFontPanelFactory"/>
|
||||
<colorAndFontDescriptorProvider implementation="org.jetbrains.plugins.gradle.config.GradleColorAndFontDescriptorsProvider"/>
|
||||
|
||||
<applicationService serviceImplementation="org.jetbrains.plugins.gradle.remote.GradleApiFacadeManager"/>
|
||||
<applicationService serviceImplementation="org.jetbrains.plugins.gradle.util.GradleLibraryManager"/>
|
||||
|
||||
@@ -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));
|
||||
|
||||
+22
-43
@@ -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<String, TextAttributesKey> getAdditionalHighlightingTagToDescriptorMap() {
|
||||
return null;
|
||||
public ColorDescriptor[] getColorDescriptors() {
|
||||
return new ColorDescriptor[0];
|
||||
}
|
||||
}
|
||||
+29
@@ -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");
|
||||
}
|
||||
}
|
||||
+300
@@ -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<TextAttributesKey, DefaultMutableTreeNode> myNodes = new HashMap<TextAttributesKey, DefaultMutableTreeNode>();
|
||||
|
||||
private final List<ColorAndFontSettingsListener> myListeners = new CopyOnWriteArrayList<ColorAndFontSettingsListener>();
|
||||
private final JPanel myContent = new JPanel(new GridBagLayout());
|
||||
private final JXPanel myNodeRenderPanel = new JXPanel(new BorderLayout());
|
||||
private final Ref<Boolean> myAllowTreeExpansion = new Ref<Boolean>(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<Tree, DefaultTreeModel> pair = init();
|
||||
myTree = pair.first;
|
||||
myTreeModel = pair.second;
|
||||
}
|
||||
|
||||
private Pair<Tree, DefaultTreeModel> 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, DefaultTreeModel>(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<TextAttributesKey, DefaultMutableTreeNode> 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<TextAttributesKey, DefaultMutableTreeNode> 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<String> descriptor = new GradleProjectStructureNodeDescriptor<String>(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
* <p/>
|
||||
* 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.
|
||||
* <p/>
|
||||
* 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() {
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
+2
-1
@@ -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
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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.
|
||||
* <p/>
|
||||
* 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.
|
||||
* <p/>
|
||||
* 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.
|
||||
* <p/>
|
||||
* 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.
|
||||
* <p/>
|
||||
* Example: particular module is renamed at the intellij, i.e. <code>'module.name'</code> 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.
|
||||
* <p/>
|
||||
* 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() {
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
+2
-2
@@ -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<GradleProje
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return GradleConstants.GRADLE_ICON;
|
||||
return GradleIcons.GRADLE_ICON;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
@@ -10,6 +10,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.gradle.importing.GradleProjectImportBuilder;
|
||||
import org.jetbrains.plugins.gradle.model.*;
|
||||
import org.jetbrains.plugins.gradle.importing.wizard.AbstractImportFromGradleWizardStep;
|
||||
import org.jetbrains.plugins.gradle.ui.GradleProjectStructureNode;
|
||||
import org.jetbrains.plugins.gradle.util.GradleBundle;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
+9
-13
@@ -1,12 +1,13 @@
|
||||
package org.jetbrains.plugins.gradle.importing.wizard.adjust;
|
||||
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.gradle.model.*;
|
||||
import org.jetbrains.plugins.gradle.ui.GradleIcons;
|
||||
import org.jetbrains.plugins.gradle.ui.GradleProjectStructureNode;
|
||||
import org.jetbrains.plugins.gradle.ui.GradleProjectStructureNodeDescriptor;
|
||||
import org.jetbrains.plugins.gradle.util.GradleBundle;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.tree.DefaultTreeModel;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
@@ -27,37 +28,32 @@ public class GradleProjectStructureFactory {
|
||||
/** Shared instance of the current (stateless) class. */
|
||||
public static final GradleProjectStructureFactory INSTANCE = new GradleProjectStructureFactory();
|
||||
|
||||
private static final Icon PROJECT_ICON = IconLoader.getIcon("/nodes/ideaProject.png");
|
||||
private static final Icon MODULE_ICON = IconLoader.getIcon("/nodes/ModuleOpen.png");
|
||||
private static final Icon CONTENT_ROOT_ICON = IconLoader.getIcon("/modules/addContentEntry.png");
|
||||
private static final Icon LIB_ICON = IconLoader.getIcon("/nodes/ppLib.png");
|
||||
|
||||
@SuppressWarnings("MethodMayBeStatic")
|
||||
@NotNull
|
||||
public <T extends GradleEntity> GradleProjectStructureNodeDescriptor buildDescriptor(@NotNull T entity) {
|
||||
final Ref<GradleProjectStructureNodeDescriptor> result = new Ref<GradleProjectStructureNodeDescriptor>();
|
||||
final Ref<GradleProjectStructureNodeDescriptor<GradleEntity>> result = new Ref<GradleProjectStructureNodeDescriptor<GradleEntity>>();
|
||||
entity.invite(new GradleEntityVisitor() {
|
||||
@Override
|
||||
public void visit(@NotNull GradleProject project) {
|
||||
result.set(new GradleProjectStructureNodeDescriptor(project, project.getName(), PROJECT_ICON));
|
||||
result.set(new GradleProjectStructureNodeDescriptor<GradleEntity>(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<GradleEntity>(module, module.getName(), GradleIcons.MODULE_ICON));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(@NotNull GradleContentRoot contentRoot) {
|
||||
result.set(new GradleProjectStructureNodeDescriptor(
|
||||
result.set(new GradleProjectStructureNodeDescriptor<GradleEntity>(
|
||||
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<GradleEntity>(library, library.getName(), GradleIcons.LIB_ICON));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
-40
@@ -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<GradleEntity> {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
+67
-7
@@ -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<LibraryOrderEntry> policy = new RootPolicy<LibraryOrderEntry>() {
|
||||
@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<Project> buildDescriptor(@NotNull Project project) {
|
||||
return new GradleProjectStructureNodeDescriptor<Project>(project, project.getName(), GradleIcons.PROJECT_ICON);
|
||||
}
|
||||
|
||||
public static GradleProjectStructureNodeDescriptor<Module> buildDescriptor(@NotNull Module module) {
|
||||
return new GradleProjectStructureNodeDescriptor<Module>(module, module.getName(), GradleIcons.MODULE_ICON);
|
||||
}
|
||||
|
||||
public static GradleProjectStructureNodeDescriptor<LibraryOrderEntry> buildDescriptor(@NotNull LibraryOrderEntry library) {
|
||||
return new GradleProjectStructureNodeDescriptor<LibraryOrderEntry>(library, library.getPresentableName(), GradleIcons.LIB_ICON);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.jetbrains.plugins.gradle.importing.wizard.adjust;
|
||||
package org.jetbrains.plugins.gradle.ui;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
+42
@@ -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 <T> target element type
|
||||
*/
|
||||
public class GradleProjectStructureNodeDescriptor<T> extends PresentableNodeDescriptor<T> {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.jetbrains.plugins.gradle.util;
|
||||
package org.jetbrains.plugins.gradle.ui;
|
||||
|
||||
import org.intellij.lang.annotations.JdkConstants;
|
||||
|
||||
+2
-1
@@ -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.*;
|
||||
+1
-1
@@ -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;
|
||||
@@ -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";
|
||||
|
||||
@@ -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 {
|
||||
* <p/>
|
||||
* <b>Note:</b> 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() {
|
||||
|
||||
Reference in New Issue
Block a user