X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.document.ui%2Fsrc%2Forg%2Fsimantics%2Fdocument%2Fui%2Fgraphfile%2FExternalEditorAdapter.java;h=07ed6432771cced743a3a1ac5e17f3c7478c913c;hp=42190d87829283cf165d4ede9a49422abf645fae;hb=c8e675ae59eebb045a095a07e54462d0fe87f5cb;hpb=8783f9ee2b67f83160d88f43a7aef02a6b25f955 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); }