|
12 | 12 |
|
13 | 13 | import org.eclipse.jface.dialogs.IDialogSettings;
|
14 | 14 | import org.eclipse.jface.preference.IPreferenceStore;
|
| 15 | +import org.eclipse.jface.text.AbstractInformationControlManager; |
15 | 16 | import org.eclipse.jface.text.IDocument;
|
| 17 | +import org.eclipse.jface.text.IInformationControl; |
| 18 | +import org.eclipse.jface.text.IInformationControlCreator; |
16 | 19 | import org.eclipse.jface.text.contentassist.ContentAssistant;
|
17 | 20 | import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
|
18 | 21 | import org.eclipse.jface.text.contentassist.IContentAssistant;
|
19 | 22 | import org.eclipse.jface.text.formatter.IContentFormatter;
|
| 23 | +import org.eclipse.jface.text.information.IInformationPresenter; |
| 24 | +import org.eclipse.jface.text.information.IInformationProvider; |
| 25 | +import org.eclipse.jface.text.information.InformationPresenter; |
20 | 26 | import org.eclipse.jface.text.source.ISourceViewer;
|
| 27 | +import org.eclipse.swt.SWT; |
| 28 | +import org.eclipse.swt.widgets.Shell; |
21 | 29 | import org.eclipse.ui.texteditor.ITextEditor;
|
22 | 30 | import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
|
23 | 31 | import org.eclipse.wst.jsdt.internal.ui.text.ContentAssistPreference;
|
|
29 | 37 |
|
30 | 38 | import ts.eclipse.ide.jsdt.internal.ui.editor.contentassist.TypeScriptCompletionProcessor;
|
31 | 39 | import ts.eclipse.ide.jsdt.internal.ui.editor.format.TypeScriptContentFormatter;
|
| 40 | +import ts.eclipse.ide.jsdt.ui.actions.ITypeScriptEditorActionDefinitionIds; |
| 41 | +import ts.eclipse.ide.ui.outline.TypeScriptElementProvider; |
| 42 | +import ts.eclipse.ide.ui.outline.TypeScriptQuickOutlineDialog; |
32 | 43 | import ts.eclipse.ide.ui.utils.EditorUtils;
|
33 | 44 |
|
34 | 45 | /**
|
@@ -103,4 +114,69 @@ private IDialogSettings getSettings(final String sectionName) {
|
103 | 114 | public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
|
104 | 115 | return new TypeScriptContentFormatter(EditorUtils.getResource(getEditor()));
|
105 | 116 | }
|
| 117 | + |
| 118 | + /** |
| 119 | + * Returns the outline presenter which will determine and shown information |
| 120 | + * requested for the current cursor position. |
| 121 | + * |
| 122 | + * @param sourceViewer |
| 123 | + * the source viewer to be configured by this configuration |
| 124 | + * @param doCodeResolve |
| 125 | + * a boolean which specifies whether code resolve should be used |
| 126 | + * to compute the JavaScript element |
| 127 | + * @return an information presenter |
| 128 | + * |
| 129 | + */ |
| 130 | + @Override |
| 131 | + public IInformationPresenter getOutlinePresenter(final ISourceViewer sourceViewer, final boolean doCodeResolve) { |
| 132 | + InformationPresenter presenter = null; |
| 133 | + if (doCodeResolve) { |
| 134 | + // presenter = new |
| 135 | + // InformationPresenter(getOutlinePresenterControlCreator(sourceViewer, |
| 136 | + // ITypeScriptEditorActionDefinitionIds.OPEN_STRUCTURE)); |
| 137 | + return null; |
| 138 | + } else { |
| 139 | + presenter = new InformationPresenter( |
| 140 | + getOutlinePresenterControlCreator(sourceViewer, ITypeScriptEditorActionDefinitionIds.SHOW_OUTLINE)); |
| 141 | + } |
| 142 | + presenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer)); |
| 143 | + presenter.setAnchor(AbstractInformationControlManager.ANCHOR_GLOBAL); |
| 144 | + IInformationProvider provider = new TypeScriptElementProvider(getEditor()); |
| 145 | + presenter.setInformationProvider(provider, IDocument.DEFAULT_CONTENT_TYPE); |
| 146 | + presenter.setInformationProvider(provider, IJavaScriptPartitions.JAVA_DOC); |
| 147 | + presenter.setInformationProvider(provider, IJavaScriptPartitions.JAVA_MULTI_LINE_COMMENT); |
| 148 | + presenter.setInformationProvider(provider, IJavaScriptPartitions.JAVA_SINGLE_LINE_COMMENT); |
| 149 | + presenter.setInformationProvider(provider, IJavaScriptPartitions.JAVA_STRING); |
| 150 | + presenter.setInformationProvider(provider, IJavaScriptPartitions.JAVA_CHARACTER); |
| 151 | + presenter.setSizeConstraints(50, 20, true, false); |
| 152 | + return presenter; |
| 153 | + } |
| 154 | + |
| 155 | + /** |
| 156 | + * Returns the outline presenter control creator. The creator is a factory |
| 157 | + * creating outline presenter controls for the given source viewer. This |
| 158 | + * implementation always returns a creator for |
| 159 | + * <code>JavaOutlineInformationControl</code> instances. |
| 160 | + * |
| 161 | + * @param sourceViewer |
| 162 | + * the source viewer to be configured by this configuration |
| 163 | + * @param commandId |
| 164 | + * the ID of the command that opens this control |
| 165 | + * @return an information control creator |
| 166 | + * |
| 167 | + */ |
| 168 | + private IInformationControlCreator getOutlinePresenterControlCreator(final ISourceViewer sourceViewer, |
| 169 | + final String commandId) { |
| 170 | + return new IInformationControlCreator() { |
| 171 | + public IInformationControl createInformationControl(final Shell parent) { |
| 172 | + int shellStyle = SWT.RESIZE; |
| 173 | + try { |
| 174 | + return new TypeScriptQuickOutlineDialog(parent, shellStyle, |
| 175 | + ((TypeScriptEditor) getEditor()).getTypeScriptFile()); |
| 176 | + } catch (Exception e) { |
| 177 | + return null; |
| 178 | + } |
| 179 | + } |
| 180 | + }; |
| 181 | + } |
106 | 182 | }
|
0 commit comments