Search in sources :

Example 1 with ImageHyperlink

use of org.eclipse.ui.forms.widgets.ImageHyperlink in project egit by eclipse.

the class CommitEditor method createHeaderContents.

/**
 * @see org.eclipse.ui.forms.editor.SharedHeaderFormEditor#createHeaderContents(org.eclipse.ui.forms.IManagedForm)
 */
@Override
protected void createHeaderContents(IManagedForm headerForm) {
    headerForm.addPart(new FocusManagerFormPart(headerFocusTracker) {

        @Override
        public void setDefaultFocus() {
            headerForm.getForm().getForm().setFocus();
        }
    });
    RepositoryCommit commit = getCommit();
    ScrolledForm form = headerForm.getForm();
    String commitName = commit.getRevCommit().name();
    String title = getFormattedHeaderTitle(commitName);
    HeaderText text = new HeaderText(form.getForm(), title, commitName);
    Control textControl = text.getControl();
    if (textControl != null) {
        headerFocusTracker.addToFocusTracking(textControl);
    }
    form.setToolTipText(commitName);
    getToolkit().decorateFormHeading(form.getForm());
    toolbar = form.getToolBarManager();
    ControlContribution repositoryLabelControl = new ControlContribution(// $NON-NLS-1$
    "repositoryLabel") {

        @Override
        protected Control createControl(Composite parent) {
            FormToolkit toolkit = getHeaderForm().getToolkit();
            String label = getCommit().getRepositoryName();
            ImageHyperlink link = new ImageHyperlink(parent, SWT.NONE);
            // Focus tracking on this link doesn't really work. It's a
            // focusable control inside another focusable control (the
            // toolbar). When focus leaves this control through tabbing
            // or deactivating the editor, the toolbar gets the focus (and
            // possibly loses it right away again). Thus the focus tracker
            // will always see the toolbar as the last focused control.
            // Unfortunately there is no other way to get some text onto
            // the first line of a FormHeading.
            headerFocusTracker.addToFocusTracking(link);
            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 link;
        }
    };
    toolbar.add(repositoryLabelControl);
    CommonUtils.getService(getSite(), IPartService.class).addPartListener(activationListener);
    if (commit.isStash()) {
        toolbar.add(createActionContributionItem(StashApplyHandler.ID, UIText.CommitEditor_toolbarApplyStash, UIIcons.STASH_APPLY));
        toolbar.add(createActionContributionItem(StashDropHandler.ID, UIText.CommitEditor_toolbarDeleteStash, PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE)));
    } else {
        toolbar.add(createActionContributionItem(CreateTagHandler.ID, UIText.CommitEditor_toolbarCreateTag, UIIcons.TAG));
        toolbar.add(createActionContributionItem(CreateBranchHandler.ID, UIText.CommitEditor_toolbarCreateBranch, UIIcons.BRANCH));
        toolbar.add(createActionContributionItem(CheckoutHandler.ID, UIText.CommitEditor_toolbarCheckOut, UIIcons.CHECKOUT));
        toolbar.add(createActionContributionItem(CherryPickHandler.ID, UIText.CommitEditor_toolbarCherryPick, UIIcons.CHERRY_PICK));
        toolbar.add(createActionContributionItem(RevertHandler.ID, UIText.CommitEditor_toolbarRevert, UIIcons.REVERT));
        toolbar.add(createActionContributionItem(ShowInHistoryHandler.ID, UIText.CommitEditor_toolbarShowInHistory, UIIcons.HISTORY));
    }
    addContributions(toolbar);
    toolbar.update(true);
    getSite().setSelectionProvider(new ISelectionProvider() {

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

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

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

        @Override
        public void addSelectionChangedListener(ISelectionChangedListener listener) {
        // Ignored
        }
    });
    if (toolbar instanceof ToolBarManager) {
        Control control = ((ToolBarManager) toolbar).getControl();
        if (control != null) {
            headerFocusTracker.addToFocusTracking(control);
        }
    }
}
Also used : HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ControlContribution(org.eclipse.jface.action.ControlContribution) IPartService(org.eclipse.ui.IPartService) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ToolBarManager(org.eclipse.jface.action.ToolBarManager) Control(org.eclipse.swt.widgets.Control) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ScrolledForm(org.eclipse.ui.forms.widgets.ScrolledForm) RepositoriesView(org.eclipse.egit.ui.internal.repository.RepositoriesView) ISelection(org.eclipse.jface.viewers.ISelection) PartInitException(org.eclipse.ui.PartInitException) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 2 with ImageHyperlink

use of org.eclipse.ui.forms.widgets.ImageHyperlink in project tdq-studio-se by Talend.

the class DynamicAnalysisMasterPage method createCollapseAllLink.

private void createCollapseAllLink(Composite actionBarComp) {
    ImageHyperlink collapseAllImageLink = toolkit.createImageHyperlink(actionBarComp, SWT.NONE);
    collapseAllImageLink.setToolTipText(getCollapseAllString());
    WorkbenchUtils.setHyperlinkImage(collapseAllImageLink, ImageLib.getImage(ImageLib.COLLAPSE_ALL));
    collapseAllImageLink.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            List<ExpandableComposite> previewChartList = getPreviewChartList();
            if (previewChartList != null && !previewChartList.isEmpty()) {
                for (ExpandableComposite comp : previewChartList) {
                    comp.setExpanded(false);
                    comp.getParent().pack();
                }
            }
        }
    });
}
Also used : HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) List(java.util.List) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 3 with ImageHyperlink

use of org.eclipse.ui.forms.widgets.ImageHyperlink in project tdq-studio-se by Talend.

the class MatchAnalysisDetailsPage method createAnaDataLabelComposite.

/**
 * create Analysis Data Label Composite.
 *
 * @param dataparent
 */
private void createAnaDataLabelComposite(Composite dataparent) {
    Composite titleComposite = toolkit.createComposite(dataparent);
    GridLayout layout = new GridLayout(2, Boolean.TRUE);
    titleComposite.setLayout(layout);
    analyzeDataLabel = new Label(titleComposite, SWT.NONE);
    final int analysisColumnSize = analysisHandler.getAnalyzedColumns().size();
    final RepositoryNode firstColumnNode = analysisColumnSize > 0 ? RepositoryNodeHelper.recursiveFind(analysisHandler.getAnalyzedColumns().get(0)) : null;
    // register: refresh the dataprovider combobox when the name of the data provider is changed.
    refreshDataProiverLabel = new EventReceiver() {

        @Override
        public boolean handle(Object data) {
            if (firstColumnNode != null) {
                updateAnalyzeDataLabel(firstColumnNode);
            }
            return true;
        }
    };
    EventManager.getInstance().register(getCurrentModelElement(), EventEnum.DQ_MATCH_ANALYSIS_REFRESH_DATAPROVIDER_LABEL, refreshDataProiverLabel);
    if (analysisColumnSize > 0 && firstColumnNode != null) {
        updateAnalyzeDataLabel(firstColumnNode);
    } else if (analysisColumnSize > 0 && firstColumnNode == null) {
        // $NON-NLS-1$
        analyzeDataLabel.setText(analyzeDataDefaultInfo + "The connection is not available now!");
    } else {
        analyzeDataLabel.setText(analyzeDataDefaultInfo);
    }
    // ADD msjian TDQ-8040 2013-11-8: Add a button "show in repository view"
    ImageHyperlink showInDQViewLink = toolkit.createImageHyperlink(titleComposite, SWT.NONE);
    // $NON-NLS-1$
    showInDQViewLink.setToolTipText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.showDQElement"));
    showInDQViewLink.setImage(ImageLib.getImage(ImageLib.APPLICATION_HOME));
    showInDQViewLink.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            List<IRepositoryNode> analysedElements = findAllSelectedRepositoryNode();
            if (analysedElements != null && analysedElements.size() > 0) {
                DQRespositoryView dqview = CorePlugin.getDefault().findAndOpenRepositoryView();
                // if DqRepository view is not openning we will not do anything
                if (dqview == null) {
                    return;
                }
                ModelElement column = RepositoryNodeHelper.getModelElementFromRepositoryNode(analysedElements.get(0));
                ModelElement container = (ModelElement) (column.eContainer());
                RepositoryNode recursiveFind = RepositoryNodeHelper.recursiveFind(container);
                if (recursiveFind == null) {
                    recursiveFind = RepositoryNodeHelper.createRepositoryNode(container);
                }
                dqview.showSelectedElements(recursiveFind);
            }
        }
    });
// TDQ-8040~
}
Also used : HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) Label(org.eclipse.swt.widgets.Label) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) EventReceiver(org.talend.dataprofiler.core.ui.events.EventReceiver) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) GridLayout(org.eclipse.swt.layout.GridLayout) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) DQRespositoryView(org.talend.dataprofiler.core.ui.views.DQRespositoryView) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 4 with ImageHyperlink

use of org.eclipse.ui.forms.widgets.ImageHyperlink in project tdq-studio-se by Talend.

the class ResultPaginationInfo method createExpandAllLink.

/**
 * create ExpandAll Link for column name.
 *
 * @param composite
 * @param label: column name
 */
private void createExpandAllLink(Composite composite, final String label) {
    ImageHyperlink expandAllImageLink = uiPagination.getToolkit().createImageHyperlink(composite, SWT.NONE);
    // $NON-NLS-1$
    expandAllImageLink.setToolTipText(DefaultMessagesImpl.getString("ExpandColumn"));
    WorkbenchUtils.setHyperlinkImage(expandAllImageLink, ImageLib.getImage(ImageLib.EXPAND_ALL));
    expandAllImageLink.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            Composite compositePar = columnCompositeMap.get(label);
            if (compositePar.getParent() instanceof ExpandableComposite) {
                ((ExpandableComposite) compositePar.getParent()).setExpanded(true);
            }
            Control[] expandableComposite = getIndicatorExpandableCompositeList(label);
            for (Control control : expandableComposite) {
                if (control instanceof ExpandableComposite) {
                    ((ExpandableComposite) control).setExpanded(true);
                    ((ExpandableComposite) control).getParent().pack();
                }
            }
            form.reflow(true);
        }
    });
}
Also used : Control(org.eclipse.swt.widgets.Control) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 5 with ImageHyperlink

use of org.eclipse.ui.forms.widgets.ImageHyperlink in project tdq-studio-se by Talend.

the class ResultPaginationInfo method createCollapseAllLink.

/**
 * create CollapseAll Link for column name.
 *
 * @param composite
 * @param label: column name
 */
private void createCollapseAllLink(Composite composite, final String label) {
    ImageHyperlink collapseAllImageLink = uiPagination.getToolkit().createImageHyperlink(composite, SWT.NONE);
    // $NON-NLS-1$
    collapseAllImageLink.setToolTipText(DefaultMessagesImpl.getString("CollapseColumn"));
    WorkbenchUtils.setHyperlinkImage(collapseAllImageLink, ImageLib.getImage(ImageLib.COLLAPSE_ALL));
    collapseAllImageLink.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            Control[] expandableComposite = getIndicatorExpandableCompositeList(label);
            for (Control control : expandableComposite) {
                if (control instanceof ExpandableComposite) {
                    ((ExpandableComposite) control).setExpanded(false);
                    ((ExpandableComposite) control).getParent().pack();
                }
            }
            form.reflow(true);
        }
    });
}
Also used : Control(org.eclipse.swt.widgets.Control) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Aggregations

ImageHyperlink (org.eclipse.ui.forms.widgets.ImageHyperlink)50 HyperlinkEvent (org.eclipse.ui.forms.events.HyperlinkEvent)46 HyperlinkAdapter (org.eclipse.ui.forms.events.HyperlinkAdapter)45 GridLayout (org.eclipse.swt.layout.GridLayout)37 Composite (org.eclipse.swt.widgets.Composite)35 GridData (org.eclipse.swt.layout.GridData)34 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)19 TableViewer (org.eclipse.jface.viewers.TableViewer)17 Section (org.eclipse.ui.forms.widgets.Section)16 TableWrapData (org.eclipse.ui.forms.widgets.TableWrapData)16 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)8 CLabel (org.eclipse.swt.custom.CLabel)7 List (java.util.List)5 Image (org.eclipse.swt.graphics.Image)5 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)4 Control (org.eclipse.swt.widgets.Control)4 Label (org.eclipse.swt.widgets.Label)4 ArrayList (java.util.ArrayList)3 ILabelProvider (org.eclipse.jface.viewers.ILabelProvider)3 DisposeEvent (org.eclipse.swt.events.DisposeEvent)3