# HG changeset patch # User Martin Fousek # Date 1299107017 -3600 # Node ID 60f4cc6038b3262f62bbeae951418987888602f6 # Parent bca6b070e8d1f551fa0c8e0dfa9841a09391ec7a removing UI freezing by change of default Smarty delimiters diff -r bca6b070e8d1 -r 60f4cc6038b3 php.smarty/src/org/netbeans/modules/php/smarty/editor/TplKit.java --- a/php.smarty/src/org/netbeans/modules/php/smarty/editor/TplKit.java Wed Mar 02 22:05:53 2011 +0100 +++ b/php.smarty/src/org/netbeans/modules/php/smarty/editor/TplKit.java Thu Mar 03 00:03:37 2011 +0100 @@ -45,6 +45,7 @@ import org.netbeans.editor.ext.ExtKit; import org.netbeans.modules.editor.NbEditorKit; import javax.swing.Action; +import javax.swing.SwingUtilities; import javax.swing.text.*; import org.netbeans.modules.editor.NbEditorUtilities; import org.openide.filesystems.FileObject; @@ -53,10 +54,10 @@ import org.netbeans.modules.csl.api.InstantRenameAction; import org.netbeans.modules.csl.api.SelectCodeElementAction; import org.netbeans.modules.csl.api.ToggleBlockCommentAction; +import org.netbeans.modules.editor.NbEditorDocument; import org.netbeans.modules.php.smarty.editor.lexer.TplTopTokenId; import org.netbeans.modules.php.smarty.editor.utlis.TplUtils; import org.netbeans.spi.lexer.MutableTextInput; -import sun.rmi.runtime.Log; /** * Editor kit implementation for TPL content type @@ -115,7 +116,7 @@ return TextAction.augmentList(super.createActions(), javaActions); } - public void initLexerColoringListener(Document doc) { + public void initLexerColoringListener(final Document doc) { DataObject dobj = NbEditorUtilities.getDataObject(doc); FileObject fobj = (dobj != null) ? dobj.getPrimaryFile() : null; @@ -127,10 +128,23 @@ inputAttributes.setValue(TplTopTokenId.language(), TplMetaData.class, tplMetaData, false); doc.putProperty(InputAttributes.class, inputAttributes); - MutableTextInput mti = (MutableTextInput) doc.getProperty(MutableTextInput.class); - if (mti != null) { - mti.tokenHierarchyControl().rebuild(); - } + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + NbEditorDocument nbdoc = (NbEditorDocument) doc; + nbdoc.runAtomic(new Runnable() { + + @Override + public void run() { + MutableTextInput mti = (MutableTextInput) doc.getProperty(MutableTextInput.class); + if (mti != null) { + mti.tokenHierarchyControl().rebuild(); + } + } + }); + } + }); } @Override diff -r bca6b070e8d1 -r 60f4cc6038b3 php.smarty/src/org/netbeans/modules/php/smarty/editor/lexer/TplTopLexer.java --- a/php.smarty/src/org/netbeans/modules/php/smarty/editor/lexer/TplTopLexer.java Wed Mar 02 22:05:53 2011 +0100 +++ b/php.smarty/src/org/netbeans/modules/php/smarty/editor/lexer/TplTopLexer.java Thu Mar 03 00:03:37 2011 +0100 @@ -194,7 +194,7 @@ char cc = (char) c; text = input.readText(); textLength = text.length(); - switch (state) { + switch (state) { case INIT: case OUTER: if (isSmartyOpenDelimiter(text)) { diff -r bca6b070e8d1 -r 60f4cc6038b3 php.smarty/src/org/netbeans/modules/php/smarty/editor/utlis/LexerUtils.java --- a/php.smarty/src/org/netbeans/modules/php/smarty/editor/utlis/LexerUtils.java Wed Mar 02 22:05:53 2011 +0100 +++ b/php.smarty/src/org/netbeans/modules/php/smarty/editor/utlis/LexerUtils.java Thu Mar 03 00:03:37 2011 +0100 @@ -39,6 +39,7 @@ package org.netbeans.modules.php.smarty.editor.utlis; import javax.swing.text.Document; +import org.netbeans.modules.editor.NbEditorDocument; import org.netbeans.modules.php.smarty.editor.TplKit; import org.netbeans.spi.lexer.MutableTextInput; import org.openide.text.CloneableEditor; @@ -70,14 +71,21 @@ TopComponent[] topComponents = WindowManager.getDefault().getOpenedTopComponents(WindowManager.getDefault().findMode("editor")); for (TopComponent topComponent : topComponents) { if (topComponent instanceof CloneableEditor) { - Document doc = ((CloneableEditor) topComponent).getEditorPane().getDocument(); + final Document doc = ((CloneableEditor) topComponent).getEditorPane().getDocument(); if (((CloneableEditor) topComponent).getEditorPane().getEditorKit() instanceof TplKit) { ((TplKit) ((CloneableEditor) topComponent).getEditorPane().getEditorKit()).initLexerColoringListener(doc); } - MutableTextInput mti = (MutableTextInput) doc.getProperty(MutableTextInput.class); - if (mti != null) { - mti.tokenHierarchyControl().rebuild(); - } + NbEditorDocument nbdoc = (NbEditorDocument) doc; + nbdoc.runAtomic(new Runnable() { + + @Override + public void run() { + MutableTextInput mti = (MutableTextInput) doc.getProperty(MutableTextInput.class); + if (mti != null) { + mti.tokenHierarchyControl().rebuild(); + } + } + }); } } }