Skip to content

Commit a43229b

Browse files
committed
[FEATURE] custom wrapping settings for CSV
Fixes #36
1 parent da51eb9 commit a43229b

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

src/main/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvCodeStyleSettingsProvider.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import com.intellij.application.options.CodeStyleAbstractConfigurable;
44
import com.intellij.application.options.CodeStyleAbstractPanel;
55
import com.intellij.application.options.TabbedLanguageCodeStylePanel;
6-
import com.intellij.application.options.codeStyle.WrappingAndBracesPanel;
7-
import com.intellij.lang.Language;
86
import com.intellij.openapi.editor.Editor;
97
import com.intellij.openapi.editor.colors.EditorColorsScheme;
108
import com.intellij.openapi.editor.ex.EditorEx;
@@ -54,17 +52,23 @@ public CsvCodeStyleMainPanel(CodeStyleSettings currentSettings, CodeStyleSetting
5452
@Override
5553
protected void initTabs(CodeStyleSettings settings) {
5654
addTab(new CsvCodeStyleOptionTreeWithPreviewPanel(settings));
55+
addTab(new CsvWrappingPanel(settings));
5756
}
5857

59-
public class CsvCodeStyleOptionTreeWithPreviewPanel extends WrappingAndBracesPanel {
60-
61-
public CsvCodeStyleOptionTreeWithPreviewPanel(CodeStyleSettings settings) {
58+
protected class CsvWrappingPanel extends MyWrappingAndBracesPanel {
59+
public CsvWrappingPanel(CodeStyleSettings settings) {
6260
super(settings);
6361
}
6462

6563
@Override
66-
public LanguageCodeStyleSettingsProvider.SettingsType getSettingsType() {
67-
return LanguageCodeStyleSettingsProvider.SettingsType.LANGUAGE_SPECIFIC;
64+
public String getTabTitle() {
65+
return "Wrapping";
66+
}
67+
}
68+
69+
protected class CsvCodeStyleOptionTreeWithPreviewPanel extends MyWrappingAndBracesPanel {
70+
public CsvCodeStyleOptionTreeWithPreviewPanel(CodeStyleSettings settings) {
71+
super(settings);
6872
}
6973

7074
@Override
@@ -73,8 +77,8 @@ protected String getTabTitle() {
7377
}
7478

7579
@Override
76-
public Language getDefaultLanguage() {
77-
return CsvCodeStyleMainPanel.this.getDefaultLanguage();
80+
public LanguageCodeStyleSettingsProvider.SettingsType getSettingsType() {
81+
return LanguageCodeStyleSettingsProvider.SettingsType.LANGUAGE_SPECIFIC;
7882
}
7983

8084
private void updatePreviewHighlighter(EditorEx editor) {

src/main/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvLanguageCodeStyleSettingsProvider.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ public void customizeSettings(@NotNull CodeStyleSettingsCustomizable consumer, @
5757
"Leading whitespaces",
5858
"Tabularize (ignores Trimming settings)");
5959
}
60+
61+
if (settingsType == SettingsType.WRAPPING_AND_BRACES_SETTINGS) {
62+
consumer.showStandardOptions(
63+
CodeStyleSettingsCustomizable.WrappingOrBraceOption.RIGHT_MARGIN.toString(),
64+
CodeStyleSettingsCustomizable.WrappingOrBraceOption.WRAP_LONG_LINES.toString(),
65+
CodeStyleSettingsCustomizable.WrappingOrBraceOption.WRAP_ON_TYPING.toString()
66+
);
67+
}
6068
}
6169

6270
@Override
@@ -79,6 +87,9 @@ public CommonCodeStyleSettings getDefaultCommonSettings() {
7987
commonSettings.getIndentOptions().USE_TAB_CHARACTER = true;
8088
commonSettings.getIndentOptions().SMART_TABS = false;
8189
commonSettings.getIndentOptions().KEEP_INDENTS_ON_EMPTY_LINES = true;
90+
commonSettings.WRAP_ON_TYPING = CommonCodeStyleSettings.WrapOnTyping.NO_WRAP.intValue;
91+
commonSettings.WRAP_LONG_LINES = false;
92+
commonSettings.RIGHT_MARGIN = Integer.MAX_VALUE;
8293
return commonSettings;
8394
}
8495
}

0 commit comments

Comments
 (0)