protected SourceViewer createViewer (Composite composite) { SourceViewer viewer = ViewerHelper.createEditor(composite); viewer.getControl().setData(WIDGET_ID, WIDGET_ACTION_SCRIPT); FocusListener listener = new FocusListener() { @Override public void focusGained(FocusEvent e) { } @Override public void focusLost(FocusEvent event) { if (!notification) return; if (viewer.getDocument() == null) return; String content = viewer.getDocument().get(); getProperties().setPropertyValue(ModelProperties.PROPERTY_EDGE_ACTION, content); } }; viewer.getControl().addFocusListener(listener); return viewer; }
protected SourceViewer createViewer (Composite composite) { SourceViewer viewer = ViewerHelper.createEditor(composite); viewer.getControl().setData(WIDGET_ID, WIDGET_GUARD_SCRIPT); FocusListener listener = new FocusListener() { @Override public void focusGained(FocusEvent e) { } @Override public void focusLost(FocusEvent event) { if (!notification) return; if (viewer.getDocument() == null) return; String content = viewer.getDocument().get(); getProperties().setPropertyValue(ModelProperties.PROPERTY_EDGE_GUARD, content); } }; viewer.getControl().addFocusListener(listener); return viewer; }
/** * Returns the {@link TMPresentationReconciler} of the given text viewer and * null otherwise. * * @param textViewer * @return the {@link TMPresentationReconciler} of the given text viewer and * null otherwise. */ public static TMPresentationReconciler getTMPresentationReconciler(ITextViewer textViewer) { try { Field field = SourceViewer.class.getDeclaredField("fPresentationReconciler"); if (field != null) { field.setAccessible(true); IPresentationReconciler presentationReconciler = (IPresentationReconciler) field.get(textViewer); return presentationReconciler instanceof TMPresentationReconciler ? (TMPresentationReconciler) presentationReconciler : null; } } catch (Exception e) { } return null; }
private StyledText buildEditorText( Composite parent){ final SourceViewer sourceViewer = new SourceViewer(parent, null, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); final HConfiguration sourceConf = new HConfiguration(HContentAssistProcessor.PARAM_PROCESSOR); sourceViewer.configure(sourceConf); sourceViewer.setDocument(DocumentUtils.createDocument1()); sourceViewer.getControl().addKeyListener(new KeyAdapter() { public void keyPressed( KeyEvent e){ // if ((e.character == ' ') && ((e.stateMask & SWT.CTRL) != 0)) { if (Utils.isAutoAssistInvoked(e)) { IContentAssistant ca = sourceConf.getContentAssistant(sourceViewer); ca.showPossibleCompletions(); } } }); return sourceViewer.getTextWidget(); }
/** * Removes the item from the view, performing necessary * cleanup. * * @param item */ private void removeItem(ExpandItem item) { // remove the source viewer's control from the // font listener since it no longer needs to be // notified of font changes. fontListener.removeControl(((SourceViewer) viewers.get(item)).getControl()); // retrieve the id for the item // the id is stored in the item's data, which should be a marker, // as set in the updateItem method final Object data = item.getData(KEY); items.remove(Integer.parseInt(data.toString())); item.getControl().dispose(); item.dispose(); }
protected SourceViewer createViewer(Composite parent) { IDocument document= new Document(); JavaScriptTextTools tools= JSDTTypeScriptUIPlugin.getDefault().getJavaTextTools(); tools.setupJavaDocumentPartitioner(document, IJavaScriptPartitions.JAVA_PARTITIONING); IPreferenceStore store= JSDTTypeScriptUIPlugin.getDefault().getCombinedPreferenceStore(); SourceViewer viewer= new JavaSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store); SimpleJavaSourceViewerConfiguration configuration= new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaScriptPartitions.JAVA_PARTITIONING, false); viewer.configure(configuration); viewer.setEditable(false); viewer.setDocument(document); Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); viewer.getTextWidget().setFont(font); new TypeScriptSourcePreviewerUpdater(viewer, configuration, store); Control control= viewer.getControl(); GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL); control.setLayoutData(data); return viewer; }
@Override protected void configureTextViewer(TextViewer viewer) { if (viewer instanceof SourceViewer) { SourceViewer sourceViewer = (SourceViewer) viewer; if (fSourceViewer == null) fSourceViewer = new ArrayList<>(); if (!fSourceViewer.contains(sourceViewer)) fSourceViewer.add(sourceViewer); TypeScriptTextTools tools = JSDTTypeScriptUIPlugin.getDefault().getJavaTextTools(); if (tools != null) { IEditorInput editorInput = getEditorInput(sourceViewer); sourceViewer.unconfigure(); if (editorInput == null) { sourceViewer.configure(getSourceViewerConfiguration(sourceViewer, null)); return; } getSourceViewerConfiguration(sourceViewer, editorInput); } } }
@Override protected void setActionsActivated(SourceViewer sourceViewer, boolean state) { if (fEditor != null) { Object editor = fEditor.get(sourceViewer); if (editor instanceof TypeScriptEditorAdapter) { TypeScriptEditorAdapter cuea = (TypeScriptEditorAdapter) editor; cuea.setActionsActivated(state); IAction saveAction = cuea.getAction(ITextEditorActionConstants.SAVE); if (saveAction instanceof IPageListener) { PartEventAction partEventAction = (PartEventAction) saveAction; IWorkbenchPart compareEditorPart = getCompareConfiguration().getContainer().getWorkbenchPart(); if (state) partEventAction.partActivated(compareEditorPart); else partEventAction.partDeactivated(compareEditorPart); } } } }
/** * Creates the viewer to be used to display the pattern. Subclasses may override. * * @param parent the parent composite of the viewer * @return a configured <code>SourceViewer</code> */ protected SourceViewer createViewer(Composite parent) { SourceViewer viewer= new SourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); SourceViewerConfiguration configuration= new SourceViewerConfiguration() { @Override public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { ContentAssistant assistant= new ContentAssistant(); assistant.enableAutoActivation(true); assistant.enableAutoInsert(true); assistant.setContentAssistProcessor(fTemplateProcessor, IDocument.DEFAULT_CONTENT_TYPE); return assistant; } }; viewer.configure(configuration); return viewer; }
private SourceViewer doCreateViewer(Composite parent) { Label label= new Label(parent, SWT.NONE); label.setText(TemplatesMessages.TemplatePreferencePage_preview); GridData data= new GridData(); data.horizontalSpan= 2; label.setLayoutData(data); SourceViewer viewer= createViewer(parent); viewer.setEditable(false); Cursor arrowCursor= viewer.getTextWidget().getDisplay().getSystemCursor(SWT.CURSOR_ARROW); viewer.getTextWidget().setCursor(arrowCursor); // Don't set caret to 'null' as this causes https://bugs.eclipse.org/293263 // viewer.getTextWidget().setCaret(null); Control control= viewer.getControl(); data= new GridData(GridData.FILL_BOTH); data.horizontalSpan= 2; data.heightHint= convertHeightInCharsToPixels(5); control.setLayoutData(data); return viewer; }
protected void configureSourceViewer(SourceViewer sourceViewer) { IEditorInput editorInput = getEditorInput(sourceViewer); SourceViewerConfiguration sourceViewerConfiguration = createSourceViewerConfiguration(sourceViewer, editorInput); sourceViewer.unconfigure(); sourceViewer.configure(sourceViewerConfiguration); if (sourceViewer.getDocument() instanceof IXtextDocument) { IXtextDocument xtextDocument = (IXtextDocument) sourceViewer.getDocument(); if (!xtextDocument.readOnly(TEST_EXISTING_XTEXT_RESOURCE)) { String[] configuredContentTypes = sourceViewerConfiguration.getConfiguredContentTypes(sourceViewer); for (String contentType : configuredContentTypes) { sourceViewer.removeTextHovers(contentType); } sourceViewer.setHyperlinkDetectors(null, sourceViewerConfiguration.getHyperlinkStateMask(sourceViewer)); } } }
protected SourceViewerConfiguration createSourceViewerConfiguration(SourceViewer sourceViewer, IEditorInput editorInput) { SourceViewerConfiguration sourceViewerConfiguration = null; if (editorInput != null && getEditor(sourceViewer) != null) { DefaultMergeEditor mergeEditor = getEditor(sourceViewer); sourceViewerConfiguration = mergeEditor.getXtextSourceViewerConfiguration(); try { mergeEditor.init((IEditorSite) mergeEditor.getSite(), editorInput); mergeEditor.createActions(); } catch (PartInitException partInitException) { throw new WrappedException(partInitException); } } else { sourceViewerConfiguration = sourceViewerConfigurationProvider.get(); } return sourceViewerConfiguration; }
@Override protected void setActionsActivated(SourceViewer sourceViewer, boolean state) { DefaultMergeEditor mergeEditor = getEditor(sourceViewer); if (mergeEditor != null) { mergeEditor.setActionsActivated(state); IAction saveAction = mergeEditor.getAction(ITextEditorActionConstants.SAVE); if (saveAction instanceof IPageListener) { PartEventAction partEventAction = (PartEventAction) saveAction; IWorkbenchPart compareEditorPart = getCompareConfiguration().getContainer().getWorkbenchPart(); if (state) { partEventAction.partActivated(compareEditorPart); } else { partEventAction.partDeactivated(compareEditorPart); } } } }
@Override protected SourceViewer createSourceViewer(Composite parent, int textOrientation) { if (getSite() != null) { if (sourceViewerEditorMap == null) { sourceViewerEditorMap = Maps.newHashMapWithExpectedSize(3); } DefaultMergeEditor mergeEditor = createMergeEditor(); mergeEditor.setXtextEditorCallback(new CompoundXtextEditorCallback(null)); mergeEditor.setTextOrientation(textOrientation); mergeEditor.setInternalSite(getSite()); mergeEditor.createPartControl(parent); SourceViewer internalSourceViewer = (SourceViewer) mergeEditor.getInternalSourceViewer(); sourceViewerEditorMap.put(internalSourceViewer, mergeEditor); return internalSourceViewer; } return super.createSourceViewer(parent, textOrientation); }
protected OperationHistoryListener installUndoRedoSupport(SourceViewer viewer, IDocument document, final EmbeddedEditorActions actions) { IDocumentUndoManager undoManager = DocumentUndoManagerRegistry.getDocumentUndoManager(document); final IUndoContext context = undoManager.getUndoContext(); // XXX cp uncommented // IOperationHistory operationHistory = PlatformUI.getWorkbench().getOperationSupport().getOperationHistory(); OperationHistoryListener operationHistoryListener = new OperationHistoryListener(context, new IUpdate() { public void update() { actions.updateAction(ITextEditorActionConstants.REDO); actions.updateAction(ITextEditorActionConstants.UNDO); } }); viewer.addTextListener(new ITextListener() { public void textChanged(TextEvent event) { actions.updateAction(ITextEditorActionConstants.REDO); actions.updateAction(ITextEditorActionConstants.UNDO); } }); // // operationHistory.addOperationHistoryListener(operationHistoryListener); return operationHistoryListener; }
public LogFileViewer(Composite parent, int style) { store = LogViewerPlugin.getDefault().getPreferenceStore(); if (store.getBoolean(ILogViewerConstants.PREF_WORD_WRAP)) style |= SWT.WRAP; showWhenUpdated = store.getBoolean(ILogViewerConstants.PREF_SHOW_WHEN_UPDATED); showTopOfFile = store.getBoolean(ILogViewerConstants.PREF_SHOW_TOP_OF_FILE); txtViewer = new SourceViewer(parent,null,style); FontData[] fontData = PreferenceConverter.getFontDataArray(store,ILogViewerConstants.PREF_EDITOR_FONT_STYLE); if(fontData == null) { fontData = JFaceResources.getDefaultFont().getFontData(); } txtViewer.getTextWidget().setFont(new Font(Display.getCurrent(),fontData)); propertyChangeListener = new PropertyChangeListener(); store.addPropertyChangeListener(propertyChangeListener); createCursorLinePainter(); createAndInstallPresentationReconciler(); }
public AbstractFormatterSelectionBlock(IStatusChangeListener context, IProject project, IWorkbenchPreferenceContainer container) { super(context, project, ProfileManager.collectPreferenceKeys(TEMP_LIST, true), container); Collections.sort(TEMP_LIST, new Comparator<IScriptFormatterFactory>() { public int compare(IScriptFormatterFactory s1, IScriptFormatterFactory s2) { return s1.getName().compareToIgnoreCase(s2.getName()); } }); factories = TEMP_LIST.toArray(new IScriptFormatterFactory[TEMP_LIST.size()]); TEMP_LIST = new ArrayList<IScriptFormatterFactory>(); sourcePreviewViewers = new ArrayList<SourceViewer>(); // Override the super preferences lookup order. // All the changes to the formatter settings should go to the instance scope (no project scope here). Only the // selected profile will be picked from the project scope and then the instance scope when requested. fLookupOrder = new IScopeContext[] { EclipseUtil.instanceScope(), EclipseUtil.defaultScope() }; }
@Override protected SourceViewer createPatternViewer(Composite parent) { IDocument document= new Document(); JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools(); tools.setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING); IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore(); JavaSourceViewer viewer= new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL, store); SimpleJavaSourceViewerConfiguration configuration= new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING, false); viewer.configure(configuration); viewer.setEditable(false); viewer.setDocument(document); Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); viewer.getTextWidget().setFont(font); new JavaSourcePreviewerUpdater(viewer, configuration, store); Control control= viewer.getControl(); GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL); control.setLayoutData(data); viewer.setEditable(false); return viewer; }
@Override protected SourceViewer createViewer(Composite parent) { IDocument document= new Document(); JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools(); tools.setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING); IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore(); SourceViewer viewer= new JavaSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store); SimpleJavaSourceViewerConfiguration configuration= new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING, false); viewer.configure(configuration); viewer.setEditable(false); viewer.setDocument(document); Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); viewer.getTextWidget().setFont(font); new JavaSourcePreviewerUpdater(viewer, configuration, store); Control control= viewer.getControl(); GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL); control.setLayoutData(data); return viewer; }
@Override protected void configureTextViewer(TextViewer textViewer) { if (!(textViewer instanceof SourceViewer)) return; if (fPreferenceStore == null) { fSourceViewerConfigurations= new ArrayList<SourceViewerConfiguration>(3); fPreferenceStore= JavaPlugin.getDefault().getCombinedPreferenceStore(); fPreferenceChangeListener= new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { Iterator<SourceViewerConfiguration> iter= fSourceViewerConfigurations.iterator(); while (iter.hasNext()) ((PropertiesFileSourceViewerConfiguration)iter.next()).handlePropertyChangeEvent(event); invalidateTextPresentation(); } }; fPreferenceStore.addPropertyChangeListener(fPreferenceChangeListener); } SourceViewerConfiguration sourceViewerConfiguration= new PropertiesFileSourceViewerConfiguration(JavaPlugin.getDefault().getJavaTextTools().getColorManager(), fPreferenceStore, null, getDocumentPartitioning()); fSourceViewerConfigurations.add(sourceViewerConfiguration); ((SourceViewer)textViewer).configure(sourceViewerConfiguration); }
JavaTextViewer(Composite parent) { fSourceViewer= new SourceViewer(parent, null, SWT.LEFT_TO_RIGHT | SWT.H_SCROLL | SWT.V_SCROLL); JavaTextTools tools= JavaCompareUtilities.getJavaTextTools(); if (tools != null) { IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore(); fSourceViewer.configure(new JavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING)); } fSourceViewer.setEditable(false); String symbolicFontName= JavaMergeViewer.class.getName(); Font font= JFaceResources.getFont(symbolicFontName); if (font != null) fSourceViewer.getTextWidget().setFont(font); }
@Override protected void configureTextViewer(TextViewer viewer) { if (viewer instanceof SourceViewer) { SourceViewer sourceViewer= (SourceViewer)viewer; if (fSourceViewer == null) fSourceViewer= new ArrayList<SourceViewer>(); if (!fSourceViewer.contains(sourceViewer)) fSourceViewer.add(sourceViewer); JavaTextTools tools= JavaCompareUtilities.getJavaTextTools(); if (tools != null) { IEditorInput editorInput= getEditorInput(sourceViewer); sourceViewer.unconfigure(); if (editorInput == null) { sourceViewer.configure(getSourceViewerConfiguration(sourceViewer, null)); return; } getSourceViewerConfiguration(sourceViewer, editorInput); } } }
@Override protected void setActionsActivated(SourceViewer sourceViewer, boolean state) { if (fEditor != null) { Object editor= fEditor.get(sourceViewer); if (editor instanceof CompilationUnitEditorAdapter) { CompilationUnitEditorAdapter cuea = (CompilationUnitEditorAdapter)editor; cuea.setActionsActivated(state); IAction saveAction= cuea.getAction(ITextEditorActionConstants.SAVE); if (saveAction instanceof IPageListener) { PartEventAction partEventAction = (PartEventAction) saveAction; IWorkbenchPart compareEditorPart= getCompareConfiguration().getContainer().getWorkbenchPart(); if (state) partEventAction.partActivated(compareEditorPart); else partEventAction.partDeactivated(compareEditorPart); } } } }
private Control createPreviewer(Composite parent) { IPreferenceStore store = new ChainedPreferenceStore(new IPreferenceStore[] { fOverlayStore, EditorConfigUIPlugin.getDefault().getCombinedPreferenceStore() }); fPreviewViewer = new SourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); fColorManager = new EditorConfigColorManager(false); EditorConfigSourceViewerConfiguration configuration = new EditorConfigSourceViewerConfiguration(fColorManager, store, null, IEditorConfigPartitions.EDITOR_CONFIG_PARTITIONING); fPreviewViewer.configure(configuration); Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_CONFIG_EDITOR_TEXT_FONT); fPreviewViewer.getTextWidget().setFont(font); new SourcePreviewerUpdater(fPreviewViewer, configuration, store); fPreviewViewer.setEditable(false); String content = loadPreviewContentFromFile("EditorConfigEditorColorSettingPreviewCode.txt"); //$NON-NLS-1$ IDocument document = new Document(content); EditorConfigDocumentSetupParticipant.setupDocument(document); fPreviewViewer.setDocument(document); return fPreviewViewer.getControl(); }
/** * Creates, configures and returns a source viewer to present the template * pattern on the preference page. Clients may override to provide a * custom source viewer featuring e.g. syntax coloring. * * @param parent * the parent control * @return a configured source viewer */ @Override protected final SourceViewer createViewer(Composite parent) { final ApexSourceViewerConfiguration configuration = new ApexSourceViewerConfiguration(preferenceStore(), null); configuration.init(this.componentModel.getProject()); final IDocument document = new Document(); new ApexDocumentSetupParticipant().setup(document); SourceViewer viewer= new SourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); viewer.configure(configuration); viewer.setDocument(document); viewer.getTextWidget().setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT)); viewer.setEditable(false); return viewer; }
private SourceViewer doCreateViewer(Composite parent) { Label label = new Label(parent, SWT.NONE); label.setText(NewWizardMessages.WizardPage_4); GridData data = new GridData(); data.horizontalSpan = 2; label.setLayoutData(data); SourceViewer viewer = createViewer(parent); viewer.setEditable(false); Control control = viewer.getControl(); data = new GridData(GridData.FILL_BOTH); data.horizontalSpan = 2; data.heightHint = convertHeightInCharsToPixels(5); // [261274] - source viewer was growing to fit the max line width of the template data.widthHint = convertWidthInCharsToPixels(2); control.setLayoutData(data); return viewer; }
@Override protected SourceViewer createViewer(Composite parent) { final SourceViewer viewer = super.createViewer(parent); new ApexDocumentSetupParticipant().setup(viewer.getDocument()); final ApexSourceViewerConfiguration configuration = new ApexSourceViewerConfiguration(preferenceStore(), null); configuration.init(null); viewer.unconfigure(); viewer.configure(configuration); viewer.getTextWidget().setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT)); viewer.setEditable(false); return viewer; }
/** * Saves input code to model */ private void saveModel( ) { if ( isCodeModified( ) && editObject instanceof DesignElementHandle ) { saveEditorContentsDE( (DesignElementHandle) editObject, isSaveScript ); } setIsModified( false ); ( (IFormPage) getParentEditor( ) ).getEditor( ) .editorDirtyStateChanged( ); firePropertyChange( PROP_DIRTY ); SourceViewer viewer = getViewer( ); IUndoManager undoManager = viewer == null ? null : viewer.getUndoManager( ); if ( undoManager != null ) { undoManager.endCompoundChange( ); } cleanPoint = getUndoLevel( ); }
private SourceViewer doCreateViewer(Composite parent) { Label label = new Label(parent, SWT.NONE); label.setText("Preview"); GridData data = new GridData(); data.horizontalSpan = 2; label.setLayoutData(data); SourceViewer viewer = createViewer(parent); viewer.setEditable(false); Control control = viewer.getControl(); data = new GridData(GridData.FILL_BOTH); data.horizontalSpan = 1; data.verticalSpan=2; data.heightHint = convertHeightInCharsToPixels(5); // [261274] - source viewer was growing to fit the max line width of the template data.widthHint = convertWidthInCharsToPixels(2); control.setLayoutData(data); fImage=new Label(parent, SWT.NONE); fImage.setLayoutData(data); return viewer; }
PyContentViewer(Composite parent, CompareConfiguration mp) { fSourceViewer = new SourceViewer(parent, null, SWT.LEFT_TO_RIGHT | SWT.H_SCROLL | SWT.V_SCROLL); IPreferenceStore store = PydevPrefs.getChainedPrefStore(); final ColorAndStyleCache c = new ColorAndStyleCache(store); // Ideally we wouldn't pass null for the grammarVersionProvider... although // I haven't been able to get to this code at all (is this something still needed?) // It seems that Eclipse (in 4.5m5 at least) never gets to use the org.eclipse.compare.contentViewers // as it seems to use what's provided by org.eclipse.compare.contentMergeViewers or the // editor directly... if that's not the case, first we need to discover how that's still needed. fSourceViewer.configure(new PyEditConfigurationWithoutEditor(c, store, null)); fSourceViewer.setEditable(false); parent.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { c.dispose(); } }); }
/** * Important: update only asynchronously... */ public void invalidateTextPresentation() { if (viewer != null) { RunInUiThread.async(new Runnable() { @Override public void run() { ITextViewer v = viewer; if (v != null && v instanceof SourceViewer) { SourceViewer sourceViewer = (SourceViewer) v; StyledText textWidget = sourceViewer.getTextWidget(); if (textWidget != null && !textWidget.isDisposed()) { sourceViewer.invalidateTextPresentation(); } } } }); } }
private SourceViewer doCreateViewer(Composite parent) { Label label = new Label(parent, SWT.NONE); label.setText(HTMLUIMessages.NewHTMLTemplatesWizardPage_5); GridData data = new GridData(); data.horizontalSpan = 2; label.setLayoutData(data); SourceViewer viewer = createViewer(parent); viewer.setEditable(false); Control control = viewer.getControl(); data = new GridData(GridData.FILL_BOTH); data.horizontalSpan = 2; data.heightHint = convertHeightInCharsToPixels(5); // [261274] - source viewer was growing to fit the max line width of the template data.widthHint = convertWidthInCharsToPixels(2); control.setLayoutData(data); return viewer; }
private SourceViewer doCreateViewer(Composite parent) { Label label = new Label(parent, SWT.NONE); label.setText(Messages.NewGenericFileTemplatesWizardPage_2); GridData data = new GridData(); data.horizontalSpan = 2; label.setLayoutData(data); SourceViewer viewer = createViewer(parent); viewer.setEditable(false); Control control = viewer.getControl(); data = new GridData(GridData.FILL_BOTH); data.horizontalSpan = 2; data.heightHint = convertHeightInCharsToPixels(5); control.setLayoutData(data); return viewer; }
@Override protected SourceViewer createViewer(Composite parent) { LangSourceViewer viewer = new LangSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); final IContentAssistProcessor templateProcessor = getTemplateProcessor(); IDocument document = new Document(); LangDocumentPartitionerSetup.getInstance().setup(document); IPreferenceStore store = LangUIPlugin.getDefault().getCombinedPreferenceStore(); SourceViewerConfiguration configuration = EditorSettings_Actual .createTemplateEditorSourceViewerConfiguration(store, templateProcessor); viewer.configure(configuration); viewer.setEditable(true); viewer.setDocument(document); return viewer; }