darksmilie
Erfahrenes Mitglied
Hi,
ich habe mir ein eigenen XML Editor geschrieben. Nun möchte ich, das mein Editor auch eine Autovervollständigung besitzt, aber ich habe das Problem, das mein contentassistent nicht aktiv ist, bzw. nix macht, wenn ich die Tastenkombination drücke.
hier ist mein code für mein content assistent:
Editor.properties:
XMLCompletionProcessor:
XMLSourceViewerConfiguration:
XMLEditor:
ich habe mir ein eigenen XML Editor geschrieben. Nun möchte ich, das mein Editor auch eine Autovervollständigung besitzt, aber ich habe das Problem, das mein contentassistent nicht aktiv ist, bzw. nix macht, wenn ich die Tastenkombination drücke.
hier ist mein code für mein content assistent:
Editor.properties:
Code:
## Actions ##
ContentAssistProposal.label=Content Assist@Ctrl+SPACE
ContentAssistProposal.tooltip=Content Assist
ContentAssistProposal.image=
ContentAssistProposal.description=Content Assist
XMLCompletionProcessor:
Code:
public class XMLCompletionProcessor implements IContentAssistProcessor {
private final static String[] proposalDisplays = new String[] { "test" };
private final static String[] proposalReplacements = new String[] { "TEST" };
public ICompletionProposal[] computeCompletionProposals(
final ITextViewer viewer, final int documentOffset) {
// we return just the list of proposals
int length = proposalDisplays.length;
ICompletionProposal[] result = new ICompletionProposal[length];
for (int i = 0; i < length; i++) {
String toDisplay = proposalDisplays[i];
IContextInformation info = new ContextInformation(toDisplay, toDisplay);
result[i] = new CompletionProposal(proposalReplacements[i],
documentOffset, 0, proposalReplacements[i].length(), null,
proposalDisplays[i], info, "Test2");
}
return result;
}
public IContextInformation[] computeContextInformation(
final ITextViewer viewer, final int documentOffset) {
// no context infopops
return null;
}
public char[] getCompletionProposalAutoActivationCharacters() {
// no auto activation characters, we trigger only on user request
return new char[0];
}
public char[] getContextInformationAutoActivationCharacters() {
// no context infopops
return new char[0];
}
public String getErrorMessage() {
return null;
}
public IContextInformationValidator getContextInformationValidator() {
// no context infopops
return null;
}
}
XMLSourceViewerConfiguration:
Code:
@Override
public IContentAssistant getContentAssistant(final ISourceViewer sv) {
ContentAssistant result = new ContentAssistant();
result.setContentAssistProcessor(new XMLCompletionProcessor(),
IDocument.DEFAULT_CONTENT_TYPE);
result.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
return result;
}
XMLEditor:
Code:
@Override
protected void createActions() {
super.createActions();
IAction action = createAction();
String actionId = ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS;
action.setActionDefinitionId(actionId);
setAction("ContentAssistProposal", action);
}
private IAction createAction() {
ResourceBundle bundle = Plugin.getDefault().getResourceBundle();
return new TextOperationAction(bundle, "ContentAssistProposal.", this,
ISourceViewer.CONTENTASSIST_PROPOSALS);
}