Skip to content

Commit 93389e0

Browse files
committed
Insert dummy text at current caret position
TODO: Replace dummy text with timestamp.
1 parent 8e93de0 commit 93389e0

3 files changed

Lines changed: 23 additions & 3 deletions

File tree

nbproject/genfiles.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
build.xml.data.CRC32=43fc1f1b
1+
build.xml.data.CRC32=6e79f9f7
22
build.xml.script.CRC32=3fa314a7
33
build.xml.stylesheet.CRC32=15ca8a54@2.75.1
44
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
55
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6-
nbproject/build-impl.xml.data.CRC32=43fc1f1b
6+
nbproject/build-impl.xml.data.CRC32=6e79f9f7
77
nbproject/build-impl.xml.script.CRC32=8f8bb75c
88
nbproject/build-impl.xml.stylesheet.CRC32=49aa68b0@2.75.1

nbproject/project.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66
<code-name-base>com.github.zoliszabo.netbeans.quickinsert</code-name-base>
77
<standalone/>
88
<module-dependencies>
9+
<dependency>
10+
<code-name-base>org.netbeans.modules.editor.lib2</code-name-base>
11+
<build-prerequisite/>
12+
<compile-dependency/>
13+
<run-dependency>
14+
<release-version>1</release-version>
15+
<specification-version>2.21.1.55.3</specification-version>
16+
</run-dependency>
17+
</dependency>
918
<dependency>
1019
<code-name-base>org.openide.awt</code-name-base>
1120
<build-prerequisite/>

src/com/github/zoliszabo/netbeans/quickinsert/InsertCurrentTimestamp.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@
77

88
import java.awt.event.ActionEvent;
99
import java.awt.event.ActionListener;
10+
import javax.swing.text.BadLocationException;
11+
import javax.swing.text.JTextComponent;
12+
import org.netbeans.api.editor.EditorRegistry;
1013
import org.openide.awt.ActionID;
1114
import org.openide.awt.ActionReference;
1215
import org.openide.awt.ActionReferences;
1316
import org.openide.awt.ActionRegistration;
17+
import org.openide.util.Exceptions;
1418
import org.openide.util.NbBundle.Messages;
1519

1620
@ActionID(
@@ -31,6 +35,13 @@ public final class InsertCurrentTimestamp implements ActionListener {
3135

3236
@Override
3337
public void actionPerformed(ActionEvent e) {
34-
// TODO implement action body
38+
JTextComponent lastFocusedEditor = EditorRegistry.lastFocusedComponent();
39+
if (lastFocusedEditor != null) {
40+
try {
41+
lastFocusedEditor.getDocument().insertString(lastFocusedEditor.getCaretPosition(), "ABCD", null);
42+
} catch (BadLocationException ex) {
43+
Exceptions.printStackTrace(ex);
44+
}
45+
}
3546
}
3647
}

0 commit comments

Comments
 (0)