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);
}
}
}
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();
}
}
}
});
}
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~
}
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);
}
});
}
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);
}
});
}
Aggregations