I'm doing something wrong with my ColorSettingsPage
Hi all,
I'm currently re-writing my Arc plugin for IntelliJ - partly for fun and partly because it was a bit of a mess. Anyway, I just added a simple implementation of ColorSettingsPage, and I'm getting the following error:
[ 50789] ERROR - plication.impl.ApplicationImpl - Access is allowed from event dispatch thread only.
Details: Current thread: Thread[ApplicationImpl pooled thread,4,Idea Thread Group] 5494539
Our dispatch thread:Thread[AWT-EventQueue-1 9.0.2#IU-95.66, eap:false,6,Idea Thread Group] 2200494
SystemEventQueueThread: Thread[AWT-EventQueue-1 9.0.2#IU-95.66, eap:false,6,Idea Thread Group] 2200494
java.lang.Throwable
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:55)
at com.intellij.openapi.application.impl.ApplicationImpl.a(ApplicationImpl.java:860)
at com.intellij.openapi.application.impl.ApplicationImpl.assertIsDispatchThread(ApplicationImpl.java:847)
at com.intellij.openapi.editor.impl.MarkupModelImpl.assertDispatchThread(MarkupModelImpl.java:64)
at com.intellij.openapi.editor.impl.MarkupModelImpl$1.assertDispatchThread(MarkupModelImpl.java:58)
at com.intellij.openapi.editor.impl.HighlighterList$1.sort(HighlighterList.java:33)
at com.intellij.util.containers.SortedList.ensureSorted(SortedList.java:61)
at com.intellij.util.containers.SortedList.iterator(SortedList.java:81)
at com.intellij.openapi.editor.impl.HighlighterList.getHighlighterIterator(HighlighterList.java:133)
at com.intellij.openapi.editor.impl.EditorGutterComponentImpl.a(EditorGutterComponentImpl.java:348)
at com.intellij.openapi.editor.impl.EditorGutterComponentImpl.c(EditorGutterComponentImpl.java:455)
at com.intellij.openapi.editor.impl.EditorGutterComponentImpl.updateSize(EditorGutterComponentImpl.java:423)
at com.intellij.openapi.editor.impl.EditorImpl.<init>(EditorImpl.java:339)
at com.intellij.openapi.editor.impl.EditorFactoryImpl.a(EditorFactoryImpl.java:160)
at com.intellij.openapi.editor.impl.EditorFactoryImpl.createViewer(EditorFactoryImpl.java:135)
at com.intellij.application.options.colors.FontEditorPreview.createPreviewEditor(FontEditorPreview.java:75)
at com.intellij.application.options.colors.SimpleEditorPreview.<init>(SimpleEditorPreview.java:69)
at com.intellij.application.options.colors.ColorAndFontOptions$2.createPanel(ColorAndFontOptions.java:329)
at com.intellij.application.options.colors.ColorAndFontOptions$InnerSearchableConfigurable.a(ColorAndFontOptions.java:1003)
at com.intellij.application.options.colors.ColorAndFontOptions$InnerSearchableConfigurable.createComponent(ColorAndFontOptions.java:1034)
at com.intellij.openapi.options.newEditor.OptionsEditor$Simple.<init>(OptionsEditor.java:1113)
at com.intellij.openapi.options.newEditor.OptionsEditor.b(OptionsEditor.java:350)
at com.intellij.openapi.options.newEditor.OptionsEditor.access$2100(OptionsEditor.java:63)
at com.intellij.openapi.options.newEditor.OptionsEditor$6$1.run(OptionsEditor.java:328)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:695)
at com.intellij.openapi.options.newEditor.OptionsEditor$6.run(OptionsEditor.java:326)
at com.intellij.openapi.application.impl.ApplicationImpl$5.run(ApplicationImpl.java:329)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:417)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:269)
at java.util.concurrent.FutureTask.run(FutureTask.java:123)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:651)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:676)
at java.lang.Thread.run(Thread.java:613)
at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:125)
[ 50790] ERROR - plication.impl.ApplicationImpl - IntelliJ IDEA 9.0.2 Build #IU-95.66
[ 50790] ERROR - plication.impl.ApplicationImpl - JDK: 1.5.0_24
[ 50790] ERROR - plication.impl.ApplicationImpl - VM: Java HotSpot(TM) Client VM
[ 50790] ERROR - plication.impl.ApplicationImpl - Vendor: Apple Inc.
[ 50790] ERROR - plication.impl.ApplicationImpl - OS: Mac OS X
[ 50790] ERROR - plication.impl.ApplicationImpl - Last Action: ShowSettings
I'm at a bit of a loss, since I'm not doing anything very interesting in my ColorSettingPage implementation:
package com.bitbakery.arcwelder.config;
import com.bitbakery.arcwelder.ArcIcons;
import com.bitbakery.arcwelder.file.ArcFile;
import com.bitbakery.arcwelder.file.ArcFileType;
import com.bitbakery.arcwelder.highlighter.ArcEditorHighlighter;
import com.bitbakery.arcwelder.highlighter.ArcSyntaxHighlighter;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.openapi.options.colors.AttributesDescriptor;
import com.intellij.openapi.options.colors.ColorDescriptor;
import com.intellij.openapi.options.colors.ColorSettingsPage;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.HashMap;
import java.util.Map;
import static com.bitbakery.arcwelder.highlighter.ArcSyntaxHighlighter.*;
/**
* This hooks into the "Colors and Fonts" configuration page to enable the user
* to set their own colors for tokens in *.arc files
*/
public class ArcColorSettingsPage implements ColorSettingsPage {
@NotNull
public String getDisplayName() {
return "Arc";
}
@Nullable
public Icon getIcon() {
return ArcIcons.FILE;
}
@NotNull
public AttributesDescriptor[] getAttributeDescriptors() {
return ATTRS;
}
private static final AttributesDescriptor[] ATTRS = new AttributesDescriptor[]{
new AttributesDescriptor(COMMENT_ID, COMMENT),
new AttributesDescriptor(NUMBER_ID, NUMBER),
new AttributesDescriptor(STRING_ID, STRING),
new AttributesDescriptor(CHAR_ID, CHAR),
new AttributesDescriptor(BOOLEAN_ID, BOOLEAN),
new AttributesDescriptor(DEF_ID, DEF),
new AttributesDescriptor(MAC_ID, MAC),
new AttributesDescriptor(SPECIAL_CHARACTER_ID, SPECIAL_CHARACTER),
new AttributesDescriptor(MACRO_TEMPLATE_ID, MACRO_TEMPLATE_CHARACTER),
new AttributesDescriptor(SPECIAL_FORM_ID, SPECIAL_FORM),
new AttributesDescriptor(PAREN_ID, PAREN),
new AttributesDescriptor(SQUARE_BRACKET_ID, SQUARE_BRACKET)
};
@NotNull
public ColorDescriptor[] getColorDescriptors() {
return new ColorDescriptor[0];
}
@NotNull
public SyntaxHighlighter getHighlighter() {
// TODO - Could this guy be troublesome...?
return new ArcSyntaxHighlighter();
}
@NonNls
@NotNull
public String getDemoText() {
// TODO - This should be internationalized...
return "; This is a comment\n\n" +
"42\n\n" +
"\"This is a string\"\n\n" +
"(= hi [string \"Hello, \" _ ])\n\n" +
"(def hi (name)\n" +
"\t(string \"Hello, \" name))\n\n" +
"(mac rev (x y z)\n" +
"\t`(,z ,y ,x))";
}
@Nullable
public Map<String, TextAttributesKey> getAdditionalHighlightingTagToDescriptorMap() {
// We need to let the Color and Settings page know if we have any coloring that relies on the annotator...
HashMap<String, TextAttributesKey> map = new HashMap<String, TextAttributesKey>();
map.put(DOCSTRING_ID, DOCSTRING);
return map;
}
}
Any suggestions would be greatly appreciated.
Thanks,
KurtC
Please sign in to leave a comment.
Hello Kurt,
This is unfortunately an IDEA core problem, not something you're doing wrong.
The options dialog sometimes initilalizes pages in a background thread, and
such exceptions can be thrown as a result (although they're actually harmless).
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
Excellent! As always, thanks for your help.