Search in sources :

Example 16 with ControlContribution

use of org.eclipse.jface.action.ControlContribution in project egit by eclipse.

the class ReflogView method updateRefLink.

private void updateRefLink(final String name) {
    IToolBarManager toolbar = form.getToolBarManager();
    toolbar.removeAll();
    ControlContribution refLabelControl = new ControlContribution(// $NON-NLS-1$
    "refLabel") {

        @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);
}
Also used : Repository(org.eclipse.jgit.lib.Repository) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) IToolBarManager(org.eclipse.jface.action.IToolBarManager) RowLayout(org.eclipse.swt.layout.RowLayout) ControlContribution(org.eclipse.jface.action.ControlContribution) Image(org.eclipse.swt.graphics.Image) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Aggregations

ControlContribution (org.eclipse.jface.action.ControlContribution)16 Composite (org.eclipse.swt.widgets.Composite)16 SelectionEvent (org.eclipse.swt.events.SelectionEvent)13 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)12 Control (org.eclipse.swt.widgets.Control)12 Separator (org.eclipse.jface.action.Separator)11 Combo (org.eclipse.swt.widgets.Combo)7 IToolBarManager (org.eclipse.jface.action.IToolBarManager)5 Button (org.eclipse.swt.widgets.Button)5 IAction (org.eclipse.jface.action.IAction)4 ActionManager (com.cubrid.common.ui.spi.action.ActionManager)3 IContributionItem (org.eclipse.jface.action.IContributionItem)3 ToolBarManager (org.eclipse.jface.action.ToolBarManager)3 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)3 OracleDDLFormat (org.jkiss.dbeaver.ext.oracle.model.OracleDDLFormat)3 RestoreQueryEditorAction (com.cubrid.common.ui.common.action.RestoreQueryEditorAction)2 Action (org.eclipse.jface.action.Action)2 ActionContributionItem (org.eclipse.jface.action.ActionContributionItem)2 StatusLineManager (org.eclipse.jface.action.StatusLineManager)2 Repository (org.eclipse.jgit.lib.Repository)2