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
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());
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;
}
});
}
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) {
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()) {
}
} 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$
}
}
});
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);
}