protected IInformationControl doCreateInformationControl(final Shell parent) {
if (BrowserInformationControl.isAvailable(parent)) {
final ToolBarManager tbm = new ToolBarManager(SWT.FLAT);
final String font = JFaceResources.DIALOG_FONT;
final BrowserInformationControl control = new BrowserInformationControl(
parent, font, tbm);
final PresenterControlCreator.BackAction backAction = new PresenterControlCreator.BackAction(
control);
backAction.setEnabled(false);
tbm.add(backAction);
final PresenterControlCreator.ForwardAction forwardAction = new PresenterControlCreator.ForwardAction(
control);
tbm.add(forwardAction);
forwardAction.setEnabled(false);
final PresenterControlCreator.ShowInEdocViewAction showInEdocViewAction = new PresenterControlCreator.ShowInEdocViewAction(
control);
tbm.add(showInEdocViewAction);
if (editor != null) {
final OpenDeclarationAction openDeclarationAction = new OpenDeclarationAction(
control, editor);
tbm.add(openDeclarationAction);
final SimpleSelectionProvider selectionProvider = new SimpleSelectionProvider();
final OpenEdocInExternalBrowserAction openEdocInExternalBrowserAction = new OpenEdocInExternalBrowserAction(
editor.getSite(), null);
openEdocInExternalBrowserAction
.setSpecialSelectionProvider(selectionProvider);
selectionProvider
.addSelectionChangedListener(openEdocInExternalBrowserAction);
final ImageDescriptor descriptor = ErlideImage.OBJS_EXTERNALBROWSER
.getDescriptor();
openEdocInExternalBrowserAction.setImageDescriptor(descriptor);
openEdocInExternalBrowserAction.setDisabledImageDescriptor(descriptor);
selectionProvider.setSelection(new StructuredSelection());
tbm.add(openEdocInExternalBrowserAction);
// OpenExternalBrowserAction openExternalJavadocAction = new
// OpenExternalBrowserAction(
// parent.getDisplay(), selectionProvider);
// selectionProvider
// .addSelectionChangedListener(openExternalJavadocAction);
// selectionProvider.setSelection(new
// StructuredSelection());
// tbm.add(openExternalJavadocAction);
final IInputChangedListener inputChangeListener = new IInputChangedListener() {
@Override
public void inputChanged(final Object newInput) {
backAction.update();
forwardAction.update();
if (newInput == null) {
selectionProvider.setSelection(new StructuredSelection());
} else if (newInput instanceof BrowserInformationControlInput) {
final BrowserInformationControlInput input = (BrowserInformationControlInput) newInput;
final Object inputElement = input.getInputElement();
selectionProvider.setSelection(new StructuredSelection(
inputElement));
final boolean hasInputElement = inputElement != null;
showInEdocViewAction.setEnabled(hasInputElement);
openDeclarationAction.setEnabled(hasInputElement);
openEdocInExternalBrowserAction.setInput(newInput);
openEdocInExternalBrowserAction.setEnabled(hasInputElement);
}
}
};
control.addInputChangeListener(inputChangeListener);
}
tbm.update(true);
control.addLocationListener(new HandleEdocLinksLocationListener(control));
return control;
}
return new DefaultInformationControl(parent,
EditorsUI.getTooltipAffordanceString(), new ErlInformationPresenter(true));