diff --git a/SQLFormatter.jar b/SQLFormatter.jar
index 56529df..a7116c8 100644
Binary files a/SQLFormatter.jar and b/SQLFormatter.jar differ
diff --git a/resources/META-INF/plugin.xml b/resources/META-INF/plugin.xml
index d5e9132..02fb318 100644
--- a/resources/META-INF/plugin.xml
+++ b/resources/META-INF/plugin.xml
@@ -23,6 +23,7 @@
com.intellij.modules.lang
+
@@ -30,4 +31,4 @@
-
\ No newline at end of file
+
diff --git a/src/SQLFormatterConfig.java b/src/SQLFormatterConfig.java
new file mode 100644
index 0000000..212d83b
--- /dev/null
+++ b/src/SQLFormatterConfig.java
@@ -0,0 +1,39 @@
+import com.intellij.openapi.components.PersistentStateComponent;
+import com.intellij.openapi.components.ServiceManager;
+import com.intellij.openapi.components.State;
+import com.intellij.openapi.components.Storage;
+import com.intellij.util.xmlb.XmlSerializerUtil;
+import org.jetbrains.annotations.NotNull;
+
+@State(
+ name = "SQLFormatterConfig",
+ storages = {
+ @Storage("intellij-plugin-SQLFormatter.xml")
+ }
+)
+
+public class SQLFormatterConfig implements PersistentStateComponent {
+ private boolean removeNewLineCode = false;
+
+ @Override
+ public SQLFormatterConfig getState() {
+ return this;
+ }
+
+ @Override
+ public void loadState(@NotNull SQLFormatterConfig config) {
+ XmlSerializerUtil.copyBean(config, this);
+ }
+
+ public static SQLFormatterConfig getInstance() {
+ return ServiceManager.getService(SQLFormatterConfig.class);
+ }
+
+ public boolean isRemoveNewLineCode() {
+ return removeNewLineCode;
+ }
+
+ public void setRemoveNewLineCode(boolean removeNewLineCode) {
+ this.removeNewLineCode = removeNewLineCode;
+ }
+}
diff --git a/src/SQLFormatterToolWindow.form b/src/SQLFormatterToolWindow.form
index 46e8a66..b6ddc94 100644
--- a/src/SQLFormatterToolWindow.form
+++ b/src/SQLFormatterToolWindow.form
@@ -1,6 +1,6 @@
\ No newline at end of file
+
diff --git a/src/SQLFormatterToolWindow.java b/src/SQLFormatterToolWindow.java
index 43465f9..40680a1 100644
--- a/src/SQLFormatterToolWindow.java
+++ b/src/SQLFormatterToolWindow.java
@@ -18,6 +18,7 @@ public class SQLFormatterToolWindow implements ToolWindowFactory {
private JButton buttonFormat;
private JTextArea textArea;
private JLabel labelMessage;
+ private JCheckBox removeNewLineCode;
private Formatter sqlFormatter = new BasicFormatterImpl();
@@ -25,8 +26,18 @@ public SQLFormatterToolWindow() {
buttonFormat.addActionListener(e -> {
labelMessage.setText("");
String text = textArea.getText();
+ boolean shouldRemoveNewLineCode = removeNewLineCode.isSelected();
+ if (shouldRemoveNewLineCode) {
+ text = text.replace("\r", "").replace("\n", "");
+ }
String formattedText = sqlFormatter.format(text);
textArea.setText(formattedText);
+
+ SQLFormatterConfig currentConfig = SQLFormatterConfig.getInstance();
+ if (currentConfig != null) {
+ currentConfig.setRemoveNewLineCode(shouldRemoveNewLineCode);
+ SQLFormatterConfig.getInstance().loadState(currentConfig);
+ }
});
}
@@ -35,6 +46,11 @@ public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindo
ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
Content content = contentFactory.createContent(toolWindowContent, "", false);
toolWindow.getContentManager().addContent(content);
+
+ SQLFormatterConfig config = SQLFormatterConfig.getInstance();
+ if (config.isRemoveNewLineCode()) {
+ removeNewLineCode.setSelected(true);
+ }
}
{
@@ -53,10 +69,10 @@ public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindo
*/
private void $$$setupUI$$$() {
toolWindowContent = new JPanel();
- toolWindowContent.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1));
+ toolWindowContent.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1));
buttonFormat = new JButton();
buttonFormat.setText("Format");
- toolWindowContent.add(buttonFormat, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+ toolWindowContent.add(buttonFormat, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final JScrollPane scrollPane1 = new JScrollPane();
toolWindowContent.add(scrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
textArea = new JTextArea();
@@ -65,6 +81,10 @@ public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindo
labelMessage.setForeground(new Color(-2215827));
labelMessage.setText("");
toolWindowContent.add(labelMessage, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+ removeNewLineCode = new JCheckBox();
+ removeNewLineCode.setSelected(false);
+ removeNewLineCode.setText("Remove new line code");
+ toolWindowContent.add(removeNewLineCode, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
}
/**
@@ -73,4 +93,5 @@ public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindo
public JComponent $$$getRootComponent$$$() {
return toolWindowContent;
}
-}
\ No newline at end of file
+
+}