org.eclipse.jface.text.source.SourceViewer Java Examples

The following examples show how to use org.eclipse.jface.text.source.SourceViewer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PyPresentationReconciler.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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();
                    }
                }
            }
        });
    }
}
 
Example #2
Source File: TestLSPIntegration.java    From aCute with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testLSFindsDiagnosticsCSProj() throws Exception  {
	IProject project = getProject("csprojWithError");
	IFile csharpSourceFile = project.getFile("Program.cs");
	IEditorPart editor = IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), csharpSourceFile);
	SourceViewer viewer = (SourceViewer)getTextViewer(editor);
	workaroundOmniSharpIssue1088(viewer.getDocument());
	new DisplayHelper() {
		@Override
		protected boolean condition() {
			try {
				return csharpSourceFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ZERO).length > 0;
			} catch (Exception e) {
				return false;
			}
		}
	}.waitForCondition(Display.getDefault(), 5000);
	DisplayHelper.sleep(500); // time to fill marker details
	IMarker marker = csharpSourceFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ZERO)[0];
	assertTrue(marker.getType().contains("lsp4e"));
	assertEquals(12, marker.getAttribute(IMarker.LINE_NUMBER, -1));
}
 
Example #3
Source File: GamlEditTemplateDialog.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
protected SourceViewer createViewer(final Composite parent) {
	final Builder editorBuilder = configuration.getEmbeddedEditorFactory().newEditor(resourceProvider);
	editorBuilder.processIssuesBy((issues, monitor) -> {
		IStatus result = Status.OK_STATUS;
		final StringBuilder messages = new StringBuilder();
		for (final Issue issue : issues) {
			if (issue.getSeverity() == Severity.ERROR) {
				if (messages.length() != 0) {
					messages.append('\n');
				}
				messages.append(issue.getMessage());
			}
		}
		if (messages.length() != 0) {
			result = createErrorStatus(messages.toString(), null);
		}
		final IStatus toBeUpdated = result;
		getShell().getDisplay().asyncExec(() -> updateStatus(toBeUpdated));
	});
	final EmbeddedEditor handle = editorBuilder.withParent(parent);
	partialModelEditor = handle.createPartialEditor(getPrefix(), data.getTemplate().getPattern(), "", true);
	return handle.getViewer();
}
 
Example #4
Source File: GeneratedScriptPreviewPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected void createScriptPreviewComposite(final Composite mainComposite) {
    final Composite previewComposite = new Composite(mainComposite, SWT.NONE);
    previewComposite.setLayout(new FillLayout(SWT.VERTICAL));
    previewComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(2, 0).create());

    final GroovyViewer groovyViewer = sourceViewerFactory.createSourceViewer(previewComposite, true);
    groovyViewer.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 300).create());
    final SourceViewer sourceViewer = groovyViewer.getSourceViewer();
    sourceViewer.setEditable(false);
    sourceViewer.setEventConsumer(new IEventConsumer() {

        @Override
        public void processEvent(final VerifyEvent event) {
            event.doit = false;
        }
    });
    document = groovyViewer.getDocument();
    document.set(generatedExpression.getContent());
}
 
Example #5
Source File: JavaMergeViewer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@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);
		}
	}
}
 
Example #6
Source File: ParameterizeTextView.java    From http4e with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example #7
Source File: TMPresentationReconciler.java    From tm4e with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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) {
		TMUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, TMUIPlugin.PLUGIN_ID, e.getMessage(), e));
	}
	return null;
}
 
Example #8
Source File: LangTemplatePreferencePage.java    From goclipse with Eclipse Public License 1.0 6 votes vote down vote up
@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;
}
 
Example #9
Source File: LogFileViewer.java    From LogViewer with Eclipse Public License 2.0 6 votes vote down vote up
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();
}
 
Example #10
Source File: DefaultMergeViewer.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected void configureSourceViewer(SourceViewer sourceViewer) {
	IEditorInput editorInput = getEditorInput(sourceViewer);
	SourceViewerConfiguration sourceViewerConfiguration = createSourceViewerConfiguration(sourceViewer, editorInput);
	sourceViewer.unconfigure();
	sourceViewer.configure(sourceViewerConfiguration);
	IXtextDocument xtextDocument = xtextDocumentUtil.getXtextDocument(sourceViewer);
	if (xtextDocument != null) {
		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));
		}
	}
}
 
Example #11
Source File: JSEditor.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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( );
}
 
Example #12
Source File: JavaTextViewer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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);

}
 
Example #13
Source File: PropertiesFileMergeViewer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@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);
}
 
Example #14
Source File: TypeScriptMergeViewer.java    From typescript.java with MIT License 6 votes vote down vote up
@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);
			}
		}
	}
}
 
Example #15
Source File: TypeScriptMergeViewer.java    From typescript.java with MIT License 6 votes vote down vote up
@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);
		}
	}
}
 
Example #16
Source File: DefaultMergeViewer.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
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;
}
 
Example #17
Source File: DefaultMergeViewer.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@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);
			}
		}
	}
}
 
Example #18
Source File: SyntaxColoringPreferencePage.java    From editorconfig-eclipse with Apache License 2.0 6 votes vote down vote up
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();
	}
 
Example #19
Source File: JavaTemplatesPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@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;
}
 
Example #20
Source File: AbstractFormatterSelectionBlock.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
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() };
}
 
Example #21
Source File: JsonEditor.java    From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent event) {
    if (colorPreferenceKeys.contains(event.getProperty())) {
        if (getSourceViewer() instanceof SourceViewer) {
            ((SourceViewer) getSourceViewer()).unconfigure();
            initializeEditor();
            getSourceViewer().configure(sourceViewerConfiguration);
        }
    }
}
 
Example #22
Source File: CSSMergeViewer.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void configureTextViewer(TextViewer textViewer)
{
	super.configureTextViewer(textViewer);

	if (textViewer instanceof SourceViewer)
	{
		SourceViewer sourceViewer = (SourceViewer) textViewer;
		sourceViewer.unconfigure();
		IPreferenceStore preferences = CSSSourceEditor.getChainedPreferenceStore();
		CSSSourceViewerConfiguration config = new CSSSourceViewerConfiguration(preferences, null);
		sourceViewer.configure(config);
	}
}
 
Example #23
Source File: TypeScriptMergeViewer.java    From typescript.java with MIT License 5 votes vote down vote up
private void handlePropertyChange(PropertyChangeEvent event) {
	if (fSourceViewerConfiguration != null) {
		for (Iterator<Entry<SourceViewer, TypeScriptSourceViewerConfiguration>> iterator = fSourceViewerConfiguration
				.entrySet().iterator(); iterator.hasNext();) {
			Entry<SourceViewer, TypeScriptSourceViewerConfiguration> entry = iterator.next();
			TypeScriptSourceViewerConfiguration configuration = entry.getValue();
			if (configuration.affectsTextPresentation(event)) {
				configuration.handlePropertyChangeEvent(event);
				ITextViewer viewer = entry.getKey();
				viewer.invalidateTextPresentation();
			}
		}
	}
}
 
Example #24
Source File: ContractConstraintExpressionWizardPageTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @throws java.lang.Exception
 */
@Before
public void setUp() throws Exception {
    constraint = ProcessFactory.eINSTANCE.createContractConstraint();
    constraint.setExpression("");
    final Contract c = ProcessFactory.eINSTANCE.createContract();
    c.getConstraints().add(constraint);
    final ContractInput name = ProcessFactory.eINSTANCE.createContractInput();
    name.setName("name");
    c.getInputs().add(name);
    composite = realm.createComposite();
    final SourceViewer sourceViewer = new SourceViewer(composite, null, SWT.NONE);
    sourceViewer.setDocument(new Document());
    when(groovyViewer.getSourceViewer()).thenReturn(sourceViewer);
    when(editorFactory.newInstance()).thenReturn(editor);
    when(groovySourceViewerFactory.createSourceViewer(any(Composite.class), any(BonitaGroovyEditor.class))).thenReturn(groovyViewer);
    wizardPage = new ContractConstraintExpressionWizardPage(constraint,
            c.getInputs(),
            groovySourceViewerFactory,
            editorFactory,
            browserFactory);
    final ContractConstraintExpressionWizard wizard = new ContractConstraintExpressionWizard(constraint, null);
    final WizardDialog wizardContainer = new WizardDialog(composite.getShell(), wizard) {

        @Override
        protected Control createContents(final Composite parent) {
            return null;
        }
    };
    wizardContainer.create();
    assertThat(wizardContainer.getShell()).isNotNull();
    wizard.setContainer(wizardContainer);
    wizardPage.setWizard(wizard);
}
 
Example #25
Source File: AbstractFormatterPreferencePage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param composite
 */
public SourceViewer createSourcePreview(Composite composite, IScriptFormatterFactory factory)
{
	IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
	// TODO - Note that we pass the factory's preferences store and not calling to this.getPrefereceStore.
	// In case we decide to unify the preferences into the this plugin, we might need to change this.
	IPreferenceStore store = new ChainedPreferenceStore(new IPreferenceStore[] { factory.getPreferenceStore(),
			generalTextStore });
	SourceViewer fPreviewViewer = createPreviewViewer(composite, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL
			| SWT.BORDER, store);
	if (fPreviewViewer == null)
	{
		return null;
	}
	SourceViewerConfiguration configuration = (SourceViewerConfiguration) factory
			.createSimpleSourceViewerConfiguration(fColorManager, store, null, false);
	fPreviewViewer.configure(configuration);
	if (fPreviewViewer.getTextWidget().getTabs() == 0)
	{
		fPreviewViewer.getTextWidget().setTabs(4);
	}
	new ScriptSourcePreviewerUpdater(fPreviewViewer, configuration, store);
	fPreviewViewer.setEditable(false);
	IDocument document = new Document();
	fPreviewViewer.setDocument(document);
	IPartitioningConfiguration partitioningConfiguration = (IPartitioningConfiguration) factory
			.getPartitioningConfiguration();
	CompositePartitionScanner partitionScanner = new CompositePartitionScanner(
			partitioningConfiguration.createSubPartitionScanner(), new NullSubPartitionScanner(),
			new NullPartitionerSwitchStrategy());
	IDocumentPartitioner partitioner = new ExtendedFastPartitioner(partitionScanner,
			partitioningConfiguration.getContentTypes());
	partitionScanner.setPartitioner((IExtendedPartitioner) partitioner);
	partitioner.connect(document);
	document.setDocumentPartitioner(partitioner);
	return fPreviewViewer;
}
 
Example #26
Source File: JavaMergeViewer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void createPartControl(Composite composite) {
	SourceViewer sourceViewer= (SourceViewer)createJavaSourceViewer(composite, new CompositeRuler(), null, false, fTextOrientation | SWT.H_SCROLL | SWT.V_SCROLL, createChainedPreferenceStore(null));
	setSourceViewer(this, sourceViewer);
	createNavigationActions();
	getSelectionProvider().addSelectionChangedListener(getSelectionChangedListener());
}
 
Example #27
Source File: FormHelper.java    From tlaplus with MIT License 5 votes vote down vote up
/**
 * creates a forms-adopted read-only source viewer
 * @param toolkit
 * @param parent
 * @param flags
 * @return
 */
public static SourceViewer createFormsOutputViewer(FormToolkit toolkit, Composite parent, int flags)
{
    SourceViewer sourceViewer = createOutputViewer(parent, flags);
    sourceViewer.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER);

    sourceViewer.getTextWidget().setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
    toolkit.adapt(sourceViewer.getTextWidget(), true, true);

    return sourceViewer;
}
 
Example #28
Source File: FormHelper.java    From tlaplus with MIT License 5 votes vote down vote up
public static SourceViewer createFormsSourceViewer(FormToolkit toolkit, Composite parent, int flags, SourceViewerConfiguration config)
{
    SourceViewer sourceViewer = createSourceViewer(parent, flags, config);
    sourceViewer.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER);

    sourceViewer.getTextWidget().setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
    toolkit.adapt(sourceViewer.getTextWidget(), true, true);

    return sourceViewer;
}
 
Example #29
Source File: TypeScriptMergeViewer.java    From typescript.java with MIT License 5 votes vote down vote up
@Override
public void createPartControl(Composite composite) {
	SourceViewer sourceViewer = (SourceViewer) createTypeScriptSourceViewer(composite, new CompositeRuler(),
			null, false, fTextOrientation | SWT.H_SCROLL | SWT.V_SCROLL, createChainedPreferenceStore(null));
	setSourceViewer(this, sourceViewer);
	createNavigationActions();
	getSelectionProvider().addSelectionChangedListener(getSelectionChangedListener());
}
 
Example #30
Source File: GamlEditor.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
private void beforeSave() {
	if (!GamaPreferences.Modeling.EDITOR_CLEAN_UP.getValue()) { return; }
	final SourceViewer sv = getInternalSourceViewer();
	final Point p = sv.getSelectedRange();
	sv.setSelectedRange(0, sv.getDocument().getLength());
	if (sv.canDoOperation(SourceViewer.FORMAT)) {
		sv.doOperation(ISourceViewer.FORMAT);
	}
	sv.setSelectedRange(p.x, p.y);
}