public class SCLDocumentationBrowser {
- public static final String STANDARD_LIBRARY = "StandardLibrary";
+ public static final String STANDARD_LIBRARY = "StandardLibrary"; //$NON-NLS-1$
Browser browser;
Button backButton;
Text pageName;
Button refreshButton;
Button forwardButton;
- String currentPageName = "";
+ String currentPageName = ""; //$NON-NLS-1$
Button saveButton;
Button findButton;
Tree navigationTree;
private void refresh() {
SCLOsgi.SOURCE_REPOSITORY.checkUpdates();
- final Object yOffset = browser.evaluate("return window.pageYOffset !== undefined ? window.pageYOffset : ((document.compatMode || \"\") === \"CSS1Compat\") ? document.documentElement.scrollTop : document.body.scrollTop;");
+ final Object yOffset = browser.evaluate("return window.pageYOffset !== undefined ? window.pageYOffset : ((document.compatMode || \"\") === \"CSS1Compat\") ? document.documentElement.scrollTop : document.body.scrollTop;"); //$NON-NLS-1$
if(yOffset != null)
- executeWhenCompleted("window.scroll(0,"+yOffset+");");
+ executeWhenCompleted("window.scroll(0,"+yOffset+");"); //$NON-NLS-1$ //$NON-NLS-2$
browser.setUrl(locationHistory.get(locationHistoryPosition));
updateNavigationTree();
}
backButton = new Button(buttons, SWT.PUSH);
buttons.setBackground(composite.getDisplay().getSystemColor(SWT.COLOR_GRAY));
- backButton.setToolTipText("Back (Alt-Left)");
+ backButton.setToolTipText(Messages.SCLDocumentationBrowser_BackTT);
backButton.setEnabled(false);
- backButton.setImage(Activator.getInstance().getImageRegistry().get("arrow_left"));
+ backButton.setImage(Activator.getInstance().getImageRegistry().get("arrow_left")); //$NON-NLS-1$
forwardButton = new Button(buttons, SWT.PUSH);
- forwardButton.setToolTipText("Forward (Alt-Right)");
+ forwardButton.setToolTipText(Messages.SCLDocumentationBrowser_ForwardTT);
forwardButton.setEnabled(false);
- forwardButton.setImage(Activator.getInstance().getImageRegistry().get("arrow_right"));
+ forwardButton.setImage(Activator.getInstance().getImageRegistry().get("arrow_right")); //$NON-NLS-1$
refreshButton = new Button(buttons, SWT.PUSH);
- refreshButton.setToolTipText("Refresh page (Ctrl-R)");
- refreshButton.setImage(Activator.getInstance().getImageRegistry().get("arrow_refresh"));
+ refreshButton.setToolTipText(Messages.SCLDocumentationBrowser_RefreshPageTT);
+ refreshButton.setImage(Activator.getInstance().getImageRegistry().get("arrow_refresh")); //$NON-NLS-1$
pageName = new Text(buttons, SWT.BORDER | SWT.SINGLE);
GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(pageName);
findButton = new Button(buttons, SWT.PUSH);
- findButton.setToolTipText("Find SCL definitions (Ctrl-H)");
- findButton.setImage(Activator.getInstance().getImageRegistry().get("find"));
+ findButton.setToolTipText(Messages.SCLDocumentationBrowser_FindSCLDefinitionTT);
+ findButton.setImage(Activator.getInstance().getImageRegistry().get("find")); //$NON-NLS-1$
saveButton = new Button(buttons, SWT.PUSH);
- saveButton.setToolTipText("Save documentation to disk");
- saveButton.setImage(Activator.getInstance().getImageRegistry().get("disk"));
+ saveButton.setToolTipText(Messages.SCLDocumentationBrowser_SaveDocumentationToDiskTT);
+ saveButton.setImage(Activator.getInstance().getImageRegistry().get("disk")); //$NON-NLS-1$
SashForm browserBox = new SashForm(composite, SWT.BORDER | SWT.HORIZONTAL);
GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(browserBox);
browser.addLocationListener(new LocationAdapter() {
public void changing(LocationEvent event) {
String location = event.location;
- if(location.startsWith("about:blank"))
+ if(location.startsWith("about:blank")) //$NON-NLS-1$
return;
newLocation(location);
- if(location.startsWith("about:")) {
+ if(location.startsWith("about:")) { //$NON-NLS-1$
location = location.substring(6);
setCurrentLocation(location);
int hashPos = location.indexOf('#');
}
else
fragment = null;
- if(location.endsWith(".html"))
+ if(location.endsWith(".html")) //$NON-NLS-1$
location = location.substring(0, location.length()-5);
String html = HtmlDocumentationGeneration.generate(SCLOsgi.MODULE_REPOSITORY, location, null);
browser.setText(html);
if(fragment != null)
- executeWhenCompleted("location.hash = \"" + fragment + "\";");
+ executeWhenCompleted("location.hash = \"" + fragment + "\";"); //$NON-NLS-1$ //$NON-NLS-2$
event.doit = false;
}
else
return;
}
if(e.keyCode == 'k' || e.keyCode == 'K') {
- pageName.setText("?");
+ pageName.setText("?"); //$NON-NLS-1$
pageName.setSelection(1);
pageName.setFocus();
return;
}
}
if(e.keyCode == SWT.PAGE_DOWN) {
- browser.execute("window.scrollBy(0,0.8*(window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight));");
+ browser.execute("window.scrollBy(0,0.8*(window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight));"); //$NON-NLS-1$
}
else if(e.keyCode == SWT.PAGE_UP) {
- browser.execute("window.scrollBy(0,-0.8*(window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight));");
+ browser.execute("window.scrollBy(0,-0.8*(window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight));"); //$NON-NLS-1$
}
else if(e.keyCode == SWT.ARROW_DOWN) {
- browser.execute("window.scrollBy(0,100);");
+ browser.execute("window.scrollBy(0,100);"); //$NON-NLS-1$
}
else if(e.keyCode == SWT.ARROW_UP) {
- browser.execute("window.scrollBy(0,-100);");
+ browser.execute("window.scrollBy(0,-100);"); //$NON-NLS-1$
}
else if(e.keyCode == SWT.HOME) {
if(e.widget != pageName)
- browser.execute("window.scroll(0,0);");
+ browser.execute("window.scroll(0,0);"); //$NON-NLS-1$
}
else if(e.keyCode == SWT.END) {
if(e.widget != pageName)
- browser.execute("window.scroll(0,document.body.scrollHeight);");
+ browser.execute("window.scroll(0,document.body.scrollHeight);"); //$NON-NLS-1$
}
}
MouseWheelListener wheelListener = new MouseWheelListener() {
@Override
public void mouseScrolled(MouseEvent e) {
- browser.execute("window.scrollBy(0,"+e.count*(-30)+");");
+ browser.execute("window.scrollBy(0,"+e.count*(-30)+");"); //$NON-NLS-1$ //$NON-NLS-2$
}
};
composite.addMouseWheelListener(wheelListener);
@Override
public void widgetSelected(SelectionEvent e) {
DirectoryDialog dialog = new DirectoryDialog(saveButton.getShell());
- dialog.setText("Select the directory for storing the documentation.");
- dialog.setMessage("Select a directory where the documentation is generated to.");
+ dialog.setText(Messages.SCLDocumentationBrowser_SaveDocumentationDialog_Title);
+ dialog.setMessage(Messages.SCLDocumentationBrowser_SaveDocumentationDialog_Msg);
String directory = dialog.open();
if(directory != null) {
try {
GenerateAllHtmlDocumentation.generate(SCLOsgi.MODULE_REPOSITORY, Paths.get(directory));
} catch (IOException ex) {
ex.printStackTrace();
- ErrorDialog.openError(saveButton.getShell(), "Documentation generation failed", null,
- new Status(Status.ERROR, "org.simantics.scl.ui", 0, ex.toString(), ex));
+ ErrorDialog.openError(saveButton.getShell(), "Documentation generation failed", null, //$NON-NLS-1$
+ new Status(Status.ERROR, "org.simantics.scl.ui", 0, ex.toString(), ex)); //$NON-NLS-1$
}
}
}
if(dialog.open() == SCLDefinitionSelectionDialog.OK) {
SCLValue value = (SCLValue)dialog.getFirstResult();
if(value != null) {
- setLocation(value.getName().module + "#" + HtmlEscape.escape(value.getName().name));
+ setLocation(value.getName().module + "#" + HtmlEscape.escape(value.getName().name)); //$NON-NLS-1$
}
}
}
}
public void setLocation(String path) {
- browser.setUrl("about:" + path);
+ browser.setUrl("about:" + path); //$NON-NLS-1$
}
}