]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.debug.ui/src/org/simantics/debug/ui/SessionDebuggerView.java
Externalize strings in org.simantics.debug.ui
[simantics/platform.git] / bundles / org.simantics.debug.ui / src / org / simantics / debug / ui / SessionDebuggerView.java
index 0e0363fa87ec842b59a65d9119db15cc2a4a4135..1426afa6dc08af020fbabbf9cf619c4987265b7c 100644 (file)
@@ -22,6 +22,7 @@ import java.util.Set;
 
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
+import org.eclipse.osgi.util.NLS;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.browser.Browser;
 import org.eclipse.swt.custom.CTabFolder;
@@ -51,7 +52,7 @@ import org.simantics.views.swt.SimanticsView;
 @SuppressWarnings("deprecation")
 public class SessionDebuggerView extends SimanticsView {
 
-    public static final String VIEW_ID = "org.simantics.debug.sessionDebugger";
+    public static final String VIEW_ID = "org.simantics.debug.sessionDebugger"; //$NON-NLS-1$
 
     private CTabFolder folder;
     private Text commandLine;
@@ -63,7 +64,7 @@ public class SessionDebuggerView extends SimanticsView {
 
     @Override
     protected Set<String> getBrowseContexts() {
-        return Collections.singleton("");
+        return Collections.singleton(""); //$NON-NLS-1$
     }
 
     private CTabItem createItem(int index, CTabFolder folder, Control control) {
@@ -101,14 +102,14 @@ public class SessionDebuggerView extends SimanticsView {
                     if (historyPosition < 0) {
                         return;
                     } else if (historyPosition == 0) {
-                        commandLine.setText("");
+                        commandLine.setText(""); //$NON-NLS-1$
                         historyPosition = -1;
                     } else {
                         commandLine.setText(history.get(--historyPosition));
                     }
                 } else if (e.keyCode == SWT.ESC) {
                     historyPosition = -1;
-                    commandLine.setText("");
+                    commandLine.setText(""); //$NON-NLS-1$
                 } else if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
                     applyCommand(commandLine.getText());
                 }
@@ -116,7 +117,7 @@ public class SessionDebuggerView extends SimanticsView {
         });
 
         CTabItem shellItem = createItem(0, folder, shell);
-        shellItem.setText("Shell");
+        shellItem.setText(Messages.SessionDebuggerView_Shell);
 
 //        SessionDebugger deprecated = new SessionDebugger(folder, SWT.NONE, Simantics.getSession());
 //        deprecated.initializeUI();
@@ -140,7 +141,7 @@ public class SessionDebuggerView extends SimanticsView {
         } catch (DatabaseException e) {
             Activator.getDefault().getLog().log(
                     new Status(IStatus.ERROR, Activator.PLUGIN_ID,
-                            "Unexpected exception while applying command " + command, e));
+                            Messages.SessionDebuggerView_ActivatorUnexpectedException + command, e));
         }
     }
 
@@ -152,16 +153,16 @@ public class SessionDebuggerView extends SimanticsView {
                 Path p = (Path) output;
                 long size = Files.size(p);
                 if (size < (1L << 16)) {
-                    terminal.addFirst(new String(Files.readAllBytes(p), "UTF-8"));
+                    terminal.addFirst(new String(Files.readAllBytes(p), "UTF-8")); //$NON-NLS-1$
                 }
-                terminal.addFirst("Wrote command '" + command + "' output to file " + p);
+                terminal.addFirst(NLS.bind(Messages.SessionDebuggerView_WroteCommand ,new Object[] { command  , p})); 
             } catch (IOException e) {
                 Activator.getDefault().getLog().log(
                         new Status(IStatus.ERROR, Activator.PLUGIN_ID,
-                                "Unexpected I/O exception while applying command " + command, e));
+                                NLS.bind(Messages.SessionDebuggerView_ActivatorUnexpectedIOException , new Object[]{ command, e})));
             }
         } else {
-            throw new IllegalArgumentException("Unsupported output argument type " + output);
+            throw new IllegalArgumentException("Unsupported output argument type " + output); //$NON-NLS-1$
         }
         if (terminal.size() > 10)
             terminal.removeLast();
@@ -176,7 +177,7 @@ public class SessionDebuggerView extends SimanticsView {
     private void apply(String command, Object data) {
         if (data instanceof String) {
             SWTUtils.asyncExec(commandLine, () -> {
-                commandLine.setText("");
+                commandLine.setText(""); //$NON-NLS-1$
                 addHistory(command, data);
                 console.setText(formatTerminal());
             });
@@ -184,33 +185,33 @@ public class SessionDebuggerView extends SimanticsView {
             SWTUtils.asyncExec(commandLine, () -> {
                 try {
                     addHistory(command, dumpListenerReport((ListenerReport) data));
-                    commandLine.setText("");
+                    commandLine.setText(""); //$NON-NLS-1$
                     console.setText(formatTerminal());
                 } catch (IOException e) {
                     Activator.getDefault().getLog().log(
                             new Status(IStatus.ERROR, Activator.PLUGIN_ID,
-                                    "Unexpected I/O exception while applying command " + command, e));
+                                    Messages.SessionDebuggerView_ActivatorUnexpectedIOException + command, e));
                 }
             });
         }
     }
 
     private Path dumpListenerReport(ListenerReport data) throws IOException {
-        File f = Simantics.getTempfile("debug", "listenerReport");
-        try (PrintStream out = new PrintStream(f, "UTF-8")) {
-            out.print("<pre>");
+        File f = Simantics.getTempfile("debug", "listenerReport"); //$NON-NLS-1$ //$NON-NLS-2$
+        try (PrintStream out = new PrintStream(f, "UTF-8")) { //$NON-NLS-1$
+            out.print("<pre>"); //$NON-NLS-1$
             data.print(out);
-            out.print("</pre>");
+            out.print("</pre>"); //$NON-NLS-1$
         }
         return f.toPath();
     }
 
     private String formatTerminal() {
         StringBuilder b = new StringBuilder();
-        b.append("<html><head/><body>\n");
+        b.append("<html><head/><body>\n"); //$NON-NLS-1$
         for (String s : terminal)
-            b.append(s).append("<br/>\n");
-        b.append("</body></html>");
+            b.append(s).append("<br/>\n"); //$NON-NLS-1$
+        b.append("</body></html>"); //$NON-NLS-1$
         return b.toString();
     }