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 375741
Collapse All | Expand All

(-)a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/CompatibilityPart.java (-1 / +40 lines)
Lines 28-33 Link Here
28
import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
28
import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
29
import org.eclipse.e4.ui.workbench.IPresentationEngine;
29
import org.eclipse.e4.ui.workbench.IPresentationEngine;
30
import org.eclipse.e4.ui.workbench.UIEvents;
30
import org.eclipse.e4.ui.workbench.UIEvents;
31
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
32
import org.eclipse.jface.viewers.IPostSelectionProvider;
33
import org.eclipse.jface.viewers.ISelectionChangedListener;
34
import org.eclipse.jface.viewers.ISelectionProvider;
35
import org.eclipse.jface.viewers.SelectionChangedEvent;
31
import org.eclipse.swt.SWT;
36
import org.eclipse.swt.SWT;
32
import org.eclipse.swt.custom.CTabFolder;
37
import org.eclipse.swt.custom.CTabFolder;
33
import org.eclipse.swt.custom.CTabItem;
38
import org.eclipse.swt.custom.CTabItem;
Lines 53-59 Link Here
53
import org.osgi.service.event.Event;
58
import org.osgi.service.event.Event;
54
import org.osgi.service.event.EventHandler;
59
import org.osgi.service.event.EventHandler;
55
60
56
public abstract class CompatibilityPart {
61
public abstract class CompatibilityPart implements ISelectionChangedListener {
57
62
58
	public static final String COMPATIBILITY_EDITOR_URI = "bundleclass://org.eclipse.ui.workbench/org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor"; //$NON-NLS-1$
63
	public static final String COMPATIBILITY_EDITOR_URI = "bundleclass://org.eclipse.ui.workbench/org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor"; //$NON-NLS-1$
59
64
Lines 151-156 Link Here
151
				WorkbenchPlugin.log("Unable to initialize error part", ex.getStatus()); //$NON-NLS-1$
156
				WorkbenchPlugin.log("Unable to initialize error part", ex.getStatus()); //$NON-NLS-1$
152
			}
157
			}
153
		}
158
		}
159
160
		IWorkbenchPartSite site = legacyPart.getSite();
161
		if (site != null) {
162
			ISelectionProvider selectionProvider = site.getSelectionProvider();
163
			if (selectionProvider != null) {
164
				selectionProvider.addSelectionChangedListener(this);
165
166
				if (selectionProvider instanceof IPostSelectionProvider) {
167
					((IPostSelectionProvider) selectionProvider)
168
							.addPostSelectionChangedListener(this);
169
				}
170
			}
171
		}
154
		return true;
172
		return true;
155
	}
173
	}
156
174
Lines 168-173 Link Here
168
	}
186
	}
169
187
170
	private void invalidate() {
188
	private void invalidate() {
189
		if (wrapped != null) {
190
			IWorkbenchPartSite site = wrapped.getSite();
191
			if (site != null) {
192
				ISelectionProvider selectionProvider = site.getSelectionProvider();
193
				if (selectionProvider != null) {
194
					selectionProvider.removeSelectionChangedListener(this);
195
196
					if (selectionProvider instanceof IPostSelectionProvider) {
197
						((IPostSelectionProvider) selectionProvider)
198
								.removePostSelectionChangedListener(this);
199
					}
200
				}
201
			}
202
		}
203
171
		WorkbenchPartReference reference = getReference();
204
		WorkbenchPartReference reference = getReference();
172
		reference.invalidate();
205
		reference.invalidate();
173
206
Lines 380-383 Link Here
380
	public MPart getModel() {
413
	public MPart getModel() {
381
		return part;
414
		return part;
382
	}
415
	}
416
	
417
	public void selectionChanged(SelectionChangedEvent e) {
418
		ESelectionService selectionService = (ESelectionService) part.getContext().get(
419
				ESelectionService.class.getName());
420
		selectionService.setSelection(e.getSelection());
421
	}
383
}
422
}
(-)a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/SelectionService.java (-27 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
2
 * Copyright (c) 2010, 2012 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 24-30 Link Here
24
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
24
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
25
import org.eclipse.e4.ui.services.IServiceConstants;
25
import org.eclipse.e4.ui.services.IServiceConstants;
26
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
26
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
27
import org.eclipse.jface.viewers.IPostSelectionProvider;
28
import org.eclipse.jface.viewers.ISelection;
27
import org.eclipse.jface.viewers.ISelection;
29
import org.eclipse.jface.viewers.ISelectionChangedListener;
28
import org.eclipse.jface.viewers.ISelectionChangedListener;
30
import org.eclipse.jface.viewers.ISelectionProvider;
29
import org.eclipse.jface.viewers.ISelectionProvider;
Lines 113-147 Link Here
113
112
114
	@Inject
113
	@Inject
115
	void setPart(@Optional @Named(IServiceConstants.ACTIVE_PART) final MPart part) {
114
	void setPart(@Optional @Named(IServiceConstants.ACTIVE_PART) final MPart part) {
116
		if (activePart != null) {
115
		activePart = null;
117
			ISelectionProvider selectionProvider = activePart.getSite().getSelectionProvider();
118
			if (selectionProvider != null) {
119
				selectionProvider.removeSelectionChangedListener(this);
120
121
				if (selectionProvider instanceof IPostSelectionProvider) {
122
					((IPostSelectionProvider) selectionProvider)
123
							.removePostSelectionChangedListener(this);
124
				}
125
			}
126
			activePart = null;
127
		}
128
129
		if (part != null) {
116
		if (part != null) {
130
			Object client = part.getObject();
117
			Object client = part.getObject();
131
			if (client instanceof CompatibilityPart) {
118
			if (client instanceof CompatibilityPart) {
132
				IWorkbenchPart workbenchPart = ((CompatibilityPart) client).getPart();
119
				IWorkbenchPart workbenchPart = ((CompatibilityPart) client).getPart();
133
134
				ISelectionProvider selectionProvider = workbenchPart.getSite()
135
						.getSelectionProvider();
136
				if (selectionProvider != null) {
137
					selectionProvider.addSelectionChangedListener(this);
138
139
					if (selectionProvider instanceof IPostSelectionProvider) {
140
						((IPostSelectionProvider) selectionProvider)
141
								.addPostSelectionChangedListener(this);
142
					}
143
				}
144
145
				activePart = workbenchPart;
120
				activePart = workbenchPart;
146
			}
121
			}
147
		}
122
		}

Return to bug 375741