use of org.eclipse.wst.common.snippets.internal.model.SnippetManager in project liferay-ide by liferay.
the class SnippetsUtil method importSnippetsFromFile.
@SuppressWarnings("rawtypes")
public static void importSnippetsFromFile(File snippetFile) throws FileNotFoundException {
if ((snippetFile == null) || !snippetFile.exists() || !snippetFile.isFile()) {
return;
}
// InputStream stream = Files.newInputStream(snippetFile.toPath());
SnippetDefinitions definitions = ModelFactoryForUser.getInstance().load(snippetFile.getAbsolutePath());
List importCategories = definitions.getCategories();
SnippetManager manager = SnippetManager.getInstance();
List currentCategories = manager.getDefinitions().getCategories();
Display.getDefault().asyncExec(new Runnable() {
public void run() {
for (int i = 0; i < importCategories.size(); i++) {
boolean found = false;
for (int j = 0; j < currentCategories.size(); j++) {
if (((PaletteEntry) currentCategories.get(j)).getId().compareToIgnoreCase(((PaletteEntry) importCategories.get(i)).getId()) == 0) {
found = true;
break;
}
}
if (!found) {
SnippetManager manager = SnippetManager.getInstance();
manager.getPaletteRoot().add((PaletteEntry) importCategories.get(i));
}
}
}
});
// IViewPart view = findSnippetsView();
// if (view != null) {
// SnippetsView snippetsView = (SnippetsView) view;
// snippetsView.getViewer().getContents().refresh();
// }
}
Aggregations