|
|
|
@ -63,6 +63,7 @@ import java.util.logging.Level;
|
|
|
|
|
import java.util.logging.Logger;
|
|
|
|
|
import javax.swing.JFileChooser;
|
|
|
|
|
import javax.swing.JOptionPane;
|
|
|
|
|
import javax.swing.SwingUtilities;
|
|
|
|
|
import javax.swing.filechooser.FileFilter;
|
|
|
|
|
import javax.swing.filechooser.FileNameExtensionFilter;
|
|
|
|
|
import org.htmlcleaner.CleanerProperties;
|
|
|
|
@ -81,6 +82,7 @@ public class CodeExport extends javax.swing.JInternalFrame {
|
|
|
|
|
private String codeLang = "js";
|
|
|
|
|
private String html;
|
|
|
|
|
private final String origCode;
|
|
|
|
|
private String outputTxt = "";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates new form CodeExport
|
|
|
|
@ -90,6 +92,12 @@ public class CodeExport extends javax.swing.JInternalFrame {
|
|
|
|
|
public CodeExport(String code) {
|
|
|
|
|
origCode = code;
|
|
|
|
|
initComponents();
|
|
|
|
|
SwingUtilities.invokeLater(new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
html = genHtml(code);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
html = genHtml(code);
|
|
|
|
|
previewPane.setText(html);
|
|
|
|
|
previewPane.setCaretPosition(0);
|
|
|
|
@ -106,6 +114,11 @@ public class CodeExport extends javax.swing.JInternalFrame {
|
|
|
|
|
codeLang = lang;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CodeExport(String code, String lang, String out) {
|
|
|
|
|
this(code, lang);
|
|
|
|
|
outputTxt = out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String genHtml(String code) {
|
|
|
|
|
String css = "";
|
|
|
|
|
BufferedReader reader = new BufferedReader(
|
|
|
|
@ -137,9 +150,15 @@ public class CodeExport extends javax.swing.JInternalFrame {
|
|
|
|
|
if (!headerBox.getText().equals("")) {
|
|
|
|
|
html += "<p class=\"header\">" + headerBox.getText() + "</p>";
|
|
|
|
|
}
|
|
|
|
|
if (outputPlaceBox.getSelectedIndex() == 1) {
|
|
|
|
|
html += getOutput();
|
|
|
|
|
}
|
|
|
|
|
PrettifyParser parser = new PrettifyParser();
|
|
|
|
|
List<ParseResult> parseResults = parser.parse(codeLang, code);
|
|
|
|
|
html += PrettifyToHtml.toHtml(code, parseResults);
|
|
|
|
|
if (outputPlaceBox.getSelectedIndex() == 0) {
|
|
|
|
|
html += getOutput();
|
|
|
|
|
}
|
|
|
|
|
html += "</body></html>";
|
|
|
|
|
html = html.replace("\t", "<span class=\"tab\"> </span>");
|
|
|
|
|
html = html.replace("\n", "<br>");
|
|
|
|
@ -153,6 +172,15 @@ public class CodeExport extends javax.swing.JInternalFrame {
|
|
|
|
|
return html;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getOutput() {
|
|
|
|
|
return "<pre>"
|
|
|
|
|
+ outputTxt.replace("<", "<").
|
|
|
|
|
replace("&", "&").
|
|
|
|
|
replace(">", ">").
|
|
|
|
|
replace("\"", "''")
|
|
|
|
|
+ "</pre>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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
|
|
|
|
@ -178,6 +206,8 @@ public class CodeExport extends javax.swing.JInternalFrame {
|
|
|
|
|
jPanel2 = new javax.swing.JPanel();
|
|
|
|
|
exHtml = new javax.swing.JButton();
|
|
|
|
|
exPdf = new javax.swing.JButton();
|
|
|
|
|
outputPlaceBox = new javax.swing.JComboBox();
|
|
|
|
|
jLabel5 = new javax.swing.JLabel();
|
|
|
|
|
|
|
|
|
|
setClosable(true);
|
|
|
|
|
setIconifiable(true);
|
|
|
|
@ -239,38 +269,49 @@ public class CodeExport extends javax.swing.JInternalFrame {
|
|
|
|
|
.addGroup(jPanel2Layout.createSequentialGroup()
|
|
|
|
|
.addContainerGap()
|
|
|
|
|
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addComponent(exHtml, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
|
|
.addComponent(exPdf, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE))
|
|
|
|
|
.addComponent(exPdf, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
|
|
.addComponent(exHtml, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE))
|
|
|
|
|
.addContainerGap())
|
|
|
|
|
);
|
|
|
|
|
jPanel2Layout.setVerticalGroup(
|
|
|
|
|
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addGroup(jPanel2Layout.createSequentialGroup()
|
|
|
|
|
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
|
|
.addGap(18, 18, 18)
|
|
|
|
|
.addComponent(exHtml)
|
|
|
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
|
|
.addComponent(exPdf))
|
|
|
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
|
|
|
|
.addComponent(exPdf)
|
|
|
|
|
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
outputPlaceBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Below code", "Above code", "No" }));
|
|
|
|
|
outputPlaceBox.setSelectedIndex(2);
|
|
|
|
|
|
|
|
|
|
jLabel5.setText("Include output:");
|
|
|
|
|
|
|
|
|
|
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
|
|
|
|
|
jPanel1.setLayout(jPanel1Layout);
|
|
|
|
|
jPanel1Layout.setHorizontalGroup(
|
|
|
|
|
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
|
|
|
|
.addContainerGap()
|
|
|
|
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
|
|
|
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
|
|
|
|
.addComponent(jLabel5)
|
|
|
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
|
|
|
|
.addComponent(outputPlaceBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
|
|
|
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
|
|
|
|
.addComponent(jLabel1)
|
|
|
|
|
.addGap(18, 18, 18)
|
|
|
|
|
.addComponent(titleBox, javax.swing.GroupLayout.DEFAULT_SIZE, 154, Short.MAX_VALUE))
|
|
|
|
|
.addComponent(titleBox, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
|
|
.addGap(0, 0, Short.MAX_VALUE))
|
|
|
|
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
|
|
|
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addComponent(jLabel2)
|
|
|
|
|
.addComponent(jLabel3))
|
|
|
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
|
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addComponent(dateBox)
|
|
|
|
|
.addComponent(authBox))))
|
|
|
|
|
.addComponent(authBox)
|
|
|
|
|
.addComponent(dateBox))))
|
|
|
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
|
|
|
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
|
|
|
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
|
|
|
@ -278,16 +319,14 @@ public class CodeExport extends javax.swing.JInternalFrame {
|
|
|
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
|
|
.addComponent(jButton1))
|
|
|
|
|
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE))
|
|
|
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
|
|
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
|
|
.addContainerGap())
|
|
|
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
|
|
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
|
|
|
);
|
|
|
|
|
jPanel1Layout.setVerticalGroup(
|
|
|
|
|
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
|
|
|
|
.addGap(5, 5, 5)
|
|
|
|
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
|
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
|
|
|
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
|
|
|
.addComponent(titleBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
|
@ -295,7 +334,8 @@ public class CodeExport extends javax.swing.JInternalFrame {
|
|
|
|
|
.addComponent(jLabel4)
|
|
|
|
|
.addComponent(jButton1))
|
|
|
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
|
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
|
|
|
|
.addComponent(jScrollPane2)
|
|
|
|
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
|
|
|
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
|
|
|
.addComponent(jLabel2)
|
|
|
|
@ -303,25 +343,33 @@ public class CodeExport extends javax.swing.JInternalFrame {
|
|
|
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
|
|
|
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
|
|
|
.addComponent(dateBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
|
|
.addComponent(jLabel3)))
|
|
|
|
|
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE))))
|
|
|
|
|
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
|
|
|
|
.addComponent(jLabel3))
|
|
|
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
|
|
|
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
|
|
|
.addComponent(jLabel5)
|
|
|
|
|
.addComponent(outputPlaceBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
|
|
|
.addGap(0, 0, Short.MAX_VALUE)))
|
|
|
|
|
.addGap(0, 0, Short.MAX_VALUE))
|
|
|
|
|
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
|
|
|
|
.addGap(0, 0, 0))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
|
|
|
|
getContentPane().setLayout(layout);
|
|
|
|
|
layout.setHorizontalGroup(
|
|
|
|
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addComponent(jScrollPane1)
|
|
|
|
|
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
|
|
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 583, Short.MAX_VALUE)
|
|
|
|
|
.addGroup(layout.createSequentialGroup()
|
|
|
|
|
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
|
|
.addGap(0, 10, Short.MAX_VALUE))
|
|
|
|
|
);
|
|
|
|
|
layout.setVerticalGroup(
|
|
|
|
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addGroup(layout.createSequentialGroup()
|
|
|
|
|
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 268, Short.MAX_VALUE)
|
|
|
|
|
.addGap(4, 4, 4)
|
|
|
|
|
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 273, Short.MAX_VALUE)
|
|
|
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
|
|
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
|
|
.addGap(10, 10, 10))
|
|
|
|
|
.addContainerGap())
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
pack();
|
|
|
|
@ -424,10 +472,12 @@ public class CodeExport extends javax.swing.JInternalFrame {
|
|
|
|
|
private javax.swing.JLabel jLabel2;
|
|
|
|
|
private javax.swing.JLabel jLabel3;
|
|
|
|
|
private javax.swing.JLabel jLabel4;
|
|
|
|
|
private javax.swing.JLabel jLabel5;
|
|
|
|
|
private javax.swing.JPanel jPanel1;
|
|
|
|
|
private javax.swing.JPanel jPanel2;
|
|
|
|
|
private javax.swing.JScrollPane jScrollPane1;
|
|
|
|
|
private javax.swing.JScrollPane jScrollPane2;
|
|
|
|
|
private javax.swing.JComboBox outputPlaceBox;
|
|
|
|
|
private javax.swing.JTextPane previewPane;
|
|
|
|
|
private javax.swing.JTextField titleBox;
|
|
|
|
|
// End of variables declaration//GEN-END:variables
|
|
|
|
|