/*******************************************************************************
* Copyright (c) 2009, 2010 Innovation Gate GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Innovation Gate GmbH - initial API and implementation
******************************************************************************/
package de.innovationgate.eclipse.editors.tmlscript;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.contentassist.CompletionProposal;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
public class TMLScriptCompletionProposal implements ICompletionProposal {
private CompletionProposal _proposal;
private Point _selection;
private int _replacementOffset;
private String _lruCategory = null;
public String getLruCategory() {
return _lruCategory;
}
public TMLScriptCompletionProposal(String replacement, int replacementOffset, int replacementLength, int cursor, String display) {
_proposal = new CompletionProposal(replacement, replacementOffset, replacementLength, cursor, null, display, null, null);
_replacementOffset = replacementOffset;
}
public void apply(IDocument document) {
_proposal.apply(document);
if (_lruCategory != null) {
CodeCompletionLRUManager.getInstance().cache(this);
}
}
public String getAdditionalProposalInfo() {
return _proposal.getAdditionalProposalInfo();
}
public IContextInformation getContextInformation() {
return _proposal.getContextInformation();
}
public String getDisplayString() {
return _proposal.getDisplayString();
}
public Image getImage() {
return _proposal.getImage();
}
public Point getSelection(IDocument document) {
if (_selection != null) {
return _selection;
} else {
return _proposal.getSelection(document);
}
}
public void setSelection(int offset, int length) {
_selection = new Point(_replacementOffset + offset, length);
}
public void enableLRU(String category) {
_lruCategory = category;
}
}