From: <dal...@us...> - 2023-09-07 19:38:15
|
Revision: 25665 http://sourceforge.net/p/jedit/svn/25665 Author: daleanson Date: 2023-09-07 19:38:14 +0000 (Thu, 07 Sep 2023) Log Message: ----------- Added option pane for beautifier. Modified Paths: -------------- plugins/JSON/trunk/JSON.props plugins/JSON/trunk/build.xml Added Paths: ----------- plugins/JSON/trunk/src/json/options/ plugins/JSON/trunk/src/json/options/JSONOptionPane.java Modified: plugins/JSON/trunk/JSON.props =================================================================== --- plugins/JSON/trunk/JSON.props 2023-09-07 17:57:09 UTC (rev 25664) +++ plugins/JSON/trunk/JSON.props 2023-09-07 19:38:14 UTC (rev 25665) @@ -15,6 +15,7 @@ plugin.json.JSONPlugin.depend.3=plugin eclipseicons.EclipseIconsPlugin 1.0 plugin.json.JSONPlugin.depend.4=plugin sidekick.SideKickPlugin 1.7 plugin.json.JSONPlugin.depend.5=plugin beauty.BeautyPlugin 1.1 +plugin.json.JSONPlugin.depend.6=plugin CommonControlsPlugin 1.7.4 # set mode antlr4 for this sidekick sidekick.parser.json.label=JSON @@ -26,3 +27,9 @@ # mode handler mode.json.beauty.beautifier=JSON + +# option pane settings +plugin.json.JSONPlugin.option-pane=jsonplugin +options.jsonplugin.title=JSON +options.jsonplugin.label=JSON +options.jsonplugin.code=new json.options.JSONOptionPane(); Modified: plugins/JSON/trunk/build.xml =================================================================== --- plugins/JSON/trunk/build.xml 2023-09-07 17:57:09 UTC (rev 25664) +++ plugins/JSON/trunk/build.xml 2023-09-07 19:38:14 UTC (rev 25665) @@ -37,6 +37,7 @@ <pathelement location="${install.dir}/antlr-4.10.1-complete.jar"/> <pathelement location="${install.dir}/EclipseIcons.jar"/> <pathelement location="${install.dir}/Beauty.jar"/> + <pathelement location="${jedit.plugins.dir}/kappalayout.jar"/> </path> Added: plugins/JSON/trunk/src/json/options/JSONOptionPane.java =================================================================== --- plugins/JSON/trunk/src/json/options/JSONOptionPane.java (rev 0) +++ plugins/JSON/trunk/src/json/options/JSONOptionPane.java 2023-09-07 19:38:14 UTC (rev 25665) @@ -0,0 +1,90 @@ + +package json.options; + +import json.parser.JSONBeautyListener; + +import ise.java.awt.*; + +import java.awt.*; +import java.awt.event.*; +import java.io.*; +import java.util.*; + +import javax.swing.*; +import javax.swing.event.*; +import javax.swing.table.*; + +import org.gjt.sp.jedit.*; +import org.gjt.sp.jedit.msg.*; + + +/** +* An option pane to configure settings for the built-in JSON beautifier. +*/ +public class JSONOptionPane extends AbstractOptionPane { + + private JLabel beautifierLabel; + private JRadioButton attachedBrackets; + private JRadioButton brokenBrackets; + private int bracketStyle; + + public JSONOptionPane() { + super( "jsonplugin" ); + bracketStyle = jEdit.getIntegerProperty( "json.bracketStyle", JSONBeautyListener.ATTACHED ); + } + + // called when this class is first accessed + public void _init() { + installComponents(); + } + + // create the user interface components and do the layout + private void installComponents() { + setLayout( new KappaLayout() ); + setBorder( BorderFactory.createEmptyBorder( 6, 6, 6, 6 ) ); + + // create the components + beautifierLabel = new JLabel("<html><strong>JSON Beautifier"); + + // Note that the Beauty plugin is a dependency, so it's okay to use + // these properties from that plugin + attachedBrackets = new JRadioButton( "<html>" + jEdit.getProperty( "beauty.msg.Use_attached_brackets,_e.g.", "Use attached brackets, e.g." ) + "<br> object: {" ); + brokenBrackets = new JRadioButton( "<html>" + jEdit.getProperty( "beauty.msg.Use_broken_brackets,_e.g.", "Use broken brackets, e.g." ) + "<br>object:<br>{" ); + + ButtonGroup bg = new ButtonGroup(); + bg.add( attachedBrackets ); + bg.add( brokenBrackets ); + + switch ( bracketStyle ) { + case JSONBeautyListener.ATTACHED: + attachedBrackets.setSelected( true ); + brokenBrackets.setSelected( false ); + break; + case JSONBeautyListener.BROKEN: + attachedBrackets.setSelected( false ); + brokenBrackets.setSelected( true ); + break; + } + + ActionListener al = new ActionListener(){ + + public void actionPerformed( ActionEvent ae ) { + if ( attachedBrackets.equals( ae.getSource() ) ) { + bracketStyle = JSONBeautyListener.ATTACHED; + } + else if ( brokenBrackets.equals( ae.getSource() ) ) { + bracketStyle = JSONBeautyListener.BROKEN; + } + } + }; + attachedBrackets.addActionListener( al ); + brokenBrackets.addActionListener( al ); + add( "0, 1, 1, 1, W, w, 3", beautifierLabel); + add( "0, 2, 1, 1, W, w, 3", attachedBrackets ); + add( "0, 3, 1, 1, W, w, 3", brokenBrackets ); + } + + public void _save() { + jEdit.setIntegerProperty( "json.bracketStyle", bracketStyle ); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |