public PkgPatternsDetailsPage(String title) {
this.title = title;
}
public void createContents(Composite parent) {
FormToolkit toolkit = getManagedForm().getToolkit();
FieldDecoration assistDecor = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
KeyStroke assistKeyStroke = null;
try {
assistKeyStroke = KeyStroke.getInstance("Ctrl+Space");
} catch (ParseException x) {
// Ignore
}
Section mainSection = toolkit.createSection(parent, Section.TITLE_BAR);
mainSection.setText(title);
mainComposite = toolkit.createComposite(mainSection);
mainSection.setClient(mainComposite);
toolkit.createLabel(mainComposite, "Pattern:");
txtName = toolkit.createText(mainComposite, "", SWT.BORDER);
ControlDecoration decPattern = new ControlDecoration(txtName, SWT.LEFT | SWT.TOP, mainComposite);
decPattern.setImage(assistDecor.getImage());
if (assistKeyStroke == null) {
decPattern.setDescriptionText("Content assist is available. Start typing to activate");
} else {
decPattern.setDescriptionText(MessageFormat.format("Content assist is available. Press {0} or start typing to activate", assistKeyStroke.format()));
}
decPattern.setShowHover(true);
decPattern.setShowOnlyOnFocus(true);
PkgPatternsProposalProvider proposalProvider = new PkgPatternsProposalProvider(new FormPartJavaSearchContext(this));
ContentProposalAdapter patternProposalAdapter = new ContentProposalAdapter(txtName, new TextContentAdapter(), proposalProvider, assistKeyStroke, UIConstants.autoActivationCharacters());
patternProposalAdapter.addContentProposalListener(proposalProvider);
patternProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_IGNORE);
patternProposalAdapter.setAutoActivationDelay(1000);
patternProposalAdapter.setLabelProvider(new PkgPatternProposalLabelProvider());
patternProposalAdapter.addContentProposalListener(new IContentProposalListener() {
public void proposalAccepted(IContentProposal proposal) {
PkgPatternProposal patternProposal = (PkgPatternProposal) proposal;
String toInsert = patternProposal.getContent();
int currentPos = txtName.getCaretPosition();
txtName.setSelection(patternProposal.getReplaceFromPos(), currentPos);
txtName.insert(toInsert);
txtName.setSelection(patternProposal.getCursorPosition());
}
});
toolkit.createLabel(mainComposite, "Version:");
txtVersion = toolkit.createText(mainComposite, "", SWT.BORDER);
/*
* Section attribsSection = toolkit.createSection(parent, Section.TITLE_BAR | Section.TWISTIE);
* attribsSection.setText("Extra Attributes"); Composite attribsComposite =
* toolkit.createComposite(attribsSection);