Example usage for org.eclipse.jface.resource JFaceResources getBannerFont

List of usage examples for org.eclipse.jface.resource JFaceResources getBannerFont

Introduction

In this page you can find the example usage for org.eclipse.jface.resource JFaceResources getBannerFont.

Prototype

public static Font getBannerFont() 

Source Link

Document

Returns the JFace's banner font.

Usage

From source file:org.eclipse.ecf.salvo.ui.notifications.SalvoNotificationPopup.java

License:Open Source License

@Override
protected void createContentArea(Composite parent) {

    Composite composite = new Composite(parent, SWT.NULL);
    composite.setLayout(new GridLayout(2, false));
    composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));

    {/*w w  w.java  2  s  . c o  m*/
        Composite imageComposite = new Composite(composite, SWT.NULL);
        imageComposite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
        imageComposite.setLayout(new GridLayout(1, false));

        // Image
        Label lblImage = new Label(imageComposite, SWT.NONE);
        lblImage.setImage(Activator.getDefault().getImageRegistry().get("news.gif"));
        lblImage.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

        // No of Articles
        Label lblNumOfArticles = new Label(imageComposite, SWT.NONE);

        Font font = JFaceResources.getBannerFont();
        FontData fd = font.getFontData()[0];
        fd.setStyle(SWT.BOLD);
        lblNumOfArticles.setFont(new Font(font.getDevice(), fd));
        lblNumOfArticles.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
        lblNumOfArticles.setText(Integer.toString(articles.length));
    }

    {
        Composite txtComposite = new Composite(composite, SWT.NULL);
        txtComposite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
        txtComposite.setLayout(new GridLayout(1, false));

        if (articles.length < 10) {
            for (int i = 0; i < articles.length; i++) {
                Label dataLabel = new Label(txtComposite, SWT.None);
                dataLabel.setText(DecoderUtil.decodeEncodedWords(articles[i].getSubject()));
                dataLabel.setBackground(parent.getBackground());
            }
        } else {
            for (int i = 0; i < 10; i++) {
                Label dataLabel = new Label(txtComposite, SWT.None);
                dataLabel.setText(DecoderUtil.decodeEncodedWords(articles[i].getSubject()));
                dataLabel.setBackground(parent.getBackground());
            }

            Label lastDataLabel = new Label(txtComposite, SWT.None);
            lastDataLabel.setText("and " + (articles.length - 10) + " other articles received.....");
            lastDataLabel.setBackground(parent.getBackground());

            Font font = JFaceResources.getDefaultFont();
            FontData fd = font.getFontData()[0];
            fd.setStyle(SWT.BOLD | SWT.ITALIC);
            lastDataLabel.setFont(new Font(font.getDevice(), fd));
        }

    }

}

From source file:org.eclipse.egit.ui.internal.blame.BlameInformationControl.java

License:Open Source License

protected void createContent(Composite parent) {
    scrolls = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
    scrolls.setExpandHorizontal(true);/*  w w w  . ja va 2 s  .c  o  m*/
    scrolls.setExpandVertical(true);
    displayArea = new Composite(scrolls, SWT.NONE);
    scrolls.setContent(displayArea);
    displayArea.setForeground(parent.getForeground());
    displayArea.setBackground(parent.getBackground());
    displayArea.setBackgroundMode(SWT.INHERIT_FORCE);
    GridLayoutFactory.swtDefaults().equalWidth(true).applyTo(displayArea);

    commitLink = new StyledText(displayArea, SWT.READ_ONLY);
    commitLink.addMouseListener(new MouseAdapter() {

        public void mouseUp(MouseEvent e) {
            if (commitLink.getSelectionText().length() != 0)
                return;
            try {
                getShell().dispose();
                CommitEditor.open(new RepositoryCommit(revision.getRepository(), revision.getCommit()));
            } catch (PartInitException pie) {
                Activator.logError(pie.getLocalizedMessage(), pie);
            }
        }
    });
    commitLink.setFont(JFaceResources.getBannerFont());
    commitLink.setForeground(JFaceColors.getHyperlinkText(commitLink.getDisplay()));
    Cursor handCursor = new Cursor(commitLink.getDisplay(), SWT.CURSOR_HAND);
    UIUtils.hookDisposal(commitLink, handCursor);
    commitLink.setCursor(handCursor);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(commitLink);

    authorLabel = new Label(displayArea, SWT.NONE);
    authorLabel.setForeground(parent.getForeground());
    authorLabel.setBackground(parent.getBackground());
    authorLabel.setFont(UIUtils.getItalicFont(JFaceResources.DEFAULT_FONT));
    GridDataFactory.fillDefaults().grab(true, false).applyTo(authorLabel);

    committerLabel = new Label(displayArea, SWT.NONE);
    committerLabel.setForeground(parent.getForeground());
    committerLabel.setBackground(parent.getBackground());
    committerLabel.setFont(UIUtils.getItalicFont(JFaceResources.DEFAULT_FONT));
    GridDataFactory.fillDefaults().grab(true, false).applyTo(committerLabel);

    Label separator = new Label(displayArea, SWT.HORIZONTAL | SWT.SEPARATOR);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(separator);

    messageText = new StyledText(displayArea, SWT.NONE);
    messageText.setForeground(parent.getForeground());
    messageText.setBackground(parent.getBackground());
    messageText.setEditable(false);
    messageText.setFont(UIUtils.getFont(UIPreferences.THEME_CommitMessageFont));
    GridDataFactory.fillDefaults().grab(true, true).applyTo(messageText);
}

From source file:org.eclipse.egit.ui.internal.commit.CommitEditor.java

License:Open Source License

/**
 * @see org.eclipse.ui.forms.editor.SharedHeaderFormEditor#createHeaderContents(org.eclipse.ui.forms.IManagedForm)
 *///  w  ww  .  ja va 2s . c  o m
protected void createHeaderContents(IManagedForm headerForm) {
    RepositoryCommit commit = getCommit();
    ScrolledForm form = headerForm.getForm();
    new HeaderText(form.getForm(), commit.getRevCommit().name());
    form.setToolTipText(commit.getRevCommit().name());
    getToolkit().decorateFormHeading(form.getForm());

    IToolBarManager toolbar = form.getToolBarManager();

    ControlContribution repositoryLabelControl = new ControlContribution("repositoryLabel") { //$NON-NLS-1$
        @Override
        protected Control createControl(Composite parent) {
            FormToolkit toolkit = getHeaderForm().getToolkit();
            Composite composite = toolkit.createComposite(parent);
            RowLayout layout = new RowLayout();
            composite.setLayout(layout);
            composite.setBackground(null);
            String label = getCommit().getRepositoryName();

            ImageHyperlink link = new ImageHyperlink(composite, SWT.NONE);
            link.setText(label);
            link.setFont(JFaceResources.getBannerFont());
            link.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
            link.setToolTipText(UIText.CommitEditor_showGitRepo);
            link.addHyperlinkListener(new HyperlinkAdapter() {
                @Override
                public void linkActivated(HyperlinkEvent event) {
                    RepositoriesView view;
                    try {
                        view = (RepositoriesView) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
                                .getActivePage().showView(RepositoriesView.VIEW_ID);
                        view.showRepository(getCommit().getRepository());
                    } catch (PartInitException e) {
                        Activator.handleError(UIText.CommitEditor_couldNotShowRepository, e, false);
                    }
                }
            });

            return composite;
        }
    };
    toolbar.add(repositoryLabelControl);
    toolbar.add(createCommandContributionItem(CreateTagHandler.ID));
    toolbar.add(createCommandContributionItem(CreateBranchHandler.ID));
    toolbar.add(createCommandContributionItem(CheckoutHandler.ID));
    toolbar.add(createCommandContributionItem(CherryPickHandler.ID));
    toolbar.add(createCommandContributionItem(RevertHandler.ID));
    addContributions(toolbar);
    toolbar.update(true);
    getSite().setSelectionProvider(new ISelectionProvider() {

        public void setSelection(ISelection selection) {
            // Ignored
        }

        public void removeSelectionChangedListener(ISelectionChangedListener listener) {
            // Ignored
        }

        public ISelection getSelection() {
            return new StructuredSelection(getCommit());
        }

        public void addSelectionChangedListener(ISelectionChangedListener listener) {
            // Ignored
        }
    });
}

From source file:org.eclipse.egit.ui.internal.reflog.ReflogView.java

License:Open Source License

private void updateRefLink(final String name) {
    IToolBarManager toolbar = form.getToolBarManager();
    toolbar.removeAll();/*ww w  .j  a va2 s. co m*/

    ControlContribution refLabelControl = new ControlContribution("refLabel") { //$NON-NLS-1$
        @Override
        protected Control createControl(Composite cParent) {
            Composite composite = toolkit.createComposite(cParent);
            composite.setLayout(new RowLayout());
            composite.setBackground(null);

            final ImageHyperlink refLink = new ImageHyperlink(composite, SWT.NONE);
            Image image = UIIcons.BRANCH.createImage();
            UIUtils.hookDisposal(refLink, image);
            refLink.setImage(image);
            refLink.setFont(JFaceResources.getBannerFont());
            refLink.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
            refLink.addHyperlinkListener(new HyperlinkAdapter() {
                @Override
                public void linkActivated(HyperlinkEvent event) {
                    Repository repository = getRepository();
                    if (repository == null)
                        return;
                    RefSelectionDialog dialog = new RefSelectionDialog(refLink.getShell(), repository);
                    if (Window.OK == dialog.open())
                        showReflogFor(repository, dialog.getRefName());
                }
            });
            refLink.setText(Repository.shortenRefName(name));

            return composite;
        }
    };
    toolbar.add(refLabelControl);
    toolbar.update(true);
}

From source file:org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.label.LabelContentViewer.java

License:Open Source License

/**
 * Creates a new viewer and its controls.
 * /*w  w w.j  av a2  s  .  c o m*/
 * @param parent
 *            the parent of the {@link #getControl() control} of this viewer.
 */
public LabelContentViewer(Composite parent, String title, String message) {
    control = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(1, true);
    control.setLayout(layout);
    Label label = new Label(control, SWT.NONE);
    label.setText(message);
    label.setFont(JFaceResources.getBannerFont());
    label.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
    control.setData(CompareUI.COMPARE_VIEWER_TITLE, title);

}

From source file:org.eclipse.gmf.internal.bridge.ui.dashboard.DashboardFigure.java

License:Open Source License

public DashboardFigure() {
    add(logoFigure = new ImageFigure() {

        protected void paintFigure(Graphics graphics) {
            if (getImage() != null) {
                graphics.drawImage(getImage(), new Rectangle(getImage().getBounds()), getBounds());
            }//from  www .  j av  a2  s. c  o  m
        }
    });
    Image logoImage = Plugin.getDefault().getImageRegistry().get(Plugin.GMF_LOGO_IMAGE);
    if (logoImage != null) {
        logoFigure.setImage(logoImage);
    }
    add(dgmFigure = createModelFigure(Messages.DashboardFigure_DGM, Plugin.DGM_ICON));
    add(gdmFigure = createModelFigure(Messages.DashboardFigure_GDM, Plugin.GDM_ICON));
    add(dmFigure = createModelFigure(Messages.DashboardFigure_DM, Plugin.DM_ICON));
    add(tdmFigure = createModelFigure(Messages.DashboardFigure_TDM, Plugin.TDM_ICON));
    add(mmFigure = createModelFigure(Messages.DashboardFigure_MM, Plugin.MM_ICON));
    add(gmFigure = createModelFigure(Messages.DashboardFigure_GM, Plugin.GM_ICON));
    add(dm2dgmFlow = createFlowFigure(true));
    add(dm2gdmFlow = createFlowFigure(true));
    add(dm2tdmFlow = createFlowFigure(true));
    add(dm2mmFlow = createFlowFigure(true));
    add(gdm2mmFlow = createFlowFigure(false));
    add(tdm2mmFlow = createFlowFigure(false));
    add(mm2gmFlow = createFlowFigure(true));
    add(dm2dgmFigure = createFlowActionFigure());
    add(dm2gdmFigure = createFlowActionFigure());
    add(dm2tdmFigure = createFlowActionFigure());
    add(dm2mmFigure = createFlowActionFigure());
    add(mm2gmFigure = createFlowActionFigure());
    add(statusFigure = new Figure());
    statusFigure.setFont(JFaceResources.getBannerFont());
    ToolbarLayout statusLayout = new ToolbarLayout();
    statusLayout.setStretchMinorAxis(false);
    statusFigure.setLayoutManager(statusLayout);
    statusFigure.add(new Label());
    statusFigure.add(new Label());
    setLayoutManager(new DashboardLayout());
    setBorder(new MarginBorder(10));
    setBackgroundColor(DASHBOARD_BG);
    setForegroundColor(DASHBOARD_FG);
}

From source file:org.eclipse.gmf.internal.bridge.ui.dashboard.ModelFigure.java

License:Open Source License

public ModelFigure() {
    separators = new ArrayList<SeparatorFigure>();
    ToolbarLayout layout = new ToolbarLayout();
    layout.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);
    setLayoutManager(layout);//  w w  w  . j  av a  2 s  . co  m

    labelsPlate = new Figure();
    ToolbarLayout labelsLayout = new ToolbarLayout();
    labelsPlate.setLayoutManager(labelsLayout);
    add(labelsPlate);

    SeparatorFigure s1 = new SeparatorFigure();
    separators.add(s1);
    add(s1);

    actionsPlate = new Figure();
    ToolbarLayout actionsLayout = new ToolbarLayout();
    actionsLayout.setStretchMinorAxis(false);
    actionsPlate.setLayoutManager(actionsLayout);
    add(actionsPlate);

    stdActionsPlate = new Figure();
    ToolbarLayout stdActionsLayout = new ToolbarLayout(true);
    stdActionsLayout.setSpacing(2);
    stdActionsPlate.setLayoutManager(stdActionsLayout);
    actionsPlate.add(stdActionsPlate);

    Label descriptionFigure = new Label();
    descriptionFigure.setFont(JFaceResources.getBannerFont());
    addLabel(descriptionFigure);
    Label nameFigure = new Label();
    addLabel(nameFigure);
    setName(null); // init
}

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

License:Open Source License

private void updateLinks(String href) {
    Control[] children = linkContainer.getChildren();
    for (int i = 0; i < children.length; i++) {
        ImageHyperlink link = (ImageHyperlink) children[i];
        RowData data = (RowData) link.getLayoutData();
        boolean isCurrentPage = link.getHref().equals(href);
        if (isCurrentPage) {
            link.setFont(JFaceResources.getBannerFont());
        } else {/*from  w  w  w .  ja v a 2  s . c o m*/
            link.setFont(JFaceResources.getDefaultFont());
        }
        data.exclude = false;
        link.setVisible(!data.exclude);
    }
    linkContainer.layout();
    helpPart.reflow();
}

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

License:Open Source License

/**
 * @since 3.0/*from ww  w. j  a v  a 2  s .  co  m*/
 */
public void updateHeaderToolBar() {
    if (isHeaderFormDisposed()) {
        return;
    }

    final Form form = getHeaderForm().getForm().getForm();
    toolBarManager = form.getToolBarManager();

    toolBarManager.removeAll();
    //      toolBarManager.update(true);

    TaskRepository outgoingNewRepository = TasksUiUtil.getOutgoingNewTaskRepository(task);
    final TaskRepository taskRepository = (outgoingNewRepository != null) ? outgoingNewRepository
            : taskEditorInput.getTaskRepository();
    ControlContribution repositoryLabelControl = new ControlContribution(
            Messages.AbstractTaskEditorPage_Title) {
        @Override
        protected Control createControl(Composite parent) {
            FormToolkit toolkit = getHeaderForm().getToolkit();
            Composite composite = toolkit.createComposite(parent);
            RowLayout layout = new RowLayout();
            if (PlatformUiUtil.hasNarrowToolBar()) {
                layout.marginTop = 0;
                layout.marginBottom = 0;
                layout.center = true;
            }
            composite.setLayout(layout);
            composite.setBackground(null);
            String label = taskRepository.getRepositoryLabel();
            if (label.indexOf("//") != -1) { //$NON-NLS-1$
                label = label.substring((taskRepository.getRepositoryUrl().indexOf("//") + 2)); //$NON-NLS-1$
            }

            ImageHyperlink link = new ImageHyperlink(composite, SWT.NONE);
            link.setText(label);
            link.setFont(JFaceResources.getBannerFont());
            link.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
            link.setToolTipText(Messages.TaskEditor_Edit_Task_Repository_ToolTip);
            link.addHyperlinkListener(new HyperlinkAdapter() {
                @Override
                public void linkActivated(HyperlinkEvent e) {
                    TasksUiUtil.openEditRepositoryWizard(taskRepository);
                }
            });

            return composite;
        }
    };
    toolBarManager.add(repositoryLabelControl);

    toolBarManager.add(new GroupMarker("repository")); //$NON-NLS-1$
    toolBarManager.add(new GroupMarker("new")); //$NON-NLS-1$
    toolBarManager.add(new GroupMarker("open")); //$NON-NLS-1$
    toolBarManager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));

    openWithBrowserAction = new OpenWithBrowserAction();
    openWithBrowserAction.selectionChanged(new StructuredSelection(task));
    if (openWithBrowserAction.isEnabled()) {
        //         ImageDescriptor overlay = TasksUiPlugin.getDefault().getOverlayIcon(taskRepository.getConnectorKind());
        //         ImageDescriptor compositeDescriptor = new TaskListImageDescriptor(TasksUiImages.REPOSITORY_SMALL_TOP,
        //               overlay, false, true);
        openWithBrowserAction.setImageDescriptor(CommonImages.WEB);
        //openWithBrowserAction.setImageDescriptor(CommonImages.BROWSER_OPEN_TASK);
        openWithBrowserAction.setToolTipText(Messages.AbstractTaskEditorPage_Open_with_Web_Browser);
        toolBarManager.appendToGroup("open", openWithBrowserAction); //$NON-NLS-1$
    } else {
        openWithBrowserAction = null;
    }

    if (activateAction == null) {
        activateAction = new ToggleTaskActivationAction(task) {
            @Override
            public void run() {
                TaskList taskList = TasksUiPlugin.getTaskList();
                if (taskList.getTask(task.getRepositoryUrl(), task.getTaskId()) == null) {
                    setMessage(Messages.TaskEditor_Task_added_to_the_Uncategorized_container,
                            IMessageProvider.INFORMATION);
                }
                super.run();
            }
        };
    }

    toolBarManager.add(new Separator("planning")); //$NON-NLS-1$
    disposeScheduleAction();
    scheduleAction = new TaskEditorScheduleAction(task);
    toolBarManager.add(scheduleAction);

    toolBarManager.add(new GroupMarker("page")); //$NON-NLS-1$
    for (IFormPage page : getPages()) {
        if (page instanceof TaskFormPage) {
            TaskFormPage taskEditorPage = (TaskFormPage) page;
            taskEditorPage.fillToolBar(toolBarManager);
        }
    }

    toolBarManager.add(new Separator("activation")); //$NON-NLS-1$

    //      ContributionItem spacer = new ContributionItem() {
    //         @Override
    //         public void fill(ToolBar toolbar, int index) {
    //            ToolItem item = new ToolItem(toolbar, SWT.NONE);
    //            int scaleHeight = 42;
    //            if (PlatformUtil.needsCarbonToolBarFix()) {
    //               scaleHeight = 32;
    //            }
    //            final Image image = new Image(toolbar.getDisplay(), CommonImages.getImage(CommonImages.BLANK)
    //                  .getImageData()
    //                  .scaledTo(1, scaleHeight));
    //            item.setImage(image);
    //            item.addDisposeListener(new DisposeListener() {
    //               public void widgetDisposed(DisposeEvent e) {
    //                  image.dispose();
    //               }
    //            });
    //            item.setWidth(5);
    //            item.setEnabled(false);
    //         }
    //      };
    //      toolBarManager.add(spacer);

    //      for (IFormPage page : getPages()) {
    //         if (page instanceof AbstractTaskEditorPage) {
    //            AbstractTaskEditorPage taskEditorPage = (AbstractTaskEditorPage) page;
    //            taskEditorPage.fillLeftHeaderToolBar(toolBarManager);
    //         } else if (page instanceof TaskPlanningEditor) {
    //            TaskPlanningEditor taskEditorPage = (TaskPlanningEditor) page;
    //            taskEditorPage.fillLeftHeaderToolBar(toolBarManager);
    //         }
    //      }

    // add external contributions
    menuService = (IMenuService) getSite().getService(IMenuService.class);
    if (menuService != null && toolBarManager instanceof ContributionManager) {
        menuService.populateContributionManager((ContributionManager) toolBarManager, "toolbar:" //$NON-NLS-1$
                + ID_TOOLBAR_HEADER + "." + taskRepository.getConnectorKind()); //$NON-NLS-1$
        menuService.populateContributionManager((ContributionManager) toolBarManager, "toolbar:" //$NON-NLS-1$
                + ID_TOOLBAR_HEADER);
    }

    toolBarManager.update(true);

    // XXX move this call
    updateLeftHeaderToolBar();
    updateHeader();
}

From source file:org.eclipse.osee.framework.ui.skynet.widgets.XFlatWidget.java

License:Open Source License

private void createToolBar(Composite parent) {
    Composite composite = new Composite(parent, SWT.BORDER);
    GridLayout layout = new GridLayout(3, false);
    layout.marginHeight = 0;//from   w  w w  .j a va2  s. c  om
    layout.marginLeft = 5;
    layout.marginWidth = 2;
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

    currentPageLabel = new StyledText(composite, SWT.READ_ONLY | SWT.SINGLE | SWT.WRAP);
    currentPageLabel.setAlignment(SWT.RIGHT);
    currentPageLabel.setFont(JFaceResources.getBannerFont());
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    gd.minimumWidth = 10;
    currentPageLabel.setLayoutData(gd);
    currentPageLabel.setText("0 Items");

    Composite filler = new Composite(composite, SWT.NONE);
    GridLayout layout1 = new GridLayout(1, false);
    filler.setLayout(layout1);
    filler.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    ToolBar toolbar = new ToolBar(composite, SWT.FLAT | SWT.HORIZONTAL);
    toolbar.setLayoutData(new GridData(SWT.NONE, SWT.NONE, false, false));
    ToolBarManager manager = new ToolBarManager(toolbar);
    manager.add(new Separator());
    manager.add(new AddPage());
    manager.update(true);
}