openErrorDialog(e);
	public IRegion apply(IDocument document) {		int start= fContext.getStart();		int end= fContext.getEnd();				int indentationLevel= guessIndentationLevel(document, start);		IDocument template= getDocument(indentationLevel);		try {			// backup and replace with template			fOldText= document.get(start, end - start);						document.replace(start, end - start, template.get());				// register template position			document.addPositionCategory(TEMPLATE_POSITION);			document.addPositionUpdater(fgTemplateUpdater);			try {				document.addPosition(TEMPLATE_POSITION, new Position(start, template.get().length()));			} catch (BadPositionCategoryException e) {				JavaPlugin.log(e);				Assert.isTrue(false);				}			Position[] positions= getPositions();			LinkedPositionManager manager= new LinkedPositionManager(document);			for (int i= 0; i != positions.length; i++) {				TypedPosition position= (TypedPosition) positions[i];								if (position.getType().equals("cursor"))					continue;								int offset= position.getOffset() + start;				int length= position.getLength();								manager.addPosition(offset, length);			}						LinkedPositionUI editor= new LinkedPositionUI(fContext.getViewer(), manager);			editor.setFinalCaretOffset(getCaretOffset() + start);			editor.setCancelListener(this);			editor.enter();			return editor.getSelectedRegion();		} catch (BadLocationException e) {			JavaPlugin.log(e);			}				return null;	}