Skip to content

Commit cc70229

Browse files
committed
replace all deprecated API
1 parent b4ff763 commit cc70229

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvAnnotator.java

+15-16
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import com.intellij.lang.annotation.*;
44
import com.intellij.openapi.editor.markup.TextAttributes;
55
import com.intellij.openapi.util.Key;
6-
import com.intellij.openapi.util.TextRange;
76
import com.intellij.openapi.vcs.ui.FontUtil;
87
import com.intellij.psi.PsiElement;
98
import com.intellij.psi.tree.IElementType;
@@ -60,18 +59,17 @@ public void annotate(@NotNull final PsiElement element, @NotNull final Annotatio
6059
)
6160
);
6261
}
63-
TextRange textRange = columnInfo.getRowInfo(element).getTextRange();
64-
if (textRange.getStartOffset() - csvFile.getTextLength() == 0 && textRange.getStartOffset() > 0) {
65-
textRange = TextRange.from(textRange.getStartOffset() - 1, 1);
66-
}
6762

68-
final Annotation annotation = holder.createAnnotation(CSV_COLUMN_INFO_SEVERITY, textRange, message, tooltip);
69-
annotation.setEnforcedTextAttributes(
70-
CsvEditorSettings.getInstance().getValueColoring() == CsvEditorSettings.ValueColoring.RAINBOW ?
71-
CsvColorSettings.getTextAttributesOfColumn(columnInfo.getColumnIndex(), holder.getCurrentAnnotationSession()) :
72-
null
73-
);
74-
annotation.setNeedsUpdateOnTyping(false);
63+
holder.newAnnotation(CSV_COLUMN_INFO_SEVERITY, message)
64+
.range(element)
65+
.tooltip(tooltip)
66+
.enforcedTextAttributes(
67+
CsvEditorSettings.getInstance().getValueColoring() == CsvEditorSettings.ValueColoring.RAINBOW ?
68+
CsvColorSettings.getTextAttributesOfColumn(columnInfo.getColumnIndex(), holder.getCurrentAnnotationSession()) :
69+
null
70+
)
71+
.needsUpdateOnTyping(false)
72+
.create();
7573
}
7674
}
7775

@@ -98,10 +96,11 @@ protected boolean handleSeparatorElement(@NotNull PsiElement element, @NotNull A
9896
}
9997
}
10098
if (textAttributes != null) {
101-
final TextRange textRange = element.getTextRange();
102-
final Annotation annotation = holder.createAnnotation(CSV_COLUMN_INFO_SEVERITY, textRange, showInfoBalloon(holder.getCurrentAnnotationSession()) ? "↹" : null);
103-
annotation.setEnforcedTextAttributes(textAttributes);
104-
annotation.setNeedsUpdateOnTyping(false);
99+
holder.newAnnotation(CSV_COLUMN_INFO_SEVERITY, showInfoBalloon(holder.getCurrentAnnotationSession()) ? "↹" : null)
100+
.range(element)
101+
.enforcedTextAttributes(textAttributes)
102+
.needsUpdateOnTyping(false)
103+
.create();
105104
}
106105
return true;
107106
}

src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/CsvTableEditorSwing.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ private void initializedUIComponents() {
145145
tblEditor.setDefaultEditor(String.class, cellEditor);
146146
tblEditor.setDefaultEditor(Object.class, cellEditor);
147147
tblEditor.registerKeyboardAction(this.tableEditorActions.undo,
148-
KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_MASK), JComponent.WHEN_FOCUSED);
148+
KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_DOWN_MASK), JComponent.WHEN_FOCUSED);
149149
tblEditor.registerKeyboardAction(this.tableEditorActions.redo,
150-
KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK), JComponent.WHEN_FOCUSED);
150+
KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK), JComponent.WHEN_FOCUSED);
151151
tblEditor.registerKeyboardAction(this.tableEditorActions.redo,
152-
KeyStroke.getKeyStroke(KeyEvent.VK_Y, InputEvent.CTRL_MASK), JComponent.WHEN_FOCUSED);
152+
KeyStroke.getKeyStroke(KeyEvent.VK_Y, InputEvent.CTRL_DOWN_MASK), JComponent.WHEN_FOCUSED);
153153

154154
setFontSize(getGlobalFontSize());
155155
baseFontHeight = getFontHeight();

0 commit comments

Comments
 (0)