use of org.eclipse.jface.text.hyperlink.IHyperlinkDetector in project egit by eclipse.
the class GitHistoryPage method createControl.
@Override
public void createControl(final Composite parent) {
trace = GitTraceLocation.HISTORYVIEW.isActive();
if (trace)
GitTraceLocation.getTrace().traceEntry(GitTraceLocation.HISTORYVIEW.getLocation());
attachSelectionTracker();
historyControl = createMainPanel(parent);
warningComposite = new Composite(historyControl, SWT.NONE);
warningComposite.setLayout(new GridLayout(2, false));
warningComposite.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
warningLabel = new CLabel(warningComposite, SWT.NONE);
warningLabel.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK));
warningLabel.setToolTipText(UIText.GitHistoryPage_IncompleteListTooltip);
Link preferencesLink = new Link(warningComposite, SWT.NONE);
preferencesLink.setText(UIText.GitHistoryPage_PreferencesLink);
preferencesLink.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// $NON-NLS-1$
String preferencePageId = "org.eclipse.egit.ui.internal.preferences.HistoryPreferencePage";
PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getSite().getShell(), preferencePageId, new String[] { preferencePageId }, null);
dialog.open();
}
});
GridDataFactory.fillDefaults().grab(true, true).applyTo(historyControl);
graphDetailSplit = new SashForm(historyControl, SWT.VERTICAL);
GridDataFactory.fillDefaults().grab(true, true).applyTo(graphDetailSplit);
graph = new CommitGraphTable(graphDetailSplit, getSite(), popupMgr, this, resources);
Activator.getDefault().getPreferenceStore().addPropertyChangeListener(listener);
revInfoSplit = new SashForm(graphDetailSplit, SWT.HORIZONTAL);
commentAndDiffScrolledComposite = new ScrolledComposite(revInfoSplit, SWT.H_SCROLL | SWT.V_SCROLL);
commentAndDiffScrolledComposite.setExpandHorizontal(true);
commentAndDiffScrolledComposite.setExpandVertical(true);
commentAndDiffComposite = new Composite(commentAndDiffScrolledComposite, SWT.NONE);
commentAndDiffScrolledComposite.setContent(commentAndDiffComposite);
commentAndDiffComposite.setLayout(GridLayoutFactory.fillDefaults().create());
commentViewer = new CommitMessageViewer(commentAndDiffComposite, getPartSite());
commentViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
commentViewer.addTextListener(new ITextListener() {
@Override
public void textChanged(TextEvent event) {
resizeCommentAndDiffScrolledComposite();
}
});
commentAndDiffComposite.setBackground(commentViewer.getControl().getBackground());
HyperlinkSourceViewer.Configuration configuration = new HyperlinkSourceViewer.Configuration(EditorsUI.getPreferenceStore()) {
@Override
public int getHyperlinkStateMask(ISourceViewer sourceViewer) {
return SWT.NONE;
}
@Override
protected IHyperlinkDetector[] internalGetHyperlinkDetectors(ISourceViewer sourceViewer) {
IHyperlinkDetector[] registered = super.internalGetHyperlinkDetectors(sourceViewer);
// want those to show always.
if (registered == null) {
return new IHyperlinkDetector[] { new CommitMessageViewer.KnownHyperlinksDetector() };
} else {
IHyperlinkDetector[] result = new IHyperlinkDetector[registered.length + 1];
System.arraycopy(registered, 0, result, 0, registered.length);
result[registered.length] = new CommitMessageViewer.KnownHyperlinksDetector();
return result;
}
}
@Override
public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
return new String[] { IDocument.DEFAULT_CONTENT_TYPE, CommitMessageViewer.HEADER_CONTENT_TYPE, CommitMessageViewer.FOOTER_CONTENT_TYPE };
}
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer viewer) {
PresentationReconciler reconciler = new PresentationReconciler();
reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(viewer));
DefaultDamagerRepairer hyperlinkDamagerRepairer = new DefaultDamagerRepairer(new HyperlinkTokenScanner(this, viewer));
reconciler.setDamager(hyperlinkDamagerRepairer, IDocument.DEFAULT_CONTENT_TYPE);
reconciler.setRepairer(hyperlinkDamagerRepairer, IDocument.DEFAULT_CONTENT_TYPE);
TextAttribute headerDefault = new TextAttribute(PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
DefaultDamagerRepairer headerDamagerRepairer = new DefaultDamagerRepairer(new HyperlinkTokenScanner(this, viewer, headerDefault));
reconciler.setDamager(headerDamagerRepairer, CommitMessageViewer.HEADER_CONTENT_TYPE);
reconciler.setRepairer(headerDamagerRepairer, CommitMessageViewer.HEADER_CONTENT_TYPE);
DefaultDamagerRepairer footerDamagerRepairer = new DefaultDamagerRepairer(new FooterTokenScanner(this, viewer));
reconciler.setDamager(footerDamagerRepairer, CommitMessageViewer.FOOTER_CONTENT_TYPE);
reconciler.setRepairer(footerDamagerRepairer, CommitMessageViewer.FOOTER_CONTENT_TYPE);
return reconciler;
}
};
commentViewer.configure(configuration);
diffViewer = new DiffViewer(commentAndDiffComposite, null, SWT.NONE);
diffViewer.configure(new DiffViewer.Configuration(EditorsUI.getPreferenceStore()));
diffViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
setWrap(store.getBoolean(UIPreferences.RESOURCEHISTORY_SHOW_COMMENT_WRAP));
commentAndDiffScrolledComposite.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
if (!resizing && commentViewer.getTextWidget().getWordWrap()) {
resizeCommentAndDiffScrolledComposite();
}
}
});
fileViewer = new CommitFileDiffViewer(revInfoSplit, getSite());
fileViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
List<FileDiff> diffs = new ArrayList<>();
if (selection instanceof IStructuredSelection) {
IStructuredSelection sel = (IStructuredSelection) selection;
for (Object obj : sel.toList()) if (obj instanceof FileDiff)
diffs.add((FileDiff) obj);
}
formatDiffs(diffs);
}
});
layoutSashForm(graphDetailSplit, UIPreferences.RESOURCEHISTORY_GRAPH_SPLIT);
layoutSashForm(revInfoSplit, UIPreferences.RESOURCEHISTORY_REV_SPLIT);
attachCommitSelectionChanged();
initActions();
getSite().setSelectionProvider(new RepositorySelectionProvider(graph.getTableView(), () -> {
HistoryPageInput myInput = getInputInternal();
return myInput != null ? myInput.getRepository() : null;
}));
getSite().registerContextMenu(POPUP_ID, popupMgr, graph.getTableView());
// Track which of our controls has the focus, so that we can focus the
// last focused one in setFocus().
focusTracker = new FocusTracker();
trackFocus(graph.getControl());
trackFocus(diffViewer.getControl());
trackFocus(commentViewer.getControl());
trackFocus(fileViewer.getControl());
layout();
myRefsChangedHandle = Repository.getGlobalListenerList().addRefsChangedListener(this);
IToolBarManager manager = getSite().getActionBars().getToolBarManager();
searchBar = new // $NON-NLS-1$
SearchBar(// $NON-NLS-1$
GitHistoryPage.class.getName() + ".searchBar", graph, actions.findAction, getSite().getActionBars());
// $NON-NLS-1$
manager.prependToGroup("org.eclipse.team.ui.historyView", searchBar);
getSite().getActionBars().updateActionBars();
if (trace)
GitTraceLocation.getTrace().traceExit(GitTraceLocation.HISTORYVIEW.getLocation());
}
use of org.eclipse.jface.text.hyperlink.IHyperlinkDetector in project mylyn.docs by eclipse.
the class AbstractTextSourceViewerConfiguration method getHyperlinkDetectors.
@SuppressWarnings("unchecked")
@Override
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
List<IHyperlinkDetector> customDetectors = createCustomHyperlinkDetectors(sourceViewer);
if (sourceViewer == null || fPreferenceStore == null) {
return customDetectors.toArray(new IHyperlinkDetector[customDetectors.size()]);
}
HyperlinkDetectorRegistry registry = EditorsUI.getHyperlinkDetectorRegistry();
HyperlinkDetectorDescriptor[] descriptors = registry.getHyperlinkDetectorDescriptors();
Map<String, IAdaptable> targets = getHyperlinkDetectorTargets(sourceViewer);
List<IHyperlinkDetector> detectors = new ArrayList<>(8);
if (markupHyperlinksFirst) {
detectors.addAll(customDetectors);
}
if (hyperlinkDetectors != null) {
detectors.addAll(hyperlinkDetectors);
}
for (Map.Entry<String, IAdaptable> target : targets.entrySet()) {
String targetId = target.getKey();
IAdaptable context = target.getValue();
for (HyperlinkDetectorDescriptor descriptor : descriptors) {
if (targetId.equals(descriptor.getTargetId())) {
if (filterHyperlinkDescriptor(descriptor)) {
continue;
}
HyperlinkDetectorDelegate delegate = new HyperlinkDetectorDelegate(descriptor, fPreferenceStore);
delegate.setContext(context);
detectors.add(delegate);
}
}
}
if (!markupHyperlinksFirst) {
detectors.addAll(customDetectors);
}
return detectors.toArray(new IHyperlinkDetector[detectors.size()]);
}
use of org.eclipse.jface.text.hyperlink.IHyperlinkDetector in project mylyn.docs by eclipse.
the class HtmlViewerConfiguration method createCustomHyperlinkDetectors.
@Override
protected List<IHyperlinkDetector> createCustomHyperlinkDetectors(ISourceViewer sourceViewer) {
List<IHyperlinkDetector> detectors = new ArrayList<>(1);
AnnotationHyperlinkDetector annotationHyperlinkDetector = createAnnotationHyperlinkDetector();
sourceViewer.getTextWidget().setData(AnnotationHyperlinkDetector.class.getName(), annotationHyperlinkDetector);
detectors.add(annotationHyperlinkDetector);
return detectors;
}
use of org.eclipse.jface.text.hyperlink.IHyperlinkDetector in project jbosstools-hibernate by jbosstools.
the class HBMXMLStructuredTextViewerConfiguration method getHyperlinkDetectors.
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
if (sourceViewer == null || hyperLinksEnabled()) {
return null;
}
IHyperlinkDetector[] baseDetectors = super.getHyperlinkDetectors(sourceViewer);
IService service = StructuredTextViewerConfigurationUtil.getService(sourceViewer);
HBMXMLHyperlinkDetector hyperlinkDetector = new HBMXMLHyperlinkDetector(service);
if (baseDetectors == null || baseDetectors.length == 0) {
return new IHyperlinkDetector[] { hyperlinkDetector };
} else {
IHyperlinkDetector[] result = new IHyperlinkDetector[baseDetectors.length + 1];
result[0] = hyperlinkDetector;
for (int i = 0; i < baseDetectors.length; i++) {
result[i + 1] = baseDetectors[i];
}
return result;
}
}
Aggregations