Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 337289 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/xtext/gmf/glue/concurrency/SimpleDirtyResource.java (-3 / +3 lines)
Lines 40-48 Link Here
40
		return resource.getSerializer().serialize(resource.getContents().get(0));
40
		return resource.getSerializer().serialize(resource.getContents().get(0));
41
	}
41
	}
42
	
42
	
43
//	public String getActualContents() {
43
	public String getActualContents() {
44
//		return resource.getSerializer().serialize(resource.getContents().get(0));
44
		return getContents();
45
//	}
45
	}
46
46
47
	public IResourceDescription getDescription() {
47
	public IResourceDescription getDescription() {
48
		return resourceDescriptionManager.getResourceDescription(resource);
48
		return resourceDescriptionManager.getResourceDescription(resource);
(-)src/org/eclipse/xtext/gmf/glue/edit/part/PopupXtextEditorKeyListener.java (-12 / +2 lines)
Lines 38-57 Link Here
38
	 * @param popupXtextEditorHelper 
38
	 * @param popupXtextEditorHelper 
39
	 * @param contentAssistant 
39
	 * @param contentAssistant 
40
	 */
40
	 */
41
	public PopupXtextEditorKeyListener(PopupXtextEditorHelper popupXtextEditorHelper, ContentAssistantFacade contentAssistant) {
41
	public PopupXtextEditorKeyListener(PopupXtextEditorHelper popupXtextEditorHelper, ContentAssistant contentAssistant) {
42
		this.popupXtextEditorHelper = popupXtextEditorHelper;
42
		this.popupXtextEditorHelper = popupXtextEditorHelper;
43
		try {
43
		this.contentAssistant = contentAssistant;
44
			Field f = ContentAssistantFacade.class.getDeclaredField("fContentAssistant") ;
45
			f.setAccessible(true) ;
46
			this.contentAssistant = (ContentAssistant) f.get(contentAssistant) ;
47
			System.out.println() ;
48
		}
49
		catch (Exception exception) {
50
			System.out.println(exception) ;
51
			this.contentAssistant = null ;
52
		}
53
		isIgnoreNextESC = false;
44
		isIgnoreNextESC = false;
54
		
55
	}
45
	}
56
46
57
	@Override
47
	@Override
(-)src/org/eclipse/xtext/gmf/glue/edit/part/PopupXtextEditorHelper.java (-1 / +6 lines)
Lines 11-16 Link Here
11
import java.util.List;
11
import java.util.List;
12
import java.util.Map;
12
import java.util.Map;
13
13
14
import org.eclipse.core.commands.operations.DefaultOperationHistory;
14
import org.eclipse.core.commands.operations.IOperationHistory;
15
import org.eclipse.core.commands.operations.IOperationHistory;
15
import org.eclipse.core.commands.operations.IUndoContext;
16
import org.eclipse.core.commands.operations.IUndoContext;
16
import org.eclipse.core.commands.operations.OperationHistoryFactory;
17
import org.eclipse.core.commands.operations.OperationHistoryFactory;
Lines 27-32 Link Here
27
import org.eclipse.jface.action.IAction;
28
import org.eclipse.jface.action.IAction;
28
import org.eclipse.jface.commands.ActionHandler;
29
import org.eclipse.jface.commands.ActionHandler;
29
import org.eclipse.jface.text.ITextOperationTarget;
30
import org.eclipse.jface.text.ITextOperationTarget;
31
import org.eclipse.jface.text.contentassist.ContentAssistant;
30
import org.eclipse.jface.text.source.ISourceViewer;
32
import org.eclipse.jface.text.source.ISourceViewer;
31
import org.eclipse.jface.text.source.SourceViewer;
33
import org.eclipse.jface.text.source.SourceViewer;
32
import org.eclipse.jface.text.templates.TemplateException;
34
import org.eclipse.jface.text.templates.TemplateException;
Lines 58-63 Link Here
58
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
60
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
59
import org.eclipse.ui.texteditor.IUpdate;
61
import org.eclipse.ui.texteditor.IUpdate;
60
import org.eclipse.xtext.gmf.glue.Activator;
62
import org.eclipse.xtext.gmf.glue.Activator;
63
import org.eclipse.xtext.gmf.glue.partialEditing.CustomXtextSourceViewer;
61
import org.eclipse.xtext.gmf.glue.partialEditing.ISyntheticResourceProvider;
64
import org.eclipse.xtext.gmf.glue.partialEditing.ISyntheticResourceProvider;
62
import org.eclipse.xtext.gmf.glue.partialEditing.OperationHistoryListener;
65
import org.eclipse.xtext.gmf.glue.partialEditing.OperationHistoryListener;
63
import org.eclipse.xtext.gmf.glue.partialEditing.PartialModelEditor;
66
import org.eclipse.xtext.gmf.glue.partialEditing.PartialModelEditor;
Lines 109-114 Link Here
109
	private String semanticElementFragment;
112
	private String semanticElementFragment;
110
	private EObject semanticElement ;
113
	private EObject semanticElement ;
111
	private String textToEdit ;
114
	private String textToEdit ;
115
	
112
	/**
116
	/**
113
	 * The file extension used to dynamically select the appropriate xtext editor
117
	 * The file extension used to dynamically select the appropriate xtext editor
114
	 */
118
	 */
Lines 290-298 Link Here
290
	private void registerKeyListener() {
294
	private void registerKeyListener() {
291
		//XtextSourceViewer sourceViewer = (XtextSourceViewer) xtextEditor.getInternalSourceViewer();
295
		//XtextSourceViewer sourceViewer = (XtextSourceViewer) xtextEditor.getInternalSourceViewer();
292
		final StyledText xtextTextWidget = sourceViewerHandle.getViewer().getTextWidget();
296
		final StyledText xtextTextWidget = sourceViewerHandle.getViewer().getTextWidget();
297
		CustomXtextSourceViewer viewer = (CustomXtextSourceViewer)sourceViewerHandle.getViewer() ;
293
		keyListener = 
298
		keyListener = 
294
			new PopupXtextEditorKeyListener
299
			new PopupXtextEditorKeyListener
295
						(this, sourceViewerHandle.getViewer().getContentAssistantFacade());
300
						(this, (ContentAssistant) viewer.getContentAssistant());
296
		//keyListener.installUndoRedoSupport(sourceViewerHandle.getViewer()) ;
301
		//keyListener.installUndoRedoSupport(sourceViewerHandle.getViewer()) ;
297
		xtextTextWidget.addVerifyKeyListener(keyListener);
302
		xtextTextWidget.addVerifyKeyListener(keyListener);
298
		xtextTextWidget.addKeyListener(keyListener);
303
		xtextTextWidget.addKeyListener(keyListener);
(-)src/org/eclipse/xtext/gmf/glue/partialEditing/SyntheticResourceProvider.java (-5 / +14 lines)
Lines 14-22 Link Here
14
import org.eclipse.xtext.IGrammarAccess;
14
import org.eclipse.xtext.IGrammarAccess;
15
import org.eclipse.xtext.gmf.glue.edit.part.PopupXtextEditorHelper;
15
import org.eclipse.xtext.gmf.glue.edit.part.PopupXtextEditorHelper;
16
import org.eclipse.xtext.resource.XtextResource;
16
import org.eclipse.xtext.resource.XtextResource;
17
import org.eclipse.xtext.ui.resource.IResourceSetProvider;
17
import org.eclipse.xtext.resource.XtextResourceSet;
18
18
19
import com.google.inject.Inject;
19
import com.google.inject.Inject;
20
import com.google.inject.Provider;
20
21
21
/**
22
/**
22
 * @author Sebastian Zarnekow - Initial contribution and API
23
 * @author Sebastian Zarnekow - Initial contribution and API
Lines 28-47 Link Here
28
	 */
29
	 */
29
	public static final String SYNTHETIC_SCHEME = "synthetic";
30
	public static final String SYNTHETIC_SCHEME = "synthetic";
30
	
31
	
31
	@Inject 
32
	//@Inject 
32
	private IResourceSetProvider resourceSetProvider;
33
	//private IResourceSetProvider resourceSetProvider;
34
	@Inject
35
	private Provider<XtextResourceSet> resourceSetProvider;
33
	
36
	
34
	@Inject
37
	@Inject
35
	private IGrammarAccess grammarAccess;
38
	private IGrammarAccess grammarAccess;
36
	
39
	
40
	
41
	
37
	public XtextResource createResource() {
42
	public XtextResource createResource() {
38
		ResourceSet resourceSet = resourceSetProvider.get(null);
43
		ResourceSet resourceSet = resourceSetProvider.get();
44
//		EObject context = PopupXtextEditorHelper.context ;
45
//		ResourceSet resourceSet = context.eResource().getResourceSet() ;
39
		Resource grammarResource = resourceSet.createResource(
46
		Resource grammarResource = resourceSet.createResource(
40
				URI.createURI(SYNTHETIC_SCHEME + ":/" + grammarAccess.getGrammar().getName() + ".xtext"));
47
				URI.createURI(SYNTHETIC_SCHEME + ":/" + grammarAccess.getGrammar().getName() + ".xtext"));
41
		grammarResource.getContents().add(EcoreUtil.copy(grammarAccess.getGrammar()));
48
		grammarResource.getContents().add(EcoreUtil.copy(grammarAccess.getGrammar()));
42
		XtextResource result = (XtextResource) resourceSet.createResource(
49
		XtextResource result = (XtextResource) resourceSet.createResource(
43
				URI.createURI(SYNTHETIC_SCHEME + ":/" + grammarAccess.getGrammar().getName() + "." + PopupXtextEditorHelper.fileExtension));
50
				URI.createURI(SYNTHETIC_SCHEME + ":/" + grammarAccess.getGrammar().getName() + "." + PopupXtextEditorHelper.fileExtension));
44
		resourceSet.getResources().add(result);
51
		resourceSet.getResources().add(result);
45
		return result;
52
		return result ;		
53
46
	}
54
	}
55
	
47
}
56
}
(-)src/org/eclipse/xtext/gmf/glue/partialEditing/SourceViewerHandleFactory.java (-11 / +10 lines)
Lines 11-18 Link Here
11
import java.util.List;
11
import java.util.List;
12
12
13
import org.eclipse.core.runtime.IProgressMonitor;
13
import org.eclipse.core.runtime.IProgressMonitor;
14
import org.eclipse.jface.text.source.IOverviewRuler;
14
import org.eclipse.jface.text.source.ISharedTextColors;
15
import org.eclipse.jface.text.source.ISharedTextColors;
15
import org.eclipse.jface.text.source.IVerticalRuler;
16
import org.eclipse.jface.text.source.IVerticalRuler;
17
import org.eclipse.jface.text.source.OverviewRuler;
16
import org.eclipse.jface.text.source.VerticalRuler;
18
import org.eclipse.jface.text.source.VerticalRuler;
17
import org.eclipse.swt.SWT;
19
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.events.DisposeEvent;
20
import org.eclipse.swt.events.DisposeEvent;
Lines 71-90 Link Here
71
	 *
73
	 *
72
	 */
74
	 */
73
	public SourceViewerHandle create(Composite parent, ISyntheticResourceProvider resourceProvider) {
75
	public SourceViewerHandle create(Composite parent, ISyntheticResourceProvider resourceProvider) {
76
		/*
77
		 * final IVerticalRuler ruler = new VerticalRuler(VERTICAL_RULER_WIDTH, new DefaultMarkerAnnotationAccess());
78
		final IOverviewRuler oRuler = new OverviewRuler(new DefaultMarkerAnnotationAccess(), VERTICAL_RULER_WIDTH, getSharedColors());
79
		final XtextSourceViewer viewer = sourceViewerFactory.createSourceViewer(parent, ruler, oRuler, true, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
80
		 */
81
		
74
		//final XtextSourceViewer viewer= sourceViewerFactory.createSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
82
		//final XtextSourceViewer viewer= sourceViewerFactory.createSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
75
		final IVerticalRuler ruler = new VerticalRuler(VERTICAL_RULER_WIDTH, null) ;
83
		final IVerticalRuler ruler = new VerticalRuler(VERTICAL_RULER_WIDTH, null) ;
76
		final XtextSourceViewer viewer = sourceViewerFactory.createSourceViewer(parent, ruler, null, true, SWT.None);
84
		//final XtextSourceViewer viewer = sourceViewerFactory.createSourceViewer(parent, ruler, null, true, SWT.None);
85
		final XtextSourceViewer viewer = new CustomXtextSourceViewer(parent, ruler, null, true, SWT.None);
77
		XtextSourceViewerConfiguration viewerConfiguration = sourceViewerConfigurationProvider.get();
86
		XtextSourceViewerConfiguration viewerConfiguration = sourceViewerConfigurationProvider.get();
78
//		SourceViewerConfiguration configuration= new SourceViewerConfiguration() {
79
//			public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
80
//
81
//				ContentAssistant assistant= new ContentAssistant();
82
//				assistant.enableAutoActivation(true);
83
//				assistant.enableAutoInsert(true);
84
//				assistant.setContentAssistProcessor(fTemplateProcessor, IDocument.DEFAULT_CONTENT_TYPE);
85
//				return assistant;
86
//			}
87
//		};
88
		viewer.configure(viewerConfiguration);
87
		viewer.configure(viewerConfiguration);
89
		
88
		
90
		final SourceViewerDecorationSupport viewerDecorationSupport = new SourceViewerDecorationSupport(viewer, null, new DefaultMarkerAnnotationAccess(), getSharedColors());
89
		final SourceViewerDecorationSupport viewerDecorationSupport = new SourceViewerDecorationSupport(viewer, null, new DefaultMarkerAnnotationAccess(), getSharedColors());
(-)src/org/eclipse/xtext/gmf/glue/partialEditing/CustomXtextSourceViewer.java (+63 lines)
Line 0 Link Here
1
/*****************************************************************************
2
 * Copyright (c) 2011 CEA LIST.
3
 *
4
 *    
5
 * All rights reserved. This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 *
10
 * Contributors:
11
 *  CEA LIST - Initial API and implementation
12
 *
13
 *****************************************************************************/
14
15
package org.eclipse.xtext.gmf.glue.partialEditing;
16
17
import org.eclipse.jface.text.DocumentCommand;
18
import org.eclipse.jface.text.contentassist.IContentAssistant;
19
import org.eclipse.jface.text.source.IOverviewRuler;
20
import org.eclipse.jface.text.source.IVerticalRuler;
21
import org.eclipse.swt.widgets.Composite;
22
import org.eclipse.xtext.ui.editor.XtextSourceViewer;
23
24
/**
25
 * This class extends XtextSourceViewer with the method getContentAssistant()
26
 * This method was available on XtextSourceViewer in Xtext 1.0, and used
27
 * for integration in Papyrus.
28
 * 
29
 * @author CEA LIST - Initial contribution and API
30
 */
31
public class CustomXtextSourceViewer extends XtextSourceViewer {
32
33
	/**
34
	 * @param parent 
35
	 * @param ruler 
36
	 * @param overviewRuler 
37
	 * @param showsAnnotationOverview 
38
	 * @param styles 
39
	 *
40
	 */
41
	public CustomXtextSourceViewer(Composite parent, IVerticalRuler ruler, IOverviewRuler overviewRuler,
42
			boolean showsAnnotationOverview, int styles) {
43
		super(parent, ruler, overviewRuler, showsAnnotationOverview, styles);
44
	}
45
46
	/**
47
	 * Used in papyrus integration for managing content assist in popup editors.
48
	 * @return the content assistant
49
	 *
50
	 */
51
	public IContentAssistant getContentAssistant() {
52
		return fContentAssistant;
53
	}
54
55
	@Override
56
	protected void customizeDocumentCommand(DocumentCommand command) {
57
		// TODO: TextViewer.customizeDocumentCommand generates exceptions. Why?
58
		//super.customizeDocumentCommand(command);
59
	}
60
	
61
	
62
	
63
}
(-)META-INF/MANIFEST.MF (-1 / +3 lines)
Lines 18-27 Link Here
18
 org.eclipse.uml2.uml;bundle-version="3.1.0",
18
 org.eclipse.uml2.uml;bundle-version="3.1.0",
19
 org.eclipse.papyrus.sasheditor;bundle-version="0.8.0",
19
 org.eclipse.papyrus.sasheditor;bundle-version="0.8.0",
20
 org.eclipse.papyrus.editor;bundle-version="0.8.0",
20
 org.eclipse.papyrus.editor;bundle-version="0.8.0",
21
 org.eclipse.papyrus.core;bundle-version="0.8.0"
21
 org.eclipse.papyrus.core;bundle-version="0.8.0",
22
 org.eclipse.papyrus.properties.runtime;bundle-version="0.8.0"
22
Bundle-RequiredExecutionEnvironment: J2SE-1.5
23
Bundle-RequiredExecutionEnvironment: J2SE-1.5
23
Bundle-ActivationPolicy: lazy
24
Bundle-ActivationPolicy: lazy
24
Export-Package: org.eclipse.xtext.gmf.glue,
25
Export-Package: org.eclipse.xtext.gmf.glue,
26
 org.eclipse.xtext.gmf.glue.concurrency,
25
 org.eclipse.xtext.gmf.glue.contentassist,
27
 org.eclipse.xtext.gmf.glue.contentassist,
26
 org.eclipse.xtext.gmf.glue.edit.part,
28
 org.eclipse.xtext.gmf.glue.edit.part,
27
 org.eclipse.xtext.gmf.glue.editingdomain,
29
 org.eclipse.xtext.gmf.glue.editingdomain,

Return to bug 337289