X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=bundles%2Forg.simantics.scl.ui%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fui%2Fbrowser%2FSCLDocumentationBrowser.java;h=f5cdfbf60120c9928f2c745a7e12b4e984c95fdd;hb=9712014e959584157b02e594be8719c151b8f5b0;hp=fe871ab1c5cc58452d85c6610bc73307cbf0282e;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/browser/SCLDocumentationBrowser.java b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/browser/SCLDocumentationBrowser.java index fe871ab1c..f5cdfbf60 100644 --- a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/browser/SCLDocumentationBrowser.java +++ b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/browser/SCLDocumentationBrowser.java @@ -46,14 +46,14 @@ import org.simantics.scl.ui.Activator; 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; @@ -95,9 +95,9 @@ public class SCLDocumentationBrowser { 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(); } @@ -133,29 +133,29 @@ public class SCLDocumentationBrowser { 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); @@ -192,10 +192,10 @@ public class SCLDocumentationBrowser { 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('#'); @@ -206,14 +206,14 @@ public class SCLDocumentationBrowser { } 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 @@ -245,7 +245,7 @@ public class SCLDocumentationBrowser { return; } if(e.keyCode == 'k' || e.keyCode == 'K') { - pageName.setText("?"); + pageName.setText("?"); //$NON-NLS-1$ pageName.setSelection(1); pageName.setFocus(); return; @@ -256,24 +256,24 @@ public class SCLDocumentationBrowser { } } 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$ } } @@ -285,7 +285,7 @@ public class SCLDocumentationBrowser { 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); @@ -327,16 +327,16 @@ public class SCLDocumentationBrowser { @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$ } } } @@ -348,7 +348,7 @@ public class SCLDocumentationBrowser { 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$ } } } @@ -417,6 +417,6 @@ public class SCLDocumentationBrowser { } public void setLocation(String path) { - browser.setUrl("about:" + path); + browser.setUrl("about:" + path); //$NON-NLS-1$ } }