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;
@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;
@Override
protected Set<String> getBrowseContexts() {
- return Collections.singleton("");
+ return Collections.singleton(""); //$NON-NLS-1$
}
private CTabItem createItem(int index, CTabFolder folder, Control control) {
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());
}
});
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();
} 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));
}
}
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();
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());
});
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();
}