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

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

Introduction

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

Prototype

public DialogTray getTray() 

Source Link

Document

Returns the tray currently shown in the dialog, or null if there is no tray.

Usage

From source file:de.walware.ecommons.debug.ui.HelpRequestor.java

License:Open Source License

public static void closeHelpTray(final TrayDialog dialog) {
    if (dialog.getTray() instanceof HelpRequestor.InfoTray) {
        dialog.closeTray();//from w w w.  j ava 2s .com
    }
}

From source file:eu.esdihumboldt.hale.ui.function.internal.NewRelationPage.java

License:Open Source License

/**
 * @see ViewerWizardSelectionPage#createViewer(Composite)
 *//*w w  w .java 2s  .com*/
@Override
protected Pair<StructuredViewer, Control> createViewer(Composite parent) {
    PatternFilter filter = new PatternFilter();
    filter.setIncludeLeadingWildcard(true);
    FilteredTree tree = new FilteredTree(parent, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL, filter,
            true);

    viewer = tree.getViewer();
    viewer.setContentProvider(
            new FunctionWizardNodeContentProvider(getContainer(), initialSelection, selectionMatcher));
    viewer.setLabelProvider(new FunctionWizardNodeLabelProvider());
    // no input needed, but we have to set something
    viewer.setInput(Boolean.TRUE);

    // set focus on viewer control to prevent odd behavior
    viewer.getControl().setFocus();

    // expand selection
    viewer.expandAll();

    // selection context
    contextProvider = new HALEContextProvider(viewer, null);

    // help update on page shown
    if (getContainer() instanceof IPageChangeProvider) {
        ((IPageChangeProvider) getContainer())
                .addPageChangedListener(changeListener = new IPageChangedListener() {

                    @Override
                    public void pageChanged(PageChangedEvent event) {
                        if (event.getSelectedPage() == NewRelationPage.this) {
                            // update the help button
                            if (getContainer() instanceof HaleWizardDialog) {
                                ((HaleWizardDialog) getContainer())
                                        .setHelpButtonEnabled(getHelpContext() != null);
                            }
                        }
                    }

                });
    }

    // help update on selection change
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IContext context = getHelpContext();

            // update the help button
            if (getContainer() instanceof HaleWizardDialog) {
                ((HaleWizardDialog) getContainer()).setHelpButtonEnabled(context != null);
            }

            // update the help
            if (context != null) {
                TrayDialog trayDialog = (TrayDialog) getContainer();
                if (trayDialog.getTray() != null) {
                    // if the tray is already open, update the help
                    performHelp();
                }
            }
        }
    });

    // load page configuration
    // XXX would be better if called from outside
    ProjectService ps = (ProjectService) PlatformUI.getWorkbench().getService(ProjectService.class);
    restore(ps.getConfigurationService());

    return new Pair<StructuredViewer, Control>(viewer, tree);
}

From source file:eu.esdihumboldt.hale.ui.function.internal.NewRelationPage.java

License:Open Source License

@Override
public void performHelp() {
    IContext helpContext = getHelpContext();

    if (helpContext == null) {
        TrayDialog trayDialog = (TrayDialog) getContainer();
        if (trayDialog.getTray() != null) {
            trayDialog.closeTray();/*  ww w .j a  v a 2 s.  co  m*/
        }
    } else {
        PlatformUI.getWorkbench().getHelpSystem().displayHelp(helpContext);
    }
}

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

License:Open Source License

/**
 * Show the AST viewer in the wizard tray.
 * //from   www.jav  a2s  . co 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

/**
 * /*www .java 2  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
 * /*w  w w . ja  v  a 2  s  .co  m*/
 * @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./* w  w  w  .  ja va2  s .  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:eu.esdihumboldt.hale.ui.HaleWizardPage.java

License:Open Source License

/**
 * @see DialogPage#performHelp()//from www . j av a2 s  .co  m
 */
@Override
public void performHelp() {
    boolean closed = false;
    if (getContainer() instanceof TrayDialog) {
        TrayDialog trayDialog = (TrayDialog) getContainer();
        if (trayDialog.getTray() != null) {
            closed = trayDialog.getTray().getClass().getSimpleName().equals("HelpTray");
            trayDialog.closeTray();
        }
    }
    if (!closed && getHelpContext() != null)
        PlatformUI.getWorkbench().getHelpSystem().displayHelp(getHelpContext());
}

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

License:Open Source License

/**
 * Executes the command./*from   ww  w  .j a  v a 2 s . c om*/
 */
public Object execute(ExecutionEvent event) throws ExecutionException {
    Display display = Display.getCurrent();
    if (display == null) {
        display = Display.getDefault();
    }
    if (display != null) {
        Shell shell = Display.getCurrent().getActiveShell();
        if (shell != null && !shell.isDisposed()) {
            Object shellData = shell.getData();
            if (shellData instanceof TrayDialog) {
                TrayDialog trayDialog = (TrayDialog) shellData;
                if (trayDialog.getTray() instanceof HelpTray) {
                    trayDialog.closeTray();
                }
            }
        }
    }
    return null;
}

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();
    if (tray == null) {
        tray = new HelpTray();
        dialog.openTray(tray);/*from  w w  w  .ja v  a 2  s.co  m*/
    }
    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
    }
}