use of org.eclipse.jdt.internal.ui.refactoring.contentassist.JavaTypeCompletionProcessor in project bndtools by bndtools.
the class NewTypeWizardPage method createSuperInterfacesControls.
/**
* Creates the controls for the superclass name field. Expects a <code>GridLayout</code> with at least 3 columns.
*
* @param composite
* the parent composite
* @param nColumns
* number of columns to span
*/
protected void createSuperInterfacesControls(Composite composite, int nColumns) {
//$NON-NLS-1$
final String INTERFACE = "interface";
fSuperInterfacesDialogField.doFillIntoGrid(composite, nColumns);
final TableViewer tableViewer = fSuperInterfacesDialogField.getTableViewer();
tableViewer.setColumnProperties(new String[] { INTERFACE });
TableTextCellEditor cellEditor = new TableTextCellEditor(tableViewer, 0) {
@Override
protected void doSetFocus() {
if (text != null) {
text.setFocus();
text.setSelection(text.getText().length());
checkSelection();
checkDeleteable();
checkSelectable();
}
}
};
JavaTypeCompletionProcessor superInterfaceCompletionProcessor = new JavaTypeCompletionProcessor(false, false, true);
superInterfaceCompletionProcessor.setCompletionContextRequestor(new CompletionContextRequestor() {
@Override
public StubTypeContext getStubTypeContext() {
return getSuperInterfacesStubTypeContext();
}
});
@SuppressWarnings("deprecation") org.eclipse.jface.contentassist.SubjectControlContentAssistant contentAssistant = ControlContentAssistHelper.createJavaContentAssistant(superInterfaceCompletionProcessor);
Text cellEditorText = cellEditor.getText();
@SuppressWarnings({ "deprecation", "unused" }) org.eclipse.ui.contentassist.ContentAssistHandler contentAssistantHandler = org.eclipse.ui.contentassist.ContentAssistHandler.createHandlerForText(cellEditorText, contentAssistant);
TextFieldNavigationHandler.install(cellEditorText);
cellEditor.setContentAssistant(contentAssistant);
tableViewer.setCellEditors(new CellEditor[] { cellEditor });
tableViewer.setCellModifier(new ICellModifier() {
@Override
public void modify(Object element, String property, Object value) {
Object el = element;
if (el instanceof Item)
el = ((Item) el).getData();
((InterfaceWrapper) el).interfaceName = (String) value;
fSuperInterfacesDialogField.elementChanged((InterfaceWrapper) el);
}
@Override
public Object getValue(Object element, String property) {
return ((InterfaceWrapper) element).interfaceName;
}
@Override
public boolean canModify(Object element, String property) {
return true;
}
});
tableViewer.getTable().addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent event) {
if (event.keyCode == SWT.F2 && event.stateMask == 0) {
ISelection selection = tableViewer.getSelection();
if (!(selection instanceof IStructuredSelection))
return;
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
tableViewer.editElement(structuredSelection.getFirstElement(), 0);
}
}
});
GridData gd = (GridData) fSuperInterfacesDialogField.getListControl(null).getLayoutData();
if (fTypeKind == CLASS_TYPE) {
gd.heightHint = convertHeightInCharsToPixels(3);
} else {
gd.heightHint = convertHeightInCharsToPixels(6);
}
gd.grabExcessVerticalSpace = false;
gd.widthHint = getMaxFieldWidth();
}
use of org.eclipse.jdt.internal.ui.refactoring.contentassist.JavaTypeCompletionProcessor in project bndtools by bndtools.
the class NewTypeWizardPage method createSuperClassControls.
/**
* Creates the controls for the superclass name field. Expects a <code>GridLayout</code> with at least 3 columns.
*
* @param composite
* the parent composite
* @param nColumns
* number of columns to span
*/
protected void createSuperClassControls(Composite composite, int nColumns) {
fSuperClassDialogField.doFillIntoGrid(composite, nColumns);
Text text = fSuperClassDialogField.getTextControl(null);
LayoutUtil.setWidthHint(text, getMaxFieldWidth());
JavaTypeCompletionProcessor superClassCompletionProcessor = new JavaTypeCompletionProcessor(false, false, true);
superClassCompletionProcessor.setCompletionContextRequestor(new CompletionContextRequestor() {
@Override
public StubTypeContext getStubTypeContext() {
return getSuperClassStubTypeContext();
}
});
ControlContentAssistHelper.createTextContentAssistant(text, superClassCompletionProcessor);
TextFieldNavigationHandler.install(text);
}
Aggregations