mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote branch 'origin/master'
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
<templates>
|
||||
<template>
|
||||
<name>Java Hello World</name>
|
||||
<description><![CDATA[ Simple Java "Hello World" application. ]]>
|
||||
</description>
|
||||
<description><![CDATA[ Simple Java "Hello World" application. ]]></description>
|
||||
<path>HelloWorld.zip</path>
|
||||
</template>
|
||||
</templates>
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<template-groups xmlns="http://www.jetbrains.com/projectTemplates">
|
||||
<group>
|
||||
<name>Spring</name>
|
||||
<path>Spring</path>
|
||||
<template>
|
||||
<name>Spring Core</name>
|
||||
<description><![CDATA[ A simple console application with Spring Framework 3.2. ]]></description>
|
||||
<path>SpringApp</path>
|
||||
<input-field>IJ_BASE_PACKAGE</input-field>
|
||||
<input-field>IJ_APPLICATION_SERVER</input-field>
|
||||
</template>
|
||||
</group>
|
||||
</template-groups>
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||
targetNamespace="http://www.jetbrains.com/projectTemplates">
|
||||
<xs:element name="template-groups" type="template-groupsType"/>
|
||||
<xs:complexType name="groupType">
|
||||
<xs:sequence>
|
||||
<xs:element type="xs:string" name="name"/>
|
||||
<xs:element type="xs:string" name="path"/>
|
||||
<xs:element type="templateType" name="template"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="templateType">
|
||||
<xs:sequence>
|
||||
<xs:element type="xs:string" name="name"/>
|
||||
<xs:element type="xs:string" name="description"/>
|
||||
<xs:element type="xs:string" name="path"/>
|
||||
<xs:element name="input-field" maxOccurs="unbounded" minOccurs="0">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="IJ_BASE_PACKAGE"/>
|
||||
<xs:enumeration value="IJ_APPLICATION_SERVER"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="template-groupsType">
|
||||
<xs:sequence>
|
||||
<xs:element type="groupType" name="group"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:schema>
|
||||
@@ -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<MultiMap<String, ProjectTemplate>> myTemplates = new ClearableLazyValue<MultiMap<String, ProjectTemplate>>() {
|
||||
@NotNull
|
||||
@Override
|
||||
protected MultiMap<String, ProjectTemplate> 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<ProjectTemplate> templates = myTemplates.getValue().get(group);
|
||||
return templates.toArray(new ProjectTemplate[templates.size()]);
|
||||
}
|
||||
|
||||
private static MultiMap<String, ProjectTemplate> 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<String, ProjectTemplate> createFromText(String text) throws IOException, JDOMException {
|
||||
|
||||
List<Element> elements = JDOMUtil.loadDocument(text).getRootElement().getChildren("template");
|
||||
Element rootElement = JDOMUtil.loadDocument(text).getRootElement();
|
||||
List<Element> groups = rootElement.getChildren("group", NAMESPACE);
|
||||
MultiMap<String, ProjectTemplate> map = new MultiMap<String, ProjectTemplate>();
|
||||
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<ProjectTemplate> templates = ContainerUtil.mapNotNull(elements, new NullableFunction<Element, ProjectTemplate>() {
|
||||
return map;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static List<ProjectTemplate> createGroupTemplates(Element groupElement, final Namespace ns) {
|
||||
List<Element> elements = groupElement.getChildren("template", ns);
|
||||
|
||||
return ContainerUtil.mapNotNull(elements, new NullableFunction<Element, ProjectTemplate>() {
|
||||
@Override
|
||||
public ProjectTemplate fun(final Element element) {
|
||||
|
||||
List<Element> plugins = element.getChildren("requiredPlugin");
|
||||
List<Element> 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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+23
-9
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.application.options.InitialConfigurationDialog">
|
||||
<grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="8" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="9" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="475" height="400"/>
|
||||
@@ -19,7 +19,7 @@
|
||||
</component>
|
||||
<component id="9f9cd" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="f7d28"/>
|
||||
@@ -34,13 +34,13 @@
|
||||
</component>
|
||||
<component id="f7d28" class="javax.swing.JComboBox" binding="myColorSchemeComboBox" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="978ed" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="4" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="You can use the Settings dialog to configure any of these settings later."/>
|
||||
@@ -48,7 +48,7 @@
|
||||
</component>
|
||||
<component id="16dfd" class="javax.swing.JCheckBox" binding="myCreateScriptCheckbox">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="5" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<selected value="false"/>
|
||||
@@ -58,7 +58,7 @@
|
||||
<grid id="a1a85" binding="myCreateScriptPanel" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="5" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="2" use-parent-layout="false"/>
|
||||
<grid row="6" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
@@ -83,7 +83,7 @@
|
||||
</grid>
|
||||
<grid id="229b8" binding="myColorPreviewPanel" custom-create="true" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="1" use-parent-layout="false"/>
|
||||
<grid row="3" column="0" row-span="1" col-span="2" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="1" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
@@ -91,7 +91,7 @@
|
||||
</grid>
|
||||
<component id="e91fa" class="javax.swing.JCheckBox" binding="myCreateEntryCheckBox">
|
||||
<constraints>
|
||||
<grid row="6" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="7" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Create desktop entry (integrate in system menu)"/>
|
||||
@@ -100,7 +100,7 @@
|
||||
<grid id="5ee35" binding="myCreateEntryPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="7" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="2" use-parent-layout="false"/>
|
||||
<grid row="8" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
@@ -115,6 +115,20 @@
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<component id="4566" class="com.intellij.ui.components.JBLabel">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="IDE appearance:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="a9046" class="com.intellij.openapi.ui.ComboBox" binding="myAppearanceComboBox">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<buttonGroups>
|
||||
|
||||
+50
-1
@@ -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
|
||||
|
||||
+2
-2
@@ -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) {
|
||||
|
||||
+3
-1
@@ -31,7 +31,9 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class NaturalLanguageTextSelectioner extends ExtendWordSelectionHandlerBase {
|
||||
private static final Set<Character> NATURAL = ContainerUtil.newTroveSet('(', ')', '.', ',', ':', ';', '!', '?', '$', '@', '%', '\"', '\'', '<', '>', '[', ']');
|
||||
private static final Set<Character> NATURAL = ContainerUtil.newTroveSet(
|
||||
'(', ')', '.', ',', ':', ';', '!', '?', '$', '@', '%', '\"', '\'', '<', '>', '[', ']', '_'
|
||||
);
|
||||
private static final Set<Character> SENTENCE_END = ContainerUtil.newTroveSet('.', '!', '?');
|
||||
|
||||
@Override
|
||||
|
||||
+5
-4
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<PsiElement> getSortedElements(final List<Pair<? extends PsiNamedElement, Integer>> elementsWithWeights,
|
||||
final boolean weightsAscending) {
|
||||
return getSortedElements(elementsWithWeights, weightsAscending, null);
|
||||
}
|
||||
|
||||
public static List<PsiElement> getSortedElements(final List<Pair<? extends PsiNamedElement, Integer>> elementsWithWeights,
|
||||
final boolean weightsAscending,
|
||||
@Nullable final Comparator<PsiElement> sameNameComparator) {
|
||||
Collections.sort(elementsWithWeights, new Comparator<Pair<? extends PsiNamedElement, Integer>>() {
|
||||
public int compare(Pair<? extends PsiNamedElement, Integer> o1, Pair<? extends PsiNamedElement, Integer> 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;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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<ID<?, ?>> affected = new ArrayList<ID<?, ?>>();
|
||||
for (final ID<?, ?> indexId : myRequiringContentIndices) { // non requiring content indices should be flushed
|
||||
|
||||
@@ -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<String> 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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -44,21 +44,33 @@ public class FontPreferences {
|
||||
@NotNull private final TObjectIntHashMap<String> myFontSizes = new TObjectIntHashMap<String>();
|
||||
@NotNull private final List<String> myEffectiveFontFamilies = ContainerUtilRt.newArrayList();
|
||||
@NotNull private final List<String> 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) {
|
||||
|
||||
@@ -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<String> lines = StringUtil.splitHonorQuotes(s, ' ');
|
||||
List<String> 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);
|
||||
|
||||
+20
-14
@@ -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<String> 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<String> 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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
+35
-22
@@ -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<IdeaPluginDescriptor> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<UIManager.LookAndFeelInfo> {
|
||||
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;
|
||||
|
||||
@@ -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<UIManager.LookAndFeelInfo> {
|
||||
@Override
|
||||
public void customize(final JList list,
|
||||
final UIManager.LookAndFeelInfo value,
|
||||
final int index,
|
||||
final boolean selected,
|
||||
final boolean cellHasFocus) {
|
||||
setText(value.getName());
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
|
||||
+20
-2
@@ -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();
|
||||
|
||||
+10
@@ -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();
|
||||
|
||||
@@ -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<TextAttributesKey, TextAttributes> myOwnAttributes = ContainerUtilRt.newHashMap();
|
||||
private final Map<ColorKey, Color> 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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+12
-5
@@ -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<String> lines = ParametersListUtil.parse(paramString, true);
|
||||
assertEquals(paramString, StringUtil.join(lines, " "));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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 {
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Converts single parameter string (as created by {@link #join(java.util.List)}) into list of parameters.</p>
|
||||
* <p>Splits single parameter string (as created by {@link #join(List)}) into list of parameters.</p>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <strong>Conversion rules:</strong>
|
||||
@@ -90,11 +90,16 @@ public class ParametersListUtil {
|
||||
* <code>'"a \"1 2\"" b' => ['a="1 2"', 'b']</code>
|
||||
* </p>
|
||||
*
|
||||
* @param string parameter string to split.
|
||||
* @param parameterString parameter string to split.
|
||||
* @return array of parameters.
|
||||
*/
|
||||
@NotNull
|
||||
public static List<String> parse(@NotNull String parameterString) {
|
||||
return parse(parameterString, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<String> parse(@NotNull String parameterString, boolean keepQuotes) {
|
||||
parameterString = parameterString.trim();
|
||||
|
||||
final ArrayList<String> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ public class IntroduceLocalVariableTest extends GrIntentionTestCase {
|
||||
|
||||
@Override
|
||||
void show() {
|
||||
// nop
|
||||
close(0)
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+47
-3
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+51
-4
@@ -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
|
||||
|
||||
+24
-4
@@ -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() {
|
||||
|
||||
+10
-4
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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>(xmlAttributeValue, ((JavaFxPropertyAttributeDescriptor)descriptor).getEnumConstant(element.getText()))};
|
||||
return new PsiReference[] {new PsiReferenceBase.Immediate<XmlAttributeValue>(xmlAttributeValue, ((JavaFxPropertyAttributeDescriptor)descriptor).getEnumConstant(xmlAttributeValue.getValue()))};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+13
@@ -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),
|
||||
|
||||
+67
@@ -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<String, XmlAttributeValue> fileIds = new HashMap<String, XmlAttributeValue>();
|
||||
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>(xmlAttributeValue) {
|
||||
@Nullable
|
||||
@Override
|
||||
public PsiElement resolve() {
|
||||
return fileIds.get(referencesId);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Object[] getVariants() {
|
||||
return ArrayUtil.toStringArray(fileIds.keySet());
|
||||
}
|
||||
}};
|
||||
}
|
||||
}
|
||||
+2
-18
@@ -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);
|
||||
|
||||
|
||||
+81
@@ -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<XmlAttributeValue> {
|
||||
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<PsiMethod> methods = new ArrayList<PsiMethod>();
|
||||
for (PsiMethod method : psiClass.getMethods()) {
|
||||
if (isFactoryMethod(method)) {
|
||||
methods.add(method);
|
||||
}
|
||||
}
|
||||
return ArrayUtil.toObjectArray(methods);
|
||||
}
|
||||
return ArrayUtil.EMPTY_OBJECT_ARRAY;
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
-2
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<?import java.lang.String?>
|
||||
<?import javafx.collections.FXCollections?>
|
||||
<GridPane xmlns:fx="http://javafx.com/fxml" fx:controller="sample.Controller">
|
||||
<fx:define>
|
||||
<FXCollections fx:factory="<caret>">
|
||||
<String fx:value="A"/>
|
||||
</FXCollections>
|
||||
</fx:define>
|
||||
</GridPane>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<?import java.lang.String?>
|
||||
<?import javafx.collections.FXCollections?>
|
||||
<GridPane xmlns:fx="http://javafx.com/fxml" fx:controller="sample.Controller">
|
||||
<fx:define>
|
||||
<FXCollections fx:factory="observableArrayList">
|
||||
<String fx:value="A"/>
|
||||
</FXCollections>
|
||||
</fx:define>
|
||||
</GridPane>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<GridPane xmlns:fx="http://javafx.com/fxml">
|
||||
<fx:define>
|
||||
<Label fx:id="lab" text="MyText" GridPane.rowIndex="1"/>
|
||||
</fx:define>
|
||||
<fx:reference source="lab" <caret>/>
|
||||
</GridPane>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<GridPane xmlns:fx="http://javafx.com/fxml">
|
||||
<fx:define>
|
||||
<Label fx:id="lab" text="MyText" GridPane.rowIndex="1"/>
|
||||
</fx:define>
|
||||
<fx:reference source="lab" text=""/>
|
||||
</GridPane>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<GridPane xmlns:fx="http://javafx.com/fxml">
|
||||
<fx:define>
|
||||
<Label fx:id="lbl" text="MyText" GridPane.rowIndex="1"/>
|
||||
</fx:define>
|
||||
<fx:reference source="lbl" text="bar" layoutX="10.0" layoutY="10.0" textFill="green"/>
|
||||
</GridPane>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<GridPane xmlns:fx="http://javafx.com/fxml">
|
||||
<Button onAction= <error descr="No controller specified for top level element">"#foo"</error> text="foo" fx:id="b1" />
|
||||
</GridPane>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<GridPane xmlns:fx="http://javafx.com/fxml">
|
||||
<Button onAction=<error descr="Page language not specified.">"foo"</error> text="foo" fx:id="b1" />
|
||||
</GridPane>
|
||||
@@ -10,6 +10,11 @@
|
||||
<Image url="@appIcon.png"/>
|
||||
</image>
|
||||
</ImageView>
|
||||
<ImageView>
|
||||
<image>
|
||||
<Image url="appIcon.png"/>
|
||||
</image>
|
||||
</ImageView>
|
||||
<ImageView>
|
||||
<image>
|
||||
<Image url="@<error descr="Cannot resolve file 'unknownIcon.png'">unknownIcon.png</error>"/>
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<GridPane xmlns:fx="http://javafx.com/fxml">
|
||||
<Button text="Press Me" fx:id="b1" >
|
||||
<properties pp1="pp1_value" pp2="pp2_value" foo="bar"/>
|
||||
</Button>
|
||||
</GridPane>
|
||||
@@ -1,5 +1,5 @@
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<GridPane xmlns:fx="http://javafx.com/fxml">
|
||||
<fx:reference GridPane.halignment="CENTER" />
|
||||
<fx:reference GridPane.halignment="CENTER" source="lbl"/>
|
||||
<<error descr="Element fx:reference doesn't have required attribute source">fx:reference</error> GridPane.halignment="CENTER" />
|
||||
<fx:reference GridPane.halignment="CENTER" source="<error descr="Cannot resolve symbol 'lbl'">lbl</error>"/>
|
||||
</GridPane>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<GridPane xmlns:fx="http://javafx.com/fxml">
|
||||
<ImageView>
|
||||
<image>
|
||||
<fx:reference source="myImage"/>
|
||||
<fx:reference source="<error descr="Cannot resolve symbol 'myImage'">myImage</error>"/>
|
||||
</image>
|
||||
</ImageView>
|
||||
<fx:include source="<error descr="Cannot resolve file 'my_button.fxml'">my_button.fxml</error>"/>
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<?import java.lang.String?>
|
||||
<?import javafx.collections.FXCollections?>
|
||||
<?import java.util.ArrayList?>
|
||||
<GridPane xmlns:fx="http://javafx.com/fxml">
|
||||
<fx:define>
|
||||
<FXCollections fx:factory="observableArrayList">
|
||||
<ArrayList fx:value=<error descr="Unable to coerce 'A' to java.util.ArrayList.">"A"</error>/>
|
||||
</FXCollections>
|
||||
|
||||
<FXCollections fx:factory="observableArrayList">
|
||||
<String fx:value="A"/>
|
||||
</FXCollections>
|
||||
|
||||
</fx:define>
|
||||
</GridPane>
|
||||
+22
-1
@@ -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() {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
|
||||
+3
-7
@@ -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
|
||||
|
||||
+11
-3
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user