org.eclipse.xtext.ui.editor.embedded.IEditedResourceProvider Java Examples

The following examples show how to use org.eclipse.xtext.ui.editor.embedded.IEditedResourceProvider. 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: EditTemplateDialog.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public EditTemplateDialog(Shell parent, Template template, boolean edit, boolean isNameModifiable, 
		ContextTypeRegistry registry, TemplatesLanguageConfiguration configuration, 
		IEditedResourceProvider resourceProvider, String languageName) {
	super(parent);
	this.configuration = configuration;
	this.resourceProvider = resourceProvider;
	this.languageName = languageName;

	String title= edit
		? TemplateDialogMessages.EditTemplateDialog_title_edit
		: TemplateDialogMessages.EditTemplateDialog_title_new;
	setTitle(title);

	this.fTemplate= template;
	fIsNameModifiable= isNameModifiable;

	List<String[]> contexts= Lists.newArrayList();
	for (Iterator<TemplateContextType> it= Iterators.filter(registry.contextTypes(), TemplateContextType.class); it.hasNext();) {
		TemplateContextType type= it.next();
		contexts.add(new String[] { type.getId(), type.getName() });
	}
	fContextTypes= contexts.toArray(new String[contexts.size()][]);
	fContextTypeRegistry= registry;
}
 
Example #2
Source File: ExtractMethodUserInputPage.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
protected void createSignaturePreview(Composite composite) {
	Label previewLabel = new Label(composite, SWT.NONE);
	previewLabel.setText("Method signature preview:");
	GridData gridData = new GridData(SWT.FILL);
	gridData.horizontalSpan = 2;
	previewLabel.setLayoutData(gridData);
	signaturePreview = editorFactory.newEditor(new IEditedResourceProvider() {
		@Override
		public XtextResource createResource() {
			URI resourceURI = EcoreUtil2.getPlatformResourceOrNormalizedURI(refactoring.getXtendClass()).trimFragment();
			IProject project = projectUtil.getProject(resourceURI);
			ResourceSet resourceSet = resourceSetProvider.get(project);
			return (XtextResource) resourceSet.getResource(resourceURI, true);
		}
	}).readOnly().withParent(composite);
	GridData gridData2 = new GridData(GridData.FILL_HORIZONTAL);
	gridData2.horizontalSpan = 2;
	signaturePreview.getViewer().getControl().setLayoutData(gridData2);
	partialEditor = signaturePreview.createPartialEditor(getPartialEditorModelPrefix(),
			refactoring.getMethodSignature(), getPartialEditorModelSuffix(), true);
}
 
Example #3
Source File: GamlEditTemplateDialog.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
public GamlEditTemplateDialog(final Shell parent, final TemplatePersistenceData data, final boolean edit,
		final ContextTypeRegistry registry, final TemplatesLanguageConfiguration configuration,
		final IEditedResourceProvider resourceProvider, final String languageName) {
	super(parent);
	this.data = data;
	this.configuration = configuration;
	this.resourceProvider = resourceProvider;
	this.languageName = languageName;

	final String title = edit ? TemplateDialogMessages.EditTemplateDialog_title_edit
			: TemplateDialogMessages.EditTemplateDialog_title_new;
	setTitle(title);

	// this.fTemplate = data.getTemplate();
	// fIsNameModifiable = isNameModifiable;

	final List<String[]> contexts = Lists.newArrayList();
	for (final Iterator<TemplateContextType> it =
			Iterators.filter(registry.contextTypes(), TemplateContextType.class); it.hasNext();) {
		final TemplateContextType type = it.next();
		contexts.add(new String[] { type.getId(), type.getName() });
	}
	// fContextTypes = contexts.toArray(new String[contexts.size()][]);
	// fContextTypeRegistry = registry;

}
 
Example #4
Source File: StatechartDefinitionSection.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
protected IEditedResourceProvider getXtextResourceProvider(Injector injector) {
	return new IEditedResourceProvider() {

		@Override
		public XtextResource createResource() {
			IProject activeProject = WorkspaceSynchronizer.getFile(getContextObject().eResource()).getProject();
			XtextFakeResourceContext resource = new XtextFakeResourceContext(injector, activeProject);
			xtextResource = resource.getFakeResource();
			xtextResource.eAdapters().add(new ContextElementAdapter(getContextObject()));
			return xtextResource;
		}
	};
}
 
Example #5
Source File: XtendUiModule.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IEditedResourceProvider> bindIEditedResourceProvider() {
	return FormatterResourceProvider.class;
}
 
Example #6
Source File: StatechartDefinitionSection.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
protected EmbeddedEditor createEmbeddedEditor() {
	Injector embeddedEditorInjector = getEmbeddedStatechartSpecificationInjector();
	EmbeddedEditorFactory instance = embeddedEditorInjector.getInstance(EmbeddedEditorFactory.class);
	IEditedResourceProvider provider = getXtextResourceProvider(embeddedEditorInjector);
	return instance.newEditor(provider).showErrorAndWarningAnnotations().withParent(this);
}