use of org.eclipse.ui.texteditor.TextEditorAction in project eclipse.platform.text by eclipse.
the class DefaultEncodingSupport method createStatusEncodingChangeControl.
/**
* Creates the control which allows to change the encoding.
* In case of encoding errors this control will be placed below
* the status of the status editor.
*
* @param parent the parent control
* @param status the status
* @since 3.1
*/
public void createStatusEncodingChangeControl(Composite parent, final IStatus status) {
final IAction action = fTextEditor.getAction(ITextEditorActionConstants.CHANGE_ENCODING);
if (action instanceof TextEditorAction)
((TextEditorAction) action).update();
if (action == null || !action.isEnabled())
return;
Shell shell = parent.getShell();
Display display = shell.getDisplay();
Color bgColor = display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
Button button = new Button(parent, SWT.PUSH | SWT.FLAT);
button.setText(action.getText());
button.addSelectionListener(new SelectionAdapter() {
/*
* @see org.eclipse.swt.events.SelectionAdapter#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
action.run();
}
});
button.setFocus();
Label filler = new Label(parent, SWT.NONE);
filler.setLayoutData(new GridData(GridData.FILL_BOTH));
filler.setBackground(bgColor);
}
Aggregations