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

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

Introduction

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

Prototype

public int getSize() 

Source Link

Document

Return the number of contributions in this manager.

Usage

From source file:com.atlassian.connector.eclipse.internal.crucible.ui.dialogs.AbstractCrucibleCommentDialog.java

License:Open Source License

protected void createWikiTextControl(Composite composite, FormToolkit toolkit) {
    final AbstractTaskEditorExtension extension = new ConfluenceMarkupTaskEditorExtension();
    final String contextId = extension.getEditorContextId();

    contextService = (IContextService) PlatformUI.getWorkbench().getService(IContextService.class);
    commentContext = contextService.activateContext(contextId, new ActiveShellExpression(getShell()));

    commentText = new RichTextEditor(taskRepository, SWT.MULTI | SWT.BORDER, contextService, extension);
    final MarkupParser markupParser = new MarkupParser();
    final MarkupLanguage markupLanguage = ServiceLocator.getInstance().getMarkupLanguage("Confluence");
    if (markupLanguage != null) {
        commentText.setRenderingEngine(new AbstractRenderingEngine() {

            @Override//ww w . j a  va 2 s.c om
            public String renderAsHtml(TaskRepository repository, String text, IProgressMonitor monitor)
                    throws CoreException {

                markupParser.setMarkupLanguage(markupLanguage);
                String htmlContent = markupParser.parseToHtml(text);
                return htmlContent;
            }
        });
    } else {
        StatusHandler.log(new Status(IStatus.INFO, CrucibleUiPlugin.PLUGIN_ID,
                "Unable to locate Confluence MarkupLanguage. Browser preview will not be possible"));
    }

    commentText.setReadOnly(false);
    commentText.setSpellCheckingEnabled(true);

    // creating toolbar - must be created before actually commentText widget is created, to stay on top
    ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
    fillToolBar(toolBarManager, commentText);

    if (toolBarManager.getSize() > 0) {
        Composite toolbarComposite = toolkit.createComposite(composite);
        GridDataFactory.fillDefaults().grab(false, false).hint(SWT.DEFAULT, SWT.DEFAULT)
                .align(SWT.END, SWT.FILL).applyTo(toolbarComposite);
        toolbarComposite.setBackground(null);
        RowLayout rowLayout = new RowLayout();
        rowLayout.marginLeft = 0;
        rowLayout.marginRight = 0;
        rowLayout.marginTop = 0;
        rowLayout.marginBottom = 0;
        rowLayout.center = true;
        toolbarComposite.setLayout(rowLayout);

        toolBarManager.createControl(toolbarComposite);
    }
    // end of toolbar creation stuff

    // auto-completion support
    commentText.createControl(composite, toolkit);
    IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench()
            .getService(IHandlerService.class);
    if (handlerService != null) {
        textSupport = new CommonTextSupport(handlerService);
        textSupport.install(commentText.getViewer(), true);
    }

    commentText.showEditor();
    commentText.getViewer().getTextWidget().setBackground(null);

    GridDataFactory.fillDefaults().grab(true, true).applyTo(commentText.getControl());

    GridData textGridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL
            | GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_FILL);
    textGridData.heightHint = 100;
    textGridData.widthHint = 500;
    commentText.getControl().setLayoutData(textGridData);
}

From source file:eu.esdihumboldt.hale.ui.util.selector.AbstractViewerSelectionDialog.java

License:Open Source License

/**
 * @see Dialog#createDialogArea(Composite)
 *//* w  w w  .j  ava 2  s  .co m*/
@Override
protected Control createDialogArea(Composite parent) {
    Composite page = new Composite(parent, SWT.NONE);
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
    data.widthHint = widthHint;
    //      data.minimumHeight = 200;
    data.heightHint = heightHint;
    page.setLayoutData(data);

    GridLayout pageLayout = new GridLayout(1, false);
    pageLayout.marginLeft = 0;
    pageLayout.marginTop = 0;
    pageLayout.marginLeft = 0;
    pageLayout.marginBottom = 0;
    page.setLayout(pageLayout);

    // create tool bar first so that it is on top
    ToolBarManager manager = new ToolBarManager(SWT.FLAT | SWT.WRAP);
    ToolBar toolbar = manager.createControl(page);
    toolbar.setLayoutData(new GridData(SWT.END, SWT.BEGINNING, false, false));

    viewer = createViewer(page);
    setupViewer(viewer, initialSelection);

    // fill it after viewer creation, so that the viewer can be referenced
    // in there
    addToolBarActions(manager);
    manager.update(false);
    // dispose the tool bar again, if it is empty
    if (manager.getSize() == 0)
        toolbar.dispose();

    if (!(viewer.getControl().getLayoutData() instanceof GridData)) {
        viewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    }

    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            updateState();
        }
    });

    viewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            if (getButton(IDialogConstants.OK_ID).isEnabled())
                okPressed();
        }
    });

    updateState();

    return page;
}

From source file:net.yatomiya.e4.ui.workbench.renderers.swt.ToolBarManagerRenderer.java

License:Open Source License

private void addToManager(ToolBarManager parentManager, MToolBarElement model, IContributionItem ci) {
    MElementContainer<MUIElement> parent = model.getParent();
    // technically this shouldn't happen
    if (parent == null) {
        parentManager.add(ci);//from ww  w .  j av  a  2s  . co m
    } else {
        int index = parent.getChildren().indexOf(model);
        // shouldn't be -1, but better safe than sorry
        if (index > parentManager.getSize() || index == -1) {
            parentManager.add(ci);
        } else {
            parentManager.insert(index, ci);
        }
    }
}

From source file:org.caleydo.core.gui.toolbar.RcpToolBarView.java

License:Open Source License

private void addGeneralToolBar(Composite parent) {

    Group group = new Group(parent, SWT.NULL);
    group.setLayout(new FillLayout(SWT.VERTICAL));
    group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // group.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_GRAY));

    ToolBarManager toolBarManager = new ToolBarManager(SWT.WRAP);
    IMenuService menuService = (IMenuService) PlatformUI.getWorkbench().getService(IMenuService.class);
    menuService.populateContributionManager(toolBarManager, "toolbar:org.caleydo.core.gui.toolbar");

    if (toolBarManager.getSize() > MAX_ITEMS_PER_LINE) { // SystemUtils.IS_OS_LINUX &&
        // Needed to simulate toolbar wrapping which is not implemented for
        // linux See bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=46025
        final IContributionItem[] items = toolBarManager.getItems();
        for (int i = 0; i < items.length;) {
            ToolBarManager m = new ToolBarManager();
            for (; i < items.length && m.getSize() < MAX_ITEMS_PER_LINE; ++i)
                if (items[i].isVisible())
                    m.add(items[i]);//w  w w.ja v a 2 s. c o  m
            m.createControl(group);
        }
    } else {
        toolBarManager.createControl(group);
    }
}

From source file:org.eclipse.e4.ui.workbench.renderers.swt.ToolBarManagerRenderer.java

License:Open Source License

/**
 * @param parentManager// w  w  w  . j ava2s  .  c o m
 * @param itemModel
 * @param ci
 */
private void addToManager(ToolBarManager parentManager, MToolBarElement model, IContributionItem ci) {
    MElementContainer<MUIElement> parent = model.getParent();
    // technically this shouldn't happen
    if (parent == null) {
        parentManager.add(ci);
    } else {
        int index = parent.getChildren().indexOf(model);
        // shouldn't be -1, but better safe than sorry
        if (index > parentManager.getSize() || index == -1) {
            parentManager.add(ci);
        } else {
            parentManager.insert(index, ci);
        }
    }
}

From source file:org.eclipse.mylyn.internal.bugzilla.ui.editor.BugzillaFlagPart.java

License:Open Source License

@Override
protected void setSection(FormToolkit toolkit, Section section) {
    if (section.getTextClient() == null) {
        ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
        fillToolBar(toolBarManager);/*from   w  w  w.  j a v a  2s . c om*/

        if (toolBarManager.getSize() > 0 || getInfoOverlayText() != null) {
            Composite toolbarComposite = toolkit.createComposite(section);
            toolbarComposite.setBackground(null);
            RowLayout rowLayout = new RowLayout();
            rowLayout.marginLeft = 0;
            rowLayout.marginRight = 0;
            rowLayout.marginTop = 0;
            rowLayout.marginBottom = 0;
            rowLayout.center = true;
            toolbarComposite.setLayout(rowLayout);

            createInfoOverlay(toolbarComposite, section, toolkit);

            toolBarManager.createControl(toolbarComposite);
            section.clientVerticalSpacing = 0;
            section.descriptionVerticalSpacing = 0;
            section.setTextClient(toolbarComposite);
        }
    }
    setControl(section);
}

From source file:org.eclipse.mylyn.internal.builds.ui.editor.AbstractBuildEditorPart.java

License:Open Source License

protected void setSection(FormToolkit toolkit, Section section) {
    if (section.getTextClient() == null) {
        ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
        fillToolBar(toolBarManager);//from w ww  .ja v a2 s. c  om

        // TODO toolBarManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));

        if (toolBarManager.getSize() > 0) {
            Composite toolbarComposite = toolkit.createComposite(section);
            toolbarComposite.setBackground(null);
            RowLayout rowLayout = new RowLayout();
            rowLayout.marginLeft = 0;
            rowLayout.marginRight = 0;
            rowLayout.marginTop = 0;
            rowLayout.marginBottom = 0;
            rowLayout.center = true;
            toolbarComposite.setLayout(rowLayout);

            createInfoOverlay(toolbarComposite, section, toolkit);

            toolBarManager.createControl(toolbarComposite);

            // the toolbar adds spacing, offset to make it consistent with other sections
            section.clientVerticalSpacing = 0;
            section.descriptionVerticalSpacing = 0;
            if (section.getClient() instanceof Composite
                    && ((Composite) section.getClient()).getLayout() instanceof GridLayout) {
                GridLayout layout = (GridLayout) ((Composite) section.getClient()).getLayout();
                layout.marginHeight = 0;
                // leave one pixel for borders
                layout.marginTop = 1;
                layout.marginBottom = 5;
            }

            section.setTextClient(toolbarComposite);
        } else {
            // make spacing consistent with sections that have a toolbar
            section.clientVerticalSpacing = PlatformUiUtil.getToolbarSectionClientVerticalSpacing();
        }
    }
    setControl(section);
}

From source file:org.eclipse.mylyn.internal.tasks.ui.editors.AbstractTaskEditorSection.java

License:Open Source License

@Override
protected void setSection(FormToolkit toolkit, Section section) {
    if (section.getTextClient() == null) {
        ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
        fillToolBar(toolBarManager);//from w  w  w .j  av a2s. co m

        // TODO toolBarManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));

        if (toolBarManager.getSize() > 0) {
            Composite toolbarComposite = toolkit.createComposite(section);
            toolbarComposite.setBackground(null);
            RowLayout rowLayout = new RowLayout();
            rowLayout.marginLeft = 0;
            rowLayout.marginRight = 0;
            rowLayout.marginTop = 0;
            rowLayout.marginBottom = 0;
            rowLayout.center = true;
            toolbarComposite.setLayout(rowLayout);

            createInfoOverlay(toolbarComposite, section, toolkit);

            toolBarManager.createControl(toolbarComposite);
            section.clientVerticalSpacing = 0;
            section.descriptionVerticalSpacing = 0;
            section.setTextClient(toolbarComposite);
        }
    }
    setControl(section);
}

From source file:org.eclipse.mylyn.internal.tasks.ui.editors.PlanningPart.java

License:Open Source License

@Override
protected void setSection(FormToolkit toolkit, Section section) {
    super.setSection(toolkit, section);
    if (section.getTextClient() == null) {
        Composite toolbarComposite = toolkit.createComposite(section);
        toolbarComposite.setBackground(null);
        RowLayout rowLayout = new RowLayout();
        rowLayout.marginLeft = 0;/*from  ww  w .j  av  a 2 s  . c o m*/
        rowLayout.marginRight = 0;
        rowLayout.marginTop = 0;
        rowLayout.marginBottom = 0;
        rowLayout.center = true;
        toolbarComposite.setLayout(rowLayout);

        createScheduledLabel(toolbarComposite, section, toolkit);

        ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
        fillToolBar(toolBarManager);

        // TODO toolBarManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));

        if (toolBarManager.getSize() > 0) {
            toolBarManager.createControl(toolbarComposite);
            section.clientVerticalSpacing = 0;
            section.descriptionVerticalSpacing = 0;
        }

        section.setTextClient(toolbarComposite);
    }
}

From source file:org.eclipse.mylyn.internal.versions.tasks.ui.ChangesetPart.java

License:Open Source License

private void addToolBar(FormToolkit toolkit, Section section) {
    ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
    fillToolBar(toolBarManager);//from  www  . j  a  v  a  2  s  .  co m

    if (toolBarManager.getSize() == 0) {
        return;
    }
    Composite toolbarComposite = toolkit.createComposite(section);
    toolbarComposite.setBackground(null);
    RowLayout rowLayout = new RowLayout();
    rowLayout.marginLeft = 0;
    rowLayout.marginRight = 0;
    rowLayout.marginTop = 0;
    rowLayout.marginBottom = 0;
    rowLayout.center = true;
    toolbarComposite.setLayout(rowLayout);

    toolBarManager.createControl(toolbarComposite);
    section.clientVerticalSpacing = 0;
    section.descriptionVerticalSpacing = 0;
    section.setTextClient(toolbarComposite);
}