Skip to content

Commit d2cf751

Browse files
committed
added localization for the notebook features
cleanup of some unused code and added license header to missing files formatted files and removed unused imports fixed localization issue updated ajv to latest version: 8.17.1 updated artifactory urls fixed the execution status issue removed console.log and replaced with standard extension logger updated open jshell label
1 parent bf994f1 commit d2cf751

24 files changed

+223
-109
lines changed

nbcode/notebooks/src/org/netbeans/modules/nbcode/java/notebook/CellState.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ protected CompletableFuture<CellStateResponse> requestLatestCellState() {
144144
}
145145
return client.getNotebookCellState(new NotebookCellStateParams(notebookUri, cellUri));
146146
}
147-
148-
protected VersionAwareContent getVersionAwareContent(){
147+
148+
protected VersionAwareContent getVersionAwareContent() {
149149
return this.content.get();
150150
}
151151

nbcode/notebooks/src/org/netbeans/modules/nbcode/java/notebook/JshellStreamsHandler.java

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,65 +25,66 @@
2525

2626
/**
2727
* Handles JShell output and error streams for notebook execution.
28-
*
28+
*
2929
* @author atalati
3030
*/
3131
public class JshellStreamsHandler implements AutoCloseable {
32+
3233
private static final Logger LOG = Logger.getLogger(JshellStreamsHandler.class.getName());
3334
private final String notebookId;
3435
private final StreamingOutputStream outStream;
3536
private final StreamingOutputStream errStream;
3637
private final PrintStream printOutStream;
3738
private final PrintStream printErrStream;
3839
private final InputStream inputStream;
39-
40+
4041
public JshellStreamsHandler(String notebookId, BiConsumer<String, byte[]> streamCallback) {
4142
this(notebookId, streamCallback, streamCallback);
4243
}
43-
44-
public JshellStreamsHandler(String notebookId,
45-
BiConsumer<String, byte[]> outStreamCallback,
46-
BiConsumer<String, byte[]> errStreamCallback) {
44+
45+
public JshellStreamsHandler(String notebookId,
46+
BiConsumer<String, byte[]> outStreamCallback,
47+
BiConsumer<String, byte[]> errStreamCallback) {
4748
if (notebookId == null || notebookId.trim().isEmpty()) {
4849
throw new IllegalArgumentException("Notebook Id cannot be null or empty");
4950
}
50-
51+
5152
this.notebookId = notebookId;
5253
this.outStream = new StreamingOutputStream(createCallback(outStreamCallback));
5354
this.errStream = new StreamingOutputStream(createCallback(errStreamCallback));
5455
this.printOutStream = new PrintStream(outStream);
5556
this.printErrStream = new PrintStream(errStream);
5657
this.inputStream = new CustomInputStream(LanguageClientInstance.getInstance().getClient());
5758
}
58-
59+
5960
private Consumer<byte[]> createCallback(BiConsumer<String, byte[]> callback) {
6061
return callback != null ? output -> callback.accept(notebookId, output) : null;
6162
}
62-
63+
6364
public void setOutStreamCallback(BiConsumer<String, byte[]> callback) {
6465
outStream.setCallback(createCallback(callback));
6566
}
66-
67+
6768
public void setErrStreamCallback(BiConsumer<String, byte[]> callback) {
6869
errStream.setCallback(createCallback(callback));
6970
}
70-
71+
7172
public PrintStream getPrintOutStream() {
7273
return printOutStream;
7374
}
74-
75+
7576
public PrintStream getPrintErrStream() {
7677
return printErrStream;
7778
}
78-
79+
7980
public InputStream getInputStream() {
8081
return inputStream;
8182
}
82-
83+
8384
public String getNotebookId() {
8485
return notebookId;
8586
}
86-
87+
8788
public void flushOutputStreams() {
8889
try {
8990
outStream.flush();
@@ -92,7 +93,7 @@ public void flushOutputStreams() {
9293
// nothing can be done
9394
}
9495
}
95-
96+
9697
@Override
9798
public void close() {
9899
try {
@@ -105,4 +106,4 @@ public void close() {
105106
LOG.log(Level.WARNING, "IOException occurred while closing the streams {0}", ex.getMessage());
106107
}
107108
}
108-
}
109+
}

nbcode/notebooks/src/org/netbeans/modules/nbcode/java/notebook/LanguageClientInstance.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
* @author atalati
2424
*/
2525
public class LanguageClientInstance {
26+
2627
private WeakReference<NbCodeLanguageClient> client = null;
2728

2829
private LanguageClientInstance() {
@@ -31,17 +32,17 @@ private LanguageClientInstance() {
3132
public static LanguageClientInstance getInstance() {
3233
return LanguageClientInstance.Singleton.instance;
3334
}
34-
35+
3536
private static class Singleton {
3637

3738
private static final LanguageClientInstance instance = new LanguageClientInstance();
3839
}
39-
40-
public NbCodeLanguageClient getClient(){
41-
return this.client == null ? null: this.client.get();
40+
41+
public NbCodeLanguageClient getClient() {
42+
return this.client == null ? null : this.client.get();
4243
}
43-
44-
public void setClient(NbCodeLanguageClient client){
44+
45+
public void setClient(NbCodeLanguageClient client) {
4546
this.client = new WeakReference<>(client);
4647
}
4748
}

nbcode/notebooks/src/org/netbeans/modules/nbcode/java/notebook/NotebookCommandsHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public CompletableFuture<Object> runCommand(String command, List<Object> argumen
4848

4949
switch (command) {
5050
case NBLS_JSHELL_EXEC:
51-
return CodeEval.getInstance().evaluate(arguments).thenApply(list -> (Object)list);
51+
return CodeEval.getInstance().evaluate(arguments).thenApply(list -> (Object) list);
5252
case NBLS_JSHELL_INTERRUPT:
5353
return CompletableFuture.completedFuture(CodeEval.getInstance().interrupt(arguments));
5454
case NBLS_OPEN_PROJECT_JSHELL:

nbcode/notebooks/src/org/netbeans/modules/nbcode/java/notebook/NotebookDocumentServiceHandlerImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,16 @@ public class NotebookDocumentServiceHandlerImpl implements NotebookDocumentServi
8585
public void didOpen(DidOpenNotebookDocumentParams params) {
8686
try {
8787
NbCodeLanguageClient client = LanguageClientInstance.getInstance().getClient();
88-
if(client == null){
88+
if (client == null) {
8989
return;
9090
}
91-
client.showStatusBarMessage(new ShowStatusMessageParams(MessageType.Info,"Intializing Java kernel for notebook."));
92-
NotebookSessionManager.getInstance().createSession(params.getNotebookDocument()).whenComplete((JShell jshell,Throwable t) -> {
91+
client.showStatusBarMessage(new ShowStatusMessageParams(MessageType.Info, "Intializing Java kernel for notebook."));
92+
NotebookSessionManager.getInstance().createSession(params.getNotebookDocument()).whenComplete((JShell jshell, Throwable t) -> {
9393
if (t == null) {
9494
client.showStatusBarMessage(new ShowStatusMessageParams(MessageType.Info, "Java kernel initialized successfully"));
9595
} else {
9696
// if package import fails user is not informed ?
97-
client.showMessage(new MessageParams(MessageType.Error,"Error could not initialize Java kernel for the notebook."));
97+
client.showMessage(new MessageParams(MessageType.Error, "Error could not initialize Java kernel for the notebook."));
9898
LOG.log(Level.SEVERE, "Error could not initialize Java kernel for the notebook. : {0}", t.getMessage());
9999
}
100100
});

nbcode/notebooks/src/org/netbeans/modules/nbcode/java/notebook/NotebookDocumentStateManager.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ private void updateNotebookCellContent(NotebookDocumentChangeEventCellTextConten
150150
}
151151
int newVersion = contentChange.getDocument().getVersion();
152152
String currentContent = cellState.getContent();
153-
153+
154154
try {
155155
String updatedContent = applyContentChanges(currentContent, contentChange.getChanges());
156156
cellState.setContent(updatedContent, newVersion);
@@ -220,6 +220,7 @@ private String applyRangeChange(String content, TextDocumentContentChangeEvent c
220220

221221
return result.toString();
222222
}
223+
223224
// protected methods for ease of unit testing
224225
protected void addNewCellState(NotebookCell cell, TextDocumentItem item) {
225226
if (cell == null || item == null) {
@@ -236,8 +237,8 @@ protected void addNewCellState(NotebookCell cell, TextDocumentItem item) {
236237
throw new RuntimeException("Failed to create cell state", e);
237238
}
238239
}
239-
240-
protected Map<String, CellState> getCellsMap(){
240+
241+
protected Map<String, CellState> getCellsMap() {
241242
return cellsMap;
242243
}
243244
}

nbcode/notebooks/src/org/netbeans/modules/nbcode/java/project/CommandHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import java.util.ArrayList;
1919
import java.util.List;
2020
import java.util.concurrent.CompletableFuture;
21-
import java.util.concurrent.ExecutionException;
2221
import java.util.logging.Level;
2322
import java.util.logging.Logger;
2423
import org.netbeans.api.project.Project;

nbcode/notebooks/src/org/netbeans/modules/nbcode/java/project/ProjectConfigurationUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public static boolean isModularJDK(JavaPlatform pl) {
169169
}
170170
return false;
171171
}
172-
172+
173173
public static CompletableFuture<Boolean> buildProject(Project project) {
174174
CompletableFuture<Boolean> future = new CompletableFuture<>();
175175
ActionProvider p = project.getLookup().lookup(ActionProvider.class);

nbcode/notebooks/src/org/netbeans/modules/nbcode/java/project/ProjectModulePathConfigurationUtils.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,13 @@
3030
import org.netbeans.api.java.classpath.JavaClassPathConstants;
3131
import org.netbeans.api.java.platform.JavaPlatform;
3232
import org.netbeans.api.java.queries.BinaryForSourceQuery;
33-
import org.netbeans.api.java.queries.SourceLevelQuery;
3433
import org.netbeans.api.java.source.ClassIndex;
3534
import org.netbeans.api.java.source.ClasspathInfo;
3635
import org.netbeans.api.java.source.SourceUtils;
3736
import org.netbeans.api.project.Project;
3837
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
3938
import org.openide.filesystems.FileObject;
4039
import org.openide.filesystems.URLMapper;
41-
import org.openide.modules.SpecificationVersion;
4240

4341
/**
4442
* Methods in this class are taken from the org.netbeans.modules.jshell.support

vscode/l10n/bundle.l10n.en.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,17 @@
9999
"jdk.extension.error_msg.notEnabled": "{SERVER_NAME} not enabled",
100100
"jdk.telemetry.consent": "Allow anonymous telemetry data to be reported to Oracle? You may opt-out or in at any time from the Settings for jdk.telemetry.enabled.",
101101
"jdk.configChanged": "Configurations updated for oracle java extenion , please reload the window to restart the extension.",
102-
"jdk.configChangedFailed": "Error while updating extension configurations , please reload the window to restart the extension."
102+
"jdk.configChangedFailed": "Error while updating extension configurations , please reload the window to restart the extension.",
103+
"jdk.notebook.create.select.workspace.folder": "Select workspace folder in which notebook needs to be created",
104+
"jdk.notebook.create.select.workspace.folder.label": "Select Notebook creation folder",
105+
"jdk.notebook.create.select.workspace.folder.title": "Select folder in which notebook needs to be created",
106+
"jdk.notebook.create.error_msg.path.not.selected": "Path not selected for creating new notebook",
107+
"jdk.notebook.create.error_msg.invalid.notebook.name": "Invalid notebook file name",
108+
"jdk.notebook.create.error_msg.invalid.notebook.path": "Notebook already exists, please try creating with some different name",
109+
"jdk.notebook.create.error_msg.failed": "Failed to create new notebook",
110+
"jdk.jshell.open.error_msg.failed": "Some error occurred while launching jshell",
111+
"jdk.notebook.project.mapping.error_msg.notebook.not.found": "Please open any ${fileExtension} notebook",
112+
"jdk.notebook.project.mapping.error_msg.project.not.selected": "No project selected",
113+
"jdk.notebook.project.mapping.error_msg.failed": "Error occurred while changing notebook project context",
114+
"jdk.notebook.create.new.notebook.input.name": "Enter new Java notebook ({fileExtension}) file name"
103115
}

0 commit comments

Comments
 (0)