diff --git a/colorSchemes/src/colorSchemes/github.xml b/colorSchemes/src/colorSchemes/github.xml index 10ee41801d9e..ea6d3b4212b3 100644 --- a/colorSchemes/src/colorSchemes/github.xml +++ b/colorSchemes/src/colorSchemes/github.xml @@ -1,38 +1,39 @@ - + @@ -1164,12 +1191,12 @@ @@ -1833,32 +1890,30 @@ diff --git a/java/execution/openapi/src/com/intellij/execution/JavaExecutionUtil.java b/java/execution/openapi/src/com/intellij/execution/JavaExecutionUtil.java index 52a705e3841f..801740dec5f7 100644 --- a/java/execution/openapi/src/com/intellij/execution/JavaExecutionUtil.java +++ b/java/execution/openapi/src/com/intellij/execution/JavaExecutionUtil.java @@ -106,7 +106,7 @@ public class JavaExecutionUtil { } @Nullable - public static String getRuntimeQualifiedName(final PsiClass aClass) { + public static String getRuntimeQualifiedName(@NotNull final PsiClass aClass) { return ClassUtil.getJVMClassName(aClass); } diff --git a/java/idea-ui/src/com/intellij/platform/templates/IC_templates.xml b/java/idea-ui/src/com/intellij/platform/templates/IC_templates.xml index 8da6b26f055a..d8daaec7b869 100644 --- a/java/idea-ui/src/com/intellij/platform/templates/IC_templates.xml +++ b/java/idea-ui/src/com/intellij/platform/templates/IC_templates.xml @@ -1,8 +1,7 @@ diff --git a/java/idea-ui/src/com/intellij/platform/templates/IU_template_groups.xml b/java/idea-ui/src/com/intellij/platform/templates/IU_template_groups.xml new file mode 100644 index 000000000000..52446026f3b6 --- /dev/null +++ b/java/idea-ui/src/com/intellij/platform/templates/IU_template_groups.xml @@ -0,0 +1,13 @@ + + + Spring + Spring + + + \ No newline at end of file diff --git a/java/idea-ui/src/com/intellij/platform/templates/IU_template_groups.xsd b/java/idea-ui/src/com/intellij/platform/templates/IU_template_groups.xsd new file mode 100644 index 000000000000..c7adb5afba89 --- /dev/null +++ b/java/idea-ui/src/com/intellij/platform/templates/IU_template_groups.xsd @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java b/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java index 33b6d84e594c..e6bd637eb0fd 100644 --- a/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java +++ b/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java @@ -22,21 +22,26 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.extensions.PluginId; import com.intellij.openapi.module.ModuleType; import com.intellij.openapi.module.ModuleTypeManager; +import com.intellij.openapi.util.ClearableLazyValue; import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.io.StreamUtil; import com.intellij.platform.ProjectTemplate; import com.intellij.platform.ProjectTemplatesFactory; +import com.intellij.util.ArrayUtil; import com.intellij.util.NullableFunction; import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.containers.MultiMap; import com.intellij.util.net.HttpConfigurable; import org.jdom.Element; import org.jdom.JDOMException; +import org.jdom.Namespace; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; +import java.util.Collection; import java.util.List; import java.util.zip.ZipInputStream; @@ -47,32 +52,47 @@ import java.util.zip.ZipInputStream; public class RemoteTemplatesFactory extends ProjectTemplatesFactory { private static final String URL = "http://download.jetbrains.com/idea/project_templates/"; + private static final String SAMPLES_GALLERY = "Samples Gallery"; + private static final Namespace NAMESPACE = Namespace.getNamespace("http://www.jetbrains.com/projectTemplates"); + private final ClearableLazyValue> myTemplates = new ClearableLazyValue>() { + @NotNull + @Override + protected MultiMap compute() { + return getTemplates(); + } + }; @NotNull @Override public String[] getGroups() { - return new String[] { "Samples Gallery"}; + myTemplates.drop(); + return ArrayUtil.toStringArray(myTemplates.getValue().keySet()); } @NotNull @Override public ProjectTemplate[] createTemplates(String group, WizardContext context) { + Collection templates = myTemplates.getValue().get(group); + return templates.toArray(new ProjectTemplate[templates.size()]); + } + + private static MultiMap getTemplates() { InputStream stream = null; HttpURLConnection connection = null; String code = ApplicationInfo.getInstance().getBuild().getProductCode(); try { connection = getConnection(code + "_templates.xml"); stream = connection.getInputStream(); - String text = StreamUtil.readText(stream); + String text = StreamUtil.readText(stream, TemplateModuleBuilder.UTF_8); return createFromText(text); } catch (IOException ex) { // timeouts, lost connection etc LOG.info(ex); - return ProjectTemplate.EMPTY_ARRAY; + return MultiMap.emptyInstance(); } catch (Exception e) { LOG.error(e); - return ProjectTemplate.EMPTY_ARRAY; + return MultiMap.emptyInstance(); } finally { StreamUtil.closeStream(stream); @@ -83,15 +103,32 @@ public class RemoteTemplatesFactory extends ProjectTemplatesFactory { } @SuppressWarnings("unchecked") - public static ProjectTemplate[] createFromText(String text) throws IOException, JDOMException { + public static MultiMap createFromText(String text) throws IOException, JDOMException { - List elements = JDOMUtil.loadDocument(text).getRootElement().getChildren("template"); + Element rootElement = JDOMUtil.loadDocument(text).getRootElement(); + List groups = rootElement.getChildren("group", NAMESPACE); + MultiMap map = new MultiMap(); + if (groups.isEmpty()) { // sample gallery by default + map.put(SAMPLES_GALLERY, createGroupTemplates(rootElement, Namespace.NO_NAMESPACE)); + } + else { + for (Element group : groups) { + map.put(group.getChildText("name", NAMESPACE), createGroupTemplates(group, NAMESPACE)); + } + } - List templates = ContainerUtil.mapNotNull(elements, new NullableFunction() { + return map; + } + + @SuppressWarnings("unchecked") + private static List createGroupTemplates(Element groupElement, final Namespace ns) { + List elements = groupElement.getChildren("template", ns); + + return ContainerUtil.mapNotNull(elements, new NullableFunction() { @Override public ProjectTemplate fun(final Element element) { - List plugins = element.getChildren("requiredPlugin"); + List plugins = element.getChildren("requiredPlugin", ns); for (Element plugin : plugins) { String id = plugin.getTextTrim(); if (!PluginManager.isPluginInstalled(PluginId.getId(id))) { @@ -100,7 +137,7 @@ public class RemoteTemplatesFactory extends ProjectTemplatesFactory { } String type = element.getChildText("moduleType"); final ModuleType moduleType = ModuleTypeManager.getInstance().findByID(type); - return new ArchivedProjectTemplate(element.getChildTextTrim("name")) { + return new ArchivedProjectTemplate(element.getChildTextTrim("name", ns)) { @Override protected ModuleType getModuleType() { return moduleType; @@ -108,7 +145,7 @@ public class RemoteTemplatesFactory extends ProjectTemplatesFactory { @Override public ZipInputStream getStream() throws IOException { - String path = element.getChildText("path"); + String path = element.getChildText("path", ns); final HttpURLConnection connection = getConnection(path); return new ZipInputStream(connection.getInputStream()) { @Override @@ -122,12 +159,11 @@ public class RemoteTemplatesFactory extends ProjectTemplatesFactory { @Nullable @Override public String getDescription() { - return element.getChildTextTrim("description"); + return element.getChildTextTrim("description", ns); } }; } }); - return templates.toArray(new ProjectTemplate[templates.size()]); } private static HttpURLConnection getConnection(String path) throws IOException { diff --git a/java/java-psi-api/src/com/intellij/psi/util/ClassUtil.java b/java/java-psi-api/src/com/intellij/psi/util/ClassUtil.java index d7f8aa2a27c2..158e7dd81a16 100644 --- a/java/java-psi-api/src/com/intellij/psi/util/ClassUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/util/ClassUtil.java @@ -244,7 +244,7 @@ public class ClassUtil { } @Nullable - public static String getJVMClassName(PsiClass aClass) { + public static String getJVMClassName(@NotNull PsiClass aClass) { final PsiClass containingClass = aClass.getContainingClass(); if (containingClass != null) { String parentName = getJVMClassName(containingClass); diff --git a/platform/indexing-impl/src/com/intellij/psi/impl/search/LowLevelSearchUtil.java b/platform/indexing-impl/src/com/intellij/psi/impl/search/LowLevelSearchUtil.java index 44860d211e60..fbf027c42b48 100644 --- a/platform/indexing-impl/src/com/intellij/psi/impl/search/LowLevelSearchUtil.java +++ b/platform/indexing-impl/src/com/intellij/psi/impl/search/LowLevelSearchUtil.java @@ -205,7 +205,7 @@ public class LowLevelSearchUtil { if (index > startOffset) { char c = textArray != null ? textArray[index - 1]:text.charAt(index - 1); if (Character.isJavaIdentifierPart(c) && c != '$') { - if (searcher.isHandleEscapeSequences() && (index < 2 || !isNotEscapedBackslash(text, textArray, startOffset, index-2))) { //escape sequence + if (!searcher.isHandleEscapeSequences() || (index < 2 || !isNotEscapedBackslash(text, textArray, startOffset, index-2))) { //escape sequence continue; } } diff --git a/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.form b/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.form index 016b0ff43980..c075d84ff01b 100644 --- a/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.form +++ b/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.form @@ -1,6 +1,6 @@
- + @@ -19,7 +19,7 @@ - + @@ -34,13 +34,13 @@ - + - + @@ -48,7 +48,7 @@ - + @@ -58,7 +58,7 @@ - + @@ -83,7 +83,7 @@ - + @@ -91,7 +91,7 @@ - + @@ -100,7 +100,7 @@ - + @@ -115,6 +115,20 @@ + + + + + + + + + + + + + + diff --git a/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.java b/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.java index 5df38fa51864..1a852b2993a5 100644 --- a/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.java +++ b/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.java @@ -23,11 +23,15 @@ import com.intellij.ide.DataManager; import com.intellij.ide.actions.CreateDesktopEntryAction; import com.intellij.ide.actions.CreateLauncherScriptAction; import com.intellij.ide.todo.TodoConfiguration; -import com.intellij.ui.ListCellRendererWrapper; +import com.intellij.ide.ui.LafComboBoxRenderer; +import com.intellij.ide.ui.LafManager; +import com.intellij.ide.ui.laf.LafManagerImpl; import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.PlatformDataKeys; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ApplicationNamesInfo; import com.intellij.openapi.application.PathManager; +import com.intellij.openapi.application.impl.ApplicationImpl; import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.colors.EditorColorsScheme; import com.intellij.openapi.keymap.Keymap; @@ -37,11 +41,14 @@ import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.progress.Task; import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.ComboBox; import com.intellij.openapi.ui.DialogWrapper; +import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.vcs.changes.RefreshablePanel; import com.intellij.ui.AbstractTitledSeparatorWithIcon; +import com.intellij.ui.ListCellRendererWrapper; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -64,6 +71,7 @@ public class InitialConfigurationDialog extends DialogWrapper { private JCheckBox myCreateEntryCheckBox; private JCheckBox myGlobalEntryCheckBox; private JPanel myCreateEntryPanel; + private ComboBox myAppearanceComboBox; private String myColorSettingsPage; private SimpleEditorPreview myPreviewEditor; private ColorAndFontOptions myPreviewOptions; @@ -81,6 +89,33 @@ public class InitialConfigurationDialog extends DialogWrapper { } } + myAppearanceComboBox.setModel(new DefaultComboBoxModel(LafManager.getInstance().getInstalledLookAndFeels())); + myAppearanceComboBox.setRenderer(new LafComboBoxRenderer()); + myAppearanceComboBox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent event) { + UIManager.LookAndFeelInfo selectedLaf = (UIManager.LookAndFeelInfo) myAppearanceComboBox.getSelectedItem(); + if (selectedLaf.getName().contains("Darcula")) { + myColorSchemeComboBox.setSelectedItem(EditorColorsManager.getInstance().getScheme("Darcula")); + } + } + }); + myColorSchemeComboBox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent event) { + EditorColorsScheme scheme = (EditorColorsScheme) myColorSchemeComboBox.getSelectedItem(); + if (scheme.getName().equals("Darcula")) { + UIManager.LookAndFeelInfo[] lafs = LafManager.getInstance().getInstalledLookAndFeels(); + for (UIManager.LookAndFeelInfo laf : lafs) { + if (laf.getName().contains("Darcula")) { + myAppearanceComboBox.setSelectedItem(laf); + break; + } + } + } + } + }); + myKeymapComboBox.setModel(new DefaultComboBoxModel(keymaps.toArray(new Keymap[keymaps.size()]))); myKeymapComboBox.setRenderer(new ListCellRendererWrapper() { @Override @@ -334,6 +369,20 @@ public class InitialConfigurationDialog extends DialogWrapper { } }); } + UIManager.LookAndFeelInfo info = (UIManager.LookAndFeelInfo) myAppearanceComboBox.getSelectedItem(); + LafManagerImpl lafManager = (LafManagerImpl)LafManager.getInstance(); + if (info.getName().contains("Darcula")) { + lafManager.setLookAndFeelAfterRestart(info); + int rc = Messages.showYesNoDialog(project, "IDE appearance settings will be applied after restart. Would you like to restart now?", + "IDE Appearance", Messages.getQuestionIcon()); + if (rc == Messages.YES) { + ((ApplicationImpl) ApplicationManager.getApplication()).restart(true); + } + } + else if (!info.equals(lafManager.getCurrentLookAndFeel())) { + lafManager.setCurrentLookAndFeel(info); + lafManager.updateUI(); + } } @Override 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 c45acb38add3..5d7ae51e43e9 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 @@ -1067,10 +1067,10 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract } public void apply(EditorColorsScheme scheme) { - getFontPreferences().copyTo(scheme.getFontPreferences()); + scheme.setFontPreferences(getFontPreferences()); scheme.setLineSpacing(myLineSpacing); scheme.setQuickDocFontSize(getQuickDocFontSize()); - getConsoleFontPreferences().copyTo(scheme.getConsoleFontPreferences()); + scheme.setConsoleFontPreferences(getConsoleFontPreferences()); scheme.setConsoleLineSpacing(getConsoleLineSpacing()); for (EditorSchemeAttributeDescriptor descriptor : myDescriptors) { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/wordSelection/NaturalLanguageTextSelectioner.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/wordSelection/NaturalLanguageTextSelectioner.java index 7aa5cfb6715f..fb2a60a607ff 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/wordSelection/NaturalLanguageTextSelectioner.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/wordSelection/NaturalLanguageTextSelectioner.java @@ -31,7 +31,9 @@ import java.util.List; import java.util.Set; public class NaturalLanguageTextSelectioner extends ExtendWordSelectionHandlerBase { - private static final Set NATURAL = ContainerUtil.newTroveSet('(', ')', '.', ',', ':', ';', '!', '?', '$', '@', '%', '\"', '\'', '<', '>', '[', ']'); + private static final Set NATURAL = ContainerUtil.newTroveSet( + '(', ')', '.', ',', ':', ';', '!', '?', '$', '@', '%', '\"', '\'', '<', '>', '[', ']', '_' + ); private static final Set SENTENCE_END = ContainerUtil.newTroveSet('.', '!', '?'); @Override diff --git a/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/DocumentFoldingInfo.java b/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/DocumentFoldingInfo.java index 6f4f7d5c70ac..e209838afb33 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/DocumentFoldingInfo.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/DocumentFoldingInfo.java @@ -134,16 +134,17 @@ class DocumentFoldingInfo implements JDOMExternalizable, CodeFoldingState { continue; } FoldRegion region = FoldingUtil.findFoldRegion(editor, marker.getStartOffset(), marker.getEndOffset()); + FoldingInfo info = marker.getUserData(FOLDING_INFO_KEY); if (region == null) { - FoldingInfo info = marker.getUserData(FOLDING_INFO_KEY); - region = editor.getFoldingModel().addFoldRegion(marker.getStartOffset(), marker.getEndOffset(), info.placeHolder); + if (info != null) { + region = editor.getFoldingModel().addFoldRegion(marker.getStartOffset(), marker.getEndOffset(), info.placeHolder); + } if (region == null) { return; } } - FoldingInfo fi = region.getUserData(FOLDING_INFO_KEY); - boolean state = fi != null && fi.expanded; + boolean state = info != null && info.expanded; region.setExpanded(state); } } diff --git a/platform/lang-impl/src/com/intellij/testIntegration/TestFinderHelper.java b/platform/lang-impl/src/com/intellij/testIntegration/TestFinderHelper.java index 58fc1de4cbd1..8b419e4a58bb 100644 --- a/platform/lang-impl/src/com/intellij/testIntegration/TestFinderHelper.java +++ b/platform/lang-impl/src/com/intellij/testIntegration/TestFinderHelper.java @@ -23,6 +23,7 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiNamedElement; import com.intellij.psi.codeStyle.NameUtil; +import org.jetbrains.annotations.Nullable; import java.util.*; @@ -72,12 +73,18 @@ public class TestFinderHelper { public static List getSortedElements(final List> elementsWithWeights, final boolean weightsAscending) { + return getSortedElements(elementsWithWeights, weightsAscending, null); + } + + public static List getSortedElements(final List> elementsWithWeights, + final boolean weightsAscending, + @Nullable final Comparator sameNameComparator) { Collections.sort(elementsWithWeights, new Comparator>() { public int compare(Pair o1, Pair o2) { int result = weightsAscending ? o1.second.compareTo(o2.second) : o2.second.compareTo(o1.second); - if (result == 0) { - result = Comparing.compare(o1.first.getName(), o2.first.getName()); - } + if (result == 0) result = Comparing.compare(o1.first.getName(), o2.first.getName()); + if (result == 0 && sameNameComparator != null) result = sameNameComparator.compare(o1.first, o2.first); + return result; } }); diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java index 4899bcd267e5..e83a755bd922 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java @@ -2113,7 +2113,7 @@ public class FileBasedIndexImpl extends FileBasedIndex { final VirtualFile file = fileContent.getVirtualFile(); final boolean reallyRemoved = myFilesToUpdate.remove(file); if (reallyRemoved && file.isValid()) { - if (onlyRemoveOutdatedData) { + if (onlyRemoveOutdatedData || isTooLarge(file)) { // on shutdown there is no need to re-index the file, just remove outdated data from indices final List> affected = new ArrayList>(); for (final ID indexId : myRequiringContentIndices) { // non requiring content indices should be flushed diff --git a/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.java b/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.java index 503d217ba1f7..dfc36e7ca9b1 100644 --- a/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.java +++ b/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 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. @@ -194,7 +194,7 @@ public class ParametersList implements Cloneable { for (ListIterator iterator = myParameters.listIterator(); iterator.hasNext(); ) { final String param = iterator.next(); if (param.startsWith(parameterPrefix)) { - if ("".equals(replacement)) { + if (replacement != null && replacement.isEmpty()) { iterator.remove(); } else { @@ -203,7 +203,7 @@ public class ParametersList implements Cloneable { return; } } - if (!"".equals(replacement)) { + if (replacement != null && !replacement.isEmpty()) { myParameters.add(position, replacement); } } @@ -211,7 +211,7 @@ public class ParametersList implements Cloneable { public void replaceOrPrepend(final @NonNls String parameter, final @NonNls String replacement) { replaceOrAdd(parameter, replacement, 0); } - + public void set(int ind, final @NonNls String value) { myParameters.set(ind, value); } diff --git a/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java b/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java index d0e32bc0e239..d21e26e750b7 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java +++ b/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java @@ -54,6 +54,7 @@ public interface EditorColorsScheme extends Cloneable, JDOMExternalizable, Schem */ @NotNull FontPreferences getFontPreferences(); + void setFontPreferences(@NotNull FontPreferences preferences); String getEditorFontName(); void setEditorFontName(String fontName); @@ -78,6 +79,7 @@ public interface EditorColorsScheme extends Cloneable, JDOMExternalizable, Schem */ @NotNull FontPreferences getConsoleFontPreferences(); + void setConsoleFontPreferences(@NotNull FontPreferences preferences); String getConsoleFontName(); void setConsoleFontName(String fontName); diff --git a/platform/platform-api/src/com/intellij/openapi/editor/colors/FontPreferences.java b/platform/platform-api/src/com/intellij/openapi/editor/colors/FontPreferences.java index 73d1b8f4b991..2d88151f088e 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/colors/FontPreferences.java +++ b/platform/platform-api/src/com/intellij/openapi/editor/colors/FontPreferences.java @@ -44,21 +44,33 @@ public class FontPreferences { @NotNull private final TObjectIntHashMap myFontSizes = new TObjectIntHashMap(); @NotNull private final List myEffectiveFontFamilies = ContainerUtilRt.newArrayList(); @NotNull private final List myRealFontFamilies = ContainerUtilRt.newArrayList(); + + @Nullable Runnable myChangeListener; /** * Font size to use by default. Default value is {@link #DEFAULT_FONT_SIZE}. */ private int myTemplateFontSize = DEFAULT_FONT_SIZE; - + + public void setChangeListener(@Nullable Runnable changeListener) { + myChangeListener = changeListener; + } + public void clear() { myEffectiveFontFamilies.clear(); myRealFontFamilies.clear(); myFontSizes.clear(); + if (myChangeListener != null) { + myChangeListener.run(); + } } public void clearFonts() { myEffectiveFontFamilies.clear(); myRealFontFamilies.clear(); + if (myChangeListener != null) { + myChangeListener.run(); + } } public boolean hasSize(@NotNull String fontName) { @@ -76,6 +88,9 @@ public class FontPreferences { public void setSize(@NotNull String fontFamily, int size) { myFontSizes.put(fontFamily, size); myTemplateFontSize = size; + if (myChangeListener != null) { + myChangeListener.run(); + } } /** @@ -132,6 +147,9 @@ public class FontPreferences { if (!myEffectiveFontFamilies.contains(effectiveFontFamily)) { myEffectiveFontFamilies.add(effectiveFontFamily); } + if (myChangeListener != null) { + myChangeListener.run(); + } } public void copyTo(@NotNull final FontPreferences preferences) { diff --git a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java index fd9063a2a148..8bf4f680fcac 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java @@ -30,6 +30,7 @@ import com.intellij.ui.*; import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.mac.MacMessages; import com.intellij.util.PairFunction; +import com.intellij.util.execution.ParametersListUtil; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.*; @@ -96,14 +97,14 @@ public class Messages { } /** - * Please, use {@link #showOkCancelDialog} or {@link #showYesNoCancelDialog} if possible (these dialogs implements native OS behavior)! + * Please, use {@link #showOkCancelDialog} or {@link #showYesNoCancelDialog} if possible (these dialogs implements native OS behavior)! */ public static int showDialog(@Nullable Project project, String message, String title, String[] options, int defaultOptionIndex, @Nullable Icon icon) { return showDialog(project, message, title, options, defaultOptionIndex, icon, null); } /** - * Please, use {@link #showOkCancelDialog} or {@link #showYesNoCancelDialog} if possible (these dialogs implements native OS behavior)! + * Please, use {@link #showOkCancelDialog} or {@link #showYesNoCancelDialog} if possible (these dialogs implements native OS behavior)! */ public static int showDialog(@Nullable Project project, String message, String title, String[] options, int defaultOptionIndex, @Nullable Icon icon, @Nullable DialogWrapper.DoNotAskOption doNotAskOption) { @@ -162,7 +163,7 @@ public class Messages { return MacMessages.getInstance() .showMessageDialog(title, message, options, false, SwingUtilities.getWindowAncestor(parent), defaultOptionIndex, defaultOptionIndex, null); } - + MessageDialog dialog = new MessageDialog(parent, message, title, options, defaultOptionIndex, defaultOptionIndex, icon, false); dialog.show(); return dialog.getExitCode(); @@ -183,7 +184,7 @@ public class Messages { if (canShowMacSheetPanel()) { return MacMessages.getInstance().showMessageDialog(title, message, options, false, null, defaultOptionIndex, focusedOptionIndex, doNotAskOption); } - + //what's it? if (application.isUnitTestMode()) throw new RuntimeException(message); MessageDialog dialog = new MessageDialog(message, title, options, defaultOptionIndex, focusedOptionIndex, icon, doNotAskOption); dialog.show(); @@ -219,7 +220,7 @@ public class Messages { MacMessages.getInstance().showOkMessageDialog(title, message, OK_BUTTON, WindowManager.getInstance().suggestParentWindow(project)); return; } - + showDialog(project, message, title, new String[]{OK_BUTTON}, 0, icon); } @@ -228,7 +229,7 @@ public class Messages { MacMessages.getInstance().showOkMessageDialog(title, message, OK_BUTTON, SwingUtilities.getWindowAncestor(parent)); return; } - + showDialog(parent, message, title, new String[]{OK_BUTTON}, 0, icon); } @@ -243,7 +244,7 @@ public class Messages { MacMessages.getInstance().showOkMessageDialog(title, message, OK_BUTTON); return; } - + showDialog(message, title, new String[]{OK_BUTTON}, 0, icon); } @@ -254,7 +255,7 @@ public class Messages { if (canShowMacSheetPanel()) { return MacMessages.getInstance().showYesNoDialog(title, message, yesText, noText, WindowManager.getInstance().suggestParentWindow(project)); } - + return showDialog(project, message, title, new String[]{yesText, noText}, 0, icon); } @@ -265,7 +266,7 @@ public class Messages { if (canShowMacSheetPanel()) { return MacMessages.getInstance().showYesNoDialog(title, message, YES_BUTTON, NO_BUTTON, WindowManager.getInstance().suggestParentWindow(project)); } - + return showYesNoDialog(project, message, title, YES_BUTTON, NO_BUTTON, icon); } @@ -276,7 +277,7 @@ public class Messages { if (canShowMacSheetPanel()) { return MacMessages.getInstance().showYesNoDialog(title, message, YES_BUTTON, NO_BUTTON, SwingUtilities.getWindowAncestor(parent)); } - + return showDialog(parent, message, title, new String[]{YES_BUTTON, NO_BUTTON}, 0, icon); } @@ -292,10 +293,10 @@ public class Messages { if (canShowMacSheetPanel()) { return MacMessages.getInstance().showYesNoDialog(title, message, yesText, noText, null, doNotAskOption); } - + return showDialog(message, title, new String[]{yesText, noText}, 0, icon, doNotAskOption); } - + /** * Use this method only if you do not know project or component * @@ -306,7 +307,7 @@ public class Messages { public static int showYesNoDialog(String message, String title, String yesText, String noText, @Nullable Icon icon) { return showYesNoDialog(message, title, yesText, noText, icon, null); } - + /** * Use this method only if you do not know project or component * @@ -328,7 +329,7 @@ public class Messages { return MacMessages.getInstance().showYesNoDialog(title, message, okText, cancelText, WindowManager.getInstance().suggestParentWindow(project), doNotAskOption); } - + return showDialog(project, message, title, new String[]{okText, cancelText}, 0, icon, doNotAskOption); } @@ -336,7 +337,7 @@ public class Messages { if (canShowMacSheetPanel()) { return MacMessages.getInstance().showYesNoDialog(title, message, okText, cancelText, WindowManager.getInstance().suggestParentWindow(project)); } - + return showDialog(project, message, title, new String[]{okText, cancelText}, 0, icon); } @@ -387,7 +388,7 @@ public class Messages { if (canShowMacSheetPanel()) { return MacMessages.getInstance().showYesNoDialog(title, message, okText, cancelText, null, doNotAskOption); } - + return showDialog(message, title, new String[]{okText, cancelText}, 0, icon, doNotAskOption); } @@ -445,7 +446,7 @@ public class Messages { MacMessages.getInstance().showErrorDialog(CommonBundle.getErrorTitle(), message, OK_BUTTON, SwingUtilities.getWindowAncestor(component)); return; } - + showDialog(component, message, CommonBundle.getErrorTitle(), new String[]{OK_BUTTON}, 0, getErrorIcon()); } @@ -469,7 +470,7 @@ public class Messages { MacMessages.getInstance().showErrorDialog(CommonBundle.getWarningTitle(), message, OK_BUTTON, WindowManager.getInstance().suggestParentWindow(project)); return; } - + showDialog(project, message, title, new String[]{OK_BUTTON}, 0, getWarningIcon()); } @@ -493,7 +494,7 @@ public class Messages { MacMessages.getInstance().showErrorDialog(CommonBundle.getWarningTitle(), message, OK_BUTTON, null); return; } - + showDialog(message, title, new String[]{OK_BUTTON}, 0, getWarningIcon()); } @@ -536,7 +537,7 @@ public class Messages { if (canShowMacSheetPanel()) { return MacMessages.getInstance().showYesNoCancelDialog(title, message, yes, no, cancel, null, doNotAskOption); } - + return showDialog(message, title, new String[]{yes, no, cancel}, 0, icon, doNotAskOption); } @@ -549,7 +550,7 @@ public class Messages { public static int showYesNoCancelDialog(String message, String title, String yes, String no, String cancel, Icon icon) { return showYesNoCancelDialog(message, title, yes, no, cancel, icon, null); } - + /** * Use this method only if you do not know project or component * @@ -809,7 +810,7 @@ public class Messages { MacMessages.getInstance().showOkMessageDialog(title, message, OK_BUTTON, SwingUtilities.getWindowAncestor(component)); return; } - + showMessageDialog(component, message, title, getInformationIcon()); } @@ -843,7 +844,7 @@ public class Messages { } /** - * Shows dialog with text area to edit long strings that don't fit in text field + * Shows dialog with text area to edit long strings that don't fit in text field. */ public static void showTextAreaDialog(final JTextField textField, final String title, @NonNls final String dimensionServiceKey) { if (isApplicationInUnitTestOrHeadless()) { @@ -853,8 +854,7 @@ public class Messages { final JTextArea textArea = new JTextArea(10, 50); textArea.setWrapStyleWord(true); textArea.setLineWrap(true); - String s = textField.getText().replaceAll("[ ]*=[ ]*", "=").replaceAll("=\\-", "=\\ \\-"); - List lines = StringUtil.splitHonorQuotes(s, ' '); + List lines = ParametersListUtil.parse(textField.getText(), true); textArea.setText(StringUtil.join(lines, "\n")); InsertPathAction.copyFromTo(textField, textArea); final DialogBuilder builder = new DialogBuilder(textField); @@ -946,7 +946,7 @@ public class Messages { public MessageDialog(Component parent, String message, String title, String[] options, int defaultOptionIndex, @Nullable Icon icon) { this(parent, message, title, options, defaultOptionIndex, icon, false); } - + public MessageDialog(Component parent, String message, String title, String[] options, int defaultOptionIndex, @Nullable Icon icon, boolean canBeParent) { this(parent, message, title, options, defaultOptionIndex, -1, icon, canBeParent); } @@ -960,7 +960,7 @@ public class Messages { public MessageDialog(String message, String title, String[] options, int defaultOptionIndex, @Nullable Icon icon) { this(message, title, options, defaultOptionIndex, icon, false); } - + public MessageDialog(String message, String title, String[] options, int defaultOptionIndex, @Nullable Icon icon, boolean canBeParent) { super(canBeParent); _init(title, message, options, defaultOptionIndex, -1, icon, null); diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/AvailablePluginsManagerMain.java b/platform/platform-impl/src/com/intellij/ide/plugins/AvailablePluginsManagerMain.java index 71d0cb4b8723..c6ea94126922 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/AvailablePluginsManagerMain.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/AvailablePluginsManagerMain.java @@ -46,26 +46,30 @@ public class AvailablePluginsManagerMain extends PluginManagerMain { public static final String N_A = "N/A"; private PluginManagerMain installed; + private final String myVendorFilter; - public AvailablePluginsManagerMain(PluginManagerMain installed, PluginManagerUISettings uiSettings) { + public AvailablePluginsManagerMain(PluginManagerMain installed, PluginManagerUISettings uiSettings, String vendorFilter) { super(uiSettings); this.installed = installed; + myVendorFilter = vendorFilter; init(); final JButton manageRepositoriesBtn = new JButton(MANAGE_REPOSITORIES); - manageRepositoriesBtn.setMnemonic('m'); - manageRepositoriesBtn.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - if (ShowSettingsUtil.getInstance().editConfigurable(myActionsPanel, new PluginHostsConfigurable())) { - final ArrayList pluginHosts = UpdateSettings.getInstance().myPluginHosts; - if (!pluginHosts.contains(((AvailablePluginsTableModel)pluginsModel).getRepository())) { - ((AvailablePluginsTableModel)pluginsModel).setRepository(AvailablePluginsTableModel.ALL, myFilter.getFilter().toLowerCase()); + if (myVendorFilter == null) { + manageRepositoriesBtn.setMnemonic('m'); + manageRepositoriesBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (ShowSettingsUtil.getInstance().editConfigurable(myActionsPanel, new PluginHostsConfigurable())) { + final ArrayList pluginHosts = UpdateSettings.getInstance().myPluginHosts; + if (!pluginHosts.contains(((AvailablePluginsTableModel)pluginsModel).getRepository())) { + ((AvailablePluginsTableModel)pluginsModel).setRepository(AvailablePluginsTableModel.ALL, myFilter.getFilter().toLowerCase()); + } + loadAvailablePlugins(); } - loadAvailablePlugins(); } - } - }); - myActionsPanel.add(manageRepositoriesBtn, BorderLayout.EAST); + }); + myActionsPanel.add(manageRepositoriesBtn, BorderLayout.EAST); + } final JButton httpProxySettingsButton = new JButton(IdeBundle.message("button.http.proxy.settings")); httpProxySettingsButton.addActionListener(new ActionListener() { @@ -83,7 +87,9 @@ public class AvailablePluginsManagerMain extends PluginManagerMain { @Override protected JScrollPane createTable() { - pluginsModel = new AvailablePluginsTableModel(); + AvailablePluginsTableModel model = new AvailablePluginsTableModel(); + model.setVendor(myVendorFilter); + pluginsModel = model; pluginTable = new PluginTable(pluginsModel); pluginTable.getTableHeader().setReorderingAllowed(false); pluginTable.setColumnWidth(PluginManagerColumnInfo.COLUMN_DOWNLOADS, 70); diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/AvailablePluginsTableModel.java b/platform/platform-impl/src/com/intellij/ide/plugins/AvailablePluginsTableModel.java index ac21018d7f3a..c58bb0dfd1c2 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/AvailablePluginsTableModel.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/AvailablePluginsTableModel.java @@ -46,6 +46,7 @@ public class AvailablePluginsTableModel extends PluginTableModel { public static final String JETBRAINS_REPO = "JetBrains"; private String myRepository = ALL; + private String myVendor = null; public AvailablePluginsTableModel() { super.columns = new ColumnInfo[] { @@ -73,6 +74,11 @@ public class AvailablePluginsTableModel extends PluginTableModel { filter(filter); } + public void setVendor(String vendor) { + myVendor = vendor; + filter(""); + } + @Override public boolean isPluginDescriptorAccepted(IdeaPluginDescriptor descriptor) { final String category = descriptor.getCategory(); @@ -80,6 +86,10 @@ public class AvailablePluginsTableModel extends PluginTableModel { if (!ALL.equals(myCategory) && !category.equals(myCategory)) return false; } + if (myVendor != null && !descriptor.getVendor().toLowerCase().contains(myVendor.toLowerCase())) { + return false; + } + final String repositoryName = ((PluginNode)descriptor).getRepositoryName(); if (repositoryName != null) { if (!ALL.equals(myRepository) && !repositoryName.equals(myRepository)) return false; diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/InstalledPluginsManagerMain.java b/platform/platform-impl/src/com/intellij/ide/plugins/InstalledPluginsManagerMain.java index a47e14a74848..58d2dcad2489 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/InstalledPluginsManagerMain.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/InstalledPluginsManagerMain.java @@ -57,27 +57,14 @@ public class InstalledPluginsManagerMain extends PluginManagerMain { super(uiSettings); init(); myActionsPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); + final JButton jbButton = new JButton("Install JetBrains plugin..."); + jbButton.setMnemonic('j'); + jbButton.addActionListener(new BrowseRepoListener("JetBrains")); + myActionsPanel.add(jbButton); + final JButton button = new JButton("Browse repositories..."); button.setMnemonic('b'); - button.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - final PluginManagerConfigurable configurable = createAvailableConfigurable(); - final SingleConfigurableEditor configurableEditor = - new SingleConfigurableEditor(myActionsPanel, configurable, ShowSettingsUtilImpl.createDimensionKey(configurable), false) { - { - setOKButtonText(CommonBundle.message("close.action.name")); - setOKButtonMnemonic('C'); - } - - @Override - protected Action[] createActions() { - return new Action[]{getOKAction()}; - } - }; - configurableEditor.show(); - } - }); + button.addActionListener(new BrowseRepoListener(null)); myActionsPanel.add(button); final JButton installPluginFromFileSystem = new JButton("Install plugin from disk..."); @@ -202,16 +189,16 @@ public class InstalledPluginsManagerMain extends PluginManagerMain { protected void propagateUpdates(ArrayList list) { } - private PluginManagerConfigurable createAvailableConfigurable() { + private PluginManagerConfigurable createAvailableConfigurable(final String vendorFilter) { return new PluginManagerConfigurable(PluginManagerUISettings.getInstance(), true) { @Override protected PluginManagerMain createPanel() { - return new AvailablePluginsManagerMain(InstalledPluginsManagerMain.this, myUISettings); + return new AvailablePluginsManagerMain(InstalledPluginsManagerMain.this, myUISettings, vendorFilter); } @Override public String getDisplayName() { - return "Browse Repositories"; + return vendorFilter != null ? "Browse " + vendorFilter + " Plugins " : "Browse Repositories"; } }; } @@ -381,4 +368,30 @@ public class InstalledPluginsManagerMain extends PluginManagerMain { } } + private class BrowseRepoListener implements ActionListener { + + private final String myVendor; + + public BrowseRepoListener(String vendor) { + myVendor = vendor; + } + + @Override + public void actionPerformed(ActionEvent e) { + final PluginManagerConfigurable configurable = createAvailableConfigurable(myVendor); + final SingleConfigurableEditor configurableEditor = + new SingleConfigurableEditor(myActionsPanel, configurable, ShowSettingsUtilImpl.createDimensionKey(configurable), false) { + { + setOKButtonText(CommonBundle.message("close.action.name")); + setOKButtonMnemonic('C'); + } + + @Override + protected Action[] createActions() { + return new Action[]{getOKAction()}; + } + }; + configurableEditor.show(); + } + } } diff --git a/platform/platform-impl/src/com/intellij/ide/ui/AppearanceConfigurable.java b/platform/platform-impl/src/com/intellij/ide/ui/AppearanceConfigurable.java index ae0f2239064c..9a475c352139 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/AppearanceConfigurable.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/AppearanceConfigurable.java @@ -22,7 +22,6 @@ import com.intellij.openapi.options.SearchableConfigurable; import com.intellij.openapi.ui.ComboBox; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.wm.ex.WindowManagerEx; -import com.intellij.ui.ListCellRendererWrapper; import com.intellij.ui.components.JBCheckBox; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; @@ -65,7 +64,7 @@ public class AppearanceConfigurable extends BaseConfigurable implements Searchab myComponent.myFontSizeCombo.setEditable(true); myComponent.myLafComboBox.setModel(new DefaultComboBoxModel(LafManager.getInstance().getInstalledLookAndFeels())); - myComponent.myLafComboBox.setRenderer(new MyLafComboBoxRenderer(myComponent.myLafComboBox.getRenderer())); + myComponent.myLafComboBox.setRenderer(new LafComboBoxRenderer()); myComponent.myEnableAlphaModeCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -297,21 +296,6 @@ public class AppearanceConfigurable extends BaseConfigurable implements Searchab return "preferences.lookFeel"; } - private static final class MyLafComboBoxRenderer extends ListCellRendererWrapper { - public MyLafComboBoxRenderer(final ListCellRenderer listCellRenderer) { - super(); - } - - @Override - public void customize(final JList list, - final UIManager.LookAndFeelInfo value, - final int index, - final boolean selected, - final boolean cellHasFocus) { - setText(value.getName()); - } - } - private static class MyComponent { private JPanel myPanel; private JComboBox myFontCombo; diff --git a/platform/platform-impl/src/com/intellij/ide/ui/LafComboBoxRenderer.java b/platform/platform-impl/src/com/intellij/ide/ui/LafComboBoxRenderer.java new file mode 100644 index 000000000000..09b733dce32b --- /dev/null +++ b/platform/platform-impl/src/com/intellij/ide/ui/LafComboBoxRenderer.java @@ -0,0 +1,31 @@ +/* + * Copyright 2000-2013 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.ide.ui; + +import com.intellij.ui.ListCellRendererWrapper; + +import javax.swing.*; + +public class LafComboBoxRenderer extends ListCellRendererWrapper { + @Override + public void customize(final JList list, + final UIManager.LookAndFeelInfo value, + final int index, + final boolean selected, + final boolean cellHasFocus) { + setText(value.getName()); + } +} diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/LafManagerImpl.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/LafManagerImpl.java index 32f36c5ea45b..c3d7661d9e42 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/LafManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/LafManagerImpl.java @@ -379,6 +379,10 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo checkLookAndFeel(lookAndFeelInfo, false); } + public void setLookAndFeelAfterRestart(UIManager.LookAndFeelInfo lookAndFeelInfo) { + myCurrentLaf = lookAndFeelInfo; + } + @Nullable private static Icon getAquaMenuDisabledIcon() { final Icon arrowIcon = (Icon)UIManager.get("Menu.arrowIcon"); diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java index d41e826c268c..b446df31d6a4 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java @@ -90,6 +90,12 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme { protected AbstractColorsScheme(EditorColorsScheme parentScheme, DefaultColorSchemesManager defaultColorSchemesManager) { myParentScheme = parentScheme; myDefaultColorSchemesManager = defaultColorSchemesManager; + myFontPreferences.setChangeListener(new Runnable() { + @Override + public void run() { + initFonts(); + } + }); } public AbstractColorsScheme(DefaultColorSchemesManager defaultColorSchemesManager) { @@ -179,7 +185,13 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme { public FontPreferences getFontPreferences() { return myFontPreferences; } - + + @Override + public void setFontPreferences(@NotNull FontPreferences preferences) { + preferences.copyTo(myFontPreferences); + initFonts(); + } + @Override public String getEditorFontName() { if (myFallbackFontName != null) { @@ -581,7 +593,13 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme { public FontPreferences getConsoleFontPreferences() { return myConsoleFontPreferences; } - + + @Override + public void setConsoleFontPreferences(@NotNull FontPreferences preferences) { + preferences.copyTo(myConsoleFontPreferences); + initFonts(); + } + @Override public String getConsoleFontName() { return myConsoleFontPreferences.getFontFamily(); diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/DelegateColorScheme.java b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/DelegateColorScheme.java index 1e0b2e285007..663b84789653 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/DelegateColorScheme.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/DelegateColorScheme.java @@ -84,6 +84,11 @@ public abstract class DelegateColorScheme implements EditorColorsScheme { return myDelegate.getFontPreferences(); } + @Override + public void setFontPreferences(@NotNull FontPreferences preferences) { + myDelegate.setFontPreferences(preferences); + } + @Override public int getEditorFontSize() { return myDelegate.getEditorFontSize(); @@ -158,6 +163,11 @@ public abstract class DelegateColorScheme implements EditorColorsScheme { return myDelegate.getConsoleFontPreferences(); } + @Override + public void setConsoleFontPreferences(@NotNull FontPreferences preferences) { + myDelegate.setConsoleFontPreferences(preferences); + } + @Override public String getConsoleFontName() { return myDelegate.getConsoleFontName(); diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java index 09e75b3f70f2..9f76d6a6a943 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java @@ -5684,7 +5684,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi private class MyColorSchemeDelegate implements EditorColorsScheme { - private final FontPreferences myFontPreferences = new FontPreferences(); + private final FontPreferences myFontPreferences = new FontPreferences(); private final Map myOwnAttributes = ContainerUtilRt.newHashMap(); private final Map myOwnColors = ContainerUtilRt.newHashMap(); private final EditorColorsScheme myCustomGlobalScheme; @@ -5807,6 +5807,12 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi return myFontPreferences.getEffectiveFontFamilies().isEmpty() ? getGlobal().getFontPreferences() : myFontPreferences; } + @Override + public void setFontPreferences(@NotNull FontPreferences preferences) { + preferences.copyTo(myFontPreferences); + initFonts(); + } + @Override public String getEditorFontName() { if (myFaceName == null) { @@ -5874,7 +5880,12 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi public FontPreferences getConsoleFontPreferences() { return getGlobal().getConsoleFontPreferences(); } - + + @Override + public void setConsoleFontPreferences(@NotNull FontPreferences preferences) { + getGlobal().setConsoleFontPreferences(preferences); + } + @Override public String getConsoleFontName() { return getGlobal().getConsoleFontName(); diff --git a/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java index 149b09a1d1be..05c7bfdb5f1b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java @@ -244,8 +244,10 @@ public class DumbServiceImpl extends DumbService { UIUtil.invokeLaterIfNeeded(new Runnable() { public void run() { final IdeFrame ideFrame = WindowManager.getInstance().getIdeFrame(myProject); - StatusBarEx statusBar = (StatusBarEx)ideFrame.getStatusBar(); - statusBar.notifyProgressByBalloon(MessageType.WARNING, message, null, null); + if (ideFrame != null) { + StatusBarEx statusBar = (StatusBarEx)ideFrame.getStatusBar(); + statusBar.notifyProgressByBalloon(MessageType.WARNING, message, null, null); + } } }); } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/execution/ParametersListTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/execution/ParametersListTest.java index fa13285ef1d4..73b73a408cba 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/execution/ParametersListTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/execution/ParametersListTest.java @@ -17,8 +17,12 @@ package com.intellij.openapi.execution; import com.intellij.execution.configurations.ParametersList; import com.intellij.execution.configurations.ParamsGroup; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.util.execution.ParametersListUtil; import org.junit.Test; +import java.util.List; + import static java.util.Arrays.asList; import static org.junit.Assert.*; @@ -171,12 +175,12 @@ public class ParametersListTest { "C:\\phing.bat"); checkTokenizer("-Dp.1=\"some text\" -Dp.2=\\\"value\\\"", "-Dp.1=some text", "-Dp.2=\"value\""); - checkTokenizer("-Dp.1=value\n\"-Dp.2=-\"\n-Dp.3=value", - "-Dp.1=value", "-Dp.2=-", "-Dp.3=value"); + checkTokenizer("-Dp.1=- -dump-config", + "-Dp.1=-", "-dump-config"); } @Test - public void joiningParams() throws Exception { + public void joiningParams() { String[] parameters = {"simpleParam", "param with spaces", "withQuote=\"", "param=\"complex quoted\""}; ParametersList parametersList = new ParametersList(); parametersList.addAll(parameters); @@ -186,16 +190,19 @@ public class ParametersListTest { } @Test - public void properties() throws Exception { + public void properties() { ParametersList params = new ParametersList(); params.addProperty("foo.foo", "\"bar bar\" bar"); assertEquals(1, params.getProperties().size()); assertEquals("\"bar bar\" bar", params.getProperties().get("foo.foo")); } - private static void checkTokenizer(final String paramString, final String... expected) { + private static void checkTokenizer(String paramString, String... expected) { ParametersList params = new ParametersList(); params.addParametersString(paramString); assertEquals(asList(expected), params.getList()); + + List lines = ParametersListUtil.parse(paramString, true); + assertEquals(paramString, StringUtil.join(lines, " ")); } } diff --git a/platform/usageView/src/com/intellij/usages/impl/rules/DirectoryGroupingRule.java b/platform/usageView/src/com/intellij/usages/impl/rules/DirectoryGroupingRule.java index 4fec12b758e1..c60de9aecdad 100644 --- a/platform/usageView/src/com/intellij/usages/impl/rules/DirectoryGroupingRule.java +++ b/platform/usageView/src/com/intellij/usages/impl/rules/DirectoryGroupingRule.java @@ -113,7 +113,7 @@ public class DirectoryGroupingRule implements UsageGroupingRule { } private PsiDirectory getDirectory() { - return PsiManager.getInstance(myProject).findDirectory(myDir); + return myDir.isValid() ? PsiManager.getInstance(myProject).findDirectory(myDir) : null; } @Override public boolean canNavigate() { diff --git a/platform/util/src/com/intellij/util/execution/ParametersListUtil.java b/platform/util/src/com/intellij/util/execution/ParametersListUtil.java index 9d8ac99297c1..01bd06127b94 100644 --- a/platform/util/src/com/intellij/util/execution/ParametersListUtil.java +++ b/platform/util/src/com/intellij/util/execution/ParametersListUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 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. @@ -70,7 +70,7 @@ public class ParametersListUtil { } /** - *

Converts single parameter string (as created by {@link #join(java.util.List)}) into list of parameters.

+ *

Splits single parameter string (as created by {@link #join(List)}) into list of parameters.

*

*

* Conversion rules: @@ -90,11 +90,16 @@ public class ParametersListUtil { * '"a \"1 2\"" b' => ['a="1 2"', 'b'] *

* - * @param string parameter string to split. + * @param parameterString parameter string to split. * @return array of parameters. */ @NotNull public static List parse(@NotNull String parameterString) { + return parse(parameterString, false); + } + + @NotNull + public static List parse(@NotNull String parameterString, boolean keepQuotes) { parameterString = parameterString.trim(); final ArrayList params = ContainerUtilRt.newArrayList(); @@ -110,7 +115,9 @@ public class ParametersListUtil { if (!escapedQuote) { inQuotes = !inQuotes; nonEmpty = true; - continue; + if (!keepQuotes) { + continue; + } } escapedQuote = false; } @@ -127,7 +134,9 @@ public class ParametersListUtil { else if (ch == '\\') { if (i < parameterString.length() - 1 && parameterString.charAt(i + 1) == '"') { escapedQuote = true; - continue; + if (!keepQuotes) { + continue; + } } } diff --git a/platform/util/src/com/intellij/util/xmlb/CollectionBinding.java b/platform/util/src/com/intellij/util/xmlb/CollectionBinding.java index 26d271b78248..1a06848a1ada 100644 --- a/platform/util/src/com/intellij/util/xmlb/CollectionBinding.java +++ b/platform/util/src/com/intellij/util/xmlb/CollectionBinding.java @@ -17,11 +17,20 @@ package com.intellij.util.xmlb; import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; import java.util.*; class CollectionBinding extends AbstractCollectionBinding { public CollectionBinding(ParameterizedType type, final Accessor accessor) { - super((Class)type.getActualTypeArguments()[0], Constants.COLLECTION, accessor); + super(getComponentClass(type), Constants.COLLECTION, accessor); + } + + private static Class getComponentClass(ParameterizedType type) { + Type arg = type.getActualTypeArguments()[0]; + if (arg instanceof ParameterizedType) { + return (Class)((ParameterizedType)arg).getRawType(); + } + return (Class)arg; } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/IntroduceLocalVariableTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/IntroduceLocalVariableTest.groovy index 24e5d5522575..afcbce22bb4f 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/IntroduceLocalVariableTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/IntroduceLocalVariableTest.groovy @@ -65,7 +65,7 @@ public class IntroduceLocalVariableTest extends GrIntentionTestCase { @Override void show() { - // nop + close(0) } @Override diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/JavaFxPsiUtil.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/JavaFxPsiUtil.java index da77e2827430..ec1e699473cc 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/JavaFxPsiUtil.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/JavaFxPsiUtil.java @@ -21,10 +21,12 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; import com.intellij.psi.impl.source.PostprocessReformattingAspect; +import com.intellij.psi.util.InheritanceUtil; import com.intellij.psi.util.PropertyUtil; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.TypeConversionUtil; import com.intellij.psi.xml.*; +import com.intellij.xml.XmlElementDescriptor; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; @@ -184,4 +186,55 @@ public class JavaFxPsiUtil { } return null; } + + public static PsiClass getControllerClass(PsiFile containingFile) { + if (containingFile instanceof XmlFile) { + final XmlTag rootTag = ((XmlFile)containingFile).getRootTag(); + if (rootTag != null) { + final XmlAttribute attribute = rootTag.getAttribute(FxmlConstants.FX_CONTROLLER); + if (attribute != null) { + final String attributeValue = attribute.getValue(); + if (!StringUtil.isEmptyOrSpaces(attributeValue)) { + return JavaPsiFacade.getInstance(containingFile.getProject()).findClass(attributeValue, containingFile.getResolveScope()); + } + } + } + } + return null; + } + + public static boolean checkIfAttributeHandler(XmlAttribute attribute) { + final String attributeName = attribute.getName(); + final XmlTag xmlTag = attribute.getParent(); + final XmlElementDescriptor descriptor = xmlTag.getDescriptor(); + if (descriptor == null) return false; + final PsiElement currentTagClass = descriptor.getDeclaration(); + if (!(currentTagClass instanceof PsiClass)) return false; + final PsiField handlerField = ((PsiClass)currentTagClass).findFieldByName(attributeName, true); + if (handlerField == null) { + return false; + } + final PsiClass objectPropertyClass = getPropertyClass(handlerField); + if (objectPropertyClass == null || !InheritanceUtil.isInheritor(objectPropertyClass, JavaFxCommonClassNames.JAVAFX_EVENT_EVENT_HANDLER)) { + return false; + } + return true; + } + + @Nullable + public static PsiClass getTagClass(XmlAttributeValue xmlAttributeValue) { + if (xmlAttributeValue == null) return null; + final PsiElement xmlAttribute = xmlAttributeValue.getParent(); + final XmlTag xmlTag = ((XmlAttribute)xmlAttribute).getParent(); + if (xmlTag != null) { + final XmlElementDescriptor descriptor = xmlTag.getDescriptor(); + if (descriptor != null) { + final PsiElement declaration = descriptor.getDeclaration(); + if (declaration instanceof PsiClass) { + return (PsiClass)declaration; + } + } + } + return null; + } } diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxDefaultAttributeDescriptor.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxDefaultAttributeDescriptor.java index 80b05a8d6397..b5894330eaea 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxDefaultAttributeDescriptor.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxDefaultAttributeDescriptor.java @@ -16,10 +16,16 @@ package org.jetbrains.plugins.javaFX.fxml.descriptors; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.psi.PsiClass; -import com.intellij.psi.PsiField; -import com.intellij.psi.PsiModifier; +import com.intellij.psi.*; +import com.intellij.psi.xml.XmlAttribute; +import com.intellij.psi.xml.XmlAttributeValue; +import com.intellij.psi.xml.XmlElement; +import com.intellij.psi.xml.XmlTag; +import com.intellij.xml.XmlAttributeDescriptor; +import com.intellij.xml.XmlElementDescriptor; +import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.javaFX.fxml.FxmlConstants; +import org.jetbrains.plugins.javaFX.fxml.JavaFxPsiUtil; import java.util.List; @@ -29,6 +35,7 @@ import java.util.List; */ public class JavaFxDefaultAttributeDescriptor extends JavaFxPropertyAttributeDescriptor { private static final Logger LOG = Logger.getInstance("#" + JavaFxDefaultAttributeDescriptor.class.getName()); + public static final String VALUE_OF = "valueOf"; private String myDefaultPropertyName = null; public JavaFxDefaultAttributeDescriptor(String name, PsiClass psiClass) { @@ -67,4 +74,41 @@ public class JavaFxDefaultAttributeDescriptor extends JavaFxPropertyAttributeDes protected boolean isConstant(PsiField field) { return field.hasModifierProperty(PsiModifier.STATIC) && field.hasModifierProperty(PsiModifier.FINAL) && field.hasModifierProperty(PsiModifier.PUBLIC); } + + @Nullable + @Override + public String validateValue(XmlElement context, String value) { + if (context instanceof XmlAttributeValue) { + final PsiElement parent = context.getParent(); + if (parent instanceof XmlAttribute) { + final XmlAttribute attribute = (XmlAttribute)parent; + if (FxmlConstants.FX_VALUE.equals(attribute.getName())) { + final PsiClass tagClass = JavaFxPsiUtil.getTagClass((XmlAttributeValue)context); + if (tagClass != null) { + final PsiMethod method = getValueOfMethod(tagClass); + if (method == null) { + return "Unable to coerce '" + value + "' to " + tagClass.getQualifiedName() + "."; + } + } + } + } + } + return super.validateValue(context, value); + } + + private static PsiMethod getValueOfMethod(PsiClass tagClass) { + final PsiMethod[] methods = tagClass.findMethodsByName(VALUE_OF, false); + for (PsiMethod method : methods) { + if (method.hasModifierProperty(PsiModifier.STATIC)) { + final PsiParameter[] parameters = method.getParameterList().getParameters(); + if (parameters.length == 1) { + final PsiType type = parameters[0].getType(); + if (type.equalsToText(CommonClassNames.JAVA_LANG_STRING) || type.equalsToText(CommonClassNames.JAVA_LANG_OBJECT)) { + return method; + } + } + } + } + return null; + } } diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxDefaultPropertyElementDescriptor.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxDefaultPropertyElementDescriptor.java index 2c682cf56fbf..f63e9f8abcee 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxDefaultPropertyElementDescriptor.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxDefaultPropertyElementDescriptor.java @@ -17,7 +17,10 @@ package org.jetbrains.plugins.javaFX.fxml.descriptors; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiMethod; +import com.intellij.psi.PsiReference; +import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.xml.XmlAttribute; +import com.intellij.psi.xml.XmlAttributeValue; import com.intellij.psi.xml.XmlTag; import com.intellij.util.ArrayUtil; import com.intellij.xml.XmlAttributeDescriptor; @@ -30,6 +33,7 @@ import org.jetbrains.plugins.javaFX.fxml.FxmlConstants; import org.jetbrains.plugins.javaFX.fxml.JavaFxPsiUtil; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -37,11 +41,11 @@ import java.util.List; */ public class JavaFxDefaultPropertyElementDescriptor implements XmlElementDescriptor{ private final String myName; - private PsiElement myElement; + private final XmlTag myXmlTag; public JavaFxDefaultPropertyElementDescriptor(String name, XmlTag tag) { myName = name; - myElement = tag; + myXmlTag = tag; } @Override @@ -62,7 +66,13 @@ public class JavaFxDefaultPropertyElementDescriptor implements XmlElementDescrip @Nullable @Override public XmlElementDescriptor getElementDescriptor(XmlTag childTag, XmlTag contextTag) { - return null; //To change body of implemented methods use File | Settings | File Templates. + if (myName.equals(FxmlConstants.FX_DEFINE)) { + final String name = childTag.getName(); + if (JavaFxPsiUtil.isClassTag(name)) { + return new JavaFxClassBackedElementDescriptor(name, childTag); + } + } + return null; } @Override @@ -74,11 +84,41 @@ public class JavaFxDefaultPropertyElementDescriptor implements XmlElementDescrip descriptors.add(new JavaFxDefaultAttributeDescriptor(defaultAttrName, getName())); } JavaFxClassBackedElementDescriptor.collectStaticAttributesDescriptors(context, descriptors); + final XmlTag referencedTag = getReferencedTag(getName(), myXmlTag); + if (referencedTag != null) { + final XmlElementDescriptor referencedDescriptor = referencedTag.getDescriptor(); + if (referencedDescriptor != null) { + final XmlAttributeDescriptor[] attributesDescriptors = referencedDescriptor.getAttributesDescriptors(referencedTag); + if (attributesDescriptors != null) { + Collections.addAll(descriptors, attributesDescriptors); + } + } + } return descriptors.toArray(new XmlAttributeDescriptor[descriptors.size()]); } return XmlAttributeDescriptor.EMPTY; } + @Nullable + private static XmlTag getReferencedTag(String name, XmlTag tag) { + if (name.equals(FxmlConstants.FX_REFERENCE)) { + final XmlAttribute attribute = tag.getAttribute(FxmlConstants.FX_ELEMENT_SOURCE); + if (attribute != null) { + final XmlAttributeValue valueElement = attribute.getValueElement(); + if (valueElement != null) { + final PsiReference reference = valueElement.getReference(); + if (reference != null) { + final PsiElement resolve = reference.resolve(); + if (resolve instanceof XmlAttributeValue) { + return PsiTreeUtil.getParentOfType(resolve, XmlTag.class); + } + } + } + } + } + return null; + } + @Nullable @Override public XmlAttributeDescriptor getAttributeDescriptor(@NonNls String attributeName, @Nullable XmlTag context) { @@ -91,6 +131,13 @@ public class JavaFxDefaultPropertyElementDescriptor implements XmlElementDescrip if (propertySetter != null) { return new JavaFxStaticPropertyAttributeDescriptor(propertySetter, attributeName); } + final XmlTag referencedTag = getReferencedTag(getName(), myXmlTag); + if (referencedTag != null) { + final XmlElementDescriptor referencedDescriptor = referencedTag.getDescriptor(); + if (referencedDescriptor != null) { + return referencedDescriptor.getAttributeDescriptor(attributeName, referencedTag); + } + } } return null; } @@ -125,7 +172,7 @@ public class JavaFxDefaultPropertyElementDescriptor implements XmlElementDescrip @Override public PsiElement getDeclaration() { - return myElement; + return myXmlTag; } @Override diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxPropertyAttributeDescriptor.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxPropertyAttributeDescriptor.java index 07aac3184d32..d18941d4777a 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxPropertyAttributeDescriptor.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxPropertyAttributeDescriptor.java @@ -2,7 +2,10 @@ package org.jetbrains.plugins.javaFX.fxml.descriptors; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; +import com.intellij.psi.xml.XmlAttribute; +import com.intellij.psi.xml.XmlAttributeValue; import com.intellij.psi.xml.XmlElement; +import com.intellij.psi.xml.XmlFile; import com.intellij.util.ArrayUtil; import com.intellij.xml.XmlAttributeDescriptor; import org.jetbrains.annotations.Nullable; @@ -87,16 +90,32 @@ public class JavaFxPropertyAttributeDescriptor implements XmlAttributeDescriptor public PsiField getEnumConstant(String attrValue) { if (isEnumerated()) { - final String fieldNameIgnoreCase = StringUtil.stripQuotesAroundValue(attrValue); final PsiClass aClass = getEnum(); - return aClass.findFieldByName(fieldNameIgnoreCase.toUpperCase(), false); + return aClass.findFieldByName(attrValue.toUpperCase(), false); } return null; } - + @Nullable @Override public String validateValue(XmlElement context, String value) { + if (context instanceof XmlAttributeValue) { + final XmlAttributeValue xmlAttributeValue = (XmlAttributeValue)context; + final PsiElement parent = xmlAttributeValue.getParent(); + if (parent instanceof XmlAttribute && JavaFxPsiUtil.checkIfAttributeHandler((XmlAttribute)parent)) { + final PsiClass controllerClass = JavaFxPsiUtil.getControllerClass(context.getContainingFile()); + if (value.startsWith("#")) { + if (controllerClass == null) { + return "No controller specified for top level element"; + } + } + else { + if (JavaFxPsiUtil.parseInjectedLanguages((XmlFile)context.getContainingFile()).isEmpty()) { + return "Page language not specified."; + } + } + } + } return null; } @@ -116,7 +135,8 @@ public class JavaFxPropertyAttributeDescriptor implements XmlAttributeDescriptor } @Override - public void init(PsiElement element) {} + public void init(PsiElement element) { + } @Override public Object[] getDependences() { diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxPropertyElementDescriptor.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxPropertyElementDescriptor.java index 2ded59af3b49..36a4c8563228 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxPropertyElementDescriptor.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxPropertyElementDescriptor.java @@ -2,12 +2,10 @@ package org.jetbrains.plugins.javaFX.fxml.descriptors; import com.intellij.codeInsight.daemon.impl.analysis.GenericsHighlightUtil; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.psi.PsiClass; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiField; -import com.intellij.psi.PsiType; +import com.intellij.psi.*; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.searches.ClassInheritorsSearch; +import com.intellij.psi.util.InheritanceUtil; import com.intellij.psi.util.PsiUtil; import com.intellij.psi.xml.XmlAttribute; import com.intellij.psi.xml.XmlTag; @@ -17,6 +15,7 @@ import com.intellij.xml.XmlAttributeDescriptor; import com.intellij.xml.XmlElementDescriptor; import com.intellij.xml.XmlElementsGroup; import com.intellij.xml.XmlNSDescriptor; +import com.intellij.xml.impl.schema.AnyXmlAttributeDescriptor; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.javaFX.fxml.FxmlConstants; @@ -107,6 +106,13 @@ public class JavaFxPropertyElementDescriptor implements XmlElementDescriptor { @Nullable @Override public XmlAttributeDescriptor getAttributeDescriptor(@NonNls String attributeName, @Nullable XmlTag context) { + final PsiElement element = getDeclaration(); + if (element instanceof PsiField) { + final PsiType type = ((PsiField)element).getType(); + if (InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_UTIL_MAP)) { + return new AnyXmlAttributeDescriptor(attributeName); + } + } return null; } diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/EnumeratedAttributeReferenceProvider.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/EnumeratedAttributeReferenceProvider.java index ce12b2e051d6..8f8746082845 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/EnumeratedAttributeReferenceProvider.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/EnumeratedAttributeReferenceProvider.java @@ -39,7 +39,7 @@ class EnumeratedAttributeReferenceProvider extends PsiReferenceProvider { if (parent instanceof XmlAttribute) { final XmlAttributeDescriptor descriptor = ((XmlAttribute)parent).getDescriptor(); if (descriptor instanceof JavaFxPropertyAttributeDescriptor && descriptor.isEnumerated()) { - return new PsiReference[]{new PsiReferenceBase.Immediate(xmlAttributeValue, ((JavaFxPropertyAttributeDescriptor)descriptor).getEnumConstant(element.getText()))}; + return new PsiReference[] {new PsiReferenceBase.Immediate(xmlAttributeValue, ((JavaFxPropertyAttributeDescriptor)descriptor).getEnumConstant(xmlAttributeValue.getValue()))}; } } } diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/FxmlReferencesContributor.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/FxmlReferencesContributor.java index 8b1d0d9917bd..148538e77ba1 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/FxmlReferencesContributor.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/FxmlReferencesContributor.java @@ -51,6 +51,16 @@ public class FxmlReferencesContributor extends PsiReferenceContributor { .and(attributeValueInFxml), new JavaFxSourceReferenceProvider()); + registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue().withParent(XmlPatterns.xmlAttribute().withName(FxmlConstants.FX_ELEMENT_SOURCE) + .withParent(XmlPatterns.xmlTag() + .withName(FxmlConstants.FX_REFERENCE))) + .and(attributeValueInFxml), + new JavaFxComponentIdReferenceProvider()); + + registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue().withParent(XmlPatterns.xmlAttribute().withName(FxmlConstants.FX_FACTORY)) + .and(attributeValueInFxml), + new JavaFxFactoryReferenceProvider()); + registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue().withValue(string().startsWith("#")) .and(attributeValueInFxml), new JavaFxEventHandlerReferenceProvider()); @@ -58,6 +68,9 @@ public class FxmlReferencesContributor extends PsiReferenceContributor { registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue().withValue(string().startsWith("@")).and(attributeValueInFxml), new JavaFxLocationReferenceProvider()); + registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue().withParent(XmlPatterns.xmlAttribute().withName("url")).and(attributeValueInFxml), + new JavaFxLocationReferenceProvider()); + registrar.registerReferenceProvider(PlatformPatterns.psiElement(XmlTokenType.XML_TAG_CHARACTERS).inFile(inFxmlElementPattern()), new ImportReferenceProvider()); registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue().and(attributeValueInFxml), diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxComponentIdReferenceProvider.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxComponentIdReferenceProvider.java new file mode 100644 index 000000000000..04550a8055a7 --- /dev/null +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxComponentIdReferenceProvider.java @@ -0,0 +1,67 @@ +/* + * Copyright 2000-2013 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 org.jetbrains.plugins.javaFX.fxml.refs; + +import com.intellij.psi.*; +import com.intellij.psi.xml.XmlAttribute; +import com.intellij.psi.xml.XmlAttributeValue; +import com.intellij.psi.xml.XmlTag; +import com.intellij.util.ArrayUtil; +import com.intellij.util.ProcessingContext; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.plugins.javaFX.fxml.FxmlConstants; + +import java.util.HashMap; +import java.util.Map; + +/** +* User: anna +*/ +class JavaFxComponentIdReferenceProvider extends PsiReferenceProvider { + @NotNull + @Override + public PsiReference[] getReferencesByElement(@NotNull PsiElement element, + @NotNull ProcessingContext context) { + final XmlAttributeValue xmlAttributeValue = (XmlAttributeValue)element; + final String referencesId = xmlAttributeValue.getValue(); + final Map fileIds = new HashMap(); + xmlAttributeValue.getContainingFile().accept(new XmlRecursiveElementVisitor() { + @Override + public void visitXmlTag(XmlTag tag) { + super.visitXmlTag(tag); + final XmlAttribute attribute = tag.getAttribute(FxmlConstants.FX_ID); + if (attribute != null) { + fileIds.put(attribute.getValue(), attribute.getValueElement()); + } + } + }); + + return new PsiReference[]{new PsiReferenceBase(xmlAttributeValue) { + @Nullable + @Override + public PsiElement resolve() { + return fileIds.get(referencesId); + } + + @NotNull + @Override + public Object[] getVariants() { + return ArrayUtil.toStringArray(fileIds.keySet()); + } + }}; + } +} diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxEventHandlerReferenceProvider.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxEventHandlerReferenceProvider.java index d1b030b514c4..8a7711ebb0b6 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxEventHandlerReferenceProvider.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxEventHandlerReferenceProvider.java @@ -17,14 +17,10 @@ package org.jetbrains.plugins.javaFX.fxml.refs; import com.intellij.openapi.diagnostic.Logger; import com.intellij.psi.*; -import com.intellij.psi.util.InheritanceUtil; import com.intellij.psi.xml.XmlAttribute; import com.intellij.psi.xml.XmlAttributeValue; -import com.intellij.psi.xml.XmlTag; import com.intellij.util.ProcessingContext; -import com.intellij.xml.XmlElementDescriptor; import org.jetbrains.annotations.NotNull; -import org.jetbrains.plugins.javaFX.fxml.JavaFxCommonClassNames; import org.jetbrains.plugins.javaFX.fxml.JavaFxPsiUtil; /** @@ -43,20 +39,8 @@ class JavaFxEventHandlerReferenceProvider extends JavaFxControllerBasedReference final XmlAttribute attribute = (XmlAttribute)xmlAttributeValue.getContext(); if (attribute == null) return PsiReference.EMPTY_ARRAY; - final String attributeName = attribute.getName(); - final XmlTag xmlTag = attribute.getParent(); - final XmlElementDescriptor descriptor = xmlTag.getDescriptor(); - if (descriptor == null) return PsiReference.EMPTY_ARRAY; - final PsiElement currentTagClass = descriptor.getDeclaration(); - if (!(currentTagClass instanceof PsiClass)) return PsiReference.EMPTY_ARRAY; - final PsiField handlerField = ((PsiClass)currentTagClass).findFieldByName(attributeName, true); - if (handlerField == null) { - return PsiReference.EMPTY_ARRAY; - } - final PsiClass objectPropertyClass = JavaFxPsiUtil.getPropertyClass(handlerField); - if (objectPropertyClass == null || !InheritanceUtil.isInheritor(objectPropertyClass, JavaFxCommonClassNames.JAVAFX_EVENT_EVENT_HANDLER)) { - return PsiReference.EMPTY_ARRAY; - } + if (!JavaFxPsiUtil.checkIfAttributeHandler(attribute)) return PsiReference.EMPTY_ARRAY; + final PsiElement currentTagClass = attribute.getParent().getDescriptor().getDeclaration(); final String eventHandlerName = attValueString.substring(1); final PsiMethod[] methods = controllerClass.findMethodsByName(eventHandlerName, true); diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxFactoryReferenceProvider.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxFactoryReferenceProvider.java new file mode 100644 index 000000000000..f2da17c1454e --- /dev/null +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxFactoryReferenceProvider.java @@ -0,0 +1,81 @@ +/* + * Copyright 2000-2013 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 org.jetbrains.plugins.javaFX.fxml.refs; + +import com.intellij.psi.*; +import com.intellij.psi.xml.XmlAttributeValue; +import com.intellij.util.ArrayUtil; +import com.intellij.util.ProcessingContext; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.plugins.javaFX.fxml.JavaFxPsiUtil; + +import java.util.ArrayList; +import java.util.List; + +/** +* User: anna +*/ +class JavaFxFactoryReferenceProvider extends PsiReferenceProvider { + @NotNull + @Override + public PsiReference[] getReferencesByElement(@NotNull PsiElement element, + @NotNull ProcessingContext context) { + final XmlAttributeValue attributeValue = (XmlAttributeValue)element; + return new PsiReference[] {new JavaFXFactoryReference(attributeValue)}; + } + + private static class JavaFXFactoryReference extends PsiReferenceBase { + public JavaFXFactoryReference(XmlAttributeValue attributeValue) { + super(attributeValue); + } + + @Nullable + @Override + public PsiElement resolve() { + final PsiClass psiClass = JavaFxPsiUtil.getTagClass(getElement()); + if (psiClass != null) { + final PsiMethod[] psiMethods = psiClass.findMethodsByName(getElement().getValue(), false); + for (PsiMethod method : psiMethods) { + if (isFactoryMethod(method)) { + return method; + } + } + } + return null; + } + + private static boolean isFactoryMethod(PsiMethod method) { + return method.hasModifierProperty(PsiModifier.STATIC) && method.getParameterList().getParametersCount() == 0; + } + + @NotNull + @Override + public Object[] getVariants() { + final PsiClass psiClass = JavaFxPsiUtil.getTagClass(getElement()); + if (psiClass != null) { + final List methods = new ArrayList(); + for (PsiMethod method : psiClass.getMethods()) { + if (isFactoryMethod(method)) { + methods.add(method); + } + } + return ArrayUtil.toObjectArray(methods); + } + return ArrayUtil.EMPTY_OBJECT_ARRAY; + } + } +} diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxLocationReferenceProvider.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxLocationReferenceProvider.java index 9e2f2eb771c4..c901ad7c9697 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxLocationReferenceProvider.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxLocationReferenceProvider.java @@ -32,8 +32,16 @@ class JavaFxLocationReferenceProvider extends PsiReferenceProvider { public PsiReference[] getReferencesByElement(@NotNull final PsiElement element, @NotNull ProcessingContext context) { final String value = ((XmlAttributeValue)element).getValue(); - final String relativePathToResource = value.substring(1); - final FileReferenceSet set = new FileReferenceSet(relativePathToResource, element, 2, null, true); + final FileReferenceSet set; + if (value.startsWith("@")) { + set = new FileReferenceSet(value.substring(1), element, 2, null, true); + } + else { + set = new FileReferenceSet(value, element, 1, null, true); + if (value.startsWith("/")) { + set.addCustomization(FileReferenceSet.DEFAULT_PATH_EVALUATOR_OPTION, FileReferenceSet.ABSOLUTE_TOP_LEVEL); + } + } return set.getAllReferences(); } } diff --git a/plugins/javaFX/testData/completion/factoryMethods.fxml b/plugins/javaFX/testData/completion/factoryMethods.fxml new file mode 100644 index 000000000000..b10f088fbc38 --- /dev/null +++ b/plugins/javaFX/testData/completion/factoryMethods.fxml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/plugins/javaFX/testData/completion/factoryMethods_after.fxml b/plugins/javaFX/testData/completion/factoryMethods_after.fxml new file mode 100644 index 000000000000..6be1200c2452 --- /dev/null +++ b/plugins/javaFX/testData/completion/factoryMethods_after.fxml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/plugins/javaFX/testData/completion/referencedAttributes.fxml b/plugins/javaFX/testData/completion/referencedAttributes.fxml new file mode 100644 index 000000000000..ac36d9d0f84b --- /dev/null +++ b/plugins/javaFX/testData/completion/referencedAttributes.fxml @@ -0,0 +1,8 @@ + + + + + + /> + diff --git a/plugins/javaFX/testData/completion/referencedAttributes_after.fxml b/plugins/javaFX/testData/completion/referencedAttributes_after.fxml new file mode 100644 index 000000000000..1e9128c4cc8d --- /dev/null +++ b/plugins/javaFX/testData/completion/referencedAttributes_after.fxml @@ -0,0 +1,8 @@ + + + + + + + diff --git a/plugins/javaFX/testData/highlighting/definedElements.fxml b/plugins/javaFX/testData/highlighting/definedElements.fxml new file mode 100644 index 000000000000..c080cdfcd5a3 --- /dev/null +++ b/plugins/javaFX/testData/highlighting/definedElements.fxml @@ -0,0 +1,8 @@ + + + + + + + diff --git a/plugins/javaFX/testData/highlighting/handlerWithoutController.fxml b/plugins/javaFX/testData/highlighting/handlerWithoutController.fxml new file mode 100644 index 000000000000..2662596e3f7d --- /dev/null +++ b/plugins/javaFX/testData/highlighting/handlerWithoutController.fxml @@ -0,0 +1,6 @@ + + + + + + diff --git a/plugins/javaFX/testData/highlighting/referenceAttributes.fxml b/plugins/javaFX/testData/highlighting/referenceAttributes.fxml index 6dd49d046575..e1f5e19afc2e 100644 --- a/plugins/javaFX/testData/highlighting/referenceAttributes.fxml +++ b/plugins/javaFX/testData/highlighting/referenceAttributes.fxml @@ -1,5 +1,5 @@ - - + <fx:reference GridPane.halignment="CENTER" /> + lbl"/> diff --git a/plugins/javaFX/testData/highlighting/sourceAttrRecognition.fxml b/plugins/javaFX/testData/highlighting/sourceAttrRecognition.fxml index 15153423931a..b17af0779ad1 100644 --- a/plugins/javaFX/testData/highlighting/sourceAttrRecognition.fxml +++ b/plugins/javaFX/testData/highlighting/sourceAttrRecognition.fxml @@ -3,7 +3,7 @@ - + myImage"/> my_button.fxml"/> diff --git a/plugins/javaFX/testData/highlighting/valueOfAcceptance.fxml b/plugins/javaFX/testData/highlighting/valueOfAcceptance.fxml new file mode 100644 index 000000000000..a4b16c30662e --- /dev/null +++ b/plugins/javaFX/testData/highlighting/valueOfAcceptance.fxml @@ -0,0 +1,16 @@ + + + + + + + + "A"/> + + + + + + + + diff --git a/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXHighlightingTest.java b/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXHighlightingTest.java index 2453baf5ccf3..701e1beb9fa6 100644 --- a/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXHighlightingTest.java +++ b/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXHighlightingTest.java @@ -3,6 +3,7 @@ package org.jetbrains.plugins.javaFX.fxml; import com.intellij.codeInsight.daemon.DaemonAnalyzerTestCase; import com.intellij.codeInsight.daemon.impl.analysis.XmlPathReferenceInspection; import com.intellij.codeInspection.LocalInspectionTool; +import com.intellij.codeInspection.htmlInspections.RequiredAttributesInspection; import com.intellij.openapi.application.PluginPathManager; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiField; @@ -24,7 +25,7 @@ public class JavaFXHighlightingTest extends DaemonAnalyzerTestCase { @Override protected LocalInspectionTool[] configureLocalInspectionTools() { - return new LocalInspectionTool[] {new XmlPathReferenceInspection()}; + return new LocalInspectionTool[] {new XmlPathReferenceInspection(), new RequiredAttributesInspection() }; } public void testLoginForm() throws Exception { @@ -125,11 +126,31 @@ public class JavaFXHighlightingTest extends DaemonAnalyzerTestCase { doTest(); } + public void testDefinedElements() throws Exception { + doTest(); + } + + public void testPropertyElementsWithAnyAttributes() throws Exception { + doTest(); + } + + public void testHandlerWithoutController() throws Exception { + doTest(); + } + + public void testHandlerWithoutPageLanguage() throws Exception { + doTest(); + } + public void testIncludeBtn() throws Exception { configureByFiles(null, getTestName(true) + ".fxml", "btn.fxml"); doDoTest(false, false); } + public void testValueOfAcceptance() throws Exception { + doTest(); + } + @NotNull @Override protected String getTestDataPath() { diff --git a/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFxCompletionTest.java b/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFxCompletionTest.java index 2c0bce26bb7d..d21c73adbe59 100644 --- a/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFxCompletionTest.java +++ b/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFxCompletionTest.java @@ -81,6 +81,14 @@ public class JavaFxCompletionTest extends CompletionTestCase { doTest("NEGATIVE_INFINITY"); } + public void testReferencedAttributes() throws Exception { + doTest("text"); + } + + public void testFactoryMethods() throws Exception { + doTest("observableArrayList"); + } + private void doTest() throws Exception { doTest(null); } diff --git a/plugins/tasks/jira-connector/src/main/java/com/intellij/tasks/jira/JiraRepository.java b/plugins/tasks/jira-connector/src/main/java/com/intellij/tasks/jira/JiraRepository.java index 78f9764fc879..02e3d431ce25 100644 --- a/plugins/tasks/jira-connector/src/main/java/com/intellij/tasks/jira/JiraRepository.java +++ b/plugins/tasks/jira-connector/src/main/java/com/intellij/tasks/jira/JiraRepository.java @@ -18,6 +18,7 @@ import com.intellij.util.xmlb.annotations.Tag; import org.apache.axis.AxisProperties; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpStatus; +import org.apache.commons.httpclient.cookie.CookiePolicy; import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.methods.PostMethod; import org.apache.commons.httpclient.methods.StringRequestEntity; @@ -117,6 +118,7 @@ public class JiraRepository extends BaseRepositoryImpl { private HttpClient login() throws Exception { HttpClient client = getHttpClient(); + client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY); if (myJira4) { PostMethod postMethod = getLoginMethodFor4x(); client.executeMethod(postMethod); diff --git a/plugins/testng/src/com/theoryinpractice/testng/model/TestData.java b/plugins/testng/src/com/theoryinpractice/testng/model/TestData.java index 9a50e135ac70..2f857253b86a 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/model/TestData.java +++ b/plugins/testng/src/com/theoryinpractice/testng/model/TestData.java @@ -239,7 +239,8 @@ public class TestData implements Cloneable element = PsiTreeUtil.getParentOfType(element, PsiModifierListOwner.class, false); if (element instanceof PsiMethod && TEST_OBJECT.equals(TestType.METHOD.getType())) { final PsiClass aClass = ((PsiMethod) element).getContainingClass(); - return Comparing.strEqual(MAIN_CLASS_NAME, JavaExecutionUtil.getRuntimeQualifiedName(aClass)) && + return aClass != null && + Comparing.strEqual(MAIN_CLASS_NAME, JavaExecutionUtil.getRuntimeQualifiedName(aClass)) && Comparing.strEqual(METHOD_NAME, ((PsiMethod) element).getName()); } else if (element instanceof PsiClass && TEST_OBJECT.equals(TestType.CLASS.getType())) { return Comparing.strEqual(MAIN_CLASS_NAME, JavaExecutionUtil.getRuntimeQualifiedName((PsiClass) element)); diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/componentTree/TreeEditOperation.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/componentTree/TreeEditOperation.java index 9bc36e53acd8..b122bdeeb96a 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/componentTree/TreeEditOperation.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/componentTree/TreeEditOperation.java @@ -19,6 +19,7 @@ import com.intellij.designer.designSurface.AbstractEditOperation; import com.intellij.designer.designSurface.FeedbackTreeLayer; import com.intellij.designer.designSurface.OperationContext; import com.intellij.designer.model.RadComponent; +import com.intellij.util.ArrayUtil; import org.jetbrains.annotations.Nullable; import java.awt.*; @@ -66,13 +67,8 @@ public abstract class TreeEditOperation extends AbstractEditOperation { } } - private boolean isChildren(RadComponent component) { - for (Object child : myContainer.getTreeChildren()) { - if (child == component) { - return true; - } - } - return false; + protected final boolean isChildren(RadComponent component) { + return ArrayUtil.indexOf(myContainer.getTreeChildren(), component) != -1; } @Override diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/feedbacks/RoundRectangleFeedback.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/feedbacks/RoundRectangleFeedback.java index fbd126a2c437..a1ce15a0e5fb 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/feedbacks/RoundRectangleFeedback.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/feedbacks/RoundRectangleFeedback.java @@ -21,6 +21,8 @@ import java.awt.*; * @author Alexander Lobas */ public class RoundRectangleFeedback extends RectangleFeedback { + private static final BasicStroke STROKE = new BasicStroke(2); + private final int myRadius; public RoundRectangleFeedback(Color color, int line, int radius) { @@ -30,9 +32,15 @@ public class RoundRectangleFeedback extends RectangleFeedback { @Override protected void paintFeedback(Graphics g) { + Graphics2D g2d = (Graphics2D)g; + + Stroke oldStroke = g2d.getStroke(); + g2d.setStroke(STROKE); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + Dimension size = getSize(); - for (int i = 0; i < myLine; i++) { - g.drawRoundRect(i, i, size.width - i - i - 1, size.height - i - i - 1, myRadius, myRadius); - } + g.drawRoundRect(0, 0, size.width - 1, size.height - 1, myRadius, myRadius); + + g2d.setStroke(oldStroke); } } \ No newline at end of file diff --git a/xml/impl/src/com/intellij/xml/util/XmlDuplicatedIdInspection.java b/xml/impl/src/com/intellij/xml/util/XmlDuplicatedIdInspection.java index e0a185402210..19b2012fdd1e 100644 --- a/xml/impl/src/com/intellij/xml/util/XmlDuplicatedIdInspection.java +++ b/xml/impl/src/com/intellij/xml/util/XmlDuplicatedIdInspection.java @@ -24,6 +24,7 @@ import com.intellij.codeInspection.ProblemsHolder; import com.intellij.openapi.extensions.Extensions; import com.intellij.psi.*; import com.intellij.psi.html.HtmlTag; +import com.intellij.psi.util.PsiUtilCore; import com.intellij.psi.xml.XmlAttribute; import com.intellij.psi.xml.XmlAttributeValue; import com.intellij.psi.xml.XmlFile; @@ -50,6 +51,10 @@ public class XmlDuplicatedIdInspection extends LocalInspectionTool { if (!(file instanceof XmlFile)) { return; } + PsiFile baseFile = PsiUtilCore.getTemplateLanguageFile(file); + if (baseFile != file && !(baseFile instanceof XmlFile)) { + return; + } final XmlRefCountHolder refHolder = XmlRefCountHolder.getRefCountHolder(value); if (refHolder == null) return;