Example usage for org.eclipse.jface.action ToolBarManager find

List of usage examples for org.eclipse.jface.action ToolBarManager find

Introduction

In this page you can find the example usage for org.eclipse.jface.action ToolBarManager find.

Prototype

@Override
    public IContributionItem find(String id) 

Source Link

Usage

From source file:de.loskutov.anyedit.actions.internal.StartupHelper.java

License:Open Source License

private static int insert(IDirtyWorkaround myAction, ToolBarManager manager, int controlIdx) {
    IContributionItem item;/* w  ww .  j  a  v  a  2 s . co m*/
    // get "file->save" action
    item = manager.find(myAction.getId());
    if (item != null) {
        // copy references to opened editor/part
        myAction.copyStateAndDispose(item);
        if (controlIdx < 0) {
            // get/remember position
            IContributionItem[] items = manager.getItems();
            for (int i = 0; i < items.length; i++) {
                if (items[i].isSeparator() || items[i] instanceof ActionContributionItem) {
                    controlIdx++;
                    if (items[i] == item) {
                        break;
                    }
                }
            }
        }
        // clean old one
        manager.remove(item);
        item = new ActionContributionItem(myAction);
        manager.insert(controlIdx, item);
        // refresh menu gui
        manager.update(true);
    } else if (controlIdx >= 0) {
        item = new ActionContributionItem(myAction);
        manager.insert(controlIdx, item);
        // refresh menu gui
        manager.update(true);
    }
    return controlIdx;
}

From source file:de.loskutov.bco.compare.BytecodeCompare.java

License:Open Source License

/**
 * @see org.eclipse.compare.CompareEditorInput#createContents(org.eclipse.swt.widgets.Composite)
 *///w ww .ja  va  2s  .  c  o  m
@Override
public Control createContents(final Composite parent) {
    Object obj = parent.getData();
    if (obj == null) {
        obj = parent.getParent().getData();
    }
    // dirty hook on this place to get reference to editor
    // CompareEditor extends EditorPart implements IReusableEditor
    if (obj instanceof IReusableEditor) {
        myEditor = (IReusableEditor) obj;
    }

    Control control = super.createContents(parent);

    CompareViewerSwitchingPane inputPane = getInputPane();
    if (inputPane != null) {
        ToolBarManager toolBarManager2 = CompareViewerPane.getToolBarManager(inputPane);
        if (toolBarManager2 == null) {
            return control;
        }
        boolean separatorExist = false;
        if (toolBarManager2.find(hideLineInfoAction.getId()) == null) {
            if (!separatorExist) {
                separatorExist = true;
                toolBarManager2.insert(0, new Separator("bco")); //$NON-NLS-1$
            }
            toolBarManager2.insertBefore("bco", hideLineInfoAction); //$NON-NLS-1$
            //                toolBarManager2.update(true);
        }
        if (toolBarManager2.find(hideLocalsAction.getId()) == null) {
            if (!separatorExist) {
                separatorExist = true;
                toolBarManager2.insert(0, new Separator("bco")); //$NON-NLS-1$
            }
            toolBarManager2.insertBefore("bco", hideLocalsAction); //$NON-NLS-1$
            //                toolBarManager2.update(true);
        }

        if (toolBarManager2.find(hideStackMapAction.getId()) == null) {
            if (!separatorExist) {
                separatorExist = true;
                toolBarManager2.insert(0, new Separator("bco")); //$NON-NLS-1$
            }
            toolBarManager2.insertBefore("bco", hideStackMapAction); //$NON-NLS-1$
            //                toolBarManager2.update(true);
        }
        if (toolBarManager2.find(expandStackMapAction.getId()) == null) {
            if (!separatorExist) {
                separatorExist = true;
                toolBarManager2.insert(0, new Separator("bco")); //$NON-NLS-1$
            }
            toolBarManager2.insertBefore("bco", expandStackMapAction); //$NON-NLS-1$
            //                toolBarManager2.update(true);
        }

        if (toolBarManager2.find(toggleAsmifierModeAction.getId()) == null) {
            if (!separatorExist) {
                toolBarManager2.insert(0, new Separator("bco")); //$NON-NLS-1$
                separatorExist = true;
            }
            toolBarManager2.insertBefore("bco", toggleAsmifierModeAction); //$NON-NLS-1$
            //                toolBarManager2.update(true);
        }
        try {
            toolBarManager2.update(true);
            toolBarManager2.getControl().getParent().layout(true);
            toolBarManager2.getControl().getParent().update();
        } catch (NullPointerException e) {
            // ignore, i'm just curios why we need this code in 3.2 and expect
            // some unwanted side effects...
        }
    }
    return control;
}

From source file:org.eclipse.mylyn.internal.reviews.ui.compare.ReviewItemCompareEditorInput.java

License:Open Source License

private void initializeGotoCommentHandlers(Composite parent, final ReviewCompareAnnotationSupport support) {
    ToolBarManager tbm = CompareViewerPane.getToolBarManager(parent);
    if (tbm != null) {
        if (tbm.find(NAVIGATION_GROUP) != null) {
            if (tbm.find(ID_NEXT_COMMENT) == null) {
                Action goToNextAction = new Action(Messages.Reviews_NextComment, ReviewsImages.NEXT_COMMENT) {
                    @Override//from  w ww .j  a v  a  2s.  com
                    public void run() {
                        support.gotoAnnotation(Direction.FORWARDS);
                    }
                };
                goToNextAction.setId(ID_NEXT_COMMENT);
                goToNextAction.setToolTipText(Messages.Reviews_NextComment_Tooltip);
                tbm.appendToGroup(NAVIGATION_GROUP, goToNextAction);
            }

            if (tbm.find(ID_PREVIOUS_COMMENT) == null) {
                Action goToPreviousAction = new Action(Messages.Reviews_PreviousComment,
                        ReviewsImages.PREVIOUS_COMMENT) {
                    @Override
                    public void run() {
                        support.gotoAnnotation(Direction.BACKWARDS);
                    }
                };
                goToPreviousAction.setId(ID_PREVIOUS_COMMENT);
                goToPreviousAction.setToolTipText(Messages.Reviews_PreviousComment_Tooltip);
                tbm.appendToGroup(NAVIGATION_GROUP, goToPreviousAction);
            }
        } else {// bug 430151
            StatusHandler.log(new Status(IStatus.ERROR, ReviewsUiPlugin.PLUGIN_ID,
                    "Could not create comment navigation buttons", new Exception())); //$NON-NLS-1$
        }
        tbm.update(true);
    }
}

From source file:org.eclipse.mylyn.reviews.r4e.ui.tests.proxy.R4EUITestCommands.java

License:Open Source License

/**
 * Method progressElement Progress Element to next state
 * //from  w  w w .  ja v a2 s.c o m
 * @param aElement
 * @param aNextState
 */
public void progressElement(IR4EUIModelElement aElement, Object aNextState) {
    //Inner class that runs the command on the UI thread
    class RunProgressElement implements Runnable {
        private IR4EUIModelElement element;

        public void setElement(IR4EUIModelElement aElement) {
            element = aElement;
        }

        public void run() {
            try {
                //Set focus on Navigator view and select element
                setFocusOnNavigatorElement(element);

                //Create Event for Command
                Event event = new Event();
                event.widget = null;
                ToolBarManager toolbar = (ToolBarManager) R4EUIModelController.getNavigatorView().getViewSite()
                        .getActionBars().getToolBarManager();
                IContributionItem contribItem = toolbar.find(R4EUIConstants.NEXT_STATE_ELEMENT_COMMAND);
                for (ToolItem item : toolbar.getControl().getItems()) {
                    if (item.getData().equals(contribItem)) {
                        event.widget = item;
                        break;
                    }
                }

                //Execute Progress Element Command
                fParentProxy.getCommandProxy().executeCommand(R4EUIConstants.NEXT_STATE_ELEMENT_COMMAND, event);
                TestUtils.waitForJobs();
            } catch (ExecutionException e) {
                // ignore, test will fail later
            } catch (NotDefinedException e) {
                // ignore, test will fail later
            } catch (NotEnabledException e) {
                // ignore, test will fail later
            } catch (NotHandledException e) {
                // ignore, test will fail later
            }
        }
    }
    ;

    //Run the UI job and wait until the command is completely executed before continuing
    RunProgressElement progressJob = new RunProgressElement();
    progressJob.setElement(aElement);
    Display.getDefault().syncExec(progressJob);
    TestUtils.waitForJobs();
}

From source file:org.eclipse.mylyn.reviews.r4e.ui.tests.proxy.R4EUITestCommands.java

License:Open Source License

/**
 * Method regressElement Regress Element to previous state
 * //from  ww w .j av  a 2s. c o m
 * @param aElement
 */
public void regressElement(IR4EUIModelElement aElement) {
    //Inner class that runs the command on the UI thread
    class RunRegressElement implements Runnable {
        private IR4EUIModelElement element;

        public void setElement(IR4EUIModelElement aElement) {
            element = aElement;
        }

        public void run() {
            try {
                //Set focus on Navigator view and select element
                setFocusOnNavigatorElement(element);

                //Create Event for Command
                Event event = new Event();
                event.widget = null;
                ToolBarManager toolbar = (ToolBarManager) R4EUIModelController.getNavigatorView().getViewSite()
                        .getActionBars().getToolBarManager();
                IContributionItem contribItem = toolbar.find(R4EUIConstants.PREVIOUS_STATE_ELEMENT_COMMAND);
                for (ToolItem item : toolbar.getControl().getItems()) {
                    if (item.getData().equals(contribItem)) {
                        event.widget = item;
                        break;
                    }
                }

                //Execute Progress Element Command
                fParentProxy.getCommandProxy().executeCommand(R4EUIConstants.PREVIOUS_STATE_ELEMENT_COMMAND,
                        event);
                TestUtils.waitForJobs();
            } catch (ExecutionException e) {
                // ignore, test will fail later
            } catch (NotDefinedException e) {
                // ignore, test will fail later
            } catch (NotEnabledException e) {
                // ignore, test will fail later
            } catch (NotHandledException e) {
                // ignore, test will fail later
            }
        }
    }
    ;

    //Run the UI job and wait until the command is completely executed before continuing
    RunRegressElement progressJob = new RunRegressElement();
    progressJob.setElement(aElement);
    Display.getDefault().syncExec(progressJob);
    TestUtils.waitForJobs();
}

From source file:org.eclipse.mylyn.reviews.r4e.ui.tests.proxy.R4EUITestReviewGroup.java

License:Open Source License

/**
 * Create a new Review Group/*from  ww  w  . j  av  a 2  s .  co  m*/
 * 
 * @param aParentFolder
 * @param aName
 * @param aDescription
 * @param aEntry
 * @param aProjects
 * @param aComponents
 * @param aRuleSets
 * @return R4EUIReviewGroup
 */
public R4EUIReviewGroup createReviewGroup(String aParentFolder, String aName, String aDescription,
        String aEntry, String[] aProjects, String[] aComponents, String[] aRuleSets) {

    //Inject mockup dialog for New Review Group
    IReviewGroupInputDialog mockReviewGroupDialog = mock(ReviewGroupInputDialog.class);
    R4EUIDialogFactory.getInstance().setReviewGroupInputDialog(mockReviewGroupDialog);

    //Here we need to stub the ReviewGroupInputDialog get methods to return what we want
    when(mockReviewGroupDialog.getGroupFolderValue()).thenReturn(aParentFolder);
    when(mockReviewGroupDialog.getGroupNameValue()).thenReturn(aName);
    when(mockReviewGroupDialog.getGroupDescriptionValue()).thenReturn(aDescription);
    when(mockReviewGroupDialog.getDefaultEntryCriteriaValue()).thenReturn(aEntry);
    when(mockReviewGroupDialog.getAvailableProjectsValues()).thenReturn(aProjects);
    when(mockReviewGroupDialog.getAvailableComponentsValues()).thenReturn(aComponents);
    when(mockReviewGroupDialog.getRuleSetValues()).thenReturn(aRuleSets);
    when(mockReviewGroupDialog.open()).thenReturn(Window.OK);

    //Inner class that runs the command on the UI thread
    class RunCreateReviewGroup implements Runnable {
        private R4EUIReviewGroup group;

        public R4EUIReviewGroup getGroup() {
            return group;
        }

        public void run() {
            try {
                //Create Event for Command
                Event event = new Event();
                event.widget = null;
                ToolBarManager toolbar = (ToolBarManager) R4EUIModelController.getNavigatorView().getViewSite()
                        .getActionBars().getToolBarManager();
                IContributionItem contribItem = toolbar.find(R4EUIConstants.NEW_CHILD_ELEMENT_COMMAND);
                for (ToolItem item : toolbar.getControl().getItems()) {
                    if (item.getData().equals(contribItem)) {
                        event.widget = item;
                        break;
                    }
                }

                //Execute New Review Group Command
                fParentProxy.getCommandProxy().executeCommand(R4EUIConstants.NEW_CHILD_ELEMENT_COMMAND, event);
                TestUtils.waitForJobs();
                group = (R4EUIReviewGroup) getNavigatorSelectedElement();
            } catch (ExecutionException e) {
                // ignore, test will fail later
            } catch (NotDefinedException e) {
                // ignore, test will fail later
            } catch (NotEnabledException e) {
                // ignore, test will fail later
            } catch (NotHandledException e) {
                // ignore, test will fail later
            }
        }
    }
    ;

    //Run the UI job and wait until the command is completely executed before continuing
    RunCreateReviewGroup groupJob = new RunCreateReviewGroup();
    Display.getDefault().syncExec(groupJob);
    TestUtils.waitForJobs();
    return groupJob.getGroup();
}

From source file:org.eclipse.ui.tests.menus.MenuPopulationTest.java

License:Open Source License

public void testToolBarItems() throws Exception {
    Field iconField = CommandContributionItem.class.getDeclaredField(FIELD_ICON);
    iconField.setAccessible(true);//from  w  w  w  .j  av  a 2 s .com

    ToolBarManager manager = new ToolBarManager();
    menuService.populateContributionManager(manager, "toolbar:" + TEST_CONTRIBUTIONS_CACHE_ID);

    IContributionItem ici = manager.find(ID_DEFAULT);
    assertTrue(ici instanceof CommandContributionItem);
    CommandContributionItem cmd = (CommandContributionItem) ici;

    ImageDescriptor icon = (ImageDescriptor) iconField.get(cmd);
    assertNotNull(icon);
    String iconString = icon.toString();
    assertEquals(ICONS_ANYTHING_GIF, iconString.substring(iconString.lastIndexOf('/')));

    ici = manager.find(ID_ALL);
    assertTrue(ici instanceof CommandContributionItem);
    cmd = (CommandContributionItem) ici;
    icon = (ImageDescriptor) iconField.get(cmd);
    assertNotNull(icon);
    iconString = icon.toString();
    assertEquals(ICONS_MOCK_GIF, iconString.substring(iconString.lastIndexOf('/')));

    ici = manager.find(ID_TOOLBAR);
    assertTrue(ici instanceof CommandContributionItem);
    cmd = (CommandContributionItem) ici;
    icon = (ImageDescriptor) iconField.get(cmd);
    assertNotNull(icon);
    iconString = icon.toString();
    assertEquals(ICONS_VIEW_GIF, iconString.substring(iconString.lastIndexOf('/')));

    manager.dispose();
}

From source file:org.rssowl.ui.internal.dialogs.SearchNewsDialog.java

License:Open Source License

private void createConditionControls(Composite container) {
    Composite topControlsContainer = new Composite(container, SWT.None);
    topControlsContainer.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1));
    topControlsContainer.setLayout(LayoutUtils.createGridLayout(5, 10, 3));

    /* Radio to select Condition Matching */
    fMatchAllRadio = new Button(topControlsContainer, SWT.RADIO);
    fMatchAllRadio.setText(Messages.SearchNewsDialog_MATCH_ALL);
    fMatchAllRadio.setSelection(fMatchAllConditions);

    fMatchAnyRadio = new Button(topControlsContainer, SWT.RADIO);
    fMatchAnyRadio.setText(Messages.SearchNewsDialog_MATCH_ANY);
    fMatchAnyRadio.setSelection(!fMatchAllConditions);

    /* Separator */
    Label sep = new Label(topControlsContainer, SWT.SEPARATOR | SWT.VERTICAL);
    sep.setLayoutData(new GridData(SWT.DEFAULT, 16));

    /* Scope *//*ww w  .ja v  a2s . c o  m*/
    Composite scopeContainer = new Composite(topControlsContainer, SWT.None);
    scopeContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
    scopeContainer.setLayout(LayoutUtils.createGridLayout(2, 0, 0, 0, 5, false));
    ((GridLayout) scopeContainer.getLayout()).marginLeft = 2;

    Label locationLabel = new Label(scopeContainer, SWT.NONE);
    locationLabel.setText(Messages.SearchNewsDialog_SEARCH_IN);

    fLocationControl = new LocationControl(scopeContainer, SWT.WRAP) {
        @Override
        protected String getDefaultLabel() {
            return Messages.SearchNewsDialog_ALL_NEWS;
        }
    };
    fLocationControl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
    ((GridData) fLocationControl.getLayoutData()).widthHint = 100;
    fLocationControl.setLayout(LayoutUtils.createGridLayout(1, 0, 0, 0, 0, false));

    /* ToolBar to add and select existing saved searches */
    final ToolBarManager dialogToolBar = new ToolBarManager(SWT.RIGHT | SWT.FLAT);

    /* Columns */
    IAction columnDropdown = new Action(Messages.SearchNewsDialog_VISIBLE_COLUMNS, IAction.AS_DROP_DOWN_MENU) {
        @Override
        public void run() {
            OwlUI.positionDropDownMenu(this, dialogToolBar);
        }

        @Override
        public ImageDescriptor getImageDescriptor() {
            return OwlUI.COLUMNS;
        }

        @Override
        public String getId() {
            return COLUMNS_ACTION;
        }
    };

    columnDropdown.setMenuCreator(new ContextMenuCreator() {

        @Override
        public Menu createMenu(Control parent) {
            Menu menu = new Menu(parent);

            MenuItem restoreDefaults = new MenuItem(menu, SWT.None);
            restoreDefaults.setText(Messages.SearchNewsDialog_RESTORE_DEFAULT_COLUMNS);
            restoreDefaults.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    NewsColumnViewModel defaultModel = NewsColumnViewModel.createDefault(true);
                    if (!defaultModel.equals(fColumnModel))
                        showColumns(defaultModel, true);
                }
            });

            new MenuItem(menu, SWT.SEPARATOR);

            NewsColumn[] columns = NewsColumn.values();
            for (final NewsColumn column : columns) {
                if (column.isSelectable()) {
                    MenuItem item = new MenuItem(menu, SWT.CHECK);
                    item.setText(column.getName());
                    if (fColumnModel.contains(column))
                        item.setSelection(true);

                    item.addSelectionListener(new SelectionAdapter() {
                        @Override
                        public void widgetSelected(SelectionEvent e) {
                            if (fColumnModel.contains(column))
                                fColumnModel.removeColumn(column);
                            else
                                fColumnModel.addColumn(column);

                            showColumns(fColumnModel, true);
                        }
                    });
                }
            }

            return menu;
        }
    });

    dialogToolBar.add(columnDropdown);

    /* Separator */
    dialogToolBar.add(new Separator());

    /* Toggle Preview */
    final String previewActionId = "org.rssowl.ui.internal.dialogs.search.PreviewAction"; //$NON-NLS-1$
    IAction previewAction = new Action(Messages.SearchNewsDialog_PREVIEW_RESULTS, IAction.AS_CHECK_BOX) {
        @Override
        public void run() {
            fIsPreviewVisible = !fIsPreviewVisible;
            fSashForm.setWeights(fIsPreviewVisible ? THREE_SASH_WEIGHTS : TWO_SASH_WEIGHTS);
            fBottomSash.setVisible(fIsPreviewVisible);
            fSashForm.layout();
            dialogToolBar.find(previewActionId).update(IAction.TOOL_TIP_TEXT);

            /* Select and Show News if required */
            if (fIsPreviewVisible && fResultViewer.getTable().getItemCount() > 0) {

                /* Select first News if required */
                if (fResultViewer.getSelection().isEmpty())
                    fResultViewer.getTable().select(0);

                /* Set input and Focus */
                fBrowserViewer
                        .setInput(((IStructuredSelection) fResultViewer.getSelection()).getFirstElement());
                hideBrowser(false);
                fResultViewer.getTable().setFocus();

                /* Make sure to show the selection */
                fResultViewer.getTable().showSelection();
            }
        }

        @Override
        public ImageDescriptor getImageDescriptor() {
            return OwlUI.getImageDescriptor("icons/etool16/browsermaximized.gif"); //$NON-NLS-1$
        }

        @Override
        public String getToolTipText() {
            if (fIsPreviewVisible)
                return Messages.SearchNewsDialog_HIDE_PREVIEW;

            return Messages.SearchNewsDialog_SHOW_PREVIEW;
        }
    };
    previewAction.setId(previewActionId);
    previewAction.setChecked(fIsPreviewVisible);
    dialogToolBar.add(previewAction);

    /* Separator */
    dialogToolBar.add(new Separator());

    /* Existing Saved Searches */
    IAction savedSearches = new Action(Messages.SearchNewsDialog_SHOW_SAVED_SEARCH, IAction.AS_DROP_DOWN_MENU) {
        @Override
        public void run() {
            OwlUI.positionDropDownMenu(this, dialogToolBar);
        }

        @Override
        public ImageDescriptor getImageDescriptor() {
            return OwlUI.SEARCHMARK;
        }

        @Override
        public String getId() {
            return SEARCHES_ACTION;
        }
    };

    savedSearches.setMenuCreator(new ContextMenuCreator() {

        @Override
        public Menu createMenu(Control parent) {
            Collection<ISearchMark> searchMarks = CoreUtils.loadSortedSearchMarks();
            Menu menu = new Menu(parent);

            /* Create new Saved Search */
            MenuItem newSavedSearch = new MenuItem(menu, SWT.NONE);
            newSavedSearch.setText(Messages.SearchNewsDialog_NEW_SAVED_SEARCH);
            newSavedSearch.setImage(OwlUI.getImage(fResources, "icons/etool16/add.gif")); //$NON-NLS-1$
            newSavedSearch.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    onSave();
                }
            });

            /* Separator */
            if (searchMarks.size() > 0)
                new MenuItem(menu, SWT.SEPARATOR);

            /* Show Existing Saved Searches */
            for (final ISearchMark searchMark : searchMarks) {
                MenuItem item = new MenuItem(menu, SWT.None);
                item.setText(searchMark.getName());
                item.setImage(OwlUI.getImage(fResources, OwlUI.SEARCHMARK));
                item.addSelectionListener(new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        show(searchMark);
                    }
                });
            }

            return menu;
        }
    });

    dialogToolBar.add(savedSearches);
    dialogToolBar.createControl(topControlsContainer);
    dialogToolBar.getControl().setLayoutData(new GridData(SWT.END, SWT.CENTER, true, true));

    /* Container for Conditions */
    final Composite conditionsContainer = new Composite(container, SWT.NONE);
    conditionsContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
    conditionsContainer.setLayout(LayoutUtils.createGridLayout(2, 5, 10));
    conditionsContainer.setBackground(container.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    conditionsContainer.setBackgroundMode(SWT.INHERIT_FORCE);
    conditionsContainer.addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            GC gc = e.gc;
            Rectangle clArea = conditionsContainer.getClientArea();
            gc.setForeground(conditionsContainer.getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
            gc.drawLine(clArea.x, clArea.y, clArea.x + clArea.width, clArea.y);
        }
    });

    /* Search Conditions List */
    fSearchConditionList = new SearchConditionList(conditionsContainer, SWT.None, getDefaultConditions());
    fSearchConditionList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
    fSearchConditionList.setVisibleItemCount(3);

    /* Show Initial Scope if present */
    if (fInitialScope != null && fInitialScope.getValue() instanceof Long[][])
        fLocationControl.select((Long[][]) fInitialScope.getValue());

    /* Show Initial Conditions if present */
    if (fInitialConditions != null)
        fSearchConditionList.showConditions(fInitialConditions);

    /* Focus Input */
    int index = 0;
    if (fInitialConditions != null && fInitialConditions.size() == 2)
        index = 1;

    fSearchConditionList.focusInput(index);
}

From source file:org.rssowl.ui.internal.OwlUI.java

License:Open Source License

/**
 * @param action the dropdown action./*from   w  w w. j a  v a  2  s.c  o m*/
 * @param manager the toolbar containing the action.
 */
public static void positionDropDownMenu(Action action, ToolBarManager manager) {
    Menu menu = action.getMenuCreator().getMenu(manager.getControl());
    if (menu != null) {

        /* Adjust Location */
        IContributionItem contributionItem = manager.find(action.getId());
        if (contributionItem != null && contributionItem instanceof ActionContributionItem) {
            Widget widget = ((ActionContributionItem) contributionItem).getWidget();
            if (widget != null && widget instanceof ToolItem) {
                ToolItem item = (ToolItem) widget;
                Rectangle rect = item.getBounds();
                Point pt = new Point(rect.x, rect.y + rect.height);
                pt = manager.getControl().toDisplay(pt);
                if (Application.IS_MAC)
                    pt.y += 5;
                menu.setLocation(pt.x, pt.y);
            }
        }

        /* Set Visible */
        menu.setVisible(true);
    }
}