--- /dev/null
+package org.simantics.modeling.ui.scl.imports;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.simantics.modeling.ui.scl.imports.messages"; //$NON-NLS-1$
+ public static String OntologyImportModulesAction_AddOntology;
+ public static String SCLModulesImportModulesAction_AddModulesFromProject;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
public class ModuleSelectionDialog extends FilteredItemsSelectionDialog {
- private static final String SCL_MODULE_SELECTION_DIALOG = "SCL_MODULE_SELECTION_DIALOG";
+ private static final String SCL_MODULE_SELECTION_DIALOG = "SCL_MODULE_SELECTION_DIALOG"; //$NON-NLS-1$
Read<Collection<String>> query;
if(patternText != null && patternText.length() > 0)
patternMatcher.setPattern(patternText);
else
- patternMatcher.setPattern("*");
+ patternMatcher.setPattern("*"); //$NON-NLS-1$
}
@Override
if(getPattern().indexOf('/') > 0)
return matches((String)item);
else {
- for(String part : ((String)item).split("/"))
+ for(String part : ((String)item).split("/")) //$NON-NLS-1$
if(matches(part))
return true;
return false;
TransientCacheListener.<Collection<String>>instance()))
contentProvider.add(module, itemsFilter);
} catch (DatabaseException e) {
- ShowError.showError("Failed to find modules",
- "Exception was thrown during search for modules", e);
+ ShowError.showError("Failed to find modules", //$NON-NLS-1$
+ "Exception was thrown during search for modules", e); //$NON-NLS-1$
close();
}
public static final OntologyImportModulesAction INSTANCE = new OntologyImportModulesAction();
public OntologyImportModulesAction() {
- super("Add ontology", 10.0);
+ super(Messages.OntologyImportModulesAction_AddOntology, 10.0);
}
@Override
public boolean editImports(Shell shell, ArrayList<CommandSessionImportEntry> imports) {
ModuleSelectionDialog dialog = new ModuleSelectionDialog(shell, OntologiesQuery.INSTANCE);
+ dialog.setTitle(Messages.OntologyImportModulesAction_AddOntology);
if(dialog.open() == Dialog.OK) {
for(Object r : dialog.getResult()) {
String uri = (String)r;
}
public String getDefaultLocalName(String ontologyUri) {
- if(ontologyUri.contains("/Layer0-"))
- return "L0";
- if(ontologyUri.contains("/Structural-"))
- return "STR";
- if(ontologyUri.contains("/Modeling-"))
- return "MOD";
- return "";
+ if(ontologyUri.contains("/Layer0-")) //$NON-NLS-1$
+ return "L0"; //$NON-NLS-1$
+ if(ontologyUri.contains("/Structural-")) //$NON-NLS-1$
+ return "STR"; //$NON-NLS-1$
+ if(ontologyUri.contains("/Modeling-")) //$NON-NLS-1$
+ return "MOD"; //$NON-NLS-1$
+ return ""; //$NON-NLS-1$
}
}
public static final SCLModulesImportModulesAction INSTANCE = new SCLModulesImportModulesAction();
public SCLModulesImportModulesAction() {
- super("Add modules from project", 20.0);
+ super(Messages.SCLModulesImportModulesAction_AddModulesFromProject, 20.0);
}
@Override
public boolean editImports(Shell shell, ArrayList<CommandSessionImportEntry> imports) {
ModuleSelectionDialog dialog = new ModuleSelectionDialog(shell,
new SCLModulesQuery(Simantics.getProjectResource()));
+ dialog.setTitle(Messages.SCLModulesImportModulesAction_AddModulesFromProject);
if(dialog.open() == Dialog.OK) {
for(Object r : dialog.getResult()) {
String uri = (String)r;
- new CommandSessionImportEntry(uri, "", true).addTo(imports);
+ new CommandSessionImportEntry(uri, "", true).addTo(imports); //$NON-NLS-1$
}
return true;
}
--- /dev/null
+OntologyImportModulesAction_AddOntology=Add Ontology
+SCLModulesImportModulesAction_AddModulesFromProject=Add Modules from Project
public class Activator extends AbstractUIPlugin {
- public static final String PLUGIN_ID = "org.simantics.scl.ui";
+ public static final String PLUGIN_ID = "org.simantics.scl.ui"; //$NON-NLS-1$
private static Activator INSTANCE;
@Override
protected void initializeImageRegistry(ImageRegistry reg) {
- reg.put("arrow_left", Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/arrow_left.png") );
- reg.put("arrow_right", Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/arrow_right.png") );
- reg.put("arrow_refresh", Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/arrow_refresh.png") );
- reg.put("find", Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/find.png") );
- reg.put("disk", Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/disk.png") );
- reg.put("error", Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/error.png") );
- reg.put("import_error", Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/import_error.png") );
- reg.put("warning", Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/warning.png") );
+ reg.put("arrow_left", Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/arrow_left.png") ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ reg.put("arrow_right", Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/arrow_right.png") ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ reg.put("arrow_refresh", Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/arrow_refresh.png") ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ reg.put("find", Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/find.png") ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ reg.put("disk", Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/disk.png") ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ reg.put("error", Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/error.png") ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ reg.put("import_error", Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/import_error.png") ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ reg.put("warning", Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/warning.png") ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
@Override
@Override
public String getLabel() {
- return name + " :: " + type + " (" + module + ")";
+ return name + " :: " + type + " (" + module + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
@Override
ArrayList<IContentProposal> proposals = new ArrayList<IContentProposal>();
for(SCLValue value : values)
- if(!value.isPrivate() && !(value.getName().name.contains("$") &&
+ if(!value.isPrivate() && !(value.getName().name.contains("$") && //$NON-NLS-1$
Character.isLetter(value.getName().name.charAt(0))))
proposals.add(new SCLContentProposal(value));
prefix = prefix.toLowerCase();
for(Map.Entry<String,Type> entry : session.localNamesForContentProposals().entrySet())
if(entry.getKey().toLowerCase().startsWith(prefix))
- proposals.add(new SCLContentProposal(entry.getKey(), "LocalEnvironment", entry.getValue()));
+ proposals.add(new SCLContentProposal(entry.getKey(), "LocalEnvironment", entry.getValue())); //$NON-NLS-1$
return proposals.toArray(new IContentProposal[proposals.size()]);
}
while (--offset >= 0 && (Character.isJavaIdentifierPart(currentText.charAt(offset)) && !Character.isWhitespace(currentText.charAt(offset))))
length--;
- int nameSpaceBeginRange = currentText.lastIndexOf(".", caretEndRange - 1);
+ int nameSpaceBeginRange = currentText.lastIndexOf(".", caretEndRange - 1); //$NON-NLS-1$
if (nameSpaceBeginRange > length)
length = nameSpaceBeginRange;
int endRange = currentText.length();
public Object execute(ExecutionEvent event) throws ExecutionException {
Display display = PlatformUI.getWorkbench().getDisplay();
Shell shell = new Shell(display);
- shell.setText("SCL Documentation browser");
+ shell.setText(Messages.LaunchSCLDocumentationBrowser_SCLDocumentationBrowser);
shell.setLayout(new FillLayout());
SCLDocumentationBrowser browser;
try {
browser = new SCLDocumentationBrowser(shell);
} catch (SWTError e) {
- System.out.println("Could not instantiate the browser: " + e.getMessage());
+ System.out.println("Could not instantiate the browser: " + e.getMessage()); //$NON-NLS-1$
display.dispose();
return null;
}
- browser.setLocation("Prelude");
+ browser.setLocation("Prelude"); //$NON-NLS-1$
shell.open();
return null;
--- /dev/null
+package org.simantics.scl.ui.browser;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.simantics.scl.ui.browser.messages"; //$NON-NLS-1$
+ public static String LaunchSCLDocumentationBrowser_SCLDocumentationBrowser;
+ public static String SCLDefinitionSelectionDialog_ChooseSCLDefinition;
+ public static String SCLDocumentationBrowser_BackTT;
+ public static String SCLDocumentationBrowser_FindSCLDefinitionTT;
+ public static String SCLDocumentationBrowser_ForwardTT;
+ public static String SCLDocumentationBrowser_RefreshPageTT;
+ public static String SCLDocumentationBrowser_SaveDocumentationToDiskTT;
+ public static String SCLDocumentationBrowser_SaveDocumentationDialog_Msg;
+ public static String SCLDocumentationBrowser_SaveDocumentationDialog_Title;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
import org.simantics.scl.ui.Activator;
public class SCLDefinitionSelectionDialog extends FilteredItemsSelectionDialog {
- private static final String DIALOG_SETTINGS = "SCLDefinitionSelectionDialogSettings";
+ private static final String DIALOG_SETTINGS = "SCLDefinitionSelectionDialogSettings"; //$NON-NLS-1$
public SCLDefinitionSelectionDialog(Shell shell) {
super(shell, false);
- setTitle("Choose an SCL definition");
+ setTitle(Messages.SCLDefinitionSelectionDialog_ChooseSCLDefinition);
setSelectionHistory(new DefinitionSelectionHistory());
setListLabelProvider(new LabelProvider() {
@Override
return (String)element;
SCLValue value = (SCLValue)element;
if(element == null)
- return "";
+ return ""; //$NON-NLS-1$
Name name = value.getName();
- return name.name + " (" + name.module + ") :: " + value.getType();
+ return name.name + " (" + name.module + ") :: " + value.getType(); //$NON-NLS-1$ //$NON-NLS-2$
}
});
}
if(patternText != null && patternText.length() > 0)
patternMatcher.setPattern(patternText);
else
- patternMatcher.setPattern("*");
+ patternMatcher.setPattern("*"); //$NON-NLS-1$
}
@Override
public boolean matchItem(Object item) {
String text = item.toString();
- if(getPattern().contains("/"))
+ if(getPattern().contains("/")) //$NON-NLS-1$
return matches(text);
else {
int p = text.lastIndexOf('/');
}
private boolean isTupleValue(Name name) {
- return name.module.equals(Types.BUILTIN) && name.name.startsWith("(") &&
- (name.name.equals("()") || name.name.charAt(1) == ',');
+ return name.module.equals(Types.BUILTIN) && name.name.startsWith("(") && //$NON-NLS-1$
+ (name.name.equals("()") || name.name.charAt(1) == ','); //$NON-NLS-1$
}
@Override
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$
}
}
public void testDocumentationBrowser() throws Exception {
Display display = new Display();
Shell shell = new Shell(display);
- shell.setText("SCL module documentation");
+ shell.setText("SCL module documentation"); //$NON-NLS-1$
shell.setLayout(new FillLayout());
SCLDocumentationBrowser browser;
try {
browser = new SCLDocumentationBrowser(shell);
} catch (SWTError e) {
- System.out.println("Could not instantiate Browser: " + e.getMessage());
+ System.out.println("Could not instantiate Browser: " + e.getMessage()); //$NON-NLS-1$
display.dispose();
return;
}
- browser.setLocation("Prelude");
+ browser.setLocation("Prelude"); //$NON-NLS-1$
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
--- /dev/null
+LaunchSCLDocumentationBrowser_SCLDocumentationBrowser=SCL Documentation Browser
+SCLDefinitionSelectionDialog_ChooseSCLDefinition=Choose an SCL Definition
+SCLDocumentationBrowser_BackTT=Back (Alt-Left)
+SCLDocumentationBrowser_FindSCLDefinitionTT=Find SCL Definitions (Ctrl-H)
+SCLDocumentationBrowser_ForwardTT=Forward (Alt-Right)
+SCLDocumentationBrowser_RefreshPageTT=Refresh Page (Ctrl-R)
+SCLDocumentationBrowser_SaveDocumentationToDiskTT=Save Documentation to Disk
+SCLDocumentationBrowser_SaveDocumentationDialog_Msg=Select the directory where to generate the documentation
+SCLDocumentationBrowser_SaveDocumentationDialog_Title=Select Output Directory
*/
public static final int HIDE_INPUT = 1 << 0;
- public static final String PLUGIN_ID = "org.simantics.scl.ui";
+ public static final String PLUGIN_ID = "org.simantics.scl.ui"; //$NON-NLS-1$
public static final int COMMAND_HISTORY_SIZE = 50;
// Initialize current text font
fontRegistry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getFontRegistry();
fontRegistry.addListener(fontRegistryListener);
- FontDescriptor font = FontDescriptor.createFrom( fontRegistry.getFontData("org.simantics.scl.consolefont") );
+ FontDescriptor font = FontDescriptor.createFrom( fontRegistry.getFontData("org.simantics.scl.consolefont") ); //$NON-NLS-1$
setTextFont(font);
setLayout(new FormLayout());
GC gc = new GC(deco);
int inputLeftPos = gc.getFontMetrics().getAverageCharWidth()*2;
gc.dispose();
- deco.setText(">");
+ deco.setText(">"); //$NON-NLS-1$
deco.setLayoutData( formData(sash, 100, 0, new Tuple2(0, inputLeftPos)) );
// Input area
input = new StyledText(this, SWT.MULTI);
input.setFont(textFont);
input.setLayoutData( formData(sash, 100, new Tuple2(0, inputLeftPos), 100) );
- adjustInputSize("");
+ adjustInputSize(""); //$NON-NLS-1$
input.addVerifyKeyListener(event -> {
switch(event.keyCode) {
case SWT.KEYPAD_CR:
}
});
input.addVerifyListener(e -> {
- if(e.text.contains("\n")) {
+ if(e.text.contains("\n")) { //$NON-NLS-1$
int lineId = input.getLineAtOffset(e.start);
int lineOffset = input.getOffsetAtLine(lineId);
int indentAmount;
for(indentAmount=0;
lineOffset+indentAmount < input.getCharCount() &&
- input.getTextRange(lineOffset+indentAmount, 1).equals(" ");
+ input.getTextRange(lineOffset+indentAmount, 1).equals(" "); //$NON-NLS-1$
++indentAmount);
StringBuilder indent = new StringBuilder();
indent.append('\n');
for(int i=0;i<indentAmount;++i)
indent.append(' ');
- e.text = e.text.replace("\n", indent);
+ e.text = e.text.replace("\n", indent); //$NON-NLS-1$
}
});
input.addModifyListener(e -> {
Tuple2 t = (Tuple2) o;
return new FormAttachment((Integer) t.c0, (Integer) t.c1);
}
- throw new IllegalArgumentException("argument not supported: " + o);
+ throw new IllegalArgumentException("argument not supported: " + o); //$NON-NLS-1$
}
private int getOffsetInInput(int x, int y) {
String validatedText;
- Job validationJob = new Job("SCL input validation") {
+ Job validationJob = new Job("SCL input validation") { //$NON-NLS-1$
@Override
protected IStatus run(IProgressMonitor monitor) {
};
- Job preValidationJob = new Job("SCL input validation") {
+ Job preValidationJob = new Job("SCL input validation") { //$NON-NLS-1$
@Override
protected IStatus run(IProgressMonitor monitor) {
if(!input.isDisposed()) {
// Print it into output area
//appendOutput("> " + command.replace("\n", "\n ") + "\n", greenColor, null);
- input.setText("");
+ input.setText(""); //$NON-NLS-1$
// Execute
execute(command);
range.start = 0;
range.length = 1;
input.setStyleRange(range);
- getLogger().error("The following error message didn't have a proper location: {}", annotation.description, e);
+ getLogger().error("The following error message didn't have a proper location: {}", annotation.description, e); //$NON-NLS-1$
}
}
}
public void clear() {
outputModiLock = true;
- output.setText("");
+ output.setText(""); //$NON-NLS-1$
outputModiLock = false;
}
class ConsoleActions {
public static Action createInterruptAction(SCLConsole console) {
- Action interruptAction = new Action("Interrupt current command",
- Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/stop.png")) {
+ Action interruptAction = new Action(Messages.ConsoleActions_InterruptCurrentCommand,
+ Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/stop.png")) { //$NON-NLS-1$ //$NON-NLS-2$
@Override
public void run() {
console.interruptCurrentCommands();
}
};
interruptAction.setDisabledImageDescriptor(
- Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/stop_disabled.png"));
+ Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/stop_disabled.png")); //$NON-NLS-1$ //$NON-NLS-2$
interruptAction.setEnabled(false);
return interruptAction;
}
public static Action createClearAction(SCLConsole console) {
- Action clearAction = new Action("Clear console",
- Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/clear_console.png")) {
+ Action clearAction = new Action(Messages.ConsoleActions_ClearConsole,
+ Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/clear_console.png")) { //$NON-NLS-1$ //$NON-NLS-2$
@Override
public void run() {
setEnabled(false);
}
};
clearAction.setDisabledImageDescriptor(
- Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/clear_console_disabled.png"));
+ Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/clear_console_disabled.png")); //$NON-NLS-1$ //$NON-NLS-2$
clearAction.setEnabled(false);
return clearAction;
}
--- /dev/null
+package org.simantics.scl.ui.console;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.simantics.scl.ui.console.messages"; //$NON-NLS-1$
+ public static String ConsoleActions_ClearConsole;
+ public static String ConsoleActions_InterruptCurrentCommand;
+ public static String SCLConsoleView_ManageImports;
+ public static String SCLConsoleView_RefreshAutomatically;
+ public static String SCLConsoleView_RefreshCompleted;
+ public static String SCLConsoleView_RefreshModules;
+ public static String SCLConsoleView_RunTests;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
*/
public final class Preferences {
- public static final String COMMAND_HISTORY = "COMMAND_HISTORY";
+ public static final String COMMAND_HISTORY = "COMMAND_HISTORY"; //$NON-NLS-1$
- private static final String DELIMITER = "¤¤¤¤";
+ private static final String DELIMITER = "¤¤¤¤"; //$NON-NLS-1$
public static String join(Collection<String> s, String delimiter) {
- if (s == null || s.isEmpty()) return "";
+ if (s == null || s.isEmpty()) return ""; //$NON-NLS-1$
Iterator<String> iter = s.iterator();
StringBuilder builder = new StringBuilder(iter.next());
while( iter.hasNext() )
*/
public static final int EXCLUDE_CONTRIBUTED_LISTENERS = 1 << 10;
- public static final String JOB_NAME = "org.simantics.scl.console.job";
+ public static final String JOB_NAME = "org.simantics.scl.console.job"; //$NON-NLS-1$
public static final long TERMINATE_GRACE_PERIOD = 1000L;
private THashSet<Job> currentJobs = new THashSet<Job>();
SCLReportingHandler handler = new AbstractSCLReportingHandler() {
@Override
public void print(String text) {
- appendOutput(text + "\n", null, null);
+ appendOutput(text + "\n", null, null); //$NON-NLS-1$
}
@Override
public void printError(String error) {
- appendOutput(error + "\n", redColor, null);
+ appendOutput(error + "\n", redColor, null); //$NON-NLS-1$
}
@Override
public void printCommand(String command) {
- appendOutput("> " + command.replace("\n", "\n ") + "\n", greenColor, null);
+ appendOutput("> " + command.replace("\n", "\n ") + "\n", greenColor, null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
};
input,
styledTextContentAdapter,
contentProvider,
- KeyStroke.getInstance("Ctrl+Space"),
+ KeyStroke.getInstance("Ctrl+Space"), //$NON-NLS-1$
null);
contentProposalAdapter.setAutoActivationDelay(200);
} catch (ParseException e) {
}
private String jobNameFromCommand(String command) {
- return command.split("\n")[0];
+ return command.split("\n")[0]; //$NON-NLS-1$
}
@Override
public class SCLConsoleView extends ViewPart {
- public static final String PLUGIN_ID = "org.simantics.scl.ui";
- public static final String IMPORTS = "imports";
- public static final String REFRESH_AUTOMATICALLY = "refresh-automatically";
- public static final String SEPARATOR = ";";
- public static final String DISABLED_TAG = "[DISABLED]";
+ public static final String PLUGIN_ID = "org.simantics.scl.ui"; //$NON-NLS-1$
+ public static final String IMPORTS = "imports"; //$NON-NLS-1$
+ public static final String REFRESH_AUTOMATICALLY = "refresh-automatically"; //$NON-NLS-1$
+ public static final String SEPARATOR = ";"; //$NON-NLS-1$
+ public static final String DISABLED_TAG = "[DISABLED]"; //$NON-NLS-1$
IPersistentPreferenceStore store;
SCLConsole console;
disabled = true;
entryString = entryString.substring(DISABLED_TAG.length());
}
- String[] parts = entryString.split("=");
+ String[] parts = entryString.split("="); //$NON-NLS-1$
CommandSessionImportEntry entry;
if(parts.length == 1)
- entry = new CommandSessionImportEntry(parts[0], "", true);
+ entry = new CommandSessionImportEntry(parts[0], "", true); //$NON-NLS-1$
else
entry = new CommandSessionImportEntry(parts[1], parts[0], true);
entry.disabled = disabled;
b.append(DISABLED_TAG);
if(!entry.localName.isEmpty()) {
b.append(entry.localName);
- b.append("=");
+ b.append("="); //$NON-NLS-1$
}
b.append(entry.moduleName);
}
try {
// Bit of a haxx solution to get around a deadlock caused by simply
// running the test with test.run()
- console.execute("import \"Commands/Tests\"");
- console.execute("runByName \"" + test.getName() + "\"");
+ console.execute("import \"Commands/Tests\""); //$NON-NLS-1$
+ console.execute("runByName \"" + test.getName() + "\""); //$NON-NLS-1$ //$NON-NLS-2$
// test.run();
} catch (Exception e) {
e.printStackTrace();
});
// Refresh action
- toolBarManager.add(new Action("Refresh modules", IAction.AS_DROP_DOWN_MENU) {
+ toolBarManager.add(new Action(Messages.SCLConsoleView_RefreshModules, IAction.AS_DROP_DOWN_MENU) {
{
- setImageDescriptor(Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/arrow_refresh.png"));
+ setImageDescriptor(Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/arrow_refresh.png")); //$NON-NLS-1$ //$NON-NLS-2$
setMenuCreator(new IMenuCreator() {
Menu menu;
@Override
if(menu == null) {
menu = new Menu(parent);
refreshAutomaticallyItem = new MenuItem(menu, SWT.CHECK);
- refreshAutomaticallyItem.setText("Refresh automatically");
+ refreshAutomaticallyItem.setText(Messages.SCLConsoleView_RefreshAutomatically);
refreshAutomaticallyItem.setSelection(refreshAutomatically);
refreshAutomaticallyItem.addSelectionListener(new SelectionAdapter() {
@Override
public void run() {
console.getSession().getModuleRepository().getSourceRepository().checkUpdates();
console.getSession().updateRuntimeEnvironment(true);
- console.appendOutput("refresh completed\n", console.greenColor, null);
+ console.appendOutput(Messages.SCLConsoleView_RefreshCompleted, console.greenColor, null);
}
});
- toolBarManager.add(new Action("Manage imports",
- Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/configure_imports.png")) {
+ toolBarManager.add(new Action(Messages.SCLConsoleView_ManageImports,
+ Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/configure_imports.png")) { //$NON-NLS-1$ //$NON-NLS-2$
@Override
public void run() {
manageImports();
// Show action for running SCL tests if in development mode
if (Platform.inDevelopmentMode()) {
- toolBarManager.add(new Action("Run tests",
- Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/run_tests.png")) {
+ toolBarManager.add(new Action(Messages.SCLConsoleView_RunTests,
+ Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/run_tests.png")) { //$NON-NLS-1$ //$NON-NLS-2$
@Override
public void run() {
sclTestDialog();
for (String file : files) {
Path p = Paths.get(file).toAbsolutePath();
if (isScriptFile(p)) {
- console.execute("runFromFile \"" + p.toString().replace('\\', '/') + "\"");
+ console.execute("runFromFile \"" + p.toString().replace('\\', '/') + "\""); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
--- /dev/null
+ConsoleActions_ClearConsole=Clear Console
+ConsoleActions_InterruptCurrentCommand=Interrupt Current Command
+SCLConsoleView_ManageImports=Manage Imports
+SCLConsoleView_RefreshAutomatically=Refresh Automatically
+SCLConsoleView_RefreshCompleted=refresh completed\n
+SCLConsoleView_RefreshModules=Refresh Modules
+SCLConsoleView_RunTests=Run Tests
public void customizeDocumentCommand(IDocument d, DocumentCommand c) {
if (c.length == 0 && c.text != null) {
- if(c.text.equals("(")) {
- c.text = "()";
+ if(c.text.equals("(")) { //$NON-NLS-1$
+ c.text = "()"; //$NON-NLS-1$
justAddedClosingBracket = ')';
}
- else if(c.text.equals("[")) {
- c.text = "[]";
+ else if(c.text.equals("[")) { //$NON-NLS-1$
+ c.text = "[]"; //$NON-NLS-1$
justAddedClosingBracket = ']';
}
else {
if(c.text.length() == 1 && c.text.charAt(0) == justAddedClosingBracket) {
- c.text = "";
+ c.text = ""; //$NON-NLS-1$
c.shiftsCaret = false;
c.caretOffset = c.offset+1;
}
public void customizeDocumentCommand(IDocument d, DocumentCommand c) {
if (c.length == 0 && c.text != null && c.text.indexOf('\t') >= 0) {
- c.text = c.text.replace("\t", " ");
+ c.text = c.text.replace("\t", " "); //$NON-NLS-1$ //$NON-NLS-2$
}
}
@Override
public void paint(Annotation annotation, GC gc, Canvas canvas, Rectangle bounds) {
- Image image = registry.get("error");
+ Image image = registry.get("error"); //$NON-NLS-1$
if(image == null) {
- registry.put("error", ImageDescriptor.createFromFile(getClass(), "error_tsk.gif"));
- image = registry.get("error");
+ registry.put("error", ImageDescriptor.createFromFile(getClass(), "error_tsk.gif")); //$NON-NLS-1$ //$NON-NLS-2$
+ image = registry.get("error"); //$NON-NLS-1$
}
ImageUtilities.drawImage(image, gc, canvas, bounds, SWT.CENTER, SWT.TOP);
}
public class SCLDocumentSetup implements IDocumentSetupParticipant {
- public static final String COMMENT = "COMMENT";
- public static final String STRING = "STRING";
+ public static final String COMMENT = "COMMENT"; //$NON-NLS-1$
+ public static final String STRING = "STRING"; //$NON-NLS-1$
public static final String[] PARTITION_TYPES = new String[] {
COMMENT, STRING
};
- public static final String SCL_PARTIONING = "SCL_PARTIONING";
+ public static final String SCL_PARTIONING = "SCL_PARTIONING"; //$NON-NLS-1$
@Override
if(document instanceof IDocumentExtension3) {
RuleBasedPartitionScanner scanner = new RuleBasedPartitionScanner();
scanner.setPredicateRules(new IPredicateRule[] {
- new MultiLineRule("/*", "*/", new Token(COMMENT)),
- new EndOfLineRule("//", new Token(COMMENT)),
- new MultiLineRule("\"\"\"", "\"\"\"", new Token(STRING), '\\'),
- new PatternRule("\"", "\"", new Token(STRING), '\\', true),
+ new MultiLineRule("/*", "*/", new Token(COMMENT)), //$NON-NLS-1$ //$NON-NLS-2$
+ new EndOfLineRule("//", new Token(COMMENT)), //$NON-NLS-1$
+ new MultiLineRule("\"\"\"", "\"\"\"", new Token(STRING), '\\'), //$NON-NLS-1$ //$NON-NLS-2$
+ new PatternRule("\"", "\"", new Token(STRING), '\\', true), //$NON-NLS-1$ //$NON-NLS-2$
});
IDocumentPartitioner partitioner = new FastPartitioner(scanner, PARTITION_TYPES);
((IDocumentExtension3)document).setDocumentPartitioner(SCL_PARTIONING, partitioner);
this.resourceManager = resourceManager;
this.preferenceStore = EditorsUI.getPreferenceStore();
- this.sclTextEditorEnvironment = new SCLTextEditorEnvironment("");
+ this.sclTextEditorEnvironment = new SCLTextEditorEnvironment(""); //$NON-NLS-1$
}
public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
OverviewRuler rightRuler =
new OverviewRuler(annotationAccess, 12, sharedTextColors);
rightRuler.setModel(annotationModel);
- rightRuler.addAnnotationType("error");
- rightRuler.setAnnotationTypeLayer("error", 0);
- rightRuler.setAnnotationTypeColor("error", sharedTextColors.getColor(new RGB(255,0,128)));
+ rightRuler.addAnnotationType("error"); //$NON-NLS-1$
+ rightRuler.setAnnotationTypeLayer("error", 0); //$NON-NLS-1$
+ rightRuler.setAnnotationTypeColor("error", sharedTextColors.getColor(new RGB(255,0,128))); //$NON-NLS-1$
viewer = new SourceViewer(this,
leftRuler, rightRuler,
// Annotations to text area
AnnotationPainter annotationPainter =
new AnnotationPainter(viewer, annotationAccess);
- annotationPainter.addAnnotationType("error");
- annotationPainter.setAnnotationTypeColor("error", sharedTextColors.getColor(new RGB(255,0,128)));
+ annotationPainter.addAnnotationType("error"); //$NON-NLS-1$
+ annotationPainter.setAnnotationTypeColor("error", sharedTextColors.getColor(new RGB(255,0,128))); //$NON-NLS-1$
viewer.addPainter(annotationPainter);
annotationModel.addAnnotationModelListener(annotationPainter);
++end;
}
annotationModel.addAnnotation(
- new Annotation("error", true, error.description),
+ new Annotation("error", true, error.description), //$NON-NLS-1$
new Position(begin, end-begin));
}
}
public class SCLCompletionAssistProcessor implements IContentAssistProcessor {
// private String lastPrefix = null;
- private String lastError = "";
+ private String lastError = ""; //$NON-NLS-1$
private SCLTextEditorEnvironment sclTextEditorEnvironment;
public SCLCompletionAssistProcessor(SCLTextEditorEnvironment sclTextEditorEnvironment) {
tmpOffset = selection.getOffset() + selection.getLength();
final int offset = tmpOffset;
IDocument document = viewer.getDocument();
- String tmpPrefix = "";
+ String tmpPrefix = ""; //$NON-NLS-1$
try {
tmpPrefix = getPrefix(document, offset);
} catch (BadLocationException e) {
private static String getPrefix(IDocument doc, int offset) throws BadLocationException {
int docLen = doc.getLength();
if (doc == null || offset > docLen || docLen == 0)
- return "";
+ return ""; //$NON-NLS-1$
int length= 0;
while (--offset >= 0 && Character.isJavaIdentifierPart(doc.getChar(offset)) || doc.getChar(offset) == '.')
public class SCLCompletionProposal implements ICompletionProposal, ICompletionProposalExtension, ICompletionProposalExtension2, ICompletionProposalExtension3, ICompletionProposalExtension4, ICompletionProposalExtension5 {
- private static final Image PRIVATE = Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/private_co.gif").createImage();
- private static final Image PUBLIC = Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/public_co.gif").createImage();
- private static final Image CONST = Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/container_obj.gif").createImage();
- private static final Image TYPE = Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/typedef_obj.gif").createImage();
+ private static final Image PRIVATE = Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/private_co.gif").createImage(); //$NON-NLS-1$ //$NON-NLS-2$
+ private static final Image PUBLIC = Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/public_co.gif").createImage(); //$NON-NLS-1$ //$NON-NLS-2$
+ private static final Image CONST = Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/container_obj.gif").createImage(); //$NON-NLS-1$ //$NON-NLS-2$
+ private static final Image TYPE = Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/typedef_obj.gif").createImage(); //$NON-NLS-1$ //$NON-NLS-2$
private final String content;
private final String name;
String tempModule = value.getName().module;
int p = tempName.lastIndexOf('.');
if(p >= 0) {
- tempModule = tempModule + "." + tempName.substring(0, p);
+ tempModule = tempModule + "." + tempName.substring(0, p); //$NON-NLS-1$
tempName = tempName.substring(p+1);
}
this.name = tempName;
this.module = tempModule;
this.documentation = value.getDocumentation();
- this.content = name + " :: " + value.getType() + " (" + module + ")";
+ this.content = name + " :: " + value.getType() + " (" + module + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
this.replacementOffset = replacementOffset;
this.prefix = prefix;
// System.out.println(prefix);
public SCLCompletionProposal(String name, String module, SCLCompletionType completionType, int replacementOffset, String prefix) {
this.name = name;
this.module = module;
- this.content = name + " (" + module + ")";
+ this.content = name + " (" + module + ")"; //$NON-NLS-1$ //$NON-NLS-2$
this.documentation = null;
this.replacementOffset = replacementOffset;
this.prefix = prefix;
// String sadd = doc.get(start, end);
// System.out.println("toReplace : " + sadd);
if (p.y > 0) {
- doc.replace(p.x, p.y, "");
+ doc.replace(p.x, p.y, ""); //$NON-NLS-1$
doc.replace(offset, 0, getName());
} else {
String currentText = doc.get(offset - prefix.length(), prefix.length());
if (currentText.equals(getName()))
return;
- doc.replace(offset - prefix.length(), prefix.length(), "");
+ doc.replace(offset - prefix.length(), prefix.length(), ""); //$NON-NLS-1$
doc.replace(offset - prefix.length(), 0, getName());
}
} catch (BadLocationException x) {
public void updateEnvironment(IDocument document) {
String contents = document.get();
- String[] lines = contents.split("\\R+");
+ String[] lines = contents.split("\\R+"); //$NON-NLS-1$
List<ImportDeclaration> imports = new ArrayList<>();
- imports.add(new ImportDeclaration("StandardLibrary", ""));
+ imports.add(new ImportDeclaration("StandardLibrary", "")); //$NON-NLS-1$ //$NON-NLS-2$
for (String line : lines) {
line = line.trim();
- if (line.startsWith("import") || line.startsWith("include")) {
+ if (line.startsWith("import") || line.startsWith("include")) { //$NON-NLS-1$ //$NON-NLS-2$
SCLParserImpl parser = new SCLParserImpl(new StringReader(line));
try {
ImportDeclaration importDecl = (ImportDeclaration)parser.parseImport();
List<SCLCompletionProposal> proposals = new ArrayList<>();
for(SCLValue value : Environments.findValuesForPrefix(env, prefix)) {
Name name = value.getName();
- if((name.module.equals(moduleName) || !value.isPrivate()) && !(name.name.contains("$") && Character.isLetter(name.name.charAt(0))))
+ if((name.module.equals(moduleName) || !value.isPrivate()) && !(name.name.contains("$") && Character.isLetter(name.name.charAt(0)))) //$NON-NLS-1$
proposals.add(new SCLCompletionProposal(value, offset - lastPart.length(), lastPart));
}
for(TCon type : Environments.findTypesForPrefix(env, prefix)) {
proposals.add(new SCLCompletionProposal(type.name, type.module, SCLCompletionType.TYPE, offset - lastPart.length(), lastPart));
}
- if(!prefix.contains(".")) {
+ if(!prefix.contains(".")) { //$NON-NLS-1$
for (ImportDeclaration decl : cachedImports) {
if (decl.localName != null && !decl.localName.isEmpty() && decl.localName.toLowerCase().startsWith(prefix.toLowerCase())) {
proposals.add(new SCLCompletionProposal(decl.localName, decl.moduleName, SCLCompletionType.CONST, offset - prefix.length(), prefix));
@Override
public void setRange(IDocument document, int offset, int length) {
- System.out.println(">>> setRange(" + offset + ", " + length + ")");
+ System.out.println(">>> setRange(" + offset + ", " + length + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
base.setRange(document, offset, length);
}
@Override
public IToken nextToken() {
IToken result = base.nextToken();
- System.out.println(">>> nextToken -> " + result + " " + result.getData());
+ System.out.println(">>> nextToken -> " + result + " " + result.getData()); //$NON-NLS-1$ //$NON-NLS-2$
return result;
}
@Override
public int getTokenOffset() {
int result = base.getTokenOffset();
- System.out.println(">>> getTokenOffset -> " + result);
+ System.out.println(">>> getTokenOffset -> " + result); //$NON-NLS-1$
return result;
}
@Override
public int getTokenLength() {
int result = base.getTokenLength();
- System.out.println(">>> getTokenLength -> " + result);
+ System.out.println(">>> getTokenLength -> " + result); //$NON-NLS-1$
return result;
}
@Override
public void setPartialRange(IDocument document, int offset, int length, String contentType, int partitionOffset) {
- System.out.println(">>> setPartialRange(" + offset + ", " + length + ", " + contentType + ", " + partitionOffset + ")");
+ System.out.println(">>> setPartialRange(" + offset + ", " + length + ", " + contentType + ", " + partitionOffset + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
base.setPartialRange(document, offset, length, contentType, partitionOffset);
}
return text.substring(startPos, endPos);
}
- private static final String SYMBOL_CHARS = "!$%&*+/<=>?@\\^|-:~.";
+ private static final String SYMBOL_CHARS = "!$%&*+/<=>?@\\^|-:~."; //$NON-NLS-1$
private static boolean isSymbolPart(char c) {
for(int i=0;i<SYMBOL_CHARS.length();++i)
--- /dev/null
+package org.simantics.scl.ui.editor2;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.simantics.scl.ui.editor2.messages"; //$NON-NLS-1$
+ public static String SCLModuleEditor2DocumentProvider_Status_SCLSourceNotFound;
+ public static String SCLModuleSelectionDialog_ChooseSCLModule;
+ public static String SCLModuleSelectionDialog_Searching;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
return text.substring(startPos, endPos);
}
- private static final String SYMBOL_CHARS = "!$%&*+/<=>?@\\^|-:~.";
+ private static final String SYMBOL_CHARS = "!$%&*+/<=>?@\\^|-:~."; //$NON-NLS-1$
private static boolean isSymbolPart(char c) {
for(int i=0;i<SYMBOL_CHARS.length();++i)
// Find the line where the caret is
String lineAtCaret = extractLineAt(text, caretOffset);
- if(lineAtCaret.startsWith("import ") || lineAtCaret.startsWith("include ")) {
+ if(lineAtCaret.startsWith("import ") || lineAtCaret.startsWith("include ")) { //$NON-NLS-1$ //$NON-NLS-2$
int p1 = lineAtCaret.indexOf('"', 6);
int p2 = lineAtCaret.indexOf('"', p1+1);
SCLModuleEditorInput input = (SCLModuleEditorInput)moduleEditor.getEditorInput();
OpenSCLModule.scheduleOpenModule(moduleName);
}
} catch (InvalidModulePathException e) {
- LOGGER.error("Could not open declaration {} {}", input.getModuleName(), lineAtCaret, e);
+ LOGGER.error("Could not open declaration {} {}", input.getModuleName(), lineAtCaret, e); //$NON-NLS-1$
}
}
else {
return;
SCLModuleEditorInput input = new StandardSCLModuleEditorInput(moduleName);
try {
- SCLModuleEditor2 editor = (SCLModuleEditor2)page.openEditor(input, "org.simantics.scl.ui.editor2");
+ SCLModuleEditor2 editor = (SCLModuleEditor2)page.openEditor(input, "org.simantics.scl.ui.editor2"); //$NON-NLS-1$
if(location != Locations.NO_LOCATION) {
int begin = Locations.beginOf(location);
int end = Locations.endOf(location);
editor.selectAndReveal(begin, end-begin);
}
} catch (PartInitException e) {
- LOGGER.error("", e);
+ LOGGER.error("", e); //$NON-NLS-1$
}
};
}
return;
SCLModuleEditorInput input = new StandardSCLModuleEditorInput(moduleName);
try {
- page.openEditor(input, "org.simantics.scl.ui.editor2");
+ page.openEditor(input, "org.simantics.scl.ui.editor2"); //$NON-NLS-1$
} catch (PartInitException e) {
- LOGGER.error("Could not open module {} ", moduleName, e);
+ LOGGER.error("Could not open module {} ", moduleName, e); //$NON-NLS-1$
}
};
}
for(CompilationError error : errors) {
Annotation annotation = new Annotation(
error.severity == ErrorSeverity.ERROR || error.severity == ErrorSeverity.IMPORT_ERROR ?
- "org.eclipse.ui.workbench.texteditor.error" :
- "org.eclipse.ui.workbench.texteditor.warning",
+ "org.eclipse.ui.workbench.texteditor.error" : //$NON-NLS-1$
+ "org.eclipse.ui.workbench.texteditor.warning", //$NON-NLS-1$
true, error.description);
int begin = Locations.beginOf(error.location);
int end = Locations.endOf(error.location);
private static final char[] CHARS = new char[] { '(', ')', '{', '}', '[', ']', '<', '>' };
- private static final String MATCHING_BRACKETS = "matchingBrackets";
- private static final String MATCHING_BRACKETS_COLOR = "matchingBracketsColor";
- private static final String HIGHLIGHT_BRACKET_AT_CARET_LOCATION = "highlightBracketAtCaretLocation";
- private static final String ENCLOSING_BRACKETS = "enclosingBrackets";
+ private static final String MATCHING_BRACKETS = "matchingBrackets"; //$NON-NLS-1$
+ private static final String MATCHING_BRACKETS_COLOR = "matchingBracketsColor"; //$NON-NLS-1$
+ private static final String HIGHLIGHT_BRACKET_AT_CARET_LOCATION = "highlightBracketAtCaretLocation"; //$NON-NLS-1$
+ private static final String ENCLOSING_BRACKETS = "enclosingBrackets"; //$NON-NLS-1$
private boolean disposed = false;
protected ResourceManager resourceManager;
throws PartInitException {
super.init(site, input);
getPreferenceStore().setValue(MATCHING_BRACKETS, true);
- getPreferenceStore().setValue(MATCHING_BRACKETS_COLOR, "192,192,192");
+ getPreferenceStore().setValue(MATCHING_BRACKETS_COLOR, "192,192,192"); //$NON-NLS-1$
getPreferenceStore().setValue(HIGHLIGHT_BRACKET_AT_CARET_LOCATION, true);
getPreferenceStore().setValue(ENCLOSING_BRACKETS, true);
}
@Override
public void createPartControl(Composite parent) {
super.createPartControl(parent);
- getEditorSite().getService(IContextService.class).activateContext("org.simantics.scl.ui.editor");
+ getEditorSite().getService(IContextService.class).activateContext("org.simantics.scl.ui.editor"); //$NON-NLS-1$
updatePartName();
}
updateTextualModuleSource(element);
if(currentSource == null)
throw new CoreException(
- new Status(Status.ERROR, "org.simantics.scl.ui", "Source for the SCL module could not be found.")
+ new Status(Status.ERROR, "org.simantics.scl.ui", Messages.SCLModuleEditor2DocumentProvider_Status_SCLSourceNotFound) //$NON-NLS-1$
);
Document document;
try {
document = new Document(currentSource.getSourceText(null));
} catch (IOException e) {
throw new CoreException(
- new Status(Status.ERROR, "org.simantics.scl.ui", "Reading SCL module failed.", e)
+ new Status(Status.ERROR, "org.simantics.scl.ui", "Reading SCL module failed.", e) //$NON-NLS-1$ //$NON-NLS-2$
);
}
IDocumentPartitioner partitioner = new FastPartitioner(new SCLPartitionScanner(), SCLPartitionScanner.PARTITION_TYPES);
import org.eclipse.ui.IMemento;
import org.eclipse.ui.dialogs.FilteredItemsSelectionDialog;
import org.eclipse.ui.dialogs.SearchPattern;
-import org.simantics.scl.compiler.common.names.Name;
-import org.simantics.scl.compiler.elaboration.modules.SCLValue;
import org.simantics.scl.osgi.SCLOsgi;
import org.simantics.scl.ui.Activator;
import gnu.trove.procedure.TObjectProcedure;
public class SCLModuleSelectionDialog extends FilteredItemsSelectionDialog {
- private static final String DIALOG_SETTINGS = "SCLModuleSelectionDialogSettings";
+ private static final String DIALOG_SETTINGS = "SCLModuleSelectionDialogSettings"; //$NON-NLS-1$
public SCLModuleSelectionDialog(Shell shell) {
super(shell, false);
- setTitle("Choose an SCL module");
+ setTitle(Messages.SCLModuleSelectionDialog_ChooseSCLModule);
setSelectionHistory(new ModuleSelectionHistory());
setListLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
if(element == null)
- return "";
+ return ""; //$NON-NLS-1$
return (String)element;
}
});
if(patternText != null && patternText.length() > 0)
patternMatcher.setPattern(patternText);
else
- patternMatcher.setPattern("*");
+ patternMatcher.setPattern("*"); //$NON-NLS-1$
}
@Override
public boolean matchItem(Object item) {
String text = item.toString();
- if(getPattern().contains("/"))
+ if(getPattern().contains("/")) //$NON-NLS-1$
return matches(text);
else {
int p = text.lastIndexOf('/');
protected void fillContentProvider(AbstractContentProvider contentProvider,
ItemsFilter itemsFilter, IProgressMonitor progressMonitor)
throws CoreException {
- progressMonitor.beginTask("Searching", 1); //$NON-NLS-1$
+ progressMonitor.beginTask(Messages.SCLModuleSelectionDialog_Searching, 1);
SCLOsgi.SOURCE_REPOSITORY.forAllModules(new TObjectProcedure<String>() {
@Override
public boolean execute(String moduleName) {
import org.eclipse.jface.text.rules.Token;
public class SCLPartitionScanner extends RuleBasedPartitionScanner {
- public static final String SCL_COMMENT = "COMMENT";
- public static final String SCL_STRING = "STRING";
+ public static final String SCL_COMMENT = "COMMENT"; //$NON-NLS-1$
+ public static final String SCL_STRING = "STRING"; //$NON-NLS-1$
public static final IToken COMMENT_TOKEN = new Token(SCL_COMMENT);
public static final IToken STRING_TOKEN = new Token(SCL_STRING);
super();
setPredicateRules(new IPredicateRule[] {
- new EndOfLineRule("//", COMMENT_TOKEN),
- new MultiLineRule("\"\"\"", "\"\"\"", STRING_TOKEN, (char) 0, true),
- new SingleLineRule("\"", "\"", STRING_TOKEN, '\\'),
- new MultiLineRule("/*", "*/", COMMENT_TOKEN, (char) 0, true),
+ new EndOfLineRule("//", COMMENT_TOKEN), //$NON-NLS-1$
+ new MultiLineRule("\"\"\"", "\"\"\"", STRING_TOKEN, (char) 0, true), //$NON-NLS-1$ //$NON-NLS-2$
+ new SingleLineRule("\"", "\"", STRING_TOKEN, '\\'), //$NON-NLS-1$ //$NON-NLS-2$
+ new MultiLineRule("/*", "*/", COMMENT_TOKEN, (char) 0, true), //$NON-NLS-1$ //$NON-NLS-2$
});
}
}
import org.simantics.scl.ui.info.SCLInfo;
public class SCLPresentationReconciler extends PresentationReconciler {
- private static final FontDescriptor FONT_NORMAL = FontDescriptor.createFrom("Consolas", 10, SWT.NORMAL);
- private static final FontDescriptor FONT_BOLD = FontDescriptor.createFrom("Consolas", 10, SWT.BOLD);
+ private static final FontDescriptor FONT_NORMAL = FontDescriptor.createFrom("Consolas", 10, SWT.NORMAL); //$NON-NLS-1$
+ private static final FontDescriptor FONT_BOLD = FontDescriptor.createFrom("Consolas", 10, SWT.BOLD); //$NON-NLS-1$
public SCLPresentationReconciler(ResourceManager resourceManager) {
Font font = resourceManager.createFont(FONT_NORMAL);
@Override
public String getFactoryId() {
- return "org.simantics.scl.ui.editor.inputFactory";
+ return "org.simantics.scl.ui.editor.inputFactory"; //$NON-NLS-1$
}
}
--- /dev/null
+SCLModuleEditor2DocumentProvider_Status_SCLSourceNotFound=Source for the SCL module could not be found.
+SCLModuleSelectionDialog_ChooseSCLModule=Choose an SCL Module
+SCLModuleSelectionDialog_Searching=Searching
public static final BasicImportModulesAction INSTANCE = new BasicImportModulesAction();
public BasicImportModulesAction() {
- super("Add modules", 0.0);
+ super(Messages.BasicImportModulesAction_AddModules, 0.0);
}
@Override
public boolean editImports(Shell shell, ArrayList<CommandSessionImportEntry> imports) {
SCLModuleSelectionDialog dialog = new SCLModuleSelectionDialog(shell);
+ dialog.setTitle(Messages.BasicImportModulesAction_AddModules);
if(dialog.open() == Dialog.OK) {
for(Object r : dialog.getResult()) {
- new CommandSessionImportEntry((String)r, "", true).addTo(imports);
+ new CommandSessionImportEntry((String)r, "", true).addTo(imports); //$NON-NLS-1$
}
return true;
}
public static final ExternalImportModulesAction INSTANCE = new ExternalImportModulesAction();
public ExternalImportModulesAction() {
- super("Add external module", 95.0);
+ super(Messages.ExternalImportModulesAction_AddExternalModule, 95.0);
}
@Override
public boolean editImports(Shell shell, ArrayList<CommandSessionImportEntry> imports) {
FileDialog dialog = new FileDialog(shell);
- dialog.setFilterExtensions(new String[] {"*.scl"});
+ dialog.setFilterExtensions(new String[] {"*.scl"}); //$NON-NLS-1$
String result = dialog.open();
if(result != null) {
- new CommandSessionImportEntry("file:" + result, "", true).addTo(imports);
+ new CommandSessionImportEntry("file:" + result, "", true).addTo(imports); //$NON-NLS-1$ //$NON-NLS-2$
return true;
}
else
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
- newShell.setText("Manage Imports");
+ newShell.setText(Messages.ManageImportsDialog_ManageImports);
newShell.setMinimumSize(800, 600);
}
// Column 1: module name
TableViewerColumn column1 = new TableViewerColumn(tableViewer, SWT.NONE);
column1.getColumn().setWidth(300);
- column1.getColumn().setText("Module");
+ column1.getColumn().setText(Messages.ManageImportsDialog_Module);
column1.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
// Column 2: local name
TableViewerColumn column2 = new TableViewerColumn(tableViewer, SWT.NONE);
column2.getColumn().setWidth(100);
- column2.getColumn().setText("Local name");
+ column2.getColumn().setText(Messages.ManageImportsDialog_LocalName);
column2.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
// Column 3: status
TableViewerColumn column3 = new TableViewerColumn(tableViewer, SWT.NONE);
column3.getColumn().setWidth(200);
- column3.getColumn().setText("Status");
+ column3.getColumn().setText(Messages.ManageImportsDialog_Status);
column3.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
{
MenuItem menuItem = new MenuItem(menu, SWT.NONE);
- menuItem.setText("Delete");
+ menuItem.setText(Messages.ManageImportsDialog_Delete);
menuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
THashSet<CommandSessionImportEntry> removedEntries =
}
if(hasTransient) {
MenuItem menuItem = new MenuItem(menu, SWT.NONE);
- menuItem.setText("Make persistent");
+ menuItem.setText(Messages.ManageImportsDialog_MakePersistent);
menuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
for(CommandSessionImportEntry entry : entries)
}
if(hasPersistent) {
MenuItem menuItem = new MenuItem(menu, SWT.NONE);
- menuItem.setText("Make transient");
+ menuItem.setText(Messages.ManageImportsDialog_MakeTransient);
menuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
for(CommandSessionImportEntry entry : entries)
}
if(hasDisabled) {
MenuItem menuItem = new MenuItem(menu, SWT.NONE);
- menuItem.setText("Enable");
+ menuItem.setText(Messages.ManageImportsDialog_Enable);
menuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
for(CommandSessionImportEntry entry : entries)
}
if(hasEnabled) {
MenuItem menuItem = new MenuItem(menu, SWT.NONE);
- menuItem.setText("Disable");
+ menuItem.setText(Messages.ManageImportsDialog_Disable);
menuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
for(CommandSessionImportEntry entry : entries)
public static final ManualImportModulesAction INSTANCE = new ManualImportModulesAction();
public ManualImportModulesAction() {
- super("Add freeform module", 100.0);
+ super(Messages.ManualImportModulesAction_AddFreeformModule, 100.0);
}
@Override
public boolean editImports(Shell shell, ArrayList<CommandSessionImportEntry> imports) {
- InputDialog dialog = new InputDialog(shell, "Select module", "Write the full name of the module",
- "", null);
+ InputDialog dialog = new InputDialog(shell, Messages.ManualImportModulesAction_SelectModule,
+ Messages.ManualImportModulesAction_SelectModuleMsg, "", null); //$NON-NLS-1$
if(dialog.open() == Dialog.OK) {
- new CommandSessionImportEntry(dialog.getValue(), "", true).addTo(imports);
+ new CommandSessionImportEntry(dialog.getValue(), "", true).addTo(imports); //$NON-NLS-1$
return true;
}
else
--- /dev/null
+package org.simantics.scl.ui.imports.internal;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.simantics.scl.ui.imports.internal.messages"; //$NON-NLS-1$
+ public static String BasicImportModulesAction_AddModules;
+ public static String ExternalImportModulesAction_AddExternalModule;
+ public static String ManageImportsDialog_Delete;
+ public static String ManageImportsDialog_Disable;
+ public static String ManageImportsDialog_Enable;
+ public static String ManageImportsDialog_LocalName;
+ public static String ManageImportsDialog_MakePersistent;
+ public static String ManageImportsDialog_MakeTransient;
+ public static String ManageImportsDialog_ManageImports;
+ public static String ManageImportsDialog_Module;
+ public static String ManageImportsDialog_Status;
+ public static String ManualImportModulesAction_AddFreeformModule;
+ public static String ManualImportModulesAction_SelectModule;
+ public static String ManualImportModulesAction_SelectModuleMsg;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
public class SCLModuleSelectionDialog extends FilteredItemsSelectionDialog {
- private static final String SCL_MODULE_SELECTION_DIALOG = "SCL_MODULE_SELECTION_DIALOG";
+ private static final String SCL_MODULE_SELECTION_DIALOG = "SCL_MODULE_SELECTION_DIALOG"; //$NON-NLS-1$
public SCLModuleSelectionDialog(Shell shell) {
super(shell, true);
if(patternText != null && patternText.length() > 0)
patternMatcher.setPattern(patternText);
else
- patternMatcher.setPattern("*");
+ patternMatcher.setPattern("*"); //$NON-NLS-1$
}
@Override
if(getPattern().indexOf('/') > 0)
return matches((String)item);
else {
- for(String part : ((String)item).split("/"))
+ for(String part : ((String)item).split("/")) //$NON-NLS-1$
if(matches(part))
return true;
return false;
--- /dev/null
+BasicImportModulesAction_AddModules=Add Modules\r
+ExternalImportModulesAction_AddExternalModule=Add External Module\r
+ManageImportsDialog_Delete=Delete\r
+ManageImportsDialog_Disable=Disable\r
+ManageImportsDialog_Enable=Enable\r
+ManageImportsDialog_LocalName=Local name\r
+ManageImportsDialog_MakePersistent=Make Persistent\r
+ManageImportsDialog_MakeTransient=Make Transient\r
+ManageImportsDialog_ManageImports=Manage Imports\r
+ManageImportsDialog_Module=Module\r
+ManageImportsDialog_Status=Status\r
+ManualImportModulesAction_AddFreeformModule=Add Freeform Module\r
+ManualImportModulesAction_SelectModule=Select Module\r
+ManualImportModulesAction_SelectModuleMsg=Write the full name of the module\r
public class SCLInfo {
public static String[] RESERVED_WORDS = new String[] {
- "module",
+ "module", //$NON-NLS-1$
- "data",
- "type",
- "effect",
- "class",
- "deriving",
- "instance",
+ "data", //$NON-NLS-1$
+ "type", //$NON-NLS-1$
+ "effect", //$NON-NLS-1$
+ "class", //$NON-NLS-1$
+ "deriving", //$NON-NLS-1$
+ "instance", //$NON-NLS-1$
- "if",
- "then",
- "else",
- "match",
- "with",
- "where",
- "do",
- "mdo",
- "let",
- "in",
+ "if", //$NON-NLS-1$
+ "then", //$NON-NLS-1$
+ "else", //$NON-NLS-1$
+ "match", //$NON-NLS-1$
+ "with", //$NON-NLS-1$
+ "where", //$NON-NLS-1$
+ "do", //$NON-NLS-1$
+ "mdo", //$NON-NLS-1$
+ "let", //$NON-NLS-1$
+ "in", //$NON-NLS-1$
- "infix",
- "infixl",
- "infixr",
+ "infix", //$NON-NLS-1$
+ "infixl", //$NON-NLS-1$
+ "infixr", //$NON-NLS-1$
- "import",
- "include",
- "hiding",
- "importJava",
+ "import", //$NON-NLS-1$
+ "include", //$NON-NLS-1$
+ "hiding", //$NON-NLS-1$
+ "importJava", //$NON-NLS-1$
- "as",
- "forall",
- "rule",
- "ruleset",
- "constraint",
- "extends",
- "by",
- "select",
- "enforce",
- "transformation",
- "when"
+ "as", //$NON-NLS-1$
+ "forall", //$NON-NLS-1$
+ "rule", //$NON-NLS-1$
+ "ruleset", //$NON-NLS-1$
+ "constraint", //$NON-NLS-1$
+ "extends", //$NON-NLS-1$
+ "by", //$NON-NLS-1$
+ "select", //$NON-NLS-1$
+ "enforce", //$NON-NLS-1$
+ "transformation", //$NON-NLS-1$
+ "when" //$NON-NLS-1$
};
}
--- /dev/null
+package org.simantics.scl.ui.issues;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.simantics.scl.ui.issues.messages"; //$NON-NLS-1$
+ public static String SCLIssuesView_Description;
+ public static String SCLIssuesView_Module;
+ public static String SCLIssuesView_Refresh;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
public void init(IViewSite site, IMemento memento)
throws PartInitException {
super.init(site, memento);
- IAction action = new Action("Refresh") {
+ IAction action = new Action(Messages.SCLIssuesView_Refresh) {
@Override
public void run() {
tableViewer.setInput(SCLOsgi.MODULE_REPOSITORY);
// issuesContentProvider.refresh()
}
};
- action.setImageDescriptor(imageRegistry.getDescriptor("arrow_refresh"));
+ action.setImageDescriptor(imageRegistry.getDescriptor("arrow_refresh")); //$NON-NLS-1$
site.getActionBars().getToolBarManager().add(action);
}
table.setLinesVisible(true);
column1 = new TableViewerColumn(tableViewer, SWT.NONE);
- column1.getColumn().setText("Module");
+ column1.getColumn().setText(Messages.SCLIssuesView_Module);
column1.getColumn().setWidth(COLUMN1_DEFAULT_WIDTH);
column1.getColumn().setResizable(true);
column1.setLabelProvider(new ColumnLabelProvider() {
public Image getImage(Object element) {
SCLIssuesTableEntry entry = (SCLIssuesTableEntry)element;
return entry.error.severity == ErrorSeverity.ERROR
- ? imageRegistry.get("error")
+ ? imageRegistry.get("error") //$NON-NLS-1$
: entry.error.severity == ErrorSeverity.IMPORT_ERROR
- ? imageRegistry.get("import_error")
- : imageRegistry.get("warning");
+ ? imageRegistry.get("import_error") //$NON-NLS-1$
+ : imageRegistry.get("warning"); //$NON-NLS-1$
}
});
column2 = new TableViewerColumn(tableViewer, SWT.NONE);
- column2.getColumn().setText("Description");
+ column2.getColumn().setText(Messages.SCLIssuesView_Description);
column2.getColumn().setResizable(false);
column2.setLabelProvider(new ColumnLabelProvider() {
@Override
--- /dev/null
+SCLIssuesView_Description=Description\r
+SCLIssuesView_Module=Module\r
+SCLIssuesView_Refresh=Refresh\r
import gnu.trove.map.hash.THashMap;
public class CreateModuleAction {
- public static final String PREFIX = "reference:file:/";
+ public static final String PREFIX = "reference:file:/"; //$NON-NLS-1$
public static final void createModule(Bundle bundle, String packageName, String moduleName) throws IOException {
String bundleLocation = bundle.getLocation();
bundleLocation = bundleLocation.substring(PREFIX.length());
- Path packagePath = Paths.get(bundleLocation).resolve("scl").resolve(packageName);
+ Path packagePath = Paths.get(bundleLocation).resolve("scl").resolve(packageName); //$NON-NLS-1$
Files.createDirectories(packagePath);
- Path modulePath = packagePath.resolve(moduleName + ".scl");
+ Path modulePath = packagePath.resolve(moduleName + ".scl"); //$NON-NLS-1$
if(Files.exists(modulePath))
return;
Files.createFile(modulePath);
THashMap<String,Bundle> result = new THashMap<String,Bundle>();
for(Bundle bundle : context.getBundles()) {
String location = bundle.getLocation();
- if(location.endsWith(".jar") || !location.startsWith(PREFIX))
+ if(location.endsWith(".jar") || !location.startsWith(PREFIX)) //$NON-NLS-1$
continue;
location = location.substring(PREFIX.length());
Path bundlePath = Paths.get(location);
for(Bundle bundle : bundles.values()) {
String location = bundle.getLocation();
location = location.substring(PREFIX.length());
- Path packagePath = Paths.get(location).resolve("scl").resolve(packageName);
+ Path packagePath = Paths.get(location).resolve("scl").resolve(packageName); //$NON-NLS-1$
if(Files.exists(packagePath))
return bundle.getSymbolicName();
}
int p = packageName.lastIndexOf('/');
if(p == -1)
- return "";
+ return ""; //$NON-NLS-1$
else
return findBestPlugin(bundles, packageName.substring(0, p));
}
public static int packageMatchLength(Bundle bundle, String packageName) {
- if(bundle.getEntry("scl") == null)
+ if(bundle.getEntry("scl") == null) //$NON-NLS-1$
return 0;
- packageName = "scl/" + packageName;
+ packageName = "scl/" + packageName; //$NON-NLS-1$
while(packageName.length() > 3) {
if(bundle.getEntry(packageName) != null)
return packageName.length();
SCLModuleBrowser parentBrowser;
- String initialPackageName = "";
- String initialPluginName = "";
+ String initialPackageName = ""; //$NON-NLS-1$
+ String initialPluginName = ""; //$NON-NLS-1$
Text packageName;
Text moduleName;
@Override
protected Control createDialogArea(Composite parent) {
- getShell().setText("Create New Module");
+ getShell().setText(Messages.CreateModuleDialog_CreateNewModule);
getShell().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
// Package name
Label packageNameLabel = new Label(composite, SWT.NONE);
- packageNameLabel.setText("Package");
+ packageNameLabel.setText(Messages.CreateModuleDialog_Package);
GridDataFactory.fillDefaults().applyTo(packageNameLabel);
packageName = new Text(composite, SWT.BORDER);
// Module name
Label moduleNameLabel = new Label(composite, SWT.NONE);
- moduleNameLabel.setText("Module name");
+ moduleNameLabel.setText(Messages.CreateModuleDialog_ModuleName);
GridDataFactory.fillDefaults().applyTo(moduleNameLabel);
moduleName = new Text(composite, SWT.BORDER);
// Plugin
Label pluginNameLabel = new Label(composite, SWT.NONE);
- pluginNameLabel.setText("Plugin");
+ pluginNameLabel.setText(Messages.CreateModuleDialog_Plugin);
GridDataFactory.fillDefaults().applyTo(pluginNameLabel);
Composite pluginNameComposite = new Composite(composite, SWT.NONE);
pluginName.addModifyListener(modifyListener);
Button browsePlugins = new Button(pluginNameComposite, SWT.PUSH);
- browsePlugins.setText("Browse...");
+ browsePlugins.setText(Messages.CreateModuleDialog_Browse);
GridDataFactory.fillDefaults().applyTo(browsePlugins);
browsePlugins.addSelectionListener(new SelectionAdapter() {
@Override
boolean validModuleName = CreateModuleValidator.isValidModuleName(moduleName.getText());
if(validModuleName && validPackageName) {
- String fullModuleName = packageName.getText() + "/" + moduleName.getText();
+ String fullModuleName = packageName.getText() + "/" + moduleName.getText(); //$NON-NLS-1$
validModuleName = SCLOsgi.SOURCE_REPOSITORY.getModuleSource(fullModuleName, null) == null;
}
moduleName.setBackground(validModuleName ? normalBackground : errorBackground);
if(bundle != null) {
CreateModuleAction.createModule(bundle, packageName.getText(), moduleName.getText());
parentBrowser.refresh();
- OpenSCLModule.scheduleOpenModule(packageName.getText() + "/" + moduleName.getText());
+ OpenSCLModule.scheduleOpenModule(packageName.getText() + "/" + moduleName.getText()); //$NON-NLS-1$
}
} catch (IOException e) {
- ErrorDialog.openError(getParentShell(), "Module creation failed", e.getMessage(),
- new Status(Status.ERROR, "org.simantics.scl.ui", e.getMessage()));
+ ErrorDialog.openError(getParentShell(), "Module creation failed", e.getMessage(), //$NON-NLS-1$
+ new Status(Status.ERROR, "org.simantics.scl.ui", e.getMessage())); //$NON-NLS-1$
}
super.okPressed();
}
public static boolean isValidPackageName(String packageName) {
if(packageName.isEmpty())
return true;
- for(String part : packageName.split("/", -1))
+ for(String part : packageName.split("/", -1)) //$NON-NLS-1$
if(!isValidModuleName(part))
return false;
return true;
--- /dev/null
+package org.simantics.scl.ui.modulebrowser;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.simantics.scl.ui.modulebrowser.messages"; //$NON-NLS-1$
+ public static String CreateModuleDialog_Browse;
+ public static String CreateModuleDialog_CreateNewModule;
+ public static String CreateModuleDialog_ModuleName;
+ public static String CreateModuleDialog_Package;
+ public static String CreateModuleDialog_Plugin;
+ public static String SCLModuleBrowser_NewModuleDots;
+ public static String SCLModuleBrowser_RefreshModules;
+ public static String SCLModuleBrowser_SCLModules;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
import gnu.trove.map.hash.THashMap;
public class ModuleNameTreeEntry implements Comparable<ModuleNameTreeEntry> {
- public static final String STANDARD_LIBRARY = "StandardLibrary";
- public static final String HTTP_PREFIX = "http://";
+ public static final String STANDARD_LIBRARY = "StandardLibrary"; //$NON-NLS-1$
+ public static final String HTTP_PREFIX = "http://"; //$NON-NLS-1$
public final ModuleNameTreeEntry parent;
public final String fullName;
String newFullName;
if(parent == null) {
if(name.equals(STANDARD_LIBRARY))
- newFullName = "";
+ newFullName = ""; //$NON-NLS-1$
else
newFullName = name;
}
else
- newFullName = fullName + "/" + name;
+ newFullName = fullName + "/" + name; //$NON-NLS-1$
entry = new ModuleNameTreeEntry(this, newFullName, name);
childMap.put(name, entry);
}
public class PluginSelectionDialog extends FilteredItemsSelectionDialog {
- private static final String PLUGIN_SELECTION_DIALOG = "PLUGIN_SELECTION_DIALOG";
+ private static final String PLUGIN_SELECTION_DIALOG = "PLUGIN_SELECTION_DIALOG"; //$NON-NLS-1$
public static class Entry {
Bundle bundle;
public String getText(Object element) {
Entry entry = (Entry)element;
if(entry == null)
- return "NULL";
+ return "NULL"; //$NON-NLS-1$
return entry.bundle.getSymbolicName();
}
});
if(patternText != null && patternText.length() > 0)
patternMatcher.setPattern(patternText);
else
- patternMatcher.setPattern("*");
+ patternMatcher.setPattern("*"); //$NON-NLS-1$
}
@Override
if(getPattern().indexOf('/') > 0)
return matches(name);
else {
- for(String part : name.split("/"))
+ for(String part : name.split("/")) //$NON-NLS-1$
if(matches(part))
return true;
return false;
@Override
public void createPartControl(Composite parent) {
this.content = new SCLModuleTree(parent, SWT.NONE, SCLOsgi.MODULE_REPOSITORY);
- setPartName("SCL Modules");
+ setPartName(Messages.SCLModuleBrowser_SCLModules);
// Opening modules
content.addDoubleClickListener(new IDoubleClickListener() {
// Toolbar
IToolBarManager toolBarManager = getViewSite().getActionBars().getToolBarManager();
- toolBarManager.add(new Action("Refresh modules",
- Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/arrow_refresh.png")) {
+ toolBarManager.add(new Action(Messages.SCLModuleBrowser_RefreshModules,
+ Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/arrow_refresh.png")) { //$NON-NLS-1$ //$NON-NLS-2$
@Override
public void run() {
refresh();
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
ModuleNameTreeEntry entry = (ModuleNameTreeEntry)content.getStructuredSelection().getFirstElement();
- manager.add(new Action("New Module...") {
+ manager.add(new Action(Messages.SCLModuleBrowser_NewModuleDots) {
@Override
public void run() {
CreateModuleDialog dialog = new CreateModuleDialog(content.getControl().getShell(), SCLModuleBrowser.this);
public class SCLModuleTreeContentProvider implements ITreeContentProvider {
private ModuleRepository repository;
- private final ModuleNameTreeEntry rootEntry = new ModuleNameTreeEntry(null, "", "");
+ private final ModuleNameTreeEntry rootEntry = new ModuleNameTreeEntry(null, "", ""); //$NON-NLS-1$ //$NON-NLS-2$
public void update() {
rootEntry.clearModuleFlags();
--- /dev/null
+CreateModuleDialog_Browse=Browse...\r
+CreateModuleDialog_CreateNewModule=Create New Module\r
+CreateModuleDialog_ModuleName=Module name\r
+CreateModuleDialog_Package=Package\r
+CreateModuleDialog_Plugin=Plugin\r
+SCLModuleBrowser_NewModuleDots=New Module...\r
+SCLModuleBrowser_RefreshModules=Refresh Modules\r
+SCLModuleBrowser_SCLModules=SCL Modules\r
--- /dev/null
+package org.simantics.scl.ui.search;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.simantics.scl.ui.search.messages"; //$NON-NLS-1$
+ public static String SCLSearchQuery_SearchReferencesFor;
+ public static String SCLSearchResult_SCLSearchLabelFor;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
@Override
public String getLabel() {
- return "Search references for ";
+ return Messages.SCLSearchQuery_SearchReferencesFor;
}
@Override
import org.eclipse.core.resources.IFile;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.search.ui.ISearchQuery;
import org.eclipse.search.ui.text.AbstractTextSearchResult;
import org.eclipse.search.ui.text.IEditorMatchAdapter;
@Override
public String getLabel() {
- return "SCL search result label for " + query.getValueName();
+ return NLS.bind(Messages.SCLSearchResult_SCLSearchLabelFor , query.getValueName());
}
@Override
SCLExpressionTableEntry entry = (SCLExpressionTableEntry) element;
return entry.getContent();
} else {
- return "unsupported element " + String.valueOf(element);
+ return "unsupported element " + String.valueOf(element); //$NON-NLS-1$
}
}
SCLExpressionTableEntry entry = (SCLExpressionTableEntry) element;
return entry.getContent();
} else {
- return "unsupported element " + String.valueOf(element);
+ return "unsupported element " + String.valueOf(element); //$NON-NLS-1$
}
}
--- /dev/null
+SCLSearchQuery_SearchReferencesFor=Search references for \r
+SCLSearchResult_SCLSearchLabelFor=SCL search result label for {0}\r
--- /dev/null
+package org.simantics.scl.ui.tests;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.simantics.scl.ui.tests.messages"; //$NON-NLS-1$
+ public static String SCLTestsDialog_MonitorSearchingTests;
+ public static String SCLTestsDialog_NoName;
+ public static String SCLTestsDialog_RunSCLTests;
+ public static String SCLTestsDialog_RunTest;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
public class SCLTestsDialog extends FilteredItemsSelectionDialog {
- private static final String SCL_TEST_DIALOG_SETTINGS = "SCLTestDialogSettings";
+ private static final String SCL_TEST_DIALOG_SETTINGS = "SCLTestDialogSettings"; //$NON-NLS-1$
private List<TestRunnable> tests;
public SCLTestsDialog(Shell shell, List<TestRunnable> tests, boolean multi) {
super(shell, multi);
this.tests = tests;
- setTitle("Run SCL Tests");
+ setTitle(Messages.SCLTestsDialog_RunSCLTests);
setListLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
if (element != null)
return ((TestRunnable) element).getName();
- return "No name!";
+ return Messages.SCLTestsDialog_NoName;
}
});
setSelectionHistory(new ResourceSelectionHistory());
protected void createButtonsForButtonBar(Composite parent) {
super.createButtonsForButtonBar(parent);
Button okButton = getButton(IDialogConstants.OK_ID);
- okButton.setText("Run test");
+ okButton.setText(Messages.SCLTestsDialog_RunTest);
setButtonLayoutData(okButton);
}
if(patternText != null && patternText.length() > 0)
patternMatcher.setPattern(patternText);
else
- patternMatcher.setPattern("**");
+ patternMatcher.setPattern("**"); //$NON-NLS-1$
}
@Override
public boolean matchItem(Object item) {
if(getPattern().indexOf('/') > 0)
return matches(testName);
else {
- for(String part : (testName.split("/")))
+ for(String part : (testName.split("/"))) //$NON-NLS-1$
if(matches(part))
return true;
return false;
protected void fillContentProvider(AbstractContentProvider contentProvider,
ItemsFilter itemsFilter, IProgressMonitor progressMonitor)
throws CoreException {
- progressMonitor.beginTask("Searching tests..", tests.size());
+ progressMonitor.beginTask(Messages.SCLTestsDialog_MonitorSearchingTests, tests.size());
for (TestRunnable test : tests) {
contentProvider.add(test, itemsFilter);
progressMonitor.worked(1);
--- /dev/null
+SCLTestsDialog_MonitorSearchingTests=Searching tests..\r
+SCLTestsDialog_NoName=No name\!\r
+SCLTestsDialog_RunSCLTests=Run SCL Tests\r
+SCLTestsDialog_RunTest=Run Test\r
--- /dev/null
+## Strings externalized from bundles ##
+
+* [x] org.simantics.scl.ui
+
+## TODO ##
+
+* [ ] org.simantics.event
+* [ ] org.simantics.modeling.ui
+* [ ] org.simantics.browsing.ui*
+* ...