Search in sources :

Example 1 with AbstractInformationControl

use of org.eclipse.jface.text.AbstractInformationControl in project eclipse.platform.text by eclipse.

the class HoverTest method getHoverShell.

private Shell getHoverShell(AbstractInformationControlManager manager) {
    AbstractInformationControl[] control = { null };
    new DisplayHelper() {

        @Override
        protected boolean condition() {
            control[0] = (AbstractInformationControl) new Accessor(manager, AbstractInformationControlManager.class).get("fInformationControl");
            return control[0] != null;
        }
    }.waitForCondition(this.editor.getSite().getShell().getDisplay(), 5000);
    if (control[0] == null) {
        ScreenshotTest.takeScreenshot(getClass(), testName.getMethodName(), System.out);
        fail();
    }
    Shell shell = (Shell) new Accessor(control[0], AbstractInformationControl.class).get("fShell");
    new DisplayHelper() {

        @Override
        protected boolean condition() {
            return shell.isVisible();
        }
    }.waitForCondition(this.editor.getSite().getShell().getDisplay(), 2000);
    assertTrue(shell.isVisible());
    return shell;
}
Also used : Shell(org.eclipse.swt.widgets.Shell) AbstractInformationControl(org.eclipse.jface.text.AbstractInformationControl) DisplayHelper(org.eclipse.jface.text.tests.util.DisplayHelper) Accessor(org.eclipse.text.tests.Accessor)

Example 2 with AbstractInformationControl

use of org.eclipse.jface.text.AbstractInformationControl in project eclipse.platform.text by eclipse.

the class CompositeInformationControl method createContent.

@Override
public void createContent(Composite parent) {
    // TODO maybe use canReuse or canReplace
    this.controls = new LinkedHashMap<>();
    GridLayout layout = new GridLayout(1, false);
    parent.setLayout(layout);
    boolean firstControl = true;
    for (Entry<ITextHover, IInformationControlCreator> hoverControlCreator : this.creators.entrySet()) {
        IInformationControl informationControl = hoverControlCreator.getValue().createInformationControl(parent.getShell());
        if (informationControl instanceof AbstractInformationControl) {
            List<Control> children = Arrays.asList(((AbstractInformationControl) informationControl).getShell().getChildren());
            children.remove(parent);
            if (children.size() == 0) {
                continue;
            }
            for (Control control : children) {
                control.setParent(parent);
                control.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
            }
            if (!firstControl) {
                ((GridData) children.get(0).getLayoutData()).verticalIndent = 15;
            }
            controls.put(hoverControlCreator.getKey(), informationControl);
            firstControl = false;
        } else {
            GenericEditorPlugin.getDefault().getLog().log(new Status(IStatus.WARNING, GenericEditorPlugin.BUNDLE_ID, // $NON-NLS-1$
            "Only text hovers producing an AbstractInformationControl can be aggregated; got a " + informationControl.getClass().getSimpleName()));
            informationControl.dispose();
        }
    }
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IInformationControlCreator(org.eclipse.jface.text.IInformationControlCreator) GridLayout(org.eclipse.swt.layout.GridLayout) IInformationControl(org.eclipse.jface.text.IInformationControl) AbstractInformationControl(org.eclipse.jface.text.AbstractInformationControl) Control(org.eclipse.swt.widgets.Control) ITextHover(org.eclipse.jface.text.ITextHover) IInformationControl(org.eclipse.jface.text.IInformationControl) AbstractInformationControl(org.eclipse.jface.text.AbstractInformationControl) GridData(org.eclipse.swt.layout.GridData)

Aggregations

AbstractInformationControl (org.eclipse.jface.text.AbstractInformationControl)2 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 IInformationControl (org.eclipse.jface.text.IInformationControl)1 IInformationControlCreator (org.eclipse.jface.text.IInformationControlCreator)1 ITextHover (org.eclipse.jface.text.ITextHover)1 DisplayHelper (org.eclipse.jface.text.tests.util.DisplayHelper)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Control (org.eclipse.swt.widgets.Control)1 Shell (org.eclipse.swt.widgets.Shell)1 Accessor (org.eclipse.text.tests.Accessor)1