GitBucket
4.21.2
Toggle navigation
Snippets
Sign in
Files
Branches
1
Releases
Issues
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
mark.george
/
jrex
Browse code
Added a "quoted" feature to CSV/TSV RegEx generator.
master
1 parent
c8a933f
commit
3e580990b5701b56e0dc304c3379c7fb1bde81d7
Mark George
authored
on 30 May 2018
Patch
Showing
2 changed files
src/jrex/ui/MainFrame.form
src/jrex/ui/MainFrame.java
Ignore Space
Show notes
View
src/jrex/ui/MainFrame.form
<?xml version="1.0" encoding="UTF-8" ?> <Form version="1.8" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> <Properties> <Property name="defaultCloseOperation" type="int" value="3"/> </Properties> <SyntheticProperties> <SyntheticProperty name="formSizePolicy" type="int" value="1"/> <SyntheticProperty name="generateCenter" type="boolean" value="false"/> </SyntheticProperties> <AuxValues> <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="true"/> <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> </AuxValues> <Layout> <DimensionLayout dim="0"> <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" attributes="0"> <EmptySpace min="-2" max="-2" attributes="0"/> <Component id="splitPane" max="32767" attributes="0"/> <EmptySpace min="-2" max="-2" attributes="0"/> <Component id="pnlReplace" pref="191" max="32767" attributes="0"/> </Group> </Group> </DimensionLayout> <DimensionLayout dim="1"> <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0"> <EmptySpace max="-2" attributes="0"/> <Group type="103" groupAlignment="0" attributes="0"> <Component id="pnlReplace" max="32767" attributes="0"/> <Component id="splitPane" max="32767" attributes="0"/> </Group> <EmptySpace max="-2" attributes="0"/> </Group> </Group> </DimensionLayout> </Layout> <SubComponents> <Container class="javax.swing.JSplitPane" name="splitPane"> <Properties> <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> <Border info="null"/> </Property> <Property name="dividerLocation" type="int" value="366"/> <Property name="dividerSize" type="int" value="15"/> <Property name="orientation" type="int" value="0"/> <Property name="name" type="java.lang.String" value="splitPane" noResource="true"/> <Property name="oneTouchExpandable" type="boolean" value="true"/> </Properties> <Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/> <SubComponents> <Container class="javax.swing.JPanel" name="pnlInput"> <Properties> <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo"> <TitledBorder title="Input"> <Font PropertyName="font" name="Dialog" size="12" style="0"/> </TitledBorder> </Border> </Property> <Property name="name" type="java.lang.String" value="pnlInput" noResource="true"/> </Properties> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription"> <JSplitPaneConstraints position="top"/> </Constraint> </Constraints> <Layout> <DimensionLayout dim="0"> <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" attributes="0"> <Component id="lblColumns" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> <Component id="spnColumns" min="-2" pref="46" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> <Component id="cbQuoted" min="-2" max="-2" attributes="0"/> <EmptySpace type="separate" max="-2" attributes="0"/> <Component id="btnCsvInput" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> <Component id="btnTsvInput" min="-2" max="-2" attributes="0"/> <EmptySpace max="32767" attributes="0"/> </Group> <Component id="scrollInput" max="32767" attributes="0"/> <Group type="102" attributes="0"> <Component id="btnLoad" min="-2" max="-2" attributes="0"/> <EmptySpace type="separate" max="-2" attributes="0"/> <Component id="cbReplace" min="-2" max="-2" attributes="0"/> <EmptySpace type="separate" max="-2" attributes="0"/> <Component id="btnSaveExpr" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> <Component id="btnLoadExpr" min="-2" max="-2" attributes="0"/> <EmptySpace max="32767" attributes="0"/> <Component id="btnClear" min="-2" max="-2" attributes="0"/> </Group> <Component id="scrollTable" alignment="1" pref="711" max="32767" attributes="0"/> <Group type="102" attributes="0"> <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0"> <Component id="btnPivotWideToLong" linkSize="1" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> <Component id="btnPivotLongToWide" linkSize="1" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> <Component id="btnTranspose" linkSize="1" min="-2" max="-2" attributes="0"/> </Group> <Group type="102" alignment="0" attributes="0"> <Component id="lblExpression" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> <Component id="txtRegex" max="32767" attributes="0"/> </Group> </Group> <EmptySpace min="-2" pref="18" max="-2" attributes="0"/> <Component id="btnMatch" min="-2" max="-2" attributes="0"/> </Group> </Group> </DimensionLayout> <DimensionLayout dim="1"> <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0"> <Group type="103" groupAlignment="3" attributes="0"> <Component id="btnLoad" alignment="3" max="32767" attributes="0"/> <Component id="btnClear" alignment="3" max="32767" attributes="0"/> <Component id="cbReplace" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="btnSaveExpr" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="btnLoadExpr" alignment="3" min="-2" max="-2" attributes="0"/> </Group> <EmptySpace min="-2" max="-2" attributes="0"/> <Component id="scrollInput" pref="92" max="32767" attributes="0"/> <EmptySpace min="-2" pref="11" max="-2" attributes="0"/> <Group type="103" groupAlignment="2" attributes="0"> <Component id="lblColumns" alignment="2" min="-2" max="-2" attributes="0"/> <Component id="spnColumns" alignment="2" min="-2" max="-2" attributes="0"/> <Component id="cbQuoted" alignment="2" min="-2" max="-2" attributes="0"/> <Component id="btnCsvInput" alignment="2" min="-2" max="-2" attributes="0"/> <Component id="btnTsvInput" alignment="2" min="-2" max="-2" attributes="0"/> </Group> <EmptySpace max="-2" attributes="0"/> <Group type="103" groupAlignment="2" attributes="0"> <Component id="lblExpression" alignment="2" min="-2" max="-2" attributes="0"/> <Component id="txtRegex" alignment="2" min="-2" max="-2" attributes="0"/> <Component id="btnMatch" alignment="2" min="-2" max="-2" attributes="0"/> </Group> <EmptySpace min="-2" max="-2" attributes="0"/> <Component id="scrollTable" pref="83" max="32767" attributes="0"/> <EmptySpace min="-2" max="-2" attributes="0"/> <Group type="103" groupAlignment="3" attributes="0"> <Component id="btnPivotWideToLong" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="btnPivotLongToWide" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="btnTranspose" alignment="3" min="-2" max="-2" attributes="0"/> </Group> </Group> </Group> </DimensionLayout> </Layout> <SubComponents> <Component class="javax.swing.JButton" name="btnClear"> <Properties> <Property name="text" type="java.lang.String" value="Clear"/> <Property name="name" type="java.lang.String" value="btnClear" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnClearActionPerformed"/> </Events> </Component> <Component class="javax.swing.JButton" name="btnLoad"> <Properties> <Property name="text" type="java.lang.String" value="Open"/> <Property name="name" type="java.lang.String" value="btnLoad" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnLoadActionPerformed"/> </Events> </Component> <Container class="javax.swing.JScrollPane" name="scrollInput"> <Properties> <Property name="name" type="java.lang.String" value="scrollInput" noResource="true"/> </Properties> <AuxValues> <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> </AuxValues> <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> <SubComponents> <Component class="javax.swing.JTextArea" name="txtInput"> <Properties> <Property name="columns" type="int" value="20"/> <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> <Font name="Monospaced" size="12" style="0"/> </Property> <Property name="rows" type="int" value="5"/> <Property name="name" type="java.lang.String" value="txtInput" noResource="true"/> </Properties> </Component> </SubComponents> </Container> <Component class="javax.swing.JLabel" name="lblExpression"> <Properties> <Property name="horizontalAlignment" type="int" value="4"/> <Property name="text" type="java.lang.String" value="Capture Expression: "/> <Property name="name" type="java.lang.String" value="lblExpression" noResource="true"/> </Properties> </Component> <Component class="javax.swing.JTextField" name="txtRegex"> <Properties> <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> <Font name="Monospaced" size="12" style="0"/> </Property> <Property name="name" type="java.lang.String" value="txtRegex" noResource="true"/> </Properties> <Events> <EventHandler event="keyPressed" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="txtRegexKeyPressed"/> </Events> </Component> <Component class="javax.swing.JSpinner" name="spnColumns"> <Properties> <Property name="name" type="java.lang.String" value="spnColumns" noResource="true"/> </Properties> <Events> <EventHandler event="mouseWheelMoved" listener="java.awt.event.MouseWheelListener" parameters="java.awt.event.MouseWheelEvent" handler="spnColumnsMouseWheelMoved"/> </Events> </Component> <Component class="javax.swing.JButton" name="btnTsvInput"> <Properties> <Property name="text" type="java.lang.String" value="TSV"/> <Property name="name" type="java.lang.String" value="btnTsvInput" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnTsvInputActionPerformed"/> </Events> </Component> <Component class="javax.swing.JButton" name="btnCsvInput"> <Properties> <Property name="text" type="java.lang.String" value="CSV"/> <Property name="name" type="java.lang.String" value="btnCsvInput" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCsvInputActionPerformed"/> </Events> </Component> <Component class="javax.swing.JButton" name="btnMatch"> <Properties> <Property name="mnemonic" type="int" value="99"/> <Property name="text" type="java.lang.String" value="Capture"/> <Property name="name" type="java.lang.String" value="btnMatch" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnMatchActionPerformed"/> </Events> </Component> <Container class="javax.swing.JScrollPane" name="scrollTable"> <Properties> <Property name="name" type="java.lang.String" value="scrollTable" noResource="true"/> </Properties> <AuxValues> <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> </AuxValues> <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> <SubComponents> <Component class="javax.swing.JTable" name="jTable"> <Properties> <Property name="name" type="java.lang.String" value="jTable" noResource="true"/> </Properties> </Component> </SubComponents> </Container> <Component class="javax.swing.JCheckBox" name="cbReplace"> <Properties> <Property name="text" type="java.lang.String" value="Search/Replace "/> <Property name="name" type="java.lang.String" value="cbReplace" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbReplaceActionPerformed"/> </Events> </Component> <Component class="javax.swing.JButton" name="btnPivotWideToLong"> <Properties> <Property name="text" type="java.lang.String" value="Pivot Wide to Long"/> <Property name="name" type="java.lang.String" value="btnPivotWideToLong" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnPivotWideToLongActionPerformed"/> </Events> </Component> <Component class="javax.swing.JButton" name="btnPivotLongToWide"> <Properties> <Property name="text" type="java.lang.String" value="Pivot Long to Wide"/> <Property name="name" type="java.lang.String" value="btnPivotLongToWide" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnPivotLongToWideActionPerformed"/> </Events> </Component> <Component class="javax.swing.JButton" name="btnTranspose"> <Properties> <Property name="text" type="java.lang.String" value="Transpose"/> <Property name="name" type="java.lang.String" value="btnTranspose" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnTransposeActionPerformed"/> </Events> </Component> <Component class="javax.swing.JLabel" name="lblColumns"> <Properties> <Property name="text" type="java.lang.String" value="Columns: "/> <Property name="name" type="java.lang.String" value="lblColumns" noResource="true"/> </Properties> </Component> <Component class="javax.swing.JButton" name="btnSaveExpr"> <Properties> <Property name="text" type="java.lang.String" value="Save Expressions"/> <Property name="name" type="java.lang.String" value="btnSaveExpr" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSaveExprActionPerformed"/> </Events> </Component> <Component class="javax.swing.JButton" name="btnLoadExpr"> <Properties> <Property name="text" type="java.lang.String" value="Load Expressions"/> <Property name="name" type="java.lang.String" value="btnLoadExpr" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnLoadExprActionPerformed"/> </Events> </Component> <Component class="javax.swing.JCheckBox" name="cbQuoted"> <Properties> <Property name="text" type="java.lang.String" value="Quoted?"/> <Property name="name" type="java.lang.String" value="cbQuoted" noResource="true"/> </Properties> </Component> </SubComponents> </Container> <Container class="javax.swing.JPanel" name="pnlOutput"> <Properties> <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo"> <TitledBorder title="Output"> <Font PropertyName="font" name="Dialog" size="12" style="0"/> </TitledBorder> </Border> </Property> <Property name="name" type="java.lang.String" value="pnlOutput" noResource="true"/> </Properties> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription"> <JSplitPaneConstraints position="right"/> </Constraint> </Constraints> <Layout> <DimensionLayout dim="0"> <Group type="103" groupAlignment="0" attributes="0"> <Component id="scrollOutput" max="32767" attributes="0"/> <Group type="102" attributes="0"> <Component id="lblArgumentMarker" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> <Component id="txtMarker" linkSize="3" min="-2" pref="32" max="-2" attributes="0"/> <EmptySpace type="separate" max="-2" attributes="0"/> <Component id="cbBlanks" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> <Component id="txtBlanks" linkSize="3" min="-2" pref="62" max="-2" attributes="0"/> <EmptySpace type="separate" max="-2" attributes="0"/> <Component id="btnCsvOutput" linkSize="2" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> <Component id="btnTsvOutput" linkSize="2" max="32767" attributes="0"/> <EmptySpace max="32767" attributes="0"/> <Component id="btnSwap" min="-2" max="-2" attributes="0"/> <EmptySpace type="separate" max="-2" attributes="0"/> <Component id="btnSave" min="-2" max="-2" attributes="0"/> </Group> <Group type="102" attributes="0"> <Component id="lblFormat" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> <Component id="txtFormat" max="32767" attributes="0"/> <EmptySpace type="separate" max="-2" attributes="0"/> <Component id="btnFormat" min="-2" max="-2" attributes="0"/> </Group> </Group> </DimensionLayout> <DimensionLayout dim="1"> <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0"> <Group type="103" groupAlignment="2" attributes="0"> <Component id="lblArgumentMarker" alignment="2" min="-2" max="-2" attributes="0"/> <Component id="txtMarker" alignment="2" min="-2" max="-2" attributes="0"/> <Component id="cbBlanks" alignment="2" min="-2" max="-2" attributes="0"/> <Component id="txtBlanks" alignment="2" min="-2" max="-2" attributes="0"/> <Component id="btnCsvOutput" alignment="2" min="-2" max="-2" attributes="0"/> <Component id="btnTsvOutput" alignment="2" min="-2" max="-2" attributes="0"/> <Component id="btnSwap" alignment="2" min="-2" max="-2" attributes="0"/> <Component id="btnSave" alignment="2" min="-2" max="-2" attributes="0"/> </Group> <EmptySpace min="-2" max="-2" attributes="0"/> <Group type="103" groupAlignment="2" attributes="0"> <Component id="lblFormat" alignment="2" min="-2" max="-2" attributes="0"/> <Component id="txtFormat" alignment="2" min="-2" max="-2" attributes="0"/> <Component id="btnFormat" alignment="2" min="-2" max="-2" attributes="0"/> </Group> <EmptySpace max="-2" attributes="0"/> <Component id="scrollOutput" pref="152" max="32767" attributes="0"/> </Group> </Group> </DimensionLayout> </Layout> <SubComponents> <Component class="javax.swing.JLabel" name="lblFormat"> <Properties> <Property name="horizontalAlignment" type="int" value="4"/> <Property name="text" type="java.lang.String" value="Format Expression: "/> <Property name="name" type="java.lang.String" value="lblFormat" noResource="true"/> </Properties> </Component> <Component class="javax.swing.JTextField" name="txtFormat"> <Properties> <Property name="name" type="java.lang.String" value="txtFormat" noResource="true"/> </Properties> </Component> <Component class="javax.swing.JButton" name="btnFormat"> <Properties> <Property name="mnemonic" type="int" value="102"/> <Property name="text" type="java.lang.String" value="Format"/> <Property name="name" type="java.lang.String" value="btnFormat" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnFormatActionPerformed"/> </Events> </Component> <Container class="javax.swing.JScrollPane" name="scrollOutput"> <Properties> <Property name="name" type="java.lang.String" value="scrollOutput" noResource="true"/> </Properties> <AuxValues> <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> </AuxValues> <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> <SubComponents> <Component class="javax.swing.JTextArea" name="txtOutput"> <Properties> <Property name="columns" type="int" value="20"/> <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> <Font name="Monospaced" size="12" style="0"/> </Property> <Property name="rows" type="int" value="5"/> <Property name="name" type="java.lang.String" value="txtOutput" noResource="true"/> </Properties> </Component> </SubComponents> </Container> <Component class="javax.swing.JLabel" name="lblArgumentMarker"> <Properties> <Property name="text" type="java.lang.String" value="Column Prefix: "/> <Property name="name" type="java.lang.String" value="lblArgumentMarker" noResource="true"/> </Properties> </Component> <Component class="javax.swing.JCheckBox" name="cbBlanks"> <Properties> <Property name="text" type="java.lang.String" value="Replace blanks? "/> <Property name="name" type="java.lang.String" value="cbBlanks" noResource="true"/> </Properties> </Component> <Component class="javax.swing.JTextField" name="txtBlanks"> <Properties> <Property name="text" type="java.lang.String" value="null"/> <Property name="name" type="java.lang.String" value="txtBlanks" noResource="true"/> </Properties> </Component> <Component class="javax.swing.JButton" name="btnSwap"> <Properties> <Property name="mnemonic" type="int" value="111"/> <Property name="text" type="java.lang.String" value="Output to Input"/> <Property name="name" type="java.lang.String" value="btnSwap" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSwapActionPerformed"/> </Events> </Component> <Component class="javax.swing.JButton" name="btnCsvOutput"> <Properties> <Property name="text" type="java.lang.String" value="CSV"/> <Property name="name" type="java.lang.String" value="btnCsvOutput" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCsvOutputActionPerformed"/> </Events> </Component> <Component class="javax.swing.JButton" name="btnTsvOutput"> <Properties> <Property name="text" type="java.lang.String" value="TSV"/> <Property name="name" type="java.lang.String" value="btnTsvOutput" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnTsvOutputActionPerformed"/> </Events> </Component> <Component class="javax.swing.JTextField" name="txtMarker"> <Properties> <Property name="text" type="java.lang.String" value="?"/> <Property name="name" type="java.lang.String" value="txtMarker" noResource="true"/> </Properties> </Component> <Component class="javax.swing.JButton" name="btnSave"> <Properties> <Property name="text" type="java.lang.String" value="Save"/> <Property name="name" type="java.lang.String" value="btnSave" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSaveActionPerformed"/> </Events> </Component> </SubComponents> </Container> </SubComponents> </Container> <Component class="jrex.ui.ReplacePanel" name="pnlReplace"> <Properties> <Property name="name" type="java.lang.String" value="pnlReplace" noResource="true"/> </Properties> </Component> </SubComponents> </Form>
<?xml version="1.0" encoding="UTF-8" ?> <Form version="1.8" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> <Properties> <Property name="defaultCloseOperation" type="int" value="3"/> </Properties> <SyntheticProperties> <SyntheticProperty name="formSizePolicy" type="int" value="1"/> <SyntheticProperty name="generateCenter" type="boolean" value="false"/> </SyntheticProperties> <AuxValues> <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="true"/> <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> </AuxValues> <Layout> <DimensionLayout dim="0"> <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" attributes="0"> <EmptySpace min="-2" max="-2" attributes="0"/> <Component id="splitPane" max="32767" attributes="0"/> <EmptySpace min="-2" max="-2" attributes="0"/> <Component id="pnlReplace" pref="191" max="32767" attributes="0"/> </Group> </Group> </DimensionLayout> <DimensionLayout dim="1"> <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0"> <EmptySpace max="-2" attributes="0"/> <Group type="103" groupAlignment="0" attributes="0"> <Component id="pnlReplace" max="32767" attributes="0"/> <Component id="splitPane" max="32767" attributes="0"/> </Group> <EmptySpace max="-2" attributes="0"/> </Group> </Group> </DimensionLayout> </Layout> <SubComponents> <Container class="javax.swing.JSplitPane" name="splitPane"> <Properties> <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> <Border info="null"/> </Property> <Property name="dividerLocation" type="int" value="366"/> <Property name="dividerSize" type="int" value="15"/> <Property name="orientation" type="int" value="0"/> <Property name="name" type="java.lang.String" value="splitPane" noResource="true"/> <Property name="oneTouchExpandable" type="boolean" value="true"/> </Properties> <Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/> <SubComponents> <Container class="javax.swing.JPanel" name="pnlInput"> <Properties> <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo"> <TitledBorder title="Input"> <Font PropertyName="font" name="Dialog" size="12" style="0"/> </TitledBorder> </Border> </Property> <Property name="name" type="java.lang.String" value="pnlInput" noResource="true"/> </Properties> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription"> <JSplitPaneConstraints position="top"/> </Constraint> </Constraints> <Layout> <DimensionLayout dim="0"> <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" attributes="0"> <Component id="lblColumns" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> <Component id="spnColumns" min="-2" pref="46" max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/> <Component id="btnCsvInput" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> <Component id="btnTsvInput" min="-2" max="-2" attributes="0"/> <EmptySpace min="0" pref="0" max="32767" attributes="0"/> </Group> <Component id="scrollInput" max="32767" attributes="0"/> <Group type="102" attributes="0"> <Component id="btnLoad" min="-2" max="-2" attributes="0"/> <EmptySpace type="separate" max="-2" attributes="0"/> <Component id="cbReplace" min="-2" max="-2" attributes="0"/> <EmptySpace type="separate" max="-2" attributes="0"/> <Component id="btnSaveExpr" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> <Component id="btnLoadExpr" min="-2" max="-2" attributes="0"/> <EmptySpace max="32767" attributes="0"/> <Component id="btnClear" min="-2" max="-2" attributes="0"/> </Group> <Component id="scrollTable" alignment="1" pref="711" max="32767" attributes="0"/> <Group type="102" attributes="0"> <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0"> <Component id="btnPivotWideToLong" linkSize="1" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> <Component id="btnPivotLongToWide" linkSize="1" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> <Component id="btnTranspose" linkSize="1" min="-2" max="-2" attributes="0"/> </Group> <Group type="102" alignment="0" attributes="0"> <Component id="lblExpression" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> <Component id="txtRegex" max="32767" attributes="0"/> </Group> </Group> <EmptySpace min="-2" pref="18" max="-2" attributes="0"/> <Component id="btnMatch" min="-2" max="-2" attributes="0"/> </Group> </Group> </DimensionLayout> <DimensionLayout dim="1"> <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0"> <Group type="103" groupAlignment="3" attributes="0"> <Component id="btnLoad" alignment="3" max="32767" attributes="0"/> <Component id="btnClear" alignment="3" max="32767" attributes="0"/> <Component id="cbReplace" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="btnSaveExpr" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="btnLoadExpr" alignment="3" min="-2" max="-2" attributes="0"/> </Group> <EmptySpace min="-2" max="-2" attributes="0"/> <Component id="scrollInput" pref="92" max="32767" attributes="0"/> <EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/> <Group type="103" groupAlignment="3" attributes="0"> <Component id="btnTsvInput" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="btnCsvInput" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="spnColumns" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lblColumns" alignment="3" min="-2" max="-2" attributes="0"/> </Group> <EmptySpace min="-2" max="-2" attributes="0"/> <Group type="103" groupAlignment="3" attributes="0"> <Component id="lblExpression" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="txtRegex" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="btnMatch" alignment="3" min="-2" max="-2" attributes="0"/> </Group> <EmptySpace min="-2" max="-2" attributes="0"/> <Component id="scrollTable" pref="82" max="32767" attributes="0"/> <EmptySpace min="-2" max="-2" attributes="0"/> <Group type="103" groupAlignment="3" attributes="0"> <Component id="btnPivotWideToLong" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="btnPivotLongToWide" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="btnTranspose" alignment="3" min="-2" max="-2" attributes="0"/> </Group> </Group> </Group> </DimensionLayout> </Layout> <SubComponents> <Component class="javax.swing.JButton" name="btnClear"> <Properties> <Property name="text" type="java.lang.String" value="Clear"/> <Property name="name" type="java.lang.String" value="btnClear" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnClearActionPerformed"/> </Events> </Component> <Component class="javax.swing.JButton" name="btnLoad"> <Properties> <Property name="text" type="java.lang.String" value="Open"/> <Property name="name" type="java.lang.String" value="btnLoad" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnLoadActionPerformed"/> </Events> </Component> <Container class="javax.swing.JScrollPane" name="scrollInput"> <Properties> <Property name="name" type="java.lang.String" value="scrollInput" noResource="true"/> </Properties> <AuxValues> <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> </AuxValues> <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> <SubComponents> <Component class="javax.swing.JTextArea" name="txtInput"> <Properties> <Property name="columns" type="int" value="20"/> <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> <Font name="Monospaced" size="12" style="0"/> </Property> <Property name="rows" type="int" value="5"/> <Property name="name" type="java.lang.String" value="txtInput" noResource="true"/> </Properties> </Component> </SubComponents> </Container> <Component class="javax.swing.JLabel" name="lblExpression"> <Properties> <Property name="horizontalAlignment" type="int" value="4"/> <Property name="text" type="java.lang.String" value="Capture Expression: "/> <Property name="name" type="java.lang.String" value="lblExpression" noResource="true"/> </Properties> </Component> <Component class="javax.swing.JTextField" name="txtRegex"> <Properties> <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> <Font name="Monospaced" size="12" style="0"/> </Property> <Property name="name" type="java.lang.String" value="txtRegex" noResource="true"/> </Properties> <Events> <EventHandler event="keyPressed" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="txtRegexKeyPressed"/> </Events> </Component> <Component class="javax.swing.JSpinner" name="spnColumns"> <Properties> <Property name="name" type="java.lang.String" value="spnColumns" noResource="true"/> </Properties> <Events> <EventHandler event="mouseWheelMoved" listener="java.awt.event.MouseWheelListener" parameters="java.awt.event.MouseWheelEvent" handler="spnColumnsMouseWheelMoved"/> </Events> </Component> <Component class="javax.swing.JButton" name="btnTsvInput"> <Properties> <Property name="text" type="java.lang.String" value="TSV"/> <Property name="name" type="java.lang.String" value="btnTsvInput" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnTsvInputActionPerformed"/> </Events> </Component> <Component class="javax.swing.JButton" name="btnCsvInput"> <Properties> <Property name="text" type="java.lang.String" value="CSV"/> <Property name="name" type="java.lang.String" value="btnCsvInput" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCsvInputActionPerformed"/> </Events> </Component> <Component class="javax.swing.JButton" name="btnMatch"> <Properties> <Property name="mnemonic" type="int" value="99"/> <Property name="text" type="java.lang.String" value="Capture"/> <Property name="name" type="java.lang.String" value="btnMatch" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnMatchActionPerformed"/> </Events> </Component> <Container class="javax.swing.JScrollPane" name="scrollTable"> <Properties> <Property name="name" type="java.lang.String" value="scrollTable" noResource="true"/> </Properties> <AuxValues> <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> </AuxValues> <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> <SubComponents> <Component class="javax.swing.JTable" name="jTable"> <Properties> <Property name="name" type="java.lang.String" value="jTable" noResource="true"/> </Properties> </Component> </SubComponents> </Container> <Component class="javax.swing.JCheckBox" name="cbReplace"> <Properties> <Property name="text" type="java.lang.String" value="Search/Replace "/> <Property name="name" type="java.lang.String" value="cbReplace" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbReplaceActionPerformed"/> </Events> </Component> <Component class="javax.swing.JButton" name="btnPivotWideToLong"> <Properties> <Property name="text" type="java.lang.String" value="Pivot Wide to Long"/> <Property name="name" type="java.lang.String" value="btnPivotWideToLong" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnPivotWideToLongActionPerformed"/> </Events> </Component> <Component class="javax.swing.JButton" name="btnPivotLongToWide"> <Properties> <Property name="text" type="java.lang.String" value="Pivot Long to Wide"/> <Property name="name" type="java.lang.String" value="btnPivotLongToWide" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnPivotLongToWideActionPerformed"/> </Events> </Component> <Component class="javax.swing.JButton" name="btnTranspose"> <Properties> <Property name="text" type="java.lang.String" value="Transpose"/> <Property name="name" type="java.lang.String" value="btnTranspose" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnTransposeActionPerformed"/> </Events> </Component> <Component class="javax.swing.JLabel" name="lblColumns"> <Properties> <Property name="text" type="java.lang.String" value="Columns: "/> <Property name="name" type="java.lang.String" value="lblColumns" noResource="true"/> </Properties> </Component> <Component class="javax.swing.JButton" name="btnSaveExpr"> <Properties> <Property name="text" type="java.lang.String" value="Save Expressions"/> <Property name="name" type="java.lang.String" value="btnSaveExpr" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSaveExprActionPerformed"/> </Events> </Component> <Component class="javax.swing.JButton" name="btnLoadExpr"> <Properties> <Property name="text" type="java.lang.String" value="Load Expressions"/> <Property name="name" type="java.lang.String" value="btnLoadExpr" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnLoadExprActionPerformed"/> </Events> </Component> </SubComponents> </Container> <Container class="javax.swing.JPanel" name="pnlOutput"> <Properties> <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo"> <TitledBorder title="Output"> <Font PropertyName="font" name="Dialog" size="12" style="0"/> </TitledBorder> </Border> </Property> <Property name="name" type="java.lang.String" value="pnlOutput" noResource="true"/> </Properties> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription"> <JSplitPaneConstraints position="right"/> </Constraint> </Constraints> <Layout> <DimensionLayout dim="0"> <Group type="103" groupAlignment="0" attributes="0"> <Component id="scrollOutput" max="32767" attributes="0"/> <Group type="102" attributes="0"> <Component id="lblArgumentMarker" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> <Component id="txtMarker" linkSize="3" min="-2" pref="32" max="-2" attributes="0"/> <EmptySpace type="separate" max="-2" attributes="0"/> <Component id="cbBlanks" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> <Component id="txtBlanks" linkSize="3" min="-2" pref="62" max="-2" attributes="0"/> <EmptySpace type="separate" max="-2" attributes="0"/> <Component id="btnCsvOutput" linkSize="2" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> <Component id="btnTsvOutput" linkSize="2" max="32767" attributes="0"/> <EmptySpace max="32767" attributes="0"/> <Component id="btnSwap" min="-2" max="-2" attributes="0"/> <EmptySpace type="separate" max="-2" attributes="0"/> <Component id="btnSave" min="-2" max="-2" attributes="0"/> </Group> <Group type="102" attributes="0"> <Component id="lblFormat" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> <Component id="txtFormat" max="32767" attributes="0"/> <EmptySpace type="separate" max="-2" attributes="0"/> <Component id="btnFormat" min="-2" max="-2" attributes="0"/> </Group> </Group> </DimensionLayout> <DimensionLayout dim="1"> <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0"> <Group type="103" groupAlignment="3" attributes="0"> <Component id="lblArgumentMarker" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="cbBlanks" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="txtBlanks" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="btnSwap" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="txtMarker" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="btnCsvOutput" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="btnTsvOutput" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="btnSave" alignment="3" min="-2" max="-2" attributes="0"/> </Group> <EmptySpace min="-2" max="-2" attributes="0"/> <Group type="103" groupAlignment="3" attributes="0"> <Component id="lblFormat" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="txtFormat" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="btnFormat" alignment="3" min="-2" max="-2" attributes="0"/> </Group> <EmptySpace max="-2" attributes="0"/> <Component id="scrollOutput" pref="152" max="32767" attributes="0"/> </Group> </Group> </DimensionLayout> </Layout> <SubComponents> <Component class="javax.swing.JLabel" name="lblFormat"> <Properties> <Property name="horizontalAlignment" type="int" value="4"/> <Property name="text" type="java.lang.String" value="Format Expression: "/> <Property name="name" type="java.lang.String" value="lblFormat" noResource="true"/> </Properties> </Component> <Component class="javax.swing.JTextField" name="txtFormat"> <Properties> <Property name="name" type="java.lang.String" value="txtFormat" noResource="true"/> </Properties> </Component> <Component class="javax.swing.JButton" name="btnFormat"> <Properties> <Property name="mnemonic" type="int" value="102"/> <Property name="text" type="java.lang.String" value="Format"/> <Property name="name" type="java.lang.String" value="btnFormat" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnFormatActionPerformed"/> </Events> </Component> <Container class="javax.swing.JScrollPane" name="scrollOutput"> <Properties> <Property name="name" type="java.lang.String" value="scrollOutput" noResource="true"/> </Properties> <AuxValues> <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> </AuxValues> <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> <SubComponents> <Component class="javax.swing.JTextArea" name="txtOutput"> <Properties> <Property name="columns" type="int" value="20"/> <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> <Font name="Monospaced" size="12" style="0"/> </Property> <Property name="rows" type="int" value="5"/> <Property name="name" type="java.lang.String" value="txtOutput" noResource="true"/> </Properties> </Component> </SubComponents> </Container> <Component class="javax.swing.JLabel" name="lblArgumentMarker"> <Properties> <Property name="text" type="java.lang.String" value="Column Prefix: "/> <Property name="name" type="java.lang.String" value="lblArgumentMarker" noResource="true"/> </Properties> </Component> <Component class="javax.swing.JCheckBox" name="cbBlanks"> <Properties> <Property name="text" type="java.lang.String" value="Replace blanks? "/> <Property name="name" type="java.lang.String" value="cbBlanks" noResource="true"/> </Properties> </Component> <Component class="javax.swing.JTextField" name="txtBlanks"> <Properties> <Property name="text" type="java.lang.String" value="null"/> <Property name="name" type="java.lang.String" value="txtBlanks" noResource="true"/> </Properties> </Component> <Component class="javax.swing.JButton" name="btnSwap"> <Properties> <Property name="mnemonic" type="int" value="111"/> <Property name="text" type="java.lang.String" value="Output to Input"/> <Property name="name" type="java.lang.String" value="btnSwap" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSwapActionPerformed"/> </Events> </Component> <Component class="javax.swing.JButton" name="btnCsvOutput"> <Properties> <Property name="text" type="java.lang.String" value="CSV"/> <Property name="name" type="java.lang.String" value="btnCsvOutput" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCsvOutputActionPerformed"/> </Events> </Component> <Component class="javax.swing.JButton" name="btnTsvOutput"> <Properties> <Property name="text" type="java.lang.String" value="TSV"/> <Property name="name" type="java.lang.String" value="btnTsvOutput" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnTsvOutputActionPerformed"/> </Events> </Component> <Component class="javax.swing.JTextField" name="txtMarker"> <Properties> <Property name="text" type="java.lang.String" value="?"/> <Property name="name" type="java.lang.String" value="txtMarker" noResource="true"/> </Properties> </Component> <Component class="javax.swing.JButton" name="btnSave"> <Properties> <Property name="text" type="java.lang.String" value="Save"/> <Property name="name" type="java.lang.String" value="btnSave" noResource="true"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSaveActionPerformed"/> </Events> </Component> </SubComponents> </Container> </SubComponents> </Container> <Component class="jrex.ui.ReplacePanel" name="pnlReplace"> <Properties> <Property name="name" type="java.lang.String" value="pnlReplace" noResource="true"/> </Properties> </Component> </SubComponents> </Form>
Ignore Space
Show notes
View
src/jrex/ui/MainFrame.java
package jrex.ui; import jrex.ui.model.MutableTableModel; import jrex.ui.model.PivotTableModel; import com.google.common.collect.ListMultimap; import com.google.gson.Gson; import java.awt.Color; import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.Transparency; import java.awt.color.ColorSpace; import java.awt.image.BufferedImage; import java.awt.image.ColorConvertOp; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; import javax.swing.Action; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.JPopupMenu; import javax.swing.KeyStroke; import javax.swing.SpinnerNumberModel; import javax.swing.UIManager; import javax.swing.table.TableModel; import javax.swing.text.DefaultEditorKit; import jrex.Expressions; /** * Primary user interface frame. * * @author Mark George <mark.george@otago.ac.nz> */ public class MainFrame extends javax.swing.JFrame { private final Color defaultTextColor; public MainFrame() { initComponents(); splitPane.setResizeWeight(0.66); spnColumns.setModel(new SpinnerNumberModel(0, 0, Integer.MAX_VALUE, 1)); JPopupMenu rightClickMenu = new JPopupMenu(); Action cut = new DefaultEditorKit.CutAction(); cut.putValue(Action.NAME, "Cut"); cut.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control X")); rightClickMenu.add(cut); Action copy = new DefaultEditorKit.CopyAction(); copy.putValue(Action.NAME, "Copy"); copy.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control C")); rightClickMenu.add(copy); Action paste = new DefaultEditorKit.PasteAction(); paste.putValue(Action.NAME, "Paste"); paste.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control V")); rightClickMenu.add(paste); Action tab = new DefaultEditorKit.InsertTabAction(); tab.putValue(Action.NAME, "Insert Tab"); rightClickMenu.add(tab); txtInput.setComponentPopupMenu(rightClickMenu); txtOutput.setComponentPopupMenu(rightClickMenu); txtRegex.setComponentPopupMenu(rightClickMenu); txtFormat.setComponentPopupMenu(rightClickMenu); txtBlanks.setComponentPopupMenu(rightClickMenu); defaultTextColor = txtRegex.getBackground(); pnlReplace.setVisible(false); pnlReplace.setComponents(txtInput, txtOutput); Icon folderIcon = desaturateIcon(UIManager.getIcon("FileView.directoryIcon")); Icon floppyIcon = desaturateIcon(UIManager.getIcon("FileView.floppyDriveIcon")); Icon fileIcon = desaturateIcon(UIManager.getIcon("FileView.fileIcon")); btnSave.setIcon(floppyIcon); btnLoad.setIcon(folderIcon); btnClear.setIcon(fileIcon); } private Icon desaturateIcon(Icon icon) { int w = icon.getIconWidth(); int h = icon.getIconHeight(); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gd.getDefaultConfiguration(); BufferedImage iconImage = gc.createCompatibleImage(w, h, Transparency.TRANSLUCENT); Graphics2D g2d = iconImage.createGraphics(); icon.paintIcon(null, g2d, 0, 0); ColorConvertOp op = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), null); op.filter(iconImage, iconImage); return new ImageIcon(iconImage); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { splitPane = new javax.swing.JSplitPane(); pnlInput = new javax.swing.JPanel(); btnClear = new javax.swing.JButton(); btnLoad = new javax.swing.JButton(); scrollInput = new javax.swing.JScrollPane(); txtInput = new javax.swing.JTextArea(); lblExpression = new javax.swing.JLabel(); txtRegex = new javax.swing.JTextField(); spnColumns = new javax.swing.JSpinner(); btnTsvInput = new javax.swing.JButton(); btnCsvInput = new javax.swing.JButton(); btnMatch = new javax.swing.JButton(); scrollTable = new javax.swing.JScrollPane(); jTable = new javax.swing.JTable(); cbReplace = new javax.swing.JCheckBox(); btnPivotWideToLong = new javax.swing.JButton(); btnPivotLongToWide = new javax.swing.JButton(); btnTranspose = new javax.swing.JButton(); lblColumns = new javax.swing.JLabel(); btnSaveExpr = new javax.swing.JButton(); btnLoadExpr = new javax.swing.JButton(); cbQuoted = new javax.swing.JCheckBox(); pnlOutput = new javax.swing.JPanel(); lblFormat = new javax.swing.JLabel(); txtFormat = new javax.swing.JTextField(); btnFormat = new javax.swing.JButton(); scrollOutput = new javax.swing.JScrollPane(); txtOutput = new javax.swing.JTextArea(); lblArgumentMarker = new javax.swing.JLabel(); cbBlanks = new javax.swing.JCheckBox(); txtBlanks = new javax.swing.JTextField(); btnSwap = new javax.swing.JButton(); btnCsvOutput = new javax.swing.JButton(); btnTsvOutput = new javax.swing.JButton(); txtMarker = new javax.swing.JTextField(); btnSave = new javax.swing.JButton(); pnlReplace = new jrex.ui.ReplacePanel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); splitPane.setBorder(null); splitPane.setDividerLocation(366); splitPane.setDividerSize(15); splitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); splitPane.setName("splitPane"); // NOI18N splitPane.setOneTouchExpandable(true); pnlInput.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Input", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 0, 12))); // NOI18N pnlInput.setName("pnlInput"); // NOI18N btnClear.setText("Clear"); btnClear.setName("btnClear"); // NOI18N btnClear.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnClearActionPerformed(evt); } }); btnLoad.setText("Open"); btnLoad.setName("btnLoad"); // NOI18N btnLoad.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnLoadActionPerformed(evt); } }); scrollInput.setName("scrollInput"); // NOI18N txtInput.setColumns(20); txtInput.setFont(new java.awt.Font("Monospaced", 0, 12)); // NOI18N txtInput.setRows(5); txtInput.setName("txtInput"); // NOI18N scrollInput.setViewportView(txtInput); lblExpression.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); lblExpression.setText("Capture Expression: "); lblExpression.setName("lblExpression"); // NOI18N txtRegex.setFont(new java.awt.Font("Monospaced", 0, 12)); // NOI18N txtRegex.setName("txtRegex"); // NOI18N txtRegex.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { txtRegexKeyPressed(evt); } }); spnColumns.setName("spnColumns"); // NOI18N spnColumns.addMouseWheelListener(new java.awt.event.MouseWheelListener() { public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt) { spnColumnsMouseWheelMoved(evt); } }); btnTsvInput.setText("TSV"); btnTsvInput.setName("btnTsvInput"); // NOI18N btnTsvInput.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnTsvInputActionPerformed(evt); } }); btnCsvInput.setText("CSV"); btnCsvInput.setName("btnCsvInput"); // NOI18N btnCsvInput.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnCsvInputActionPerformed(evt); } }); btnMatch.setMnemonic('c'); btnMatch.setText("Capture"); btnMatch.setName("btnMatch"); // NOI18N btnMatch.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnMatchActionPerformed(evt); } }); scrollTable.setName("scrollTable"); // NOI18N jTable.setName("jTable"); // NOI18N scrollTable.setViewportView(jTable); cbReplace.setText("Search/Replace "); cbReplace.setName("cbReplace"); // NOI18N cbReplace.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cbReplaceActionPerformed(evt); } }); btnPivotWideToLong.setText("Pivot Wide to Long"); btnPivotWideToLong.setName("btnPivotWideToLong"); // NOI18N btnPivotWideToLong.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnPivotWideToLongActionPerformed(evt); } }); btnPivotLongToWide.setText("Pivot Long to Wide"); btnPivotLongToWide.setName("btnPivotLongToWide"); // NOI18N btnPivotLongToWide.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnPivotLongToWideActionPerformed(evt); } }); btnTranspose.setText("Transpose"); btnTranspose.setName("btnTranspose"); // NOI18N btnTranspose.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnTransposeActionPerformed(evt); } }); lblColumns.setText("Columns: "); lblColumns.setName("lblColumns"); // NOI18N btnSaveExpr.setText("Save Expressions"); btnSaveExpr.setName("btnSaveExpr"); // NOI18N btnSaveExpr.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnSaveExprActionPerformed(evt); } }); btnLoadExpr.setText("Load Expressions"); btnLoadExpr.setName("btnLoadExpr"); // NOI18N btnLoadExpr.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnLoadExprActionPerformed(evt); } }); cbQuoted.setText("Quoted?"); cbQuoted.setName("cbQuoted"); // NOI18N javax.swing.GroupLayout pnlInputLayout = new javax.swing.GroupLayout(pnlInput); pnlInput.setLayout(pnlInputLayout); pnlInputLayout.setHorizontalGroup( pnlInputLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnlInputLayout.createSequentialGroup() .addComponent(lblColumns) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(spnColumns, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(cbQuoted) .addGap(18, 18, 18) .addComponent(btnCsvInput) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnTsvInput) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(scrollInput) .addGroup(pnlInputLayout.createSequentialGroup() .addComponent(btnLoad) .addGap(18, 18, 18) .addComponent(cbReplace) .addGap(18, 18, 18) .addComponent(btnSaveExpr) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnLoadExpr) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnClear)) .addComponent(scrollTable, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 711, Short.MAX_VALUE) .addGroup(pnlInputLayout.createSequentialGroup() .addGroup(pnlInputLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnlInputLayout.createSequentialGroup() .addComponent(btnPivotWideToLong) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnPivotLongToWide) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnTranspose)) .addGroup(pnlInputLayout.createSequentialGroup() .addComponent(lblExpression) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtRegex))) .addGap(18, 18, 18) .addComponent(btnMatch)) ); pnlInputLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btnPivotLongToWide, btnPivotWideToLong, btnTranspose}); pnlInputLayout.setVerticalGroup( pnlInputLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnlInputLayout.createSequentialGroup() .addGroup(pnlInputLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnLoad, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnClear, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(cbReplace) .addComponent(btnSaveExpr) .addComponent(btnLoadExpr)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(scrollInput, javax.swing.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE) .addGap(11, 11, 11) .addGroup(pnlInputLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) .addComponent(lblColumns) .addComponent(spnColumns, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(cbQuoted) .addComponent(btnCsvInput) .addComponent(btnTsvInput)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(pnlInputLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) .addComponent(lblExpression) .addComponent(txtRegex, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnMatch)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(scrollTable, javax.swing.GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(pnlInputLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnPivotWideToLong) .addComponent(btnPivotLongToWide) .addComponent(btnTranspose))) ); splitPane.setTopComponent(pnlInput); pnlOutput.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Output", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 0, 12))); // NOI18N pnlOutput.setName("pnlOutput"); // NOI18N lblFormat.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); lblFormat.setText("Format Expression: "); lblFormat.setName("lblFormat"); // NOI18N txtFormat.setName("txtFormat"); // NOI18N btnFormat.setMnemonic('f'); btnFormat.setText("Format"); btnFormat.setName("btnFormat"); // NOI18N btnFormat.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnFormatActionPerformed(evt); } }); scrollOutput.setName("scrollOutput"); // NOI18N txtOutput.setColumns(20); txtOutput.setFont(new java.awt.Font("Monospaced", 0, 12)); // NOI18N txtOutput.setRows(5); txtOutput.setName("txtOutput"); // NOI18N scrollOutput.setViewportView(txtOutput); lblArgumentMarker.setText("Column Prefix: "); lblArgumentMarker.setName("lblArgumentMarker"); // NOI18N cbBlanks.setText("Replace blanks? "); cbBlanks.setName("cbBlanks"); // NOI18N txtBlanks.setText("null"); txtBlanks.setName("txtBlanks"); // NOI18N btnSwap.setMnemonic('o'); btnSwap.setText("Output to Input"); btnSwap.setName("btnSwap"); // NOI18N btnSwap.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnSwapActionPerformed(evt); } }); btnCsvOutput.setText("CSV"); btnCsvOutput.setName("btnCsvOutput"); // NOI18N btnCsvOutput.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnCsvOutputActionPerformed(evt); } }); btnTsvOutput.setText("TSV"); btnTsvOutput.setName("btnTsvOutput"); // NOI18N btnTsvOutput.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnTsvOutputActionPerformed(evt); } }); txtMarker.setText("?"); txtMarker.setName("txtMarker"); // NOI18N btnSave.setText("Save"); btnSave.setName("btnSave"); // NOI18N btnSave.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnSaveActionPerformed(evt); } }); javax.swing.GroupLayout pnlOutputLayout = new javax.swing.GroupLayout(pnlOutput); pnlOutput.setLayout(pnlOutputLayout); pnlOutputLayout.setHorizontalGroup( pnlOutputLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(scrollOutput) .addGroup(pnlOutputLayout.createSequentialGroup() .addComponent(lblArgumentMarker) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtMarker, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(cbBlanks) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtBlanks, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(btnCsvOutput) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnTsvOutput, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnSwap) .addGap(18, 18, 18) .addComponent(btnSave)) .addGroup(pnlOutputLayout.createSequentialGroup() .addComponent(lblFormat) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtFormat) .addGap(18, 18, 18) .addComponent(btnFormat)) ); pnlOutputLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btnCsvOutput, btnTsvOutput}); pnlOutputLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {txtBlanks, txtMarker}); pnlOutputLayout.setVerticalGroup( pnlOutputLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnlOutputLayout.createSequentialGroup() .addGroup(pnlOutputLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) .addComponent(lblArgumentMarker) .addComponent(txtMarker, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(cbBlanks) .addComponent(txtBlanks, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnCsvOutput) .addComponent(btnTsvOutput) .addComponent(btnSwap) .addComponent(btnSave)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(pnlOutputLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) .addComponent(lblFormat) .addComponent(txtFormat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnFormat)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(scrollOutput, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)) ); splitPane.setRightComponent(pnlOutput); pnlReplace.setName("pnlReplace"); // NOI18N javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(splitPane) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(pnlReplace, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(pnlReplace, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(splitPane)) .addContainerGap()) ); pack(); }// </editor-fold>//GEN-END:initComponents private void match() { txtOutput.setText(""); String regex = txtRegex.getText(); String text = txtInput.getText(); String[] input = null; try { Pattern pattern = Pattern.compile(regex); int flagsMask = pattern.flags(); StringBuilder flags = new StringBuilder(); boolean dotall = false; // work out which flags are being used if ((flagsMask & Pattern.DOTALL) == Pattern.DOTALL) { flags.append("DOTALL "); dotall = true; } if ((flagsMask & Pattern.MULTILINE) == Pattern.MULTILINE) { flags.append("MULTILINE "); } if ((flagsMask & Pattern.CASE_INSENSITIVE) == Pattern.CASE_INSENSITIVE) { flags.append("CASE_INSENSITIVE "); } PivotTableModel model = new PivotTableModel(); jTable.setModel(model); int numMatches = 0; // it DOTALL mode is on then grab the entire text rather then seperating by line if (dotall) { input = new String[1]; input[0] = text; } else { input = text.split("\n"); } for (String line : input) { Matcher matcher = pattern.matcher(line); while (matcher.find()) { // group() matches the entire line if there was a match. // This if-statment is to suppress extra empty groups from being // produced if the regex matches the entire line if (matcher.group().length() != line.length()) { continue; } numMatches++; txtOutput.append(matcher.group(0) + "\n"); String[] groups = new String[matcher.groupCount()]; for (int j = 1; j <= matcher.groupCount(); j++) { String s = matcher.group(j); groups[j - 1] = s; } model.addRow(groups); } } model.fireTableStructureChanged(); txtOutput.append("\nMatched " + numMatches + " line(s) out of " + input.length + " line(s) of input."); if (!flags.toString().isEmpty()) { txtOutput.append("\n\nFlags: " + flags.toString().trim()); } } catch (PatternSyntaxException ex) { txtOutput.setText(""); txtOutput.append(ex.getMessage()); txtRegex.setBackground(new Color(1f, 0.3f, 0.3f)); } } private void format() { String marker = txtMarker.getText(); txtOutput.setText(""); TableModel model = jTable.getModel(); String formatter = this.txtFormat.getText().replaceAll("\\" + marker + "(\\d*)", "%$1\\$s"); for (int row = 0; row < model.getRowCount(); row++) { Object[] values = new Object[model.getColumnCount()]; for (int col = 0; col < model.getColumnCount(); col++) { String val = (String) model.getValueAt(row, col); if (cbBlanks.isSelected() && val.isEmpty()) { val = txtBlanks.getText(); } values[col] = val; } String formatted = String.format(formatter, values); txtOutput.append(formatted + "\n"); } } private void transpose() { PivotTableModel model = (PivotTableModel) jTable.getModel(); model.transpose(); } private void pivotWideToLong() { PivotTableModel model = (PivotTableModel) jTable.getModel(); ListMultimap<String, String> columns = new WideToLongPivotDialog(this).mapColumns(model); if (columns != null) { model.pivotWideToLong(columns.get("preserved"), columns.get("values")); } } private void pivotLongToWide() { PivotTableModel model = (PivotTableModel) jTable.getModel(); ListMultimap<String, String> columns = new LongToWidePivotDialog(this).mapColumns(model); if (columns != null) { model.pivotLongToWide(columns.get("repeating"), columns.get("header").get(0), columns.get("value").get(0)); } } private void csv() { Integer cols = (Integer) spnColumns.getValue(); Boolean quoted = cbQuoted.isSelected(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < cols - 1; i++) { if (quoted) { sb.append("\"(.*?)\","); } else { sb.append("(.*?),"); } } if (quoted) { sb.append("\"(.*?)\""); } else { sb.append("(.*)"); } txtRegex.setText(sb.toString()); } private void tsv() { Integer cols = (Integer) spnColumns.getValue(); Boolean quoted = cbQuoted.isSelected(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < cols - 1; i++) { if (quoted) { sb.append("\"(.*?)\"\\t"); } else { sb.append("(.*?)\\t"); } } if (quoted) { sb.append("\"(.*?)\""); } else { sb.append("(.*)"); } txtRegex.setText(sb.toString()); } private void load() { JFileChooser jfc = new JFileChooser(); if (jfc.showOpenDialog(MainFrame.this) == JFileChooser.APPROVE_OPTION) { try { String data = readFile(jfc.getSelectedFile()); txtInput.setText(data); } catch (Exception ex) { JOptionPane.showMessageDialog(this, "Error", ex.getMessage(), JOptionPane.ERROR_MESSAGE); } } } private void save() { JFileChooser jfc = new JFileChooser(); int result = jfc.showSaveDialog(this); if (result == JFileChooser.APPROVE_OPTION) { File f = jfc.getSelectedFile(); if (f.exists()) { int confirm = JOptionPane.showConfirmDialog(this, "Overwrite existing file?"); if (confirm == JOptionPane.YES_OPTION) { try (BufferedWriter writer = new BufferedWriter(new FileWriter(f))) { writer.write(txtOutput.getText()); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Error", e.getMessage(), JOptionPane.ERROR_MESSAGE); } } } else { try (BufferedWriter writer = new BufferedWriter(new FileWriter(f))) { writer.write(txtOutput.getText()); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Error", e.getMessage(), JOptionPane.ERROR_MESSAGE); } } } } public String readFile(File file) throws Exception { StringBuilder fileContents; try (BufferedReader reader = new BufferedReader(new FileReader(file))) { @SuppressWarnings("UnusedAssignment") String line = null; fileContents = new StringBuilder(); while ((line = reader.readLine()) != null) { fileContents.append(line); fileContents.append(System.getProperty("line.separator")); } } return fileContents.toString(); } private void btnFormatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFormatActionPerformed format(); }//GEN-LAST:event_btnFormatActionPerformed private void btnTransposeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTransposeActionPerformed transpose(); }//GEN-LAST:event_btnTransposeActionPerformed private void btnMatchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMatchActionPerformed match(); }//GEN-LAST:event_btnMatchActionPerformed private void btnCsvInputActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCsvInputActionPerformed csv(); match(); }//GEN-LAST:event_btnCsvInputActionPerformed private void btnTsvInputActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTsvInputActionPerformed tsv(); match(); }//GEN-LAST:event_btnTsvInputActionPerformed private void btnLoadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLoadActionPerformed load(); }//GEN-LAST:event_btnLoadActionPerformed private void btnClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnClearActionPerformed txtInput.setText(""); }//GEN-LAST:event_btnClearActionPerformed private void spnColumnsMouseWheelMoved(java.awt.event.MouseWheelEvent evt) {//GEN-FIRST:event_spnColumnsMouseWheelMoved Integer value = (Integer) spnColumns.getValue(); value -= evt.getUnitsToScroll(); spnColumns.setValue(value > 0 ? value : 0); }//GEN-LAST:event_spnColumnsMouseWheelMoved private void btnPivotWideToLongActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPivotWideToLongActionPerformed pivotWideToLong(); }//GEN-LAST:event_btnPivotWideToLongActionPerformed private void txtRegexKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtRegexKeyPressed // restore default color txtRegex.setBackground(defaultTextColor); }//GEN-LAST:event_txtRegexKeyPressed private void cbReplaceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbReplaceActionPerformed pnlReplace.setVisible(cbReplace.isSelected()); }//GEN-LAST:event_cbReplaceActionPerformed private void btnSwapActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSwapActionPerformed txtInput.setText(txtOutput.getText()); }//GEN-LAST:event_btnSwapActionPerformed private void btnCsvOutputActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCsvOutputActionPerformed String marker = txtMarker.getText(); Integer cols = (Integer) jTable.getColumnCount(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < cols; i++) { sb.append(marker).append(i + 1).append(","); } String format = sb.toString(); txtFormat.setText(format.substring(0, format.length() - 1)); format(); }//GEN-LAST:event_btnCsvOutputActionPerformed private void btnTsvOutputActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTsvOutputActionPerformed String marker = txtMarker.getText(); Integer cols = (Integer) jTable.getColumnCount(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < cols; i++) { sb.append(marker).append(i + 1).append("\t"); } String format = sb.toString(); txtFormat.setText(format.substring(0, format.length() - 1)); format(); }//GEN-LAST:event_btnTsvOutputActionPerformed private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed save(); }//GEN-LAST:event_btnSaveActionPerformed private void btnPivotLongToWideActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPivotLongToWideActionPerformed pivotLongToWide(); }//GEN-LAST:event_btnPivotLongToWideActionPerformed private void btnSaveExprActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveExprActionPerformed Expressions exp = new Expressions(); exp.setBlanks(txtBlanks.getText()); exp.setBlanksEnabled(cbBlanks.isSelected()); exp.setCapture(txtRegex.getText()); exp.setFormat(txtFormat.getText()); exp.setPrefix(txtMarker.getText()); exp.setReplacements(pnlReplace.getModel().getRows()); String json = new Gson().toJson(exp); JFileChooser jfc = new JFileChooser(); int result = jfc.showSaveDialog(this); if (result == JFileChooser.APPROVE_OPTION) { File f = jfc.getSelectedFile(); if (f.exists()) { int confirm = JOptionPane.showConfirmDialog(this, "Overwrite existing file?"); if (confirm == JOptionPane.YES_OPTION) { try (BufferedWriter writer = new BufferedWriter(new FileWriter(f))) { writer.write(json); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Error", e.getMessage(), JOptionPane.ERROR_MESSAGE); } } } else { try (BufferedWriter writer = new BufferedWriter(new FileWriter(f))) { writer.write(txtOutput.getText()); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Error", e.getMessage(), JOptionPane.ERROR_MESSAGE); } } } }//GEN-LAST:event_btnSaveExprActionPerformed private void btnLoadExprActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLoadExprActionPerformed String json = null; JFileChooser jfc = new JFileChooser(); if (jfc.showOpenDialog(MainFrame.this) == JFileChooser.APPROVE_OPTION) { try { json = readFile(jfc.getSelectedFile()); } catch (Exception ex) { JOptionPane.showMessageDialog(this, "Error", ex.getMessage(), JOptionPane.ERROR_MESSAGE); } } Expressions exp = new Gson().fromJson(json, Expressions.class); txtBlanks.setText(exp.getBlanks()); cbBlanks.setSelected(exp.getBlanksEnabled()); txtRegex.setText(exp.getCapture()); txtFormat.setText(exp.getFormat()); txtMarker.setText(exp.getPrefix()); List<List<String>> replacements = exp.getReplacements(); MutableTableModel model = pnlReplace.getModel(); model.getTable().clear(); for (List<String> replacement : replacements) { model.addRow(replacement); } }//GEN-LAST:event_btnLoadExprActionPerformed public String getPrefix() { return txtMarker.getText(); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnClear; private javax.swing.JButton btnCsvInput; private javax.swing.JButton btnCsvOutput; private javax.swing.JButton btnFormat; private javax.swing.JButton btnLoad; private javax.swing.JButton btnLoadExpr; private javax.swing.JButton btnMatch; private javax.swing.JButton btnPivotLongToWide; private javax.swing.JButton btnPivotWideToLong; private javax.swing.JButton btnSave; private javax.swing.JButton btnSaveExpr; private javax.swing.JButton btnSwap; private javax.swing.JButton btnTranspose; private javax.swing.JButton btnTsvInput; private javax.swing.JButton btnTsvOutput; private javax.swing.JCheckBox cbBlanks; private javax.swing.JCheckBox cbQuoted; private javax.swing.JCheckBox cbReplace; private javax.swing.JTable jTable; private javax.swing.JLabel lblArgumentMarker; private javax.swing.JLabel lblColumns; private javax.swing.JLabel lblExpression; private javax.swing.JLabel lblFormat; private javax.swing.JPanel pnlInput; private javax.swing.JPanel pnlOutput; private jrex.ui.ReplacePanel pnlReplace; private javax.swing.JScrollPane scrollInput; private javax.swing.JScrollPane scrollOutput; private javax.swing.JScrollPane scrollTable; private javax.swing.JSplitPane splitPane; private javax.swing.JSpinner spnColumns; private javax.swing.JTextField txtBlanks; private javax.swing.JTextField txtFormat; private javax.swing.JTextArea txtInput; private javax.swing.JTextField txtMarker; private javax.swing.JTextArea txtOutput; private javax.swing.JTextField txtRegex; // End of variables declaration//GEN-END:variables }
package jrex.ui; import jrex.ui.model.MutableTableModel; import jrex.ui.model.PivotTableModel; import com.google.common.collect.ListMultimap; import com.google.gson.Gson; import java.awt.Color; import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.Transparency; import java.awt.color.ColorSpace; import java.awt.image.BufferedImage; import java.awt.image.ColorConvertOp; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; import javax.swing.Action; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.JPopupMenu; import javax.swing.KeyStroke; import javax.swing.SpinnerNumberModel; import javax.swing.UIManager; import javax.swing.table.TableModel; import javax.swing.text.DefaultEditorKit; import jrex.Expressions; /** * Primary user interface frame. * * @author Mark George <mark.george@otago.ac.nz> */ public class MainFrame extends javax.swing.JFrame { private final Color defaultTextColor; public MainFrame() { initComponents(); splitPane.setResizeWeight(0.66); spnColumns.setModel(new SpinnerNumberModel(0, 0, Integer.MAX_VALUE, 1)); JPopupMenu rightClickMenu = new JPopupMenu(); Action cut = new DefaultEditorKit.CutAction(); cut.putValue(Action.NAME, "Cut"); cut.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control X")); rightClickMenu.add(cut); Action copy = new DefaultEditorKit.CopyAction(); copy.putValue(Action.NAME, "Copy"); copy.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control C")); rightClickMenu.add(copy); Action paste = new DefaultEditorKit.PasteAction(); paste.putValue(Action.NAME, "Paste"); paste.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control V")); rightClickMenu.add(paste); Action tab = new DefaultEditorKit.InsertTabAction(); tab.putValue(Action.NAME, "Insert Tab"); rightClickMenu.add(tab); txtInput.setComponentPopupMenu(rightClickMenu); txtOutput.setComponentPopupMenu(rightClickMenu); txtRegex.setComponentPopupMenu(rightClickMenu); txtFormat.setComponentPopupMenu(rightClickMenu); txtBlanks.setComponentPopupMenu(rightClickMenu); defaultTextColor = txtRegex.getBackground(); pnlReplace.setVisible(false); pnlReplace.setComponents(txtInput, txtOutput); Icon folderIcon = desaturateIcon(UIManager.getIcon("FileView.directoryIcon")); Icon floppyIcon = desaturateIcon(UIManager.getIcon("FileView.floppyDriveIcon")); Icon fileIcon = desaturateIcon(UIManager.getIcon("FileView.fileIcon")); btnSave.setIcon(floppyIcon); btnLoad.setIcon(folderIcon); btnClear.setIcon(fileIcon); } private Icon desaturateIcon(Icon icon) { int w = icon.getIconWidth(); int h = icon.getIconHeight(); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gd.getDefaultConfiguration(); BufferedImage iconImage = gc.createCompatibleImage(w, h, Transparency.TRANSLUCENT); Graphics2D g2d = iconImage.createGraphics(); icon.paintIcon(null, g2d, 0, 0); ColorConvertOp op = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), null); op.filter(iconImage, iconImage); return new ImageIcon(iconImage); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { splitPane = new javax.swing.JSplitPane(); pnlInput = new javax.swing.JPanel(); btnClear = new javax.swing.JButton(); btnLoad = new javax.swing.JButton(); scrollInput = new javax.swing.JScrollPane(); txtInput = new javax.swing.JTextArea(); lblExpression = new javax.swing.JLabel(); txtRegex = new javax.swing.JTextField(); spnColumns = new javax.swing.JSpinner(); btnTsvInput = new javax.swing.JButton(); btnCsvInput = new javax.swing.JButton(); btnMatch = new javax.swing.JButton(); scrollTable = new javax.swing.JScrollPane(); jTable = new javax.swing.JTable(); cbReplace = new javax.swing.JCheckBox(); btnPivotWideToLong = new javax.swing.JButton(); btnPivotLongToWide = new javax.swing.JButton(); btnTranspose = new javax.swing.JButton(); lblColumns = new javax.swing.JLabel(); btnSaveExpr = new javax.swing.JButton(); btnLoadExpr = new javax.swing.JButton(); pnlOutput = new javax.swing.JPanel(); lblFormat = new javax.swing.JLabel(); txtFormat = new javax.swing.JTextField(); btnFormat = new javax.swing.JButton(); scrollOutput = new javax.swing.JScrollPane(); txtOutput = new javax.swing.JTextArea(); lblArgumentMarker = new javax.swing.JLabel(); cbBlanks = new javax.swing.JCheckBox(); txtBlanks = new javax.swing.JTextField(); btnSwap = new javax.swing.JButton(); btnCsvOutput = new javax.swing.JButton(); btnTsvOutput = new javax.swing.JButton(); txtMarker = new javax.swing.JTextField(); btnSave = new javax.swing.JButton(); pnlReplace = new jrex.ui.ReplacePanel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); splitPane.setBorder(null); splitPane.setDividerLocation(366); splitPane.setDividerSize(15); splitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); splitPane.setName("splitPane"); // NOI18N splitPane.setOneTouchExpandable(true); pnlInput.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Input", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 0, 12))); // NOI18N pnlInput.setName("pnlInput"); // NOI18N btnClear.setText("Clear"); btnClear.setName("btnClear"); // NOI18N btnClear.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnClearActionPerformed(evt); } }); btnLoad.setText("Open"); btnLoad.setName("btnLoad"); // NOI18N btnLoad.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnLoadActionPerformed(evt); } }); scrollInput.setName("scrollInput"); // NOI18N txtInput.setColumns(20); txtInput.setFont(new java.awt.Font("Monospaced", 0, 12)); // NOI18N txtInput.setRows(5); txtInput.setName("txtInput"); // NOI18N scrollInput.setViewportView(txtInput); lblExpression.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); lblExpression.setText("Capture Expression: "); lblExpression.setName("lblExpression"); // NOI18N txtRegex.setFont(new java.awt.Font("Monospaced", 0, 12)); // NOI18N txtRegex.setName("txtRegex"); // NOI18N txtRegex.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { txtRegexKeyPressed(evt); } }); spnColumns.setName("spnColumns"); // NOI18N spnColumns.addMouseWheelListener(new java.awt.event.MouseWheelListener() { public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt) { spnColumnsMouseWheelMoved(evt); } }); btnTsvInput.setText("TSV"); btnTsvInput.setName("btnTsvInput"); // NOI18N btnTsvInput.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnTsvInputActionPerformed(evt); } }); btnCsvInput.setText("CSV"); btnCsvInput.setName("btnCsvInput"); // NOI18N btnCsvInput.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnCsvInputActionPerformed(evt); } }); btnMatch.setMnemonic('c'); btnMatch.setText("Capture"); btnMatch.setName("btnMatch"); // NOI18N btnMatch.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnMatchActionPerformed(evt); } }); scrollTable.setName("scrollTable"); // NOI18N jTable.setName("jTable"); // NOI18N scrollTable.setViewportView(jTable); cbReplace.setText("Search/Replace "); cbReplace.setName("cbReplace"); // NOI18N cbReplace.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cbReplaceActionPerformed(evt); } }); btnPivotWideToLong.setText("Pivot Wide to Long"); btnPivotWideToLong.setName("btnPivotWideToLong"); // NOI18N btnPivotWideToLong.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnPivotWideToLongActionPerformed(evt); } }); btnPivotLongToWide.setText("Pivot Long to Wide"); btnPivotLongToWide.setName("btnPivotLongToWide"); // NOI18N btnPivotLongToWide.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnPivotLongToWideActionPerformed(evt); } }); btnTranspose.setText("Transpose"); btnTranspose.setName("btnTranspose"); // NOI18N btnTranspose.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnTransposeActionPerformed(evt); } }); lblColumns.setText("Columns: "); lblColumns.setName("lblColumns"); // NOI18N btnSaveExpr.setText("Save Expressions"); btnSaveExpr.setName("btnSaveExpr"); // NOI18N btnSaveExpr.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnSaveExprActionPerformed(evt); } }); btnLoadExpr.setText("Load Expressions"); btnLoadExpr.setName("btnLoadExpr"); // NOI18N btnLoadExpr.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnLoadExprActionPerformed(evt); } }); javax.swing.GroupLayout pnlInputLayout = new javax.swing.GroupLayout(pnlInput); pnlInput.setLayout(pnlInputLayout); pnlInputLayout.setHorizontalGroup( pnlInputLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnlInputLayout.createSequentialGroup() .addComponent(lblColumns) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(spnColumns, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(btnCsvInput) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnTsvInput) .addGap(0, 0, Short.MAX_VALUE)) .addComponent(scrollInput) .addGroup(pnlInputLayout.createSequentialGroup() .addComponent(btnLoad) .addGap(18, 18, 18) .addComponent(cbReplace) .addGap(18, 18, 18) .addComponent(btnSaveExpr) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnLoadExpr) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnClear)) .addComponent(scrollTable, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 711, Short.MAX_VALUE) .addGroup(pnlInputLayout.createSequentialGroup() .addGroup(pnlInputLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnlInputLayout.createSequentialGroup() .addComponent(btnPivotWideToLong) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnPivotLongToWide) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnTranspose)) .addGroup(pnlInputLayout.createSequentialGroup() .addComponent(lblExpression) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtRegex))) .addGap(18, 18, 18) .addComponent(btnMatch)) ); pnlInputLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btnPivotLongToWide, btnPivotWideToLong, btnTranspose}); pnlInputLayout.setVerticalGroup( pnlInputLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnlInputLayout.createSequentialGroup() .addGroup(pnlInputLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnLoad, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnClear, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(cbReplace) .addComponent(btnSaveExpr) .addComponent(btnLoadExpr)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(scrollInput, javax.swing.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(pnlInputLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnTsvInput) .addComponent(btnCsvInput) .addComponent(spnColumns, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lblColumns)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(pnlInputLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lblExpression) .addComponent(txtRegex, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnMatch)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(scrollTable, javax.swing.GroupLayout.DEFAULT_SIZE, 82, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(pnlInputLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnPivotWideToLong) .addComponent(btnPivotLongToWide) .addComponent(btnTranspose))) ); splitPane.setTopComponent(pnlInput); pnlOutput.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Output", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 0, 12))); // NOI18N pnlOutput.setName("pnlOutput"); // NOI18N lblFormat.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); lblFormat.setText("Format Expression: "); lblFormat.setName("lblFormat"); // NOI18N txtFormat.setName("txtFormat"); // NOI18N btnFormat.setMnemonic('f'); btnFormat.setText("Format"); btnFormat.setName("btnFormat"); // NOI18N btnFormat.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnFormatActionPerformed(evt); } }); scrollOutput.setName("scrollOutput"); // NOI18N txtOutput.setColumns(20); txtOutput.setFont(new java.awt.Font("Monospaced", 0, 12)); // NOI18N txtOutput.setRows(5); txtOutput.setName("txtOutput"); // NOI18N scrollOutput.setViewportView(txtOutput); lblArgumentMarker.setText("Column Prefix: "); lblArgumentMarker.setName("lblArgumentMarker"); // NOI18N cbBlanks.setText("Replace blanks? "); cbBlanks.setName("cbBlanks"); // NOI18N txtBlanks.setText("null"); txtBlanks.setName("txtBlanks"); // NOI18N btnSwap.setMnemonic('o'); btnSwap.setText("Output to Input"); btnSwap.setName("btnSwap"); // NOI18N btnSwap.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnSwapActionPerformed(evt); } }); btnCsvOutput.setText("CSV"); btnCsvOutput.setName("btnCsvOutput"); // NOI18N btnCsvOutput.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnCsvOutputActionPerformed(evt); } }); btnTsvOutput.setText("TSV"); btnTsvOutput.setName("btnTsvOutput"); // NOI18N btnTsvOutput.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnTsvOutputActionPerformed(evt); } }); txtMarker.setText("?"); txtMarker.setName("txtMarker"); // NOI18N btnSave.setText("Save"); btnSave.setName("btnSave"); // NOI18N btnSave.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnSaveActionPerformed(evt); } }); javax.swing.GroupLayout pnlOutputLayout = new javax.swing.GroupLayout(pnlOutput); pnlOutput.setLayout(pnlOutputLayout); pnlOutputLayout.setHorizontalGroup( pnlOutputLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(scrollOutput) .addGroup(pnlOutputLayout.createSequentialGroup() .addComponent(lblArgumentMarker) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtMarker, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(cbBlanks) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtBlanks, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(btnCsvOutput) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnTsvOutput, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnSwap) .addGap(18, 18, 18) .addComponent(btnSave)) .addGroup(pnlOutputLayout.createSequentialGroup() .addComponent(lblFormat) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtFormat) .addGap(18, 18, 18) .addComponent(btnFormat)) ); pnlOutputLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btnCsvOutput, btnTsvOutput}); pnlOutputLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {txtBlanks, txtMarker}); pnlOutputLayout.setVerticalGroup( pnlOutputLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnlOutputLayout.createSequentialGroup() .addGroup(pnlOutputLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lblArgumentMarker) .addComponent(cbBlanks) .addComponent(txtBlanks, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnSwap) .addComponent(txtMarker, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnCsvOutput) .addComponent(btnTsvOutput) .addComponent(btnSave)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(pnlOutputLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lblFormat) .addComponent(txtFormat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnFormat)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(scrollOutput, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)) ); splitPane.setRightComponent(pnlOutput); pnlReplace.setName("pnlReplace"); // NOI18N javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(splitPane) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(pnlReplace, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(pnlReplace, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(splitPane)) .addContainerGap()) ); pack(); }// </editor-fold>//GEN-END:initComponents private void match() { txtOutput.setText(""); String regex = txtRegex.getText(); String text = txtInput.getText(); String[] input = null; try { Pattern pattern = Pattern.compile(regex); int flagsMask = pattern.flags(); StringBuilder flags = new StringBuilder(); boolean dotall = false; // work out which flags are being used if ((flagsMask & Pattern.DOTALL) == Pattern.DOTALL) { flags.append("DOTALL "); dotall = true; } if ((flagsMask & Pattern.MULTILINE) == Pattern.MULTILINE) { flags.append("MULTILINE "); } if ((flagsMask & Pattern.CASE_INSENSITIVE) == Pattern.CASE_INSENSITIVE) { flags.append("CASE_INSENSITIVE "); } PivotTableModel model = new PivotTableModel(); jTable.setModel(model); int numMatches = 0; // it DOTALL mode is on then grab the entire text rather then seperating by line if (dotall) { input = new String[1]; input[0] = text; } else { input = text.split("\n"); } for (String line : input) { Matcher matcher = pattern.matcher(line); while (matcher.find()) { // group() matches the entire line if there was a match. // This if-statment is to suppress extra empty groups from being // produced if the regex matches the entire line if (matcher.group().length() != line.length()) { continue; } numMatches++; txtOutput.append(matcher.group(0) + "\n"); String[] groups = new String[matcher.groupCount()]; for (int j = 1; j <= matcher.groupCount(); j++) { String s = matcher.group(j); groups[j - 1] = s; } model.addRow(groups); } } model.fireTableStructureChanged(); txtOutput.append("\nMatched " + numMatches + " line(s) out of " + input.length + " line(s) of input."); if (!flags.toString().isEmpty()) { txtOutput.append("\n\nFlags: " + flags.toString().trim()); } } catch (PatternSyntaxException ex) { txtOutput.setText(""); txtOutput.append(ex.getMessage()); txtRegex.setBackground(new Color(1f, 0.3f, 0.3f)); } } private void format() { String marker = txtMarker.getText(); txtOutput.setText(""); TableModel model = jTable.getModel(); String formatter = this.txtFormat.getText().replaceAll("\\" + marker + "(\\d*)", "%$1\\$s"); for (int row = 0; row < model.getRowCount(); row++) { Object[] values = new Object[model.getColumnCount()]; for (int col = 0; col < model.getColumnCount(); col++) { String val = (String) model.getValueAt(row, col); if (cbBlanks.isSelected() && val.isEmpty()) { val = txtBlanks.getText(); } values[col] = val; } String formatted = String.format(formatter, values); txtOutput.append(formatted + "\n"); } } private void transpose() { PivotTableModel model = (PivotTableModel) jTable.getModel(); model.transpose(); } private void pivotWideToLong() { PivotTableModel model = (PivotTableModel) jTable.getModel(); ListMultimap<String, String> columns = new WideToLongPivotDialog(this).mapColumns(model); if (columns != null) { model.pivotWideToLong(columns.get("preserved"), columns.get("values")); } } private void pivotLongToWide() { PivotTableModel model = (PivotTableModel) jTable.getModel(); ListMultimap<String, String> columns = new LongToWidePivotDialog(this).mapColumns(model); if (columns != null) { model.pivotLongToWide(columns.get("repeating"), columns.get("header").get(0), columns.get("value").get(0)); } } private void csv() { Integer cols = (Integer) spnColumns.getValue(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < cols - 1; i++) { sb.append("(.*?),"); } sb.append("(.*)"); txtRegex.setText(sb.toString()); } private void tsv() { Integer cols = (Integer) spnColumns.getValue(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < cols - 1; i++) { sb.append("(.*?)\\t"); } sb.append("(.*)"); txtRegex.setText(sb.toString()); } private void load() { JFileChooser jfc = new JFileChooser(); if (jfc.showOpenDialog(MainFrame.this) == JFileChooser.APPROVE_OPTION) { try { String data = readFile(jfc.getSelectedFile()); txtInput.setText(data); } catch (Exception ex) { JOptionPane.showMessageDialog(this, "Error", ex.getMessage(), JOptionPane.ERROR_MESSAGE); } } } private void save() { JFileChooser jfc = new JFileChooser(); int result = jfc.showSaveDialog(this); if (result == JFileChooser.APPROVE_OPTION) { File f = jfc.getSelectedFile(); if (f.exists()) { int confirm = JOptionPane.showConfirmDialog(this, "Overwrite existing file?"); if (confirm == JOptionPane.YES_OPTION) { try (BufferedWriter writer = new BufferedWriter(new FileWriter(f))) { writer.write(txtOutput.getText()); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Error", e.getMessage(), JOptionPane.ERROR_MESSAGE); } } } else { try (BufferedWriter writer = new BufferedWriter(new FileWriter(f))) { writer.write(txtOutput.getText()); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Error", e.getMessage(), JOptionPane.ERROR_MESSAGE); } } } } public String readFile(File file) throws Exception { StringBuilder fileContents; try (BufferedReader reader = new BufferedReader(new FileReader(file))) { @SuppressWarnings("UnusedAssignment") String line = null; fileContents = new StringBuilder(); while ((line = reader.readLine()) != null) { fileContents.append(line); fileContents.append(System.getProperty("line.separator")); } } return fileContents.toString(); } private void btnFormatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFormatActionPerformed format(); }//GEN-LAST:event_btnFormatActionPerformed private void btnTransposeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTransposeActionPerformed transpose(); }//GEN-LAST:event_btnTransposeActionPerformed private void btnMatchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMatchActionPerformed match(); }//GEN-LAST:event_btnMatchActionPerformed private void btnCsvInputActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCsvInputActionPerformed csv(); match(); }//GEN-LAST:event_btnCsvInputActionPerformed private void btnTsvInputActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTsvInputActionPerformed tsv(); match(); }//GEN-LAST:event_btnTsvInputActionPerformed private void btnLoadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLoadActionPerformed load(); }//GEN-LAST:event_btnLoadActionPerformed private void btnClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnClearActionPerformed txtInput.setText(""); }//GEN-LAST:event_btnClearActionPerformed private void spnColumnsMouseWheelMoved(java.awt.event.MouseWheelEvent evt) {//GEN-FIRST:event_spnColumnsMouseWheelMoved Integer value = (Integer) spnColumns.getValue(); value -= evt.getUnitsToScroll(); spnColumns.setValue(value > 0 ? value : 0); }//GEN-LAST:event_spnColumnsMouseWheelMoved private void btnPivotWideToLongActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPivotWideToLongActionPerformed pivotWideToLong(); }//GEN-LAST:event_btnPivotWideToLongActionPerformed private void txtRegexKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtRegexKeyPressed // restore default color txtRegex.setBackground(defaultTextColor); }//GEN-LAST:event_txtRegexKeyPressed private void cbReplaceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbReplaceActionPerformed pnlReplace.setVisible(cbReplace.isSelected()); }//GEN-LAST:event_cbReplaceActionPerformed private void btnSwapActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSwapActionPerformed txtInput.setText(txtOutput.getText()); }//GEN-LAST:event_btnSwapActionPerformed private void btnCsvOutputActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCsvOutputActionPerformed String marker = txtMarker.getText(); Integer cols = (Integer) jTable.getColumnCount(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < cols; i++) { sb.append(marker).append(i + 1).append(","); } String format = sb.toString(); txtFormat.setText(format.substring(0, format.length() - 1)); format(); }//GEN-LAST:event_btnCsvOutputActionPerformed private void btnTsvOutputActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTsvOutputActionPerformed String marker = txtMarker.getText(); Integer cols = (Integer) jTable.getColumnCount(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < cols; i++) { sb.append(marker).append(i + 1).append("\t"); } String format = sb.toString(); txtFormat.setText(format.substring(0, format.length() - 1)); format(); }//GEN-LAST:event_btnTsvOutputActionPerformed private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed save(); }//GEN-LAST:event_btnSaveActionPerformed private void btnPivotLongToWideActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPivotLongToWideActionPerformed pivotLongToWide(); }//GEN-LAST:event_btnPivotLongToWideActionPerformed private void btnSaveExprActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveExprActionPerformed Expressions exp = new Expressions(); exp.setBlanks(txtBlanks.getText()); exp.setBlanksEnabled(cbBlanks.isSelected()); exp.setCapture(txtRegex.getText()); exp.setFormat(txtFormat.getText()); exp.setPrefix(txtMarker.getText()); exp.setReplacements(pnlReplace.getModel().getRows()); String json = new Gson().toJson(exp); JFileChooser jfc = new JFileChooser(); int result = jfc.showSaveDialog(this); if (result == JFileChooser.APPROVE_OPTION) { File f = jfc.getSelectedFile(); if (f.exists()) { int confirm = JOptionPane.showConfirmDialog(this, "Overwrite existing file?"); if (confirm == JOptionPane.YES_OPTION) { try (BufferedWriter writer = new BufferedWriter(new FileWriter(f))) { writer.write(json); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Error", e.getMessage(), JOptionPane.ERROR_MESSAGE); } } } else { try (BufferedWriter writer = new BufferedWriter(new FileWriter(f))) { writer.write(txtOutput.getText()); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Error", e.getMessage(), JOptionPane.ERROR_MESSAGE); } } } }//GEN-LAST:event_btnSaveExprActionPerformed private void btnLoadExprActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLoadExprActionPerformed String json = null; JFileChooser jfc = new JFileChooser(); if (jfc.showOpenDialog(MainFrame.this) == JFileChooser.APPROVE_OPTION) { try { json = readFile(jfc.getSelectedFile()); } catch (Exception ex) { JOptionPane.showMessageDialog(this, "Error", ex.getMessage(), JOptionPane.ERROR_MESSAGE); } } Expressions exp = new Gson().fromJson(json, Expressions.class); txtBlanks.setText(exp.getBlanks()); cbBlanks.setSelected(exp.getBlanksEnabled()); txtRegex.setText(exp.getCapture()); txtFormat.setText(exp.getFormat()); txtMarker.setText(exp.getPrefix()); List<List<String>> replacements = exp.getReplacements(); MutableTableModel model = pnlReplace.getModel(); model.getTable().clear(); for (List<String> replacement : replacements) { model.addRow(replacement); } }//GEN-LAST:event_btnLoadExprActionPerformed public String getPrefix() { return txtMarker.getText(); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnClear; private javax.swing.JButton btnCsvInput; private javax.swing.JButton btnCsvOutput; private javax.swing.JButton btnFormat; private javax.swing.JButton btnLoad; private javax.swing.JButton btnLoadExpr; private javax.swing.JButton btnMatch; private javax.swing.JButton btnPivotLongToWide; private javax.swing.JButton btnPivotWideToLong; private javax.swing.JButton btnSave; private javax.swing.JButton btnSaveExpr; private javax.swing.JButton btnSwap; private javax.swing.JButton btnTranspose; private javax.swing.JButton btnTsvInput; private javax.swing.JButton btnTsvOutput; private javax.swing.JCheckBox cbBlanks; private javax.swing.JCheckBox cbReplace; private javax.swing.JTable jTable; private javax.swing.JLabel lblArgumentMarker; private javax.swing.JLabel lblColumns; private javax.swing.JLabel lblExpression; private javax.swing.JLabel lblFormat; private javax.swing.JPanel pnlInput; private javax.swing.JPanel pnlOutput; private jrex.ui.ReplacePanel pnlReplace; private javax.swing.JScrollPane scrollInput; private javax.swing.JScrollPane scrollOutput; private javax.swing.JScrollPane scrollTable; private javax.swing.JSplitPane splitPane; private javax.swing.JSpinner spnColumns; private javax.swing.JTextField txtBlanks; private javax.swing.JTextField txtFormat; private javax.swing.JTextArea txtInput; private javax.swing.JTextField txtMarker; private javax.swing.JTextArea txtOutput; private javax.swing.JTextField txtRegex; // End of variables declaration//GEN-END:variables }
Show line notes below