// Here starts the actual triggering of a snippet using the
// trigger text
String fileName = keyCombos.getKeyCombo(trigger);
SnipReader snipReader = new SnipReader();
IFile activeFile = null;
if (editor.getEditorInput() instanceof IFileEditorInput) {
activeFile = ((IFileEditorInput) editor.getEditorInput()).getFile();
}
if(fileName == null) {
// nasty nasty hack to tell the user no snippet found
// InputDialog d = new InputDialog(editor.getSite().getShell(),
// "your title",
// "Please give me input ...",
// "Default",
// null);
// Text t = new Text(parent, SWT.BORDER); // your SWT text field
// ContentProposalAdapter adapter = new ContentProposalAdapter(
// t,
// new TextContentAdapter(),
// new JavaCompletionProcessor(),
// null,
// null);
//
// String result = d.getValue();
// ContentAssistant cast = new ContentAssistant();
// cast.setContentAssistProcessor(new JavaCompletionProcessor(), "");
// cast.showPossibleCompletions();
// MessageBox dialog = new MessageBox(shell,SWT.ICON_ERROR);
// dialog.setMessage("No snippet found for : "+sequence);
// dialog.open();
try {
SnipTreeView snipTreeView = (SnipTreeView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(SnipTreeView.ID_SNIPVIEWTREE);
snipTreeView.setSnipFilter(sequence);
} catch (PartInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
snipReader.read(fileName);
String indentString = "";
try {
int lineNumber = doc.getLineOfOffset(lastSpaceOffset);
int lineOffset = doc.getLineOffset(lineNumber);
indentString = doc.get().substring(lineOffset, lastSpaceOffset);
} catch (Exception e) {
System.err.println(e);
// do nothing
// System.err.println("Insert snippet failed to get insert string.");
}
if (indentString.length() > 0) {
snipReader.performIndent(indentString);
}
String snippet = "";
int finalCursorOffset = -1;
for (int i = 0; i < loopcount; i++) {
start = SnipVarParser.parse(snipReader.getSnipStartBlock(), activeFile, shell);
end = SnipVarParser.parse(snipReader.getSnipEndBlock(), activeFile, shell);
if (start == null || end == null) {
snippet = null;
break;
} else {
snippet = start + end;