Example usage for org.eclipse.jface.dialogs TrayDialog openTray

List of usage examples for org.eclipse.jface.dialogs TrayDialog openTray

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs TrayDialog openTray.

Prototype

public void openTray(DialogTray tray) throws IllegalStateException, UnsupportedOperationException 

Source Link

Document

Constructs the tray's widgets and displays the tray in this dialog.

Usage

From source file:eu.esdihumboldt.hale.ui.functions.groovy.internal.GroovyASTTray.java

License:Open Source License

/**
 * Show the AST viewer in the wizard tray.
 * /* w ww . j a v  a  2 s  .  c o m*/
 * @param page the associated wizard page
 * @param viewer the associated viewer with the Groovy source or
 *            <code>null</code>
 */
public static void showTray(final HaleWizardPage<?> page, final CompilingSourceViewer<GroovyAST> viewer) {
    if (page.getContainer() instanceof TrayDialog) {
        TrayDialog dialog = (TrayDialog) page.getContainer();

        // close existing tray
        if (dialog.getTray() != null) {
            dialog.closeTray();
        }

        dialog.openTray(new GroovyASTTray(viewer));
    } else {
        // TODO show dialog instead?
    }
}

From source file:eu.esdihumboldt.hale.ui.functions.groovy.internal.JoinTypeStructureTray.java

License:Open Source License

/**
 * //w w  w .  j a  v  a2  s.c  o m
 * Creates a tool item
 * 
 * @param bar a toolbar
 * @param page hale wizard page
 * @param schemaSpace schema space
 * @param types type provider
 */
public static void createToolItem(ToolBar bar, final HaleWizardPage<?> page, final SchemaSpaceID schemaSpace,
        final TypeProvider types) {

    ToolItem item = new ToolItem(bar, SWT.PUSH);

    item.setImage(CommonSharedImages.getImageRegistry().get(CommonSharedImages.IMG_SOURCE_SCHEMA));
    item.setToolTipText("Show source structure");

    item.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (page.getContainer() instanceof TrayDialog) {
                TrayDialog dialog = (TrayDialog) page.getContainer();

                // close existing tray
                if (dialog.getTray() != null) {
                    dialog.closeTray();
                }
                ParameterValue param = CellUtil.getFirstParameter(
                        ((GenericTypeFunctionWizard) page.getWizard()).getUnfinishedCell(),
                        JoinFunction.PARAMETER_JOIN);

                dialog.openTray(new JoinTypeStructureTray(param, types, schemaSpace));
            } else {
                // TODO show dialog instead?
            }
        }
    });

}

From source file:eu.esdihumboldt.hale.ui.functions.groovy.internal.PageFunctions.java

License:Open Source License

/**
 * Creates a tool item for a helper function dialog page
 * //from  ww w . j a  v  a 2  s .com
 * @param toolbar the tool bar
 * @param page the dialog page
 */
public static void createToolItem(ToolBar toolbar, final HaleWizardPage<?> page) {
    ToolItem item = new ToolItem(toolbar, SWT.PUSH);
    item.setToolTipText("Show functions");
    item.setImage(CommonSharedImages.getImageRegistry().get(CommonSharedImages.IMG_FUNCTION));
    item.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (page.getContainer() instanceof TrayDialog) {
                TrayDialog tray = (TrayDialog) page.getContainer();
                if (tray.getTray() != null) {
                    tray.closeTray();
                }
                tray.openTray(new PageFunctions());
            }

        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            // do nothing

        }
    });

}

From source file:eu.esdihumboldt.hale.ui.functions.groovy.internal.TypeStructureTray.java

License:Open Source License

/**
 * Create a tool item for displaying the source or target type structure in
 * the dialog tray.//from   w  w  w .j  av a2s.c om
 * 
 * @param bar the tool bar to add the item to
 * @param page the associated wizard page
 * @param types the provider for the types to display
 * @param schemaSpace the schema space
 */
public static void createToolItem(ToolBar bar, final HaleWizardPage<?> page, final SchemaSpaceID schemaSpace,
        final TypeProvider types) {
    ToolItem item = new ToolItem(bar, SWT.PUSH);
    switch (schemaSpace) {
    case SOURCE:
        item.setImage(CommonSharedImages.getImageRegistry().get(CommonSharedImages.IMG_SOURCE_SCHEMA));
        item.setToolTipText("Show source structure");
        break;
    case TARGET:
        item.setImage(CommonSharedImages.getImageRegistry().get(CommonSharedImages.IMG_TARGET_SCHEMA));
        item.setToolTipText("Show target structure");
        break;
    }
    item.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (page.getContainer() instanceof TrayDialog) {
                TrayDialog dialog = (TrayDialog) page.getContainer();

                // close existing tray
                if (dialog.getTray() != null) {
                    dialog.closeTray();
                }

                dialog.openTray(new TypeStructureTray(types, schemaSpace));
            } else {
                // TODO show dialog instead?
            }
        }
    });
}

From source file:org.eclipse.help.ui.internal.DefaultHelpUI.java

License:Open Source License

private void displayContextAsHelpTray(Shell activeShell, IContext context) {
    Control controlInFocus = activeShell.getDisplay().getFocusControl();
    TrayDialog dialog = (TrayDialog) activeShell.getData();

    DialogTray tray = dialog.getTray();// www .  ja va 2  s .  c  o m
    if (tray == null) {
        tray = new HelpTray();
        dialog.openTray(tray);
    }
    if (tray instanceof HelpTray) {
        ReusableHelpPart helpPart = ((HelpTray) tray).getHelpPart();
        if (context != null) {
            IHelpResource[] topics = context.getRelatedTopics();
            if (context.getText() == null && topics.length == 1) {
                helpPart.showURL(topics[0].getHref());
            } else {
                helpPart.showPage(IHelpUIConstants.HV_CONTEXT_HELP_PAGE);
                helpPart.update(null, context, null, controlInFocus, true);
            }
        } else {
            helpPart.showPage(IHelpUIConstants.HV_FSEARCH_PAGE, true);
        }
        helpPart.setFocus();
    } else {
        // someone else was occupying the tray; not supported
    }
}

From source file:org.eclipse.ui.tests.statushandlers.SupportTrayTest.java

License:Open Source License

public void testJFacePolicySupportProvider() {
    Map dialogState = new HashMap();
    StatusAdapter sa = new StatusAdapter(Status.OK_STATUS);
    dialogState.put(IStatusDialogConstants.CURRENT_STATUS_ADAPTER, sa);
    SupportTray st = new SupportTray(dialogState, new NullListener());

    assertNull(st.providesSupport(sa));/*from www .j a v a2s .co  m*/

    final IStatus[] _status = new IStatus[] { null };

    Policy.setErrorSupportProvider(new ErrorSupportProvider() {

        public Control createSupportArea(Composite parent, IStatus status) {
            _status[0] = status;
            return new Composite(parent, SWT.NONE);
        }
    });

    assertNotNull(st.providesSupport(sa));

    TrayDialog td = null;
    try {
        td = new TrayDialog(new Shell()) {
        };
        td.setBlockOnOpen(false);
        td.open();
        td.openTray(st);
    } finally {
        if (td != null)
            td.close();
    }

    assertEquals(Status.OK_STATUS, _status[0]);
}