Example usage for org.eclipse.jface.window Window getShell

List of usage examples for org.eclipse.jface.window Window getShell

Introduction

In this page you can find the example usage for org.eclipse.jface.window Window getShell.

Prototype

@Override
public Shell getShell() 

Source Link

Document

Returns this window's shell.

Usage

From source file:org.apache.commons.jelly.tags.jface.JFaceImageTag.java

License:Apache License

/**
 * Set default image Window/*from w  ww . j  a v  a2 s  .  co  m*/
 * @param window
 * @param image
 */
private void setWindowImage(Window window, Image image) {
    window.getShell().setImage(image);
}

From source file:org.eclipse.help.ui.internal.views.ContextHelpPart.java

License:Open Source License

private String[] computeSearchTerms(Control c) {
    // Search the control and all ancestors until we find a composite
    // which we can get a search term from
    Composite container = c instanceof Composite ? (Composite) c : c.getParent();
    SearchTerms searchTerms = new SearchTerms();
    while (container != null) {
        Object data = container.getData();
        if (data instanceof IWizardContainer) {
            IWizardContainer wc = (IWizardContainer) data;
            searchTerms.add(wc.getCurrentPage().getTitle());
            searchTerms.add(wc.getCurrentPage().getWizard().getWindowTitle());
            break;
        } else if (data instanceof IWorkbenchWindow) {
            IWorkbenchWindow window = (IWorkbenchWindow) data;
            IWorkbenchPage page = window.getActivePage();
            if (page != null) {
                IWorkbenchPart part = lastPart;
                if (part != null) {
                    if (part instanceof IViewPart) {
                        searchTerms.add(NLS.bind(Messages.ContextHelpPart_query_view,
                                part.getSite().getRegisteredName()));
                    } else if (part instanceof IEditorPart) {
                        if (part.getSite() != null && part.getSite().getRegisteredName() != null) {
                            searchTerms.add(part.getSite().getRegisteredName());
                        }/*from   w w w . j  a  v  a2s .c  o  m*/
                    }
                }
                /*
                     // Searching by perspective seems counterproductive - CG
                IPerspectiveDescriptor persp = page.getPerspective();
                if (persp != null) {
                   searchTerms.add(NLS.bind(
                Messages.ContextHelpPart_query_perspective,
                persp.getLabel()));
                }
                */
            }
            break;
        } else if (data instanceof Window) {
            Window w = (Window) data;
            if (w instanceof IPageChangeProvider) {
                Object page = ((IPageChangeProvider) w).getSelectedPage();
                String pageName = getPageName(c, page);
                if (pageName != null) {
                    searchTerms.add(pageName);
                }
            }
            searchTerms.add(w.getShell().getText());
            break;
        }
        container = container.getParent();
    }
    return (String[]) searchTerms.toArray();
}

From source file:org.eclipse.mylyn.internal.commons.ui.WindowUtil.java

License:Open Source License

/**
 * Given the desired position of the window, this method returns an adjusted position such that the window is no
 * larger than its monitor, and does not extend beyond the edge of the monitor. This is used for computing the
 * initial window position, and subclasses can use this as a utility method if they want to limit the region in
 * which the window may be moved./*from   www .  j ava 2  s.  c o m*/
 * 
 * @param window
 *            the window
 * @param preferredSize
 *            the preferred position of the window
 * @return a rectangle as close as possible to preferredSize that does not extend outside the monitor
 * @see Window#getConstrainedShellBounds
 */
public static Rectangle getConstrainedShellBounds(Window window, Rectangle preferredSize) {
    Rectangle result = new Rectangle(preferredSize.x, preferredSize.y, preferredSize.width,
            preferredSize.height);

    Monitor mon = getClosestMonitor(window.getShell().getDisplay(), Geometry.centerPoint(result));

    Rectangle bounds = mon.getClientArea();

    if (result.height > bounds.height) {
        result.height = bounds.height;
    }

    if (result.width > bounds.width) {
        result.width = bounds.width;
    }

    result.x = Math.max(bounds.x, Math.min(result.x, bounds.x + bounds.width - result.width));
    result.y = Math.max(bounds.y, Math.min(result.y, bounds.y + bounds.height - result.height));

    return result;
}

From source file:org.eclipse.pde.internal.ui.tests.macro.WindowCommandTarget.java

License:Open Source License

public void ensureVisible() {
    Window window = getWindow();
    window.getShell().setActive();
}