@ -1,17 +1,27 @@
package com.fr.design.javascript ;
import com.fr.design.constants.KeyWords ;
import com.fr.design.DesignerEnvManager ;
import com.fr.design.gui.autocomplete.* ;
import com.fr.design.constants.KeyWords ;
import com.fr.design.dialog.BasicPane ;
import com.fr.design.gui.autocomplete.AutoCompletion ;
import com.fr.design.gui.autocomplete.BasicCompletion ;
import com.fr.design.gui.autocomplete.CompletionProvider ;
import com.fr.design.gui.autocomplete.DefaultCompletionProvider ;
import com.fr.design.gui.autocomplete.ShorthandCompletion ;
import com.fr.design.gui.icontainer.UIScrollPane ;
import com.fr.design.gui.ilable.UILabel ;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxTextArea ;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.SyntaxConstants ;
import com.fr.design.javascript.beautify.JavaScriptFormatHelper ;
import com.fr.design.layout.FRGUIPaneFactory ;
import com.fr.design.dialog.BasicPane ;
import com.fr.design.utils.gui.GUICoreUtils ;
import com.fr.general.IOUtils ;
import com.fr.general.Inter ;
import javax.swing.* ;
import java.awt.* ;
import java.awt.event.MouseAdapter ;
import java.awt.event.MouseEvent ;
import java.util.ArrayList ;
public class JSContentPane extends BasicPane {
@ -24,7 +34,36 @@ public class JSContentPane extends BasicPane {
this . setLayout ( FRGUIPaneFactory . createBorderLayout ( ) ) ;
funNameLabel = new UILabel ( ) ;
this . setFunctionTitle ( args ) ;
this . add ( funNameLabel , BorderLayout . NORTH ) ;
UILabel label = new UILabel ( Inter . getLocText ( "FR-Designer_Format_JavaScript" ) , IOUtils . readIcon ( "com/fr/design/images/edit/format.png" ) , SwingConstants . LEFT ) ;
label . setCursor ( new Cursor ( Cursor . HAND_CURSOR ) ) ;
label . setToolTipText ( Inter . getLocText ( "FR-Designer_Format_JavaScript" ) ) ;
label . addMouseListener ( new MouseAdapter ( ) {
@Override
public void mouseReleased ( MouseEvent e ) {
new SwingWorker < String , Void > ( ) {
@Override
protected String doInBackground ( ) throws Exception {
return JavaScriptFormatHelper . beautify ( contentTextArea . getText ( ) ) ;
}
@Override
protected void done ( ) {
try {
String text = get ( ) ;
contentTextArea . setText ( text ) ;
} catch ( Exception ignore ) {
}
}
} . execute ( ) ;
}
} ) ;
this . add ( GUICoreUtils . createBorderLayoutPane (
funNameLabel , BorderLayout . WEST ,
label , BorderLayout . EAST
) , BorderLayout . NORTH ) ;
contentTextArea = new RSyntaxTextArea ( ) ;
contentTextArea . setCloseCurlyBraces ( true ) ;
@ -84,7 +123,7 @@ public class JSContentPane extends BasicPane {
for ( String s : args ) {
list . add ( s ) ;
}
titles = ( String [ ] ) list . toArray ( new String [ list . size ( ) ] ) ;
titles = ( String [ ] ) list . toArray ( new String [ list . size ( ) ] ) ;
}
setFunctionTitle ( titles ) ;
}