From: Tuukka Lehtonen Date: Fri, 30 Nov 2018 14:34:35 +0000 (+0200) Subject: Externalize strings in org.simantics.document.ui X-Git-Tag: v1.43.0~136^2~236 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F10%2F2510%2F2;p=simantics%2Fplatform.git Externalize strings in org.simantics.document.ui gitlab #210 Change-Id: Ibf869b4b7a0c8efcc6705f887cfb0ed1f3fac260 --- diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/Activator.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/Activator.java index 5a25c5b6b..82e158854 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/Activator.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/Activator.java @@ -58,9 +58,9 @@ public class Activator extends AbstractUIPlugin { Bundle bundle = context.getBundle(); - DOCUMENT_DECORATION_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/document_decoration.png")); - cross = ImageDescriptor.createFromURL(bundle.getResource("icons/silk_small/cross.png")); - clock_red = ImageDescriptor.createFromURL(bundle.getResource("icons/silk_small/clock_red.png")); + DOCUMENT_DECORATION_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/document_decoration.png")); //$NON-NLS-1$ + cross = ImageDescriptor.createFromURL(bundle.getResource("icons/silk_small/cross.png")); //$NON-NLS-1$ + clock_red = ImageDescriptor.createFromURL(bundle.getResource("icons/silk_small/clock_red.png")); //$NON-NLS-1$ IPath ipath = Platform.getStateLocation(bundle); location = Paths.get(ipath.toOSString()); diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/CSSCompletionAssistProcessor.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/CSSCompletionAssistProcessor.java index fe909fabd..0507fa5ef 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/CSSCompletionAssistProcessor.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/CSSCompletionAssistProcessor.java @@ -11,7 +11,7 @@ import org.eclipse.jface.text.contentassist.IContextInformationValidator; public class CSSCompletionAssistProcessor implements IContentAssistProcessor { - private String lastError = ""; + private String lastError = ""; //$NON-NLS-1$ private CSSTextEditorEnvironment environment; public CSSCompletionAssistProcessor(CSSTextEditorEnvironment environment) { @@ -26,7 +26,7 @@ public class CSSCompletionAssistProcessor implements IContentAssistProcessor { 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) { @@ -38,7 +38,7 @@ public class CSSCompletionAssistProcessor implements IContentAssistProcessor { private static String getPrefix(IDocument doc, int offset) throws BadLocationException { if (doc == null || offset >= doc.getLength()) - return ""; + return ""; //$NON-NLS-1$ int length= 0; while (--offset >= 0 && Character.isJavaIdentifierPart(doc.getChar(offset)) || doc.getChar(offset) == '.') diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/CSSCompletionProposal.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/CSSCompletionProposal.java index 8c86de8ca..aa0d23f0c 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/CSSCompletionProposal.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/CSSCompletionProposal.java @@ -22,10 +22,10 @@ import org.simantics.scl.compiler.elaboration.modules.SCLValue; public class CSSCompletionProposal 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; @@ -39,7 +39,7 @@ public class CSSCompletionProposal implements ICompletionProposal, ICompletionPr this.name = value.getName().name; this.module = value.getName().module; 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); @@ -52,7 +52,7 @@ public class CSSCompletionProposal implements ICompletionProposal, ICompletionPr public CSSCompletionProposal(String name, String module, CSSCompletionType 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; @@ -133,13 +133,13 @@ public class CSSCompletionProposal implements ICompletionProposal, ICompletionPr // 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) { diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/CSSEditor.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/CSSEditor.java index aafd46a85..d3070a0f9 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/CSSEditor.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/CSSEditor.java @@ -40,7 +40,7 @@ import org.simantics.ui.workbench.editor.input.InputValidationCombinators; */ public class CSSEditor extends TextEditor { - public static final String EDITOR_ID = "org.simantics.document.ui.csseditor"; + public static final String EDITOR_ID = "org.simantics.document.ui.csseditor"; //$NON-NLS-1$ private boolean disposed = false; @@ -84,7 +84,7 @@ public class CSSEditor extends TextEditor { try { getResourceInput().init(null); } catch (DatabaseException e) { - throw new PartInitException("Failed to initialize " + input, e); + throw new PartInitException("Failed to initialize " + input, e); //$NON-NLS-1$ } } diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/CSSModuleEditorDocumentProvider.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/CSSModuleEditorDocumentProvider.java index 23553b117..b2cf91405 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/CSSModuleEditorDocumentProvider.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/CSSModuleEditorDocumentProvider.java @@ -56,7 +56,7 @@ public class CSSModuleEditorDocumentProvider extends AbstractDocumentProvider { DocumentResource DOC = DocumentResource.getInstance(graph); currentText = graph.getPossibleRelatedValue(resource, DOC.cssDocument, Bindings.STRING); errorHappened = false; - return new Document(currentText != null ? currentText : ""); + return new Document(currentText != null ? currentText : ""); //$NON-NLS-1$ } }); } catch (DatabaseException e) { @@ -83,7 +83,7 @@ public class CSSModuleEditorDocumentProvider extends AbstractDocumentProvider { synchronized(annotationModel.getLockObject()) { annotationModel.removeAllAnnotations(); for(CompilationError error : errors) { - Annotation annotation = new Annotation("org.eclipse.ui.workbench.texteditor.error", true, + Annotation annotation = new Annotation("org.eclipse.ui.workbench.texteditor.error", true, //$NON-NLS-1$ error.description); int begin = Locations.beginOf(error.location); int end = Locations.endOf(error.location); @@ -108,7 +108,7 @@ public class CSSModuleEditorDocumentProvider extends AbstractDocumentProvider { @Override protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) throws CoreException { - TimeLogger.resetTimeAndLog("SCLModuleEditorDocumentProvider.doSaveDocument"); + TimeLogger.resetTimeAndLog("SCLModuleEditorDocumentProvider.doSaveDocument"); //$NON-NLS-1$ currentText = document.get(); Simantics.getSession().asyncRequest(new WriteRequest() { @Override diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/CSSSourceViewerConfiguration.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/CSSSourceViewerConfiguration.java index 3894faa86..44f0694f5 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/CSSSourceViewerConfiguration.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/CSSSourceViewerConfiguration.java @@ -97,8 +97,8 @@ public class CSSSourceViewerConfiguration extends SourceViewerConfiguration { ITokenScanner getSclTokenScanner() { RuleBasedScanner scanner = new RuleBasedScanner(); - Font font = new Font(device, "Courier New", 10, SWT.NORMAL); - Font boldFont = new Font(device, "Courier New", 10, SWT.BOLD); + Font font = new Font(device, "Courier New", 10, SWT.NORMAL); //$NON-NLS-1$ + Font boldFont = new Font(device, "Courier New", 10, SWT.BOLD); //$NON-NLS-1$ Token defaultToken = new Token( new TextAttribute( @@ -139,20 +139,20 @@ public class CSSSourceViewerConfiguration extends SourceViewerConfiguration { } }); - reservedWord.addWord("if", reserved); - reservedWord.addWord("then", reserved); - reservedWord.addWord("else", reserved); - reservedWord.addWord("match", reserved); - reservedWord.addWord("with", reserved); - reservedWord.addWord("data", reserved); - reservedWord.addWord("type", reserved); - reservedWord.addWord("class", reserved); + reservedWord.addWord("if", reserved); //$NON-NLS-1$ + reservedWord.addWord("then", reserved); //$NON-NLS-1$ + reservedWord.addWord("else", reserved); //$NON-NLS-1$ + reservedWord.addWord("match", reserved); //$NON-NLS-1$ + reservedWord.addWord("with", reserved); //$NON-NLS-1$ + reservedWord.addWord("data", reserved); //$NON-NLS-1$ + reservedWord.addWord("type", reserved); //$NON-NLS-1$ + reservedWord.addWord("class", reserved); //$NON-NLS-1$ IRule[] rules = new IRule[] { //new MultiLineRule("\"\"\"", "\"\"\"", string), - new PatternRule("\"", "\"", string, '\\', true), - new MultiLineRule("/*", "*/", comment), - new EndOfLineRule("//", comment), + new PatternRule("\"", "\"", string, '\\', true), //$NON-NLS-1$ //$NON-NLS-2$ + new MultiLineRule("/*", "*/", comment), //$NON-NLS-1$ //$NON-NLS-2$ + new EndOfLineRule("//", comment), //$NON-NLS-1$ reservedWord }; scanner.setRules(rules); diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/DocumentView.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/DocumentView.java index 0d7973f6a..2083c3b4a 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/DocumentView.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/DocumentView.java @@ -51,11 +51,11 @@ public class DocumentView extends ModelledView { private class PinSelection extends Action { public PinSelection() { - super("Pin Selection", IAction.AS_CHECK_BOX); + super(Messages.DocumentView_PinSelection, IAction.AS_CHECK_BOX); setImageDescriptor( BundleUtils.getImageDescriptorFromPlugin( - "org.eclipse.ui", - "icons/full/etool16/pin_editor.png")); + "org.eclipse.ui", //$NON-NLS-1$ + "icons/full/etool16/pin_editor.png")); //$NON-NLS-1$ } @Override diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/Messages.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/Messages.java new file mode 100644 index 000000000..610502639 --- /dev/null +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/Messages.java @@ -0,0 +1,16 @@ +package org.simantics.document.ui; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.simantics.document.ui.messages"; //$NON-NLS-1$ + public static String DocumentView_PinSelection; + public static String OpenEntityDocumentAdapter_DocumentEditor; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/OpenEntityDocumentAdapter.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/OpenEntityDocumentAdapter.java index bd44a50b1..2226a2413 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/OpenEntityDocumentAdapter.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/OpenEntityDocumentAdapter.java @@ -32,11 +32,11 @@ import org.simantics.utils.ui.workbench.WorkbenchUtils; public class OpenEntityDocumentAdapter extends AbstractResourceEditorAdapter { - private static final String EDITOR_ID = "org.simantics.document.ui.editor"; + private static final String EDITOR_ID = "org.simantics.document.ui.editor"; //$NON-NLS-1$ public OpenEntityDocumentAdapter() throws MalformedURLException { - super("Document Editor", ImageDescriptor.createFromURL(new URL( - "platform:/plugin/com.famfamfam.silk/icons/table.png"))); + super(Messages.OpenEntityDocumentAdapter_DocumentEditor, ImageDescriptor.createFromURL(new URL( + "platform:/plugin/com.famfamfam.silk/icons/table.png"))); //$NON-NLS-1$ } protected String getEditorId() { diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/AddUrlDocument.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/AddUrlDocument.java index 6e312cb37..738c3c6bc 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/AddUrlDocument.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/AddUrlDocument.java @@ -48,7 +48,7 @@ public class AddUrlDocument extends AddDocumentAction { @Override public void run() { - InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), "Add URL", "Input URL", "", new URLValidator()); + InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), Messages.AddUrlDocument_AddURL, Messages.AddUrlDocument_InputURL, "", new URLValidator()); //$NON-NLS-3$ if (dialog.open() != InputDialog.OK) return; final String uriString = dialog.getValue(); @@ -69,7 +69,7 @@ public class AddUrlDocument extends AddDocumentAction { } }, e -> { if (e != null) - ExceptionUtils.logAndShowError("Cannot add URL link.", e); + ExceptionUtils.logAndShowError(Messages.AddUrlDocument_CannotAddURLLink, e); }); } }; diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/AddUrlDocumentWithDetail.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/AddUrlDocumentWithDetail.java index 61210a222..829b2aa32 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/AddUrlDocumentWithDetail.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/AddUrlDocumentWithDetail.java @@ -69,7 +69,7 @@ public class AddUrlDocumentWithDetail extends AddDocumentAction { }, e -> { dialog.getAnnotationConfigurator().dispose(); if (e != null) - ExceptionUtils.logAndShowError("Cannot add URL link.", e); + ExceptionUtils.logAndShowError("Cannot add URL link.", e); //$NON-NLS-1$ }); } }; @@ -86,7 +86,7 @@ public class AddUrlDocumentWithDetail extends AddDocumentAction { } public static Resource addUrlDocumentWithDetailSCL(WriteGraph graph, Resource target, String name, String uriString) throws DatabaseException { - AddUrlDocumentWithDetail urlDocument = new AddUrlDocumentWithDetail(graph, "http://www.simantics.org/Layer0-1.1/ConsistsOf"); + AddUrlDocumentWithDetail urlDocument = new AddUrlDocumentWithDetail(graph, "http://www.simantics.org/Layer0-1.1/ConsistsOf"); //$NON-NLS-1$ Resource urlResource = urlDocument.doAddUrl(graph, name, uriString); urlDocument.linkDocument(graph, target, urlResource); return urlResource; diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/ExportDocumentFile.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/ExportDocumentFile.java index 652476d90..53777608f 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/ExportDocumentFile.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/ExportDocumentFile.java @@ -72,7 +72,7 @@ public class ExportDocumentFile implements ActionFactory { return; exportDocument(resource, filename); } catch (DatabaseException e) { - ExceptionUtils.logAndShowError("Cannot export document.", e); + ExceptionUtils.logAndShowError(Messages.ExportDocumentFile_CannotExportDocument, e); } } diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/ExportDocumentFolder.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/ExportDocumentFolder.java index 3956a5923..a7f9a9704 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/ExportDocumentFolder.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/ExportDocumentFolder.java @@ -16,7 +16,9 @@ import java.io.File; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; +import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.DirectoryDialog; import org.eclipse.swt.widgets.Display; @@ -47,7 +49,7 @@ public class ExportDocumentFolder implements ActionFactory { public ExportDocumentFolder(ReadGraph graph, String relationUri, String useResourceNames) throws DatabaseException { relation = graph.getResource(relationUri); - this.useResourceNames = useResourceNames.equals("true"); + this.useResourceNames = useResourceNames.equals("true"); //$NON-NLS-1$ } @Override @@ -70,7 +72,7 @@ public class ExportDocumentFolder implements ActionFactory { File folder = new File(folderName); int choice = -1; if (folder.list().length > 0) { - MessageDialog messageDialog = new MessageDialog(shell, "Folder export", null, "Selected folder \"" + folderName + "\" is not empty.", MessageDialog.QUESTION, new String[]{"Delete and export","Overwrite","Cancel"}, 2); + MessageDialog messageDialog = new MessageDialog(shell, Messages.ExportDocumentFolder_FolderExport, null, NLS.bind(Messages.ExportDocumentFolder_SelectedFolder, folderName), MessageDialog.QUESTION, new String[]{Messages.ExportDocumentFolder_DeleteAndExport,Messages.ExportDocumentFolder_Overwrite, IDialogConstants.CANCEL_LABEL }, 2); //$NON-NLS-3$ choice = messageDialog.open(); if (choice == 2) return; @@ -89,7 +91,7 @@ public class ExportDocumentFolder implements ActionFactory { File folder; boolean clear = false; public ExportJob(Resource resource,File folder, boolean clear) { - super("Export folder"); + super(Messages.ExportDocumentFolder_ExportFolder); this.resource = resource; this.folder = folder; this.clear = clear; @@ -97,17 +99,17 @@ public class ExportDocumentFolder implements ActionFactory { @Override protected IStatus run(IProgressMonitor monitor) { try { - monitor.beginTask("Export folder", IProgressMonitor.UNKNOWN); + monitor.beginTask(Messages.ExportDocumentFolder_ExportFolder, IProgressMonitor.UNKNOWN); if (clear) { GraphFileUtil.clearDirectoryStructure(folder); monitor.worked(1); } FileDocumentUtil.exportDocumentFolder(resource, folder, relation, useResourceNames, monitor); monitor.done(); - return new Status(IStatus.OK, Activator.PLUGIN_ID, "Folder exported."); + return new Status(IStatus.OK, Activator.PLUGIN_ID, Messages.ExportDocumentFolder_ActivatorFolderExported); } catch (Exception e) { monitor.done(); - return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Cannot export document folder.", e); + return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ExportDocumentFolder_AcivatorCannotExport, e); } } } diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/ImportDocument.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/ImportDocument.java index 52eb042ac..923f3d7bf 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/ImportDocument.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/ImportDocument.java @@ -56,13 +56,13 @@ public class ImportDocument extends AddDocumentAction { // if is, use those extensions to filter this list. // note: in windows using "reg query ..." to read bindings form registry would work. // Note : If the above mentioned filtering is implemented it should be made optional / configurable. - dialog.setFilterExtensions(new String[]{"*.*"}); + dialog.setFilterExtensions(new String[]{"*.*"}); //$NON-NLS-1$ if (dialog.open() == null) return; String filterPath = dialog.getFilterPath(); String[] filenames = dialog.getFileNames(); - ImportJob job = new ImportJob(filenames.length > 1 ? "Import files" : "Import file", resource, filterPath, filenames); + ImportJob job = new ImportJob(filenames.length > 1 ? Messages.ImportDocument_JobImportFiles : Messages.ImportDocument_ImportFile, resource, filterPath, filenames); job.setUser(true); job.schedule(); } @@ -84,7 +84,7 @@ public class ImportDocument extends AddDocumentAction { @Override protected IStatus run(final IProgressMonitor monitor) { - monitor.beginTask("Importing...", filenames.length); + monitor.beginTask(Messages.ImportDocument_ImportingDots, filenames.length); try { Simantics.getSession().syncRequest(new WriteRequest() { @Override @@ -102,9 +102,9 @@ public class ImportDocument extends AddDocumentAction { } } }); - return new Status(IStatus.OK, Activator.PLUGIN_ID, "Import succesful."); + return new Status(IStatus.OK, Activator.PLUGIN_ID, Messages.ImportDocument_ActivatorImportSucessful); } catch (DatabaseException e) { - return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import failed.", e); + return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ImportDocument_ImportFailed, e); } finally { monitor.done(); } diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/ImportDocumentFolder.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/ImportDocumentFolder.java index 88eb503f5..ab66fdab3 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/ImportDocumentFolder.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/ImportDocumentFolder.java @@ -58,7 +58,7 @@ public class ImportDocumentFolder implements ActionFactory { return; } - ImportJob job = new ImportJob("Import folder", resource, filename); + ImportJob job = new ImportJob(Messages.ImportDocumentFolder_ImportFolder, resource, filename); job.setUser(true); job.schedule(); } @@ -91,9 +91,9 @@ public class ImportDocumentFolder implements ActionFactory { } } }); - return new Status(IStatus.OK, Activator.PLUGIN_ID, "Folder imported."); + return new Status(IStatus.OK, Activator.PLUGIN_ID, Messages.ImportDocumentFolder_ActivatorFolderImported); } catch (DatabaseException e) { - return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Cannot import document folder.", e); + return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ImportDocumentFolder_ActivatorCannotImportDocumentFolder, e); } } } diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/ImportDocumentWithDetail.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/ImportDocumentWithDetail.java index 091f33e7d..be5045944 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/ImportDocumentWithDetail.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/ImportDocumentWithDetail.java @@ -74,7 +74,7 @@ public class ImportDocumentWithDetail extends AddDocumentAction { }, e -> { dialog.getAnnotationConfigurator().dispose(); if (e != null) - ExceptionUtils.logAndShowError("Cannot import document.", e); + ExceptionUtils.logAndShowError(Messages.ImportDocumentWithDetail_CannotImportDocument, e); }); } }; @@ -91,8 +91,8 @@ public class ImportDocumentWithDetail extends AddDocumentAction { public static Resource importDocumentWithDetailSCL(WriteGraph graph, Resource target, String filename) throws FileNotFoundException, DatabaseException { File file = new File(filename); if (!file.exists()) - throw new FileNotFoundException("File not found - " + file.getAbsolutePath()); - ImportDocumentWithDetail document = new ImportDocumentWithDetail(graph, "http://www.simantics.org/Layer0-1.1/ConsistsOf"); + throw new FileNotFoundException("File not found - " + file.getAbsolutePath()); //$NON-NLS-1$ + ImportDocumentWithDetail document = new ImportDocumentWithDetail(graph, "http://www.simantics.org/Layer0-1.1/ConsistsOf"); //$NON-NLS-1$ return document.doDocumentImport(graph, target, filename, file.getName()); } diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/Messages.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/Messages.java new file mode 100644 index 000000000..7e402e4ea --- /dev/null +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/Messages.java @@ -0,0 +1,35 @@ +package org.simantics.document.ui.actions; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.simantics.document.ui.actions.messages"; //$NON-NLS-1$ + public static String AddUrlDocument_AddURL; + public static String AddUrlDocument_CannotAddURLLink; + public static String AddUrlDocument_InputURL; + public static String ExportDocumentFile_CannotExportDocument; + public static String ExportDocumentFolder_AcivatorCannotExport; + public static String ExportDocumentFolder_ActivatorFolderExported; + public static String ExportDocumentFolder_DeleteAndExport; + public static String ExportDocumentFolder_ExportFolder; + public static String ExportDocumentFolder_FolderExport; + public static String ExportDocumentFolder_Overwrite; + public static String ExportDocumentFolder_SelectedFolder; + public static String ImportDocument_ActivatorImportSucessful; + public static String ImportDocument_ImportFailed; + public static String ImportDocument_ImportFile; + public static String ImportDocument_ImportingDots; + public static String ImportDocument_JobImportFiles; + public static String ImportDocumentFolder_ActivatorCannotImportDocumentFolder; + public static String ImportDocumentFolder_ActivatorFolderImported; + public static String ImportDocumentFolder_ImportFolder; + public static String ImportDocumentWithDetail_CannotImportDocument; + public static String NewDocumentFolder_Folder; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/NewDocumentFolder.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/NewDocumentFolder.java index 2feadfdcb..674ead9b2 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/NewDocumentFolder.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/NewDocumentFolder.java @@ -38,7 +38,7 @@ public class NewDocumentFolder implements ActionFactory { Layer0 l0 = Layer0.getInstance(graph); - String name = NameUtils.findFreshName(graph, "Folder", resource, relation); + String name = NameUtils.findFreshName(graph, Messages.NewDocumentFolder_Folder, resource, relation); Resource folder = graph.newResource(); graph.claim(folder, l0.InstanceOf, folderType); graph.claimLiteral(folder, l0.HasName, name); diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/messages.properties b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/messages.properties new file mode 100644 index 000000000..7297932db --- /dev/null +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/messages.properties @@ -0,0 +1,21 @@ +AddUrlDocument_AddURL=Add URL +AddUrlDocument_CannotAddURLLink=Cannot add URL link. +AddUrlDocument_InputURL=Input URL +ExportDocumentFile_CannotExportDocument=Cannot export document. +ExportDocumentFolder_AcivatorCannotExport=Cannot export document folder. +ExportDocumentFolder_ActivatorFolderExported=Folder exported. +ExportDocumentFolder_DeleteAndExport=Delete and export +ExportDocumentFolder_ExportFolder=Export folder +ExportDocumentFolder_FolderExport=Folder export +ExportDocumentFolder_Overwrite=Overwrite +ExportDocumentFolder_SelectedFolder=Selected folder "{0}" is not empty. +ImportDocument_ActivatorImportSucessful=Import successful. +ImportDocument_ImportFailed=Import failed. +ImportDocument_ImportFile=Import file +ImportDocument_ImportingDots=Importing... +ImportDocument_JobImportFiles=Import files +ImportDocumentFolder_ActivatorCannotImportDocumentFolder=Cannot import document folder. +ImportDocumentFolder_ActivatorFolderImported=Folder imported. +ImportDocumentFolder_ImportFolder=Import folder +ImportDocumentWithDetail_CannotImportDocument=Cannot import document. +NewDocumentFolder_Folder=Folder diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/contribution/DocumentTabContribution.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/contribution/DocumentTabContribution.java index 005cb9e45..f4f38a8ab 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/contribution/DocumentTabContribution.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/contribution/DocumentTabContribution.java @@ -77,7 +77,7 @@ public class DocumentTabContribution extends AbstractResourceTabContribution{ DocumentResource doc = DocumentResource.getInstance(graph); if (!graph.isInstanceOf(resource, doc.Document)) return; - result.add(new ComparableTabContributor(new DocumentPropertyTabContributor(), 1, resource, "Document")); + result.add(new ComparableTabContributor(new DocumentPropertyTabContributor(), 1, resource, Messages.DocumentTabContribution_Document)); } private class DocumentPropertyTabContributor extends PropertyTabContributorImpl { @@ -90,7 +90,7 @@ public class DocumentTabContribution extends AbstractResourceTabContribution{ GridLayoutFactory.fillDefaults().margins(3,3).spacing(1, 1).numColumns(4).applyTo(composite); Label label = new Label(composite, SWT.NONE); - label.setText("Name"); + label.setText(Messages.DocumentTabContribution_Name); TrackedText name = new TrackedText(composite, support, SWT.BORDER); name.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasName)); @@ -100,7 +100,7 @@ public class DocumentTabContribution extends AbstractResourceTabContribution{ support.register(validator); Button showButton = new Button(composite, SWT.PUSH); - showButton.setText("Show"); + showButton.setText(Messages.DocumentTabContribution_Show); showButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { @@ -110,10 +110,10 @@ public class DocumentTabContribution extends AbstractResourceTabContribution{ DocumentResource doc; try { doc = DocumentResource.getInstance(context.getSession()); - new DocumentRevisionWidget(composite, support, doc.HasOlderVersion, "Old"); - new DocumentRevisionWidget(composite, support, doc.HasNewerVersion, "New"); + new DocumentRevisionWidget(composite, support, doc.HasOlderVersion, Messages.DocumentTabContribution_Old); + new DocumentRevisionWidget(composite, support, doc.HasNewerVersion, Messages.DocumentTabContribution_New); } catch (DatabaseException e1) { - ExceptionUtils.logAndShowError("Cannot create documen version UI", e1); + ExceptionUtils.logAndShowError(Messages.DocumentTabContribution_CannotCreateDocumentVersionUI, e1); } @@ -129,7 +129,7 @@ public class DocumentTabContribution extends AbstractResourceTabContribution{ public String perform(ReadGraph graph) throws DatabaseException { Resource res = AdaptionUtils.adaptToSingle(forSelection, Resource.class); if (res == null) - return "N/A"; + return Messages.DocumentTabContribution_6; Layer0 l0 = Layer0.getInstance(graph); return graph.getPossibleRelatedValue(res, l0.HasName); } @@ -169,7 +169,7 @@ public class DocumentTabContribution extends AbstractResourceTabContribution{ try { adapter.openEditor(resource); } catch (Exception e) { - ExceptionUtils.logAndShowError("Cannot open editor", e); + ExceptionUtils.logAndShowError(Messages.DocumentTabContribution_7, e); } } }); @@ -194,7 +194,7 @@ public class DocumentTabContribution extends AbstractResourceTabContribution{ label.setText(name); text = new Text(parent, SWT.SINGLE|SWT.BORDER|SWT.READ_ONLY); showButton = new Button(parent, SWT.PUSH); - showButton.setText("Show"); + showButton.setText(Messages.DocumentTabContribution_8); showButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { @@ -203,7 +203,7 @@ public class DocumentTabContribution extends AbstractResourceTabContribution{ } }); removeButton = new Button(parent, SWT.PUSH); - removeButton.setText("Unset"); + removeButton.setText(Messages.DocumentTabContribution_9); removeButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { @@ -219,7 +219,7 @@ public class DocumentTabContribution extends AbstractResourceTabContribution{ }); revisionDoc = null; } catch (DatabaseException e1) { - ExceptionUtils.logAndShowError("Cannot remove document revision", e1); + ExceptionUtils.logAndShowError(Messages.DocumentTabContribution_10, e1); } updateUI(); } @@ -297,7 +297,7 @@ public class DocumentTabContribution extends AbstractResourceTabContribution{ @Override public void exception(AsyncReadGraph graph, Throwable t) { - ExceptionUtils.logAndShowError("Cannot show document revision", t); + ExceptionUtils.logAndShowError(Messages.DocumentTabContribution_11, t); } @Override @@ -318,7 +318,7 @@ public class DocumentTabContribution extends AbstractResourceTabContribution{ if (revisionDoc != null) text.setText(revisionDoc.getName()); else - text.setText(""); + text.setText(""); //$NON-NLS-1$ } private void setRevisionDoc(final Resource toSet) { diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/contribution/Messages.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/contribution/Messages.java new file mode 100644 index 000000000..8263dd229 --- /dev/null +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/contribution/Messages.java @@ -0,0 +1,28 @@ +package org.simantics.document.ui.contribution; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.simantics.document.ui.contribution.messages"; //$NON-NLS-1$ + public static String DocumentTabContribution_10; + public static String DocumentTabContribution_11; + public static String DocumentTabContribution_6; + public static String DocumentTabContribution_7; + public static String DocumentTabContribution_8; + public static String DocumentTabContribution_9; + public static String DocumentTabContribution_CannotCreateDocumentVersionUI; + public static String DocumentTabContribution_Document; + public static String DocumentTabContribution_Name; + public static String DocumentTabContribution_New; + public static String DocumentTabContribution_Old; + public static String DocumentTabContribution_Show; + public static String NameInputValidator_CannotHaveDuplicateName; + public static String NameInputValidator_EmptyNameNotAllowed; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/contribution/NameInputValidator.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/contribution/NameInputValidator.java index 14ff5f60d..009d803f8 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/contribution/NameInputValidator.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/contribution/NameInputValidator.java @@ -3,6 +3,7 @@ package org.simantics.document.ui.contribution; import java.util.Collection; import org.eclipse.jface.dialogs.IInputValidator; +import org.eclipse.osgi.util.NLS; import org.simantics.Simantics; import org.simantics.browsing.ui.swt.widgets.impl.Widget; import org.simantics.db.ReadGraph; @@ -20,7 +21,7 @@ public class NameInputValidator implements IInputValidator, Widget { @Override public String isValid(final String newText) { if (newText == null || newText.length() == 0) - return "Empty name is not allowed"; + return Messages.NameInputValidator_EmptyNameNotAllowed; if (selection != null) { try { return Simantics.getSession().syncRequest(new Read() { @@ -36,7 +37,7 @@ public class NameInputValidator implements IInputValidator, Widget { continue; String n = graph.getPossibleRelatedValue(resource, l0.HasName); if (newText.equals(n)) - return "Cannot have duplicate name " + newText; + return NLS.bind(Messages.NameInputValidator_CannotHaveDuplicateName, newText); } return null; } diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/contribution/messages.properties b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/contribution/messages.properties new file mode 100644 index 000000000..a2278acbb --- /dev/null +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/contribution/messages.properties @@ -0,0 +1,14 @@ +DocumentTabContribution_10=Cannot remove document revision +DocumentTabContribution_11=Cannot show document revision +DocumentTabContribution_6=N/A +DocumentTabContribution_7=Cannot open editor +DocumentTabContribution_8=Show +DocumentTabContribution_9=Unset +DocumentTabContribution_CannotCreateDocumentVersionUI=Cannot create document version UI +DocumentTabContribution_Document=Document +DocumentTabContribution_Name=Name +DocumentTabContribution_New=New +DocumentTabContribution_Old=Old +DocumentTabContribution_Show=Show +NameInputValidator_CannotHaveDuplicateName=Cannot have duplicate name {0} +NameInputValidator_EmptyNameNotAllowed=Empty name is not allowed diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/dialogs/AnnotationConfigurator.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/dialogs/AnnotationConfigurator.java index 2c63d6157..232532423 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/dialogs/AnnotationConfigurator.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/dialogs/AnnotationConfigurator.java @@ -92,7 +92,7 @@ public class AnnotationConfigurator { VirtualGraph vg = null; if (useVG) { VirtualGraphSupport support = Simantics.getSession().getService(VirtualGraphSupport.class); - vg = support.getMemoryPersistent("document_annotation"); + vg = support.getMemoryPersistent("document_annotation"); //$NON-NLS-1$ } Variable annotationHolder = null; try { @@ -101,7 +101,7 @@ public class AnnotationConfigurator { Layer0 l0 = Layer0.getInstance(graph); Resource annotationHolderDoc = graph.newResource(); graph.claim(annotationHolderDoc, l0.InstanceOf, type); - graph.claimLiteral(annotationHolderDoc, l0.HasName, "Template"); + graph.claimLiteral(annotationHolderDoc, l0.HasName, "Template"); //$NON-NLS-1$ graph.claim(lib, l0.ConsistsOf, annotationHolderDoc); if (graph.isInstanceOf(lib, type)) { copyAnnotations(graph, lib, annotationHolderDoc); @@ -187,7 +187,7 @@ public class AnnotationConfigurator { if (useVG) { VirtualGraphSupport support = Simantics.getSession().getService(VirtualGraphSupport.class); - VirtualGraph vg = support.getMemoryPersistent("document_annotation"); + VirtualGraph vg = support.getMemoryPersistent("document_annotation"); //$NON-NLS-1$ support.discard(vg); } else { diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/dialogs/FileDetailDialog.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/dialogs/FileDetailDialog.java index a8ae3c195..c8ac4ca31 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/dialogs/FileDetailDialog.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/dialogs/FileDetailDialog.java @@ -86,16 +86,16 @@ public class FileDetailDialog extends TextInputDialog{ GridDataFactory.fillDefaults().hint(500, 500).applyTo(composite); Label label = new Label(composite, SWT.NONE); - label.setText("File:"); + label.setText(Messages.FileDetailDialog_File); fileText = new Text(composite, SWT.SINGLE|SWT.BORDER); Button browseButton = new Button(composite, SWT.PUSH); - browseButton.setText("Browse"); + browseButton.setText(Messages.FileDetailDialog_Browse); label = new Label(composite, SWT.NONE); - label.setText("Name:"); + label.setText(Messages.FileDetailDialog_Name); nameText = new Text(composite, SWT.SINGLE|SWT.BORDER); label = new Label(composite, SWT.NONE); label = new Label(composite, SWT.NONE); - label.setText("Annotations:"); + label.setText(Messages.FileDetailDialog_Annotations); annotationComposite = new Composite(composite, SWT.NONE); annotationComposite.setLayout(new FillLayout()); @@ -130,7 +130,7 @@ public class FileDetailDialog extends TextInputDialog{ @Override public void widgetSelected(SelectionEvent e) { FileDialog dialog = new FileDialog(e.display.getActiveShell(),SWT.OPEN); - dialog.setFilterExtensions(new String[]{"*.*"}); + dialog.setFilterExtensions(new String[]{"*.*"}); //$NON-NLS-1$ String s = dialog.open(); if (s != null) { name = null; diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/dialogs/Messages.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/dialogs/Messages.java new file mode 100644 index 000000000..be4953446 --- /dev/null +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/dialogs/Messages.java @@ -0,0 +1,21 @@ +package org.simantics.document.ui.dialogs; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.simantics.document.ui.dialogs.messages"; //$NON-NLS-1$ + public static String FileDetailDialog_Annotations; + public static String FileDetailDialog_Browse; + public static String FileDetailDialog_File; + public static String FileDetailDialog_Name; + public static String UrlDetailDialog_Annotations; + public static String UrlDetailDialog_Name; + public static String UrlDetailDialog_URL; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/dialogs/UrlDetailDialog.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/dialogs/UrlDetailDialog.java index ef3739e1a..1c0efc6da 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/dialogs/UrlDetailDialog.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/dialogs/UrlDetailDialog.java @@ -86,13 +86,13 @@ public class UrlDetailDialog extends TextInputDialog{ GridDataFactory.fillDefaults().hint(500, 500).applyTo(composite); Label label = new Label(composite, SWT.NONE); - label.setText("URL:"); + label.setText(Messages.UrlDetailDialog_URL); urlText = new Text(composite, SWT.SINGLE|SWT.BORDER); label = new Label(composite, SWT.NONE); - label.setText("Name:"); + label.setText(Messages.UrlDetailDialog_Name); nameText = new Text(composite, SWT.SINGLE|SWT.BORDER); label = new Label(composite, SWT.NONE); - label.setText("Annotations:"); + label.setText(Messages.UrlDetailDialog_Annotations); annotationComposite = new Composite(composite, SWT.BORDER); annotationComposite.setLayout(new FillLayout()); // diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/dialogs/messages.properties b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/dialogs/messages.properties new file mode 100644 index 000000000..5d0722810 --- /dev/null +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/dialogs/messages.properties @@ -0,0 +1,7 @@ +FileDetailDialog_Annotations=Annotations: +FileDetailDialog_Browse=Browse +FileDetailDialog_File=File: +FileDetailDialog_Name=Name: +UrlDetailDialog_Annotations=Annotations: +UrlDetailDialog_Name=Name: +UrlDetailDialog_URL=URL: diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/function/All.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/function/All.java index effe30cd9..a500aa12c 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/function/All.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/function/All.java @@ -101,13 +101,13 @@ public class All { Resource documentType = graph.getSingleObject(binding, DOC.DocumentTypeBinding_HasDocumentType); Resource document = graph.newResource(); graph.claim(document, L0.InstanceOf, null, DOC.ScenegraphDocument); - graph.claimLiteral(document, L0.HasName, "Documentation"); + graph.claimLiteral(document, L0.HasName, "Documentation"); //$NON-NLS-1$ graph.claim(resource, DOC.HasDocumentation, document); graph.claim(document, L0.PartOf, resource); Resource scenegraph = graph.newResource(); graph.claim(scenegraph, L0.InstanceOf, null, documentType); - graph.claimLiteral(scenegraph, L0.HasName, "Scenegraph"); + graph.claimLiteral(scenegraph, L0.HasName, "Scenegraph"); //$NON-NLS-1$ graph.claim(scenegraph, L0.PartOf, document); graph.claim(document, DOC.ScenegraphDocument_scenegraph, scenegraph); @@ -286,7 +286,7 @@ public class All { Variable result = ScenegraphLoaderProcess.getVariable(graph, null, scenegraph, ScenegraphLoaderUtils.getRuntime(graph, context), root); if(result != null) { - Variable userDoc = result.getPossibleProperty(graph, "UserDocumentation"); + Variable userDoc = result.getPossibleProperty(graph, "UserDocumentation"); //$NON-NLS-1$ if(userDoc != null) return userDoc; } @@ -309,7 +309,7 @@ public class All { @SCLValue(type = "ReadGraph -> Resource -> Variable -> a") public static Object wikitextModifier(ReadGraph graph, final Resource resource, final Variable context) throws DatabaseException { - final ScenegraphPropertyReference textReference = ScenegraphLoaderUtils.getRelativePropertyReference(SWTThread.getThreadAccess(), graph, context, ".../TextContainer/Text#text"); + final ScenegraphPropertyReference textReference = ScenegraphLoaderUtils.getRelativePropertyReference(SWTThread.getThreadAccess(), graph, context, ".../TextContainer/Text#text"); //$NON-NLS-1$ return new FunctionImpl1() { @@ -323,12 +323,12 @@ public class All { @Override public void perform(WriteGraph graph) throws DatabaseException { - Variable selection = resolveEditSelection(graph, context, "..../Scroll/Browser#edited"); + Variable selection = resolveEditSelection(graph, context, "..../Scroll/Browser#edited"); //$NON-NLS-1$ if (selection != null) { selection.setValue(graph, (String)value, Bindings.STRING); graph.markUndoPoint(); } else { - LOGGER.error("No selection for resource : " + resource + ", Variable context : " + context + ", value : " + value); + LOGGER.error("No selection for resource : " + resource + ", Variable context : " + context + ", value : " + value); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } } @@ -351,7 +351,7 @@ public class All { @SCLValue(type = "ReadGraph -> Resource -> Variable -> String") public static String selectedDocumentPart(ReadGraph graph, Resource resource, Variable context) throws DatabaseException { - Variable selection = resolveEditSelection(graph, context, ".../Scroll/Browser#edited"); + Variable selection = resolveEditSelection(graph, context, ".../Scroll/Browser#edited"); //$NON-NLS-1$ if(selection == null) return null; return selection.getValue(graph); @@ -389,8 +389,8 @@ public class All { final ScenegraphPropertyReference selectionReference; public WikiButtonModifier(ReadGraph graph, Variable context) throws DatabaseException { - textReference = ScenegraphLoaderUtils.getRelativePropertyReference(SWTThread.getThreadAccess(), graph, context, ".../TextContainer/Text#text"); - selectionReference = ScenegraphLoaderUtils.getRelativePropertyReference(SWTThread.getThreadAccess(), graph, context, ".../TextContainer/Text#selection"); + textReference = ScenegraphLoaderUtils.getRelativePropertyReference(SWTThread.getThreadAccess(), graph, context, ".../TextContainer/Text#text"); //$NON-NLS-1$ + selectionReference = ScenegraphLoaderUtils.getRelativePropertyReference(SWTThread.getThreadAccess(), graph, context, ".../TextContainer/Text#selection"); //$NON-NLS-1$ } abstract void perform(String before, String selected, String after, Point selection); @@ -417,9 +417,9 @@ public class All { void perform(String before, String selected, String after, Point selection) { if(selected.isEmpty()) { - textReference.setValue(before + "'''bold text'''" + after); + textReference.setValue(before + "'''bold text'''" + after); //$NON-NLS-1$ } else { - textReference.setValue(before + "'''" + selected + "'''" + after); + textReference.setValue(before + "'''" + selected + "'''" + after); //$NON-NLS-1$ //$NON-NLS-2$ } } @@ -437,9 +437,9 @@ public class All { void perform(String before, String selected, String after, Point selection) { if(selected.isEmpty()) { - textReference.setValue(before + "''italic text''" + after); + textReference.setValue(before + "''italic text''" + after); //$NON-NLS-1$ } else { - textReference.setValue(before + "''" + selected + "''" + after); + textReference.setValue(before + "''" + selected + "''" + after); //$NON-NLS-1$ //$NON-NLS-2$ } } @@ -457,9 +457,9 @@ public class All { void perform(String before, String selected, String after, Point selection) { if(selected.isEmpty()) { - textReference.setValue(before + "strikethrough text" + after); + textReference.setValue(before + "strikethrough text" + after); //$NON-NLS-1$ } else { - textReference.setValue(before + "" + selected + "" + after); + textReference.setValue(before + "" + selected + "" + after); //$NON-NLS-1$ //$NON-NLS-2$ } } @@ -477,9 +477,9 @@ public class All { void perform(String before, String selected, String after, Point selection) { if(selected.isEmpty()) { - textReference.setValue(before + "strikethrough text" + after); + textReference.setValue(before + "strikethrough text" + after); //$NON-NLS-1$ } else { - textReference.setValue(before + "" + selected + "" + after); + textReference.setValue(before + "" + selected + "" + after); //$NON-NLS-1$ //$NON-NLS-2$ } } @@ -496,7 +496,7 @@ public class All { @Override void perform(String before, String selected, String after, Point selection) { - textReference.setValue(before + "\r\n
\r\n" + selected + after); + textReference.setValue(before + "\r\n
\r\n" + selected + after); //$NON-NLS-1$ } @@ -512,7 +512,7 @@ public class All { @Override void perform(String before, String selected, String after, Point selection) { - textReference.setValue(before + ":" + selected + after); + textReference.setValue(before + ":" + selected + after); //$NON-NLS-1$ } @@ -527,7 +527,7 @@ public class All { private String hex2(int value) { String result = Integer.toHexString(value); - if(result.length() == 1) result = "0" + result; + if(result.length() == 1) result = "0" + result; //$NON-NLS-1$ return result; } @@ -545,9 +545,9 @@ public class All { String hex = hex2(rgb.red) + hex2(rgb.green) + hex2(rgb.blue); if(selected.isEmpty()) { - textReference.setValue(before + "formatted text" + selected + after); + textReference.setValue(before + "formatted text" + selected + after); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ } else { - textReference.setValue(before + "" + selected + "" + after); + textReference.setValue(before + "" + selected + "" + after); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ } } @@ -564,7 +564,7 @@ public class All { @Override void perform(String before, String selected, String after, Point selection) { - textReference.setValue(before + "[[Image:root://Library/image.png|100px]]" + "\r\n" + selected + after); + textReference.setValue(before + "[[Image:root://Library/image.png|100px]]" + "\r\n" + selected + after); //$NON-NLS-1$ //$NON-NLS-2$ } @@ -580,7 +580,7 @@ public class All { @Override void perform(String before, String selected, String after, Point selection) { - textReference.setValue(before + "\r\n= Header 1 =\r\n" + selected + after); + textReference.setValue(before + "\r\n= Header 1 =\r\n" + selected + after); //$NON-NLS-1$ } @@ -596,7 +596,7 @@ public class All { @Override void perform(String before, String selected, String after, Point selection) { - textReference.setValue(before + "\r\n== Header 2 ==\r\n" + selected + after); + textReference.setValue(before + "\r\n== Header 2 ==\r\n" + selected + after); //$NON-NLS-1$ } @@ -612,7 +612,7 @@ public class All { @Override void perform(String before, String selected, String after, Point selection) { - textReference.setValue(before + "\r\n=== Header 3 ===\r\n" + selected + after); + textReference.setValue(before + "\r\n=== Header 3 ===\r\n" + selected + after); //$NON-NLS-1$ } @@ -628,7 +628,7 @@ public class All { @Override void perform(String before, String selected, String after, Point selection) { - textReference.setValue(before + "\r\n==== Header 4 ====\r\n" + selected + after); + textReference.setValue(before + "\r\n==== Header 4 ====\r\n" + selected + after); //$NON-NLS-1$ } @@ -644,11 +644,11 @@ public class All { @Override void perform(String before, String selected, String after, Point selection) { - textReference.setValue(before + "\r\n" + - "# Item1\r\n" + - "# Item2\r\n" + - "## Item2.1\r\n" + - "# Item3\r\n" + selected + after); + textReference.setValue(before + "\r\n" + //$NON-NLS-1$ + "# Item1\r\n" + //$NON-NLS-1$ + "# Item2\r\n" + //$NON-NLS-1$ + "## Item2.1\r\n" + //$NON-NLS-1$ + "# Item3\r\n" + selected + after); //$NON-NLS-1$ } @@ -664,11 +664,11 @@ public class All { @Override void perform(String before, String selected, String after, Point selection) { - textReference.setValue(before + "\r\n" + - "* Item1\r\n" + - "* Item2\r\n" + - "** Item2.1\r\n" + - "* Item3\r\n" + selected + after); + textReference.setValue(before + "\r\n" + //$NON-NLS-1$ + "* Item1\r\n" + //$NON-NLS-1$ + "* Item2\r\n" + //$NON-NLS-1$ + "** Item2.1\r\n" + //$NON-NLS-1$ + "* Item3\r\n" + selected + after); //$NON-NLS-1$ } @@ -684,16 +684,16 @@ public class All { @Override void perform(String before, String selected, String after, Point selection) { - textReference.setValue(before + "\r\n" + - "{| border=\"1\"\r\n" + - "! header\r\n" + - "! header2 \r\n" + - "|-\r\n" + - "| cell || cell2\r\n" + - "|-\r\n" + - "| cell3\r\n" + - "| cell4\r\n" + - "|}\r\n" + selected + after); + textReference.setValue(before + "\r\n" + //$NON-NLS-1$ + "{| border=\"1\"\r\n" + //$NON-NLS-1$ + "! header\r\n" + //$NON-NLS-1$ + "! header2 \r\n" + //$NON-NLS-1$ + "|-\r\n" + //$NON-NLS-1$ + "| cell || cell2\r\n" + //$NON-NLS-1$ + "|-\r\n" + //$NON-NLS-1$ + "| cell3\r\n" + //$NON-NLS-1$ + "| cell4\r\n" + //$NON-NLS-1$ + "|}\r\n" + selected + after); //$NON-NLS-1$ } @@ -707,7 +707,7 @@ public class All { @Override void perform(String before, String selected, String after, Point selection) { textReference.setValue(before + - "[[Media:root://Documents/Document.pdf|Link to a file within the model]]\r\n" + selected + after); + "[[Media:root://Documents/Document.pdf|Link to a file within the model]]\r\n" + selected + after); //$NON-NLS-1$ } }; @@ -722,7 +722,7 @@ public class All { void perform(String before, String selected, String after, Point selection) { textReference.setValue(before + - "[http://www.simantics.org External Website Link]\r\n" + selected + after); + "[http://www.simantics.org External Website Link]\r\n" + selected + after); //$NON-NLS-1$ } @@ -752,7 +752,7 @@ public class All { try { WorkbenchUtils.openEditor(editorId, new ResourceEditorInput2(editorId, root, root, rvi)); } catch (PartInitException e) { - LOGGER.error("Failed to open CSS editor for root " + root, e); + LOGGER.error("Failed to open CSS editor for root " + root, e); //$NON-NLS-1$ } }); @@ -812,17 +812,17 @@ public class All { public static String noDocumentText(ReadGraph graph, final Resource resource, final Variable context) throws DatabaseException { Variable selection = ScenegraphLoaderUtils.getPossibleVariableSelection(graph, context); - if(selection == null) return ""; + if(selection == null) return ""; //$NON-NLS-1$ Resource input = selection.getRepresents(graph); - if(input == null) return ""; + if(input == null) return ""; //$NON-NLS-1$ String path = DocumentUtils.indexRootPath(graph, selection); if(!path.isEmpty()) { - return "for " + path + selection.getName(graph); + return "for " + path + selection.getName(graph); //$NON-NLS-1$ } - return "for " + NameUtils.getSafeLabel(graph, input); + return "for " + NameUtils.getSafeLabel(graph, input); //$NON-NLS-1$ } @@ -873,7 +873,7 @@ public class All { DefaultActions.asyncPerformDefaultAction(s, input, false, false, false); } } catch (DatabaseException | InterruptedException e) { - Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to resolve URI to a database resource or variable: " + uri, e)); + Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to resolve URI to a database resource or variable: " + uri, e)); //$NON-NLS-1$ } } return true; diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/function/SearchFunction.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/function/SearchFunction.java index 3fc15364d..39ae0731b 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/function/SearchFunction.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/function/SearchFunction.java @@ -27,7 +27,7 @@ public class SearchFunction extends FunctionImpl5> results = Searching.performSearch(graph, Layer0X.getInstance(graph).Dependencies, model, - query.escaped(false).getQuery("Name","Types"), maxResults); + query.escaped(false).getQuery("Name","Types"), maxResults); //$NON-NLS-1$ //$NON-NLS-2$ return generateSearchResults(graph, results); } catch (DatabaseException e) { Logger.defaultLogError(e); diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/graphfile/DocumentVersionUtils.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/graphfile/DocumentVersionUtils.java index 82372f126..c53fd1ab3 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/graphfile/DocumentVersionUtils.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/graphfile/DocumentVersionUtils.java @@ -43,7 +43,7 @@ public class DocumentVersionUtils { public static void createNewVersion(WriteGraph graph, Resource oldDocument, Resource newDocument, Resource relation) throws DatabaseException{ DocumentResource doc = DocumentResource.getInstance(graph); if (graph.hasStatement(oldDocument, doc.HasNewerVersion)) - throw new DatabaseException("Document " + NameUtils.getSafeName(graph, oldDocument) +" has already new version"); + throw new DatabaseException("Document " + NameUtils.getSafeName(graph, oldDocument) +" has already new version"); //$NON-NLS-1$ //$NON-NLS-2$ Resource inverse = graph.getInverse(relation); Resource lib = graph.getSingleObject(oldDocument, inverse); @@ -81,7 +81,7 @@ public class DocumentVersionUtils { if (!graph.getSingleType(document2, doc.Document).equals(graph.getSingleType(document1, doc.Document))) return; if (!versionRel.equals(doc.HasNewerVersion) && !(versionRel.equals(doc.HasOlderVersion))) - throw new IllegalArgumentException("Unknow version relation + " + graph.getPossibleURI(versionRel)); + throw new IllegalArgumentException("Unknow version relation + " + graph.getPossibleURI(versionRel)); //$NON-NLS-1$ Resource versionRelInv = graph.getInverse(versionRel); // toSet must not be part of the document's version history @@ -112,7 +112,7 @@ public class DocumentVersionUtils { if (lib != null) { Resource relation = graph.getPossibleObject(lib, doc.HasLibraryRelation); String type= graph.getPossibleRelatedValue(lib, doc.HasVersionType); - if ("TREE".equals(type) && relation != null) { + if ("TREE".equals(type) && relation != null) { //$NON-NLS-1$ if (versionRel.equals(doc.HasOlderVersion)) { graph.deny(document2, graph.getInverse(relation)); graph.claim(document1,relation,document2); @@ -136,14 +136,14 @@ public class DocumentVersionUtils { public static void unsetVersion(WriteGraph graph, Resource document1, Resource document2, Resource versionRel) throws DatabaseException { DocumentResource doc = DocumentResource.getInstance(graph); if (!versionRel.equals(doc.HasNewerVersion) && !(versionRel.equals(doc.HasOlderVersion))) - throw new IllegalArgumentException("Unknow version relation + " + graph.getPossibleURI(versionRel)); + throw new IllegalArgumentException("Unknow version relation + " + graph.getPossibleURI(versionRel)); //$NON-NLS-1$ graph.deny(document1, versionRel,document2); Resource lib = getLib(graph, document1); if (lib != null) { Resource relation = graph.getPossibleObject(lib, doc.HasLibraryRelation); String type= graph.getPossibleRelatedValue(lib, doc.HasVersionType); - if ("TREE".equals(type) && relation != null) { + if ("TREE".equals(type) && relation != null) { //$NON-NLS-1$ if (versionRel.equals(doc.HasOlderVersion)) { graph.deny(document1, relation); graph.claim(lib,relation,document2); diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/graphfile/ExternalEditorAdapter.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/graphfile/ExternalEditorAdapter.java index 42190d878..07ed64327 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/graphfile/ExternalEditorAdapter.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/graphfile/ExternalEditorAdapter.java @@ -47,7 +47,7 @@ public class ExternalEditorAdapter extends AbstractResourceEditorAdapter impleme private static ExternalFileWatcher fileWatcher; public ExternalEditorAdapter() { - super("External Editor", Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/page.png")); + super(Messages.ExternalEditorAdapter_ExternalEditor, Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/page.png")); //$NON-NLS-2$ //$NON-NLS-3$ } @Override @@ -78,7 +78,7 @@ public class ExternalEditorAdapter extends AbstractResourceEditorAdapter impleme StringBuilder sb = new StringBuilder(); String uri = graph.getPossibleURI(input); if (uri != null) { - sb.append(generateSHA1(uri)).append("_"); + sb.append(generateSHA1(uri)).append("_"); //$NON-NLS-1$ } sb.append(graph.getRelatedValue(input, Layer0.getInstance(graph).HasName).toString()); Path filePath = Activator.getInstanceLocation().resolve(sb.toString()); @@ -86,11 +86,11 @@ public class ExternalEditorAdapter extends AbstractResourceEditorAdapter impleme try { GraphFileUtil.writeDataToFile(graph, input, filePath.toFile()); } catch (IOException | DatabaseException e) { - LOGGER.error("Could not write data to file ", e); + LOGGER.error("Could not write data to file ", e); //$NON-NLS-1$ } return input; }); - LOGGER.info("Adding tempFile {} with resource {}", filePath, input); + LOGGER.info("Adding tempFile {} with resource {}", filePath, input); //$NON-NLS-1$ return filePath; } }); @@ -103,20 +103,20 @@ public class ExternalEditorAdapter extends AbstractResourceEditorAdapter impleme } public static String generateSHA1(String message) { - return hashString(message, "SHA-1"); + return hashString(message, "SHA-1"); //$NON-NLS-1$ } private static String hashString(String message, String algorithm) { try { MessageDigest digest = MessageDigest.getInstance(algorithm); - byte[] hashedBytes = digest.digest(message.getBytes("UTF-8")); + byte[] hashedBytes = digest.digest(message.getBytes("UTF-8")); //$NON-NLS-1$ return convertByteArrayToHexString(hashedBytes); } catch (NoSuchAlgorithmException | UnsupportedEncodingException ex) { // Should not happen - LOGGER.error("Could not generate hash", ex); + LOGGER.error("Could not generate hash", ex); //$NON-NLS-1$ } - return ""; + return ""; //$NON-NLS-1$ } private static String convertByteArrayToHexString(byte[] arrayBytes) { @@ -171,15 +171,15 @@ public class ExternalEditorAdapter extends AbstractResourceEditorAdapter impleme Path parent = keys.get(key); Path newPath = parent.resolve(pathEvent.context()); if (ENTRY_MODIFY == kind) { - LOGGER.info("New path modified: " + newPath); + LOGGER.info("New path modified: " + newPath); //$NON-NLS-1$ Resource resource = tempFiles.get(newPath); if (resource != null) { GraphFileUtil.writeDataToGraph(newPath.toFile(), resource); } else { - LOGGER.warn("No resource found for {}", newPath.toAbsolutePath()); + LOGGER.warn("No resource found for {}", newPath.toAbsolutePath()); //$NON-NLS-1$ } } else if (ENTRY_DELETE == kind) { - System.out.println("New path deleted: " + newPath); + System.out.println("New path deleted: " + newPath); //$NON-NLS-1$ } } if (!key.reset()) { @@ -188,9 +188,9 @@ public class ExternalEditorAdapter extends AbstractResourceEditorAdapter impleme } } catch (InterruptedException e) { if (!stopped.get()) - LOGGER.error("Could not stop", e); + LOGGER.error("Could not stop", e); //$NON-NLS-1$ } catch (Throwable t) { - LOGGER.error("An error occured", t); + LOGGER.error("An error occured", t); //$NON-NLS-1$ } } }); @@ -202,7 +202,7 @@ public class ExternalEditorAdapter extends AbstractResourceEditorAdapter impleme private void register(Path path) throws IOException { if (Files.isDirectory(path)) { - LOGGER.info("Registering path {}", path); + LOGGER.info("Registering path {}", path); //$NON-NLS-1$ WatchKey key = path.toAbsolutePath().register(ws, ENTRY_DELETE, ENTRY_MODIFY); keys.put(key, path); } diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/graphfile/FileDocumentUtil.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/graphfile/FileDocumentUtil.java index 9a9e3f8f1..836a822b7 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/graphfile/FileDocumentUtil.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/graphfile/FileDocumentUtil.java @@ -11,6 +11,7 @@ import java.util.HashSet; import java.util.Set; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.osgi.util.NLS; import org.simantics.Simantics; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; @@ -63,7 +64,7 @@ public class FileDocumentUtil { } }, e -> { if (e != null) - ExceptionUtils.logAndShowError("Cannot import file " + fileName, e); + ExceptionUtils.logAndShowError(NLS.bind(Messages.FileDocumentUtil_CannotImportFile, fileName), e); }); @@ -148,7 +149,7 @@ public class FileDocumentUtil { public static void importFolder(WriteGraph graph, File folder, Resource folderResource, Resource relation, IProgressMonitor monitor) throws Exception{ if (monitor != null) { int count = _countFiles(folder); - monitor.beginTask("Import files", count); + monitor.beginTask(Messages.FileDocumentUtil_MonitorImportFiles, count); } _importFolder(graph, folder, folderResource, relation, monitor); if (monitor != null) @@ -215,7 +216,7 @@ public class FileDocumentUtil { return; int i = 1; while (true) { - String proposal = name +" (" + i +")"; + String proposal = name +" (" + i +")"; //$NON-NLS-1$ //$NON-NLS-2$ if (!names.contains(proposal)) { graph.claimLiteral(res, l0.HasName, proposal); return; @@ -295,12 +296,12 @@ public class FileDocumentUtil { name = graph.getRelatedValue(r, useResourceNames ? gf.HasResourceName : l0.HasName); canExport = true; } else if (graph.isInstanceOf(r, doc.UrlDocument)) { - name = graph.getRelatedValue(r, l0.HasName) +".url"; + name = graph.getRelatedValue(r, l0.HasName) +".url"; //$NON-NLS-1$ canExport = true; } if (canExport) { name = resolveName(folder, name, names, true); - File file = new File(folder.getAbsolutePath()+"/"+name); + File file = new File(folder.getAbsolutePath()+"/"+name); //$NON-NLS-1$ if (graph.isInstanceOf(r, doc.FileDocument)) { GraphFileUtil.writeDataToFile(graph,r, file); } else if (graph.isInstanceOf(r, doc.UrlDocument)) { @@ -317,7 +318,7 @@ public class FileDocumentUtil { if (type.size() == folderType.size() && folderType.containsAll(type)) { String name = graph.getRelatedValue(r, l0.HasName); name = resolveName(folder, name, names, false); - File subFolder = new File(folder.getAbsolutePath()+"/"+name); + File subFolder = new File(folder.getAbsolutePath()+"/"+name); //$NON-NLS-1$ if (!subFolder.exists()) { if (!subFolder.mkdir()) { // TODO : error. @@ -337,10 +338,10 @@ public class FileDocumentUtil { * @throws DatabaseException */ private static void exportUrl(File toFile, String name, String url) throws Exception{ - PrintStream os = new PrintStream(toFile,"UTF-8"); - os.println("[InternetShortcut]"); - os.println("URL="+url); - os.println("name="+name); + PrintStream os = new PrintStream(toFile,"UTF-8"); //$NON-NLS-1$ + os.println("[InternetShortcut]"); //$NON-NLS-1$ + os.println("URL="+url); //$NON-NLS-1$ + os.println("name="+name); //$NON-NLS-1$ os.flush(); os.close(); } @@ -351,11 +352,11 @@ public class FileDocumentUtil { String name = null; BufferedReader is = null; try { - is = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8")); + is = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8")); //$NON-NLS-1$ while ((s = is.readLine()) != null) { - if (s.startsWith("URL=")) { + if (s.startsWith("URL=")) { //$NON-NLS-1$ url = s.substring(4); - } else if (s.startsWith("name=")) { + } else if (s.startsWith("name=")) { //$NON-NLS-1$ name = s.substring(5); } } @@ -383,7 +384,7 @@ public class FileDocumentUtil { } private static boolean isUrl(File file) throws Exception{ - return (file.getAbsolutePath().endsWith(".url")); + return (file.getAbsolutePath().endsWith(".url")); //$NON-NLS-1$ } private static final char ESCAPE = '%'; @@ -413,7 +414,7 @@ public class FileDocumentUtil { for (int i = 0; i < len; i++) { char ch = s.charAt(i); if (ch == ESCAPE) { - String num = "0x"; + String num = "0x"; //$NON-NLS-1$ num += s.charAt(++i); num += s.charAt(++i); ch = (char)Integer.decode(num).intValue(); @@ -433,7 +434,7 @@ public class FileDocumentUtil { if (used.contains(current)) { current = createFileName(proposal, i); } else { - File subFile = new File(parentFolder.getAbsolutePath()+"/"+current); + File subFile = new File(parentFolder.getAbsolutePath()+"/"+current); //$NON-NLS-1$ if (!subFile.exists()) break; if (subFile.exists() && subFile.isFile() && subFile.canWrite()) { @@ -447,7 +448,7 @@ public class FileDocumentUtil { if (used.contains(current)) { current = proposal+i; } else { - File subFolder = new File(parentFolder.getAbsolutePath()+"/"+current); + File subFolder = new File(parentFolder.getAbsolutePath()+"/"+current); //$NON-NLS-1$ if (!subFolder.exists()) break; if (subFolder.exists() && subFolder.isDirectory()) { @@ -461,7 +462,7 @@ public class FileDocumentUtil { } private static String createFileName(String original, int i) { - int extIndex = original.lastIndexOf("."); + int extIndex = original.lastIndexOf("."); //$NON-NLS-1$ if (extIndex == -1) return original+i; return original.substring(0,extIndex) + i + original.substring(extIndex); diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/graphfile/Messages.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/graphfile/Messages.java new file mode 100644 index 000000000..24f39d7a0 --- /dev/null +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/graphfile/Messages.java @@ -0,0 +1,18 @@ +package org.simantics.document.ui.graphfile; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.simantics.document.ui.graphfile.messages"; //$NON-NLS-1$ + public static String ExternalEditorAdapter_ExternalEditor; + public static String FileDocumentUtil_CannotImportFile; + public static String FileDocumentUtil_MonitorImportFiles; + public static String UrlEditorAdapter_Browser; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/graphfile/UrlEditorAdapter.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/graphfile/UrlEditorAdapter.java index 15e4d6e74..f5c7956d8 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/graphfile/UrlEditorAdapter.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/graphfile/UrlEditorAdapter.java @@ -22,7 +22,7 @@ import org.simantics.utils.ui.ExceptionUtils; public class UrlEditorAdapter extends AbstractResourceEditorAdapter implements EditorAdapter { public UrlEditorAdapter() { - super("Browser",Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/world.png")); + super(Messages.UrlEditorAdapter_Browser,Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/world.png")); //$NON-NLS-2$ //$NON-NLS-3$ } diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/graphfile/messages.properties b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/graphfile/messages.properties new file mode 100644 index 000000000..7b56701bc --- /dev/null +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/graphfile/messages.properties @@ -0,0 +1,4 @@ +ExternalEditorAdapter_ExternalEditor=External Editor +FileDocumentUtil_CannotImportFile=Cannot import file {0} +FileDocumentUtil_MonitorImportFiles=Import files +UrlEditorAdapter_Browser=Browser diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/messages.properties b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/messages.properties new file mode 100644 index 000000000..23da786d5 --- /dev/null +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/messages.properties @@ -0,0 +1,2 @@ +DocumentView_PinSelection=Pin Selection +OpenEntityDocumentAdapter_DocumentEditor=Document Editor diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/wizard/FileDocumentImportWizard.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/wizard/FileDocumentImportWizard.java index 0959ae9f8..67ef4ae0d 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/wizard/FileDocumentImportWizard.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/wizard/FileDocumentImportWizard.java @@ -12,7 +12,7 @@ public abstract class FileDocumentImportWizard extends Wizard{ FileSelectionPage fileSelectionPage; public FileDocumentImportWizard(Resource lib) { - setWindowTitle("Document File import"); + setWindowTitle(Messages.FileDocumentImportWizard_DocumentFileImport); setNeedsProgressMonitor(false); } diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/wizard/FileSelectionPage.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/wizard/FileSelectionPage.java index eb43ee794..188d6c46c 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/wizard/FileSelectionPage.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/wizard/FileSelectionPage.java @@ -22,7 +22,7 @@ public class FileSelectionPage extends WizardPage { String fileName; public FileSelectionPage() { - super("FileSelction","Select a file",null); + super(Messages.FileSelectionPage_FileSelection,Messages.FileSelectionPage_SelectAFile,null); } @Override @@ -30,7 +30,7 @@ public class FileSelectionPage extends WizardPage { parent.setLayout(new GridLayout(3,false)); fileText = new Text(parent,SWT.BORDER|SWT.SINGLE); browseButton = new Button(parent, SWT.PUSH); - browseButton.setText("Browse"); + browseButton.setText(Messages.FileSelectionPage_Browse); GridData data; data = new GridData(); @@ -50,7 +50,7 @@ public class FileSelectionPage extends WizardPage { // TODO : is there any way to read file/executable bindings from OS? // if is, use those extensions to filter this list. // note: in windows using "reg query ..." to read bindings form registry would work. - dialog.setFilterExtensions(new String[]{"*.*"}); + dialog.setFilterExtensions(new String[]{"*.*"}); //$NON-NLS-1$ String name = dialog.open(); if (name != null) { fileText.setText(name); diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/wizard/Messages.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/wizard/Messages.java new file mode 100644 index 000000000..7e9a4fb05 --- /dev/null +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/wizard/Messages.java @@ -0,0 +1,18 @@ +package org.simantics.document.ui.wizard; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.simantics.document.ui.wizard.messages"; //$NON-NLS-1$ + public static String FileDocumentImportWizard_DocumentFileImport; + public static String FileSelectionPage_Browse; + public static String FileSelectionPage_FileSelection; + public static String FileSelectionPage_SelectAFile; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/wizard/messages.properties b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/wizard/messages.properties new file mode 100644 index 000000000..6700a2841 --- /dev/null +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/wizard/messages.properties @@ -0,0 +1,4 @@ +FileDocumentImportWizard_DocumentFileImport=Document File import +FileSelectionPage_Browse=Browse +FileSelectionPage_FileSelection=FileSelction +FileSelectionPage_SelectAFile=Select a file diff --git a/i18n.md b/i18n.md index f59af8423..9119c8b19 100644 --- a/i18n.md +++ b/i18n.md @@ -5,6 +5,7 @@ * [x] org.simantics.debug.ui * [x] org.simantics.desktop.ui * [x] org.simantics.document.linking.ui +* [x] org.simantics.document.ui * ... ## TODO ##