View | Details | Raw Unified | Return to bug 96129 | Differences between
and this patch

Collapse All | Expand All

(-)plugin.xml (-2 / +40 lines)
Lines 646-651 Link Here
646
               id="org.eclipse.ui.tests.markers.delete">
646
               id="org.eclipse.ui.tests.markers.delete">
647
         </action>
647
         </action>
648
      </actionSet>
648
      </actionSet>
649
      <actionSet
650
            label="TestEditorMulti"
651
            visible="false"
652
            id="org.eclipse.ui.tests.multieditor.actionSet">
653
         <action
654
               class="org.eclipse.ui.tests.api.MockEditorActionDelegate"
655
               disabledIcon="icons/binary_co.gif"
656
               icon="icons/view.gif"
657
               id="org.eclipse.ui.tests.multieditor.editorAction.action"
658
               label="MockMultiEditorAction"
659
               style="push"
660
               toolbarPath="Normal/Presentation"
661
               tooltip="MultiEditorActionThing"/>
662
      </actionSet>
663
      
649
   </extension>
664
   </extension>
650
   <extension
665
   <extension
651
         point="org.eclipse.ui.viewActions">
666
         point="org.eclipse.ui.viewActions">
Lines 1995-2001 Link Here
1995
            default="true"
2010
            default="true"
1996
            name="Editor w/Outline"
2011
            name="Editor w/Outline"
1997
            id="org.eclipse.ui.tests.perf_outline"
2012
            id="org.eclipse.ui.tests.perf_outline"
1998
            extensions="perf_outline"/>    
2013
            extensions="perf_outline"/>
2014
      <editor
2015
            class="org.eclipse.ui.tests.multieditor.TiledEditor"
2016
            default="false"
2017
            icon="icons/editor.gif"
2018
            id="org.eclipse.ui.tests.multieditor.TiledEditor"
2019
            name="%Editors.TiledEditor"/>
2020
      <editor
2021
            class="org.eclipse.ui.tests.multieditor.TestEditor"
2022
            contributorClass="org.eclipse.ui.tests.multieditor.TestActionBarContributor"
2023
            default="false"
2024
            extensions="etest"
2025
            icon="icons/binary_co.gif"
2026
            id="org.eclipse.ui.tests.multieditor.TestEditor"
2027
            name="%Editors.TestEditor"/>    
1999
   </extension>
2028
   </extension>
2000
   <extension
2029
   <extension
2001
         point="org.eclipse.ui.perspectives">
2030
         point="org.eclipse.ui.perspectives">
Lines 2318-2321 Link Here
2318
            icon="icons/anything.gif"
2347
            icon="icons/anything.gif"
2319
            id="org.eclipse.category1"/>   
2348
            id="org.eclipse.category1"/>   
2320
   </extension>
2349
   </extension>
2321
</plugin>            
2350
   <extension
2351
         id="org.eclipse.ui.tests.multieditor.ASPA"
2352
         name="ASPA"
2353
         point="org.eclipse.ui.actionSetPartAssociations">
2354
      <actionSetPartAssociation targetID="org.eclipse.ui.tests.multieditor.actionSet">
2355
         <part id="org.eclipse.ui.tests.multieditor.TestEditor"/>
2356
      </actionSetPartAssociation>
2357
   </extension>
2358
   
2359
</plugin>            
(-)Eclipse (+437 lines)
Added Link Here
1
package org.eclipse.ui.tests.multieditor;
2
3
import junit.framework.TestSuite;
4
5
import org.eclipse.core.resources.IFile;
6
import org.eclipse.core.resources.IProject;
7
import org.eclipse.core.resources.IWorkspace;
8
import org.eclipse.core.resources.ResourcesPlugin;
9
import org.eclipse.core.runtime.CoreException;
10
import org.eclipse.core.runtime.ILog;
11
import org.eclipse.core.runtime.ILogListener;
12
import org.eclipse.core.runtime.IStatus;
13
import org.eclipse.jface.action.IContributionItem;
14
import org.eclipse.jface.action.ToolBarContributionItem;
15
import org.eclipse.jface.action.ToolBarManager;
16
import org.eclipse.swt.widgets.Display;
17
import org.eclipse.swt.widgets.ToolBar;
18
import org.eclipse.swt.widgets.ToolItem;
19
import org.eclipse.ui.IActionBars2;
20
import org.eclipse.ui.IEditorInput;
21
import org.eclipse.ui.IEditorPart;
22
import org.eclipse.ui.IEditorRegistry;
23
import org.eclipse.ui.IViewPart;
24
import org.eclipse.ui.IWorkbenchPage;
25
import org.eclipse.ui.IWorkbenchPart;
26
import org.eclipse.ui.IWorkbenchWindow;
27
import org.eclipse.ui.PartInitException;
28
import org.eclipse.ui.internal.WorkbenchPage;
29
import org.eclipse.ui.internal.WorkbenchPlugin;
30
import org.eclipse.ui.part.FileEditorInput;
31
import org.eclipse.ui.part.IContributedContentsView;
32
import org.eclipse.ui.part.MultiEditor;
33
import org.eclipse.ui.part.MultiEditorInput;
34
import org.eclipse.ui.tests.util.CallHistory;
35
import org.eclipse.ui.tests.util.UITestCase;
36
37
/**
38
 * Test MultiEditor behaviour to highlight some of the broken functionality.
39
 * 
40
 * @since 3.1
41
 */
42
public class MultiEditorTest extends UITestCase {
43
	private static final String PROJECT_NAME = "TiledEditorProject";
44
45
	private static final String CONTENT_OUTLINE = "org.eclipse.ui.views.ContentOutline";
46
47
	private static final String TESTEDITOR_COOLBAR = "org.eclipse.ui.tests.multieditor.TestEditor";
48
49
	private static final String TILED_EDITOR_ID = "org.eclipse.ui.tests.multieditor.TiledEditor";
50
51
	private static final String EDITOR_FAIL_LOG = "Unable to create editor ID ";
52
53
	// tiled editor test files
54
	private static final String TEST01_TXT = "test01.txt";
55
56
	private static final String TEST02_TXT = "test02.txt";
57
58
	private static final String TEST03_ETEST = "test03.etest";
59
60
	private static final String TEST04_PROPERTIES = "test04.properties";
61
62
	private static final String BUILD_XML = "build.xml";
63
64
	public static TestSuite suite() {
65
		return new TestSuite(MultiEditorTest.class);
66
	}
67
68
	/**
69
	 * Can catch a MultiEditor NPE on init.
70
	 */
71
	private NPEListener fNpeListener;
72
73
	public MultiEditorTest(String tc) {
74
		super(tc);
75
	}
76
77
	/**
78
	 * Test that the test tiled editor can be opened with a basic
79
	 * MultiEditorInput with the same type of files.
80
	 * 
81
	 * @throws Throwable
82
	 *             on an error
83
	 */
84
	public void testOpenBasicEditor() throws Throwable {
85
		final String[] simpleFiles = { TEST01_TXT, TEST02_TXT };
86
87
		setupNpe();
88
89
		IWorkbenchWindow window = fWorkbench.getActiveWorkbenchWindow();
90
		IWorkbenchPage page = window.getActivePage();
91
92
		IProject testProject = findOrCreateProject(PROJECT_NAME);
93
94
		MultiEditorInput input = generateEditorInput(simpleFiles, testProject);
95
96
		// validate there are no NullPointerExceptions during editor
97
		// initialization
98
		openAndValidateEditor(page, input);
99
	}
100
101
	/**
102
	 * Test that the public methods in TiledEditor (and MultiEditor) are called
103
	 * in the correct order from 3.0 to 3.1.
104
	 * 
105
	 * @throws Throwable
106
	 */
107
	public void testOpenTestFile() throws Throwable {
108
		final String[] simpleFiles = { TEST01_TXT, TEST03_ETEST };
109
110
		setupNpe();
111
112
		IWorkbenchWindow window = fWorkbench.getActiveWorkbenchWindow();
113
		WorkbenchPage page = (WorkbenchPage) window.getActivePage();
114
115
		IProject testProject = findOrCreateProject(PROJECT_NAME);
116
117
		MultiEditorInput input = generateEditorInput(simpleFiles, testProject);
118
119
		// catches the framework NPE
120
		IEditorPart editor = openAndValidateEditor(page, input);
121
122
		// did we get a multieditor back?
123
		assertTrue(editor instanceof MultiEditor);
124
		MultiEditor multiEditor = (MultiEditor) editor;
125
126
		chewUpEvents();
127
128
		// swap focus to the last editor, which is the test editor
129
		// with the test coolbar contribution
130
		IEditorPart[] innerEditors = multiEditor.getInnerEditors();
131
		innerEditors[innerEditors.length - 1].setFocus();
132
133
		chewUpEvents();
134
135
		final String[] publicMethodTrace = { "init", "init",
136
				"createPartControl", "createInnerPartControl",
137
				"updateInnerEditorTitle", "createInnerPartControl",
138
				"updateInnerEditorTitle", "setFocus", "updateGradient",
139
				"updateGradient", "updateGradient", "updateGradient",
140
				"setFocus", "updateGradient", "updateGradient",
141
				"updateGradient", };
142
		assertTrue("The public methods weren't called in the correct order",
143
				((TiledEditor) multiEditor).callHistory
144
						.verifyOrder(publicMethodTrace));
145
	}
146
147
	/**
148
	 * Test that various items in the workbench are updated when focus moves
149
	 * through the different inner editors.
150
	 * 
151
	 * @throws Throwable
152
	 *             on an error
153
	 */
154
	public void testOpenBuildFile() throws Throwable {
155
		final String[] simpleFiles = { TEST01_TXT, TEST02_TXT,
156
				TEST04_PROPERTIES, BUILD_XML, TEST03_ETEST };
157
158
		setupNpe();
159
160
		IWorkbenchWindow window = fWorkbench.getActiveWorkbenchWindow();
161
		WorkbenchPage page = (WorkbenchPage) window.getActivePage();
162
163
		IProject testProject = findOrCreateProject(PROJECT_NAME);
164
165
		MultiEditorInput input = generateEditorInput(simpleFiles, testProject);
166
167
		// catches the framework NPE
168
		IEditorPart editor = openAndValidateEditor(page, input);
169
170
		// did we get a multieditor back?
171
		assertTrue(editor instanceof MultiEditor);
172
		MultiEditor multiEditor = (MultiEditor) editor;
173
174
		chewUpEvents();
175
176
		// get access to the appropriate coolbar
177
		IContributionItem contribution = findMyCoolBar(page);
178
179
		// our test editor contribution should not be visible
180
		// but it should be enabled
181
		assertFalse("We open in the default text editor", contribution
182
				.isVisible());
183
		assertTrue("And we're good to go", contribution.isEnabled());
184
185
		// swap focus to the last editor, which is the test editor
186
		// with the test coolbar contribution
187
		IEditorPart[] innerEditors = multiEditor.getInnerEditors();
188
		innerEditors[innerEditors.length - 1].setFocus();
189
190
		chewUpEvents();
191
192
		// our test editor contribution should now be visible and
193
		// enabled
194
		assertTrue("We are in the test editor", contribution.isVisible());
195
		assertTrue("And we're good to go", contribution.isEnabled());
196
197
		// Swap to the second last editor, which should be the ant
198
		// build editor.
199
		innerEditors[innerEditors.length - 2].setFocus();
200
		chewUpEvents();
201
202
		// get the outline view part
203
		IViewPart outline = window.getActivePage().findView(CONTENT_OUTLINE);
204
		assertNotNull(outline);
205
206
		// find out who is contributing the outline view.
207
		IContributedContentsView view = (IContributedContentsView) outline
208
				.getAdapter(IContributedContentsView.class);
209
		IWorkbenchPart part = view.getContributingPart();
210
		assertNotNull("The Outline view has not been updated by the editor",
211
				part);
212
		assertTrue("The Outline view is not talking to an editor",
213
				part instanceof IEditorPart);
214
215
		IEditorPart outlineEditor = (IEditorPart) part;
216
217
		// the active inner editor (the ant editor) should also
218
		// be the outline editor contributor ... this works in
219
		// 3.0, fails in 3.1
220
		assertEquals("The Outline view is not talking to the correct editor",
221
				multiEditor.getActiveEditor(), outlineEditor);
222
	}
223
224
	/**
225
	 * Return the test editor coolbar.
226
	 * 
227
	 * @param page
228
	 *            the workbench page
229
	 * @return the IContributionItem for the test editor cool bar.
230
	 */
231
	private IContributionItem findMyCoolBar(WorkbenchPage page) {
232
		IContributionItem contribution = ((IActionBars2) page.getActionBars())
233
				.getCoolBarManager().find(TESTEDITOR_COOLBAR);
234
		assertNotNull(contribution);
235
236
		return contribution;
237
	}
238
239
	/**
240
	 * Create the project to work in. If it already exists, just open it.
241
	 * 
242
	 * @param projectName
243
	 *            the name of the project to create
244
	 * @return the newly opened project
245
	 * @throws CoreException
246
	 */
247
	private IProject findOrCreateProject(String projectName)
248
			throws CoreException {
249
		IWorkspace workspace = ResourcesPlugin.getWorkspace();
250
		IProject testProject = workspace.getRoot().getProject(projectName);
251
		if (!testProject.exists()) {
252
			testProject.create(null);
253
		}
254
		testProject.open(null);
255
		return testProject;
256
	}
257
258
	/**
259
	 * Internal printing method, only used for investigation.
260
	 * 
261
	 * @param page
262
	 *            the workbench page
263
	 */
264
	private void checkView(WorkbenchPage page) {
265
		IViewPart[] views = page.getViews();
266
		for (int i = 0; i < views.length; ++i) {
267
			System.err.println("view: " + views[i].getViewSite().getId() + "/"
268
					+ views[i].getViewSite().getRegisteredName());
269
		}
270
	}
271
272
	/**
273
	 * Print the call history to console. Only used for investigation.
274
	 * 
275
	 * @param history
276
	 *            the editor call history object.
277
	 */
278
	private void listHistory(CallHistory history) {
279
		history.printToConsole();
280
	}
281
282
	/**
283
	 * List bits and internals of the coolbar manager contribution items. Only
284
	 * used for investigation.
285
	 * 
286
	 * @param page
287
	 *            the workbench page
288
	 */
289
	private void listItems(WorkbenchPage page) {
290
		checkView(page);
291
		IContributionItem[] items = ((IActionBars2) page.getActionBars())
292
				.getCoolBarManager().getItems();
293
		System.err.println("Length: " + items.length);
294
		for (int i = 0; i < items.length; ++i) {
295
			System.err.println("" + items[i].isEnabled() + ":"
296
					+ items[i].isVisible() + " " + items[i].getId() + "\n\t"
297
					+ items[i].getClass().getName());
298
			if (items[i] instanceof ToolBarContributionItem) {
299
				displayItem(items[i]);
300
			}
301
		}
302
		System.err.println("----");
303
	}
304
305
	/**
306
	 * Display bits of contribution item internals to the console. Only used for
307
	 * investigation.
308
	 * 
309
	 * @param contributionItem
310
	 *            the IContributionItem to display
311
	 */
312
	private void displayItem(IContributionItem contributionItem) {
313
		ToolBarManager toolBarManager = (ToolBarManager) ((ToolBarContributionItem) contributionItem)
314
				.getToolBarManager();
315
		ToolBar bar = toolBarManager.getControl();
316
		if (bar == null) {
317
			System.err.println("\tInfo-items: -1");
318
		} else {
319
			System.err.println("\tInfo-items: " + bar.getItemCount() + "/"
320
					+ bar.getEnabled() + "/" + bar.isEnabled() + "/"
321
					+ bar.isVisible());
322
			ToolItem[] tools = bar.getItems();
323
			for (int t = 0; t < tools.length; ++t) {
324
				System.err.println("\t\titem: " + tools[t].getEnabled() + " "
325
						+ tools[t].getToolTipText());
326
			}
327
		}
328
	}
329
330
	/**
331
	 * After an internal action, see if there are any outstanding SWT events.
332
	 */
333
	private void chewUpEvents() throws InterruptedException {
334
		Thread.sleep(250);
335
		Display display = Display.getCurrent();
336
		while (display.readAndDispatch())
337
			;
338
	}
339
340
	/**
341
	 * Open the test editor. It does basic validation that there is no
342
	 * NullPointerException during initialization.
343
	 * 
344
	 * @param page
345
	 *            the workbench page
346
	 * @param input
347
	 *            the editor input with multiple files
348
	 * @return the MultiEditor
349
	 * @throws PartInitException
350
	 */
351
	private IEditorPart openAndValidateEditor(IWorkbenchPage page,
352
			MultiEditorInput input) throws PartInitException {
353
		IEditorPart editorPart = page.openEditor(input,
354
				MultiEditorTest.TILED_EDITOR_ID);
355
		assertNotNull(editorPart);
356
357
		// 3.1.0 only
358
		// assertFalse("The editor never actualized",
359
		// editorPart instanceof ErrorEditorPart);
360
361
		assertTrue("Unable to create " + MultiEditorTest.TILED_EDITOR_ID,
362
				fNpeListener.noNPE);
363
		return editorPart;
364
	}
365
366
	/**
367
	 * Set up to catch any editor initialization NullPointerExceptions.
368
	 * 
369
	 */
370
	private void setupNpe() {
371
		final ILog log = WorkbenchPlugin.getDefault().getLog();
372
		fNpeListener = new NPEListener();
373
		log.addLogListener(fNpeListener);
374
	}
375
376
	/**
377
	 * Create the multi editor input in the given project. Creates the files in
378
	 * the project from template files in the classpath if they don't already
379
	 * exist.
380
	 * 
381
	 * @param simpleFiles
382
	 *            the array of filenames to copy over
383
	 * @param testProject
384
	 *            the project to create the files in
385
	 * @return the editor input used to open the multieditor
386
	 * @throws CoreException
387
	 */
388
	private MultiEditorInput generateEditorInput(String[] simpleFiles,
389
			IProject testProject) throws CoreException {
390
		String[] ids = new String[simpleFiles.length];
391
		IEditorInput[] inputs = new IEditorInput[simpleFiles.length];
392
		IEditorRegistry registry = fWorkbench.getEditorRegistry();
393
394
		for (int f = 0; f < simpleFiles.length; ++f) {
395
			IFile f1 = testProject.getFile(simpleFiles[f]);
396
			if (!f1.exists()) {
397
				f1.create(getClass().getResourceAsStream(simpleFiles[f]), true,
398
						null);
399
			}
400
			ids[f] = registry.getDefaultEditor(f1.getName()).getId();
401
			inputs[f] = new FileEditorInput(f1);
402
		}
403
404
		MultiEditorInput input = new MultiEditorInput(ids, inputs);
405
		return input;
406
	}
407
408
	/**
409
	 * Close any editors at the end of a test, so the next test can be clean.
410
	 */
411
	protected void doTearDown() throws Exception {
412
		fWorkbench.getActiveWorkbenchWindow().getActivePage().closeAllEditors(
413
				false);
414
		super.doTearDown();
415
	}
416
417
	/**
418
	 * Listens for the standard message that indicates the MultiEditor failed
419
	 * ... usually caused by incorrect framework initialization that doesn't set
420
	 * the innerChildren.
421
	 * 
422
	 * @since 3.1
423
	 * 
424
	 */
425
	public static class NPEListener implements ILogListener {
426
		public boolean noNPE = true;
427
428
		public void logging(IStatus status, String plugin) {
429
			String msg = status.getMessage();
430
			if (msg != null
431
					&& msg.indexOf(MultiEditorTest.EDITOR_FAIL_LOG
432
							+ MultiEditorTest.TILED_EDITOR_ID) >= 0) {
433
				noNPE = false;
434
			}
435
		}
436
	}
437
}
(-)Eclipse (+18 lines)
Added Link Here
1
package org.eclipse.ui.tests.multieditor;
2
3
import org.eclipse.jface.action.ICoolBarManager;
4
import org.eclipse.ui.part.EditorActionBarContributor;
5
6
public class TestActionBarContributor extends EditorActionBarContributor {
7
8
	public TestActionBarContributor() {
9
		super();
10
	}
11
12
	/* (non-Javadoc)
13
	 * @see org.eclipse.ui.part.EditorActionBarContributor#contributeToCoolBar(org.eclipse.jface.action.ICoolBarManager)
14
	 */
15
	public void contributeToCoolBar(ICoolBarManager coolBarManager) {
16
		super.contributeToCoolBar(coolBarManager);
17
	}
18
}
(-)Eclipse (+80 lines)
Added Link Here
1
package org.eclipse.ui.tests.multieditor;
2
3
import org.eclipse.core.runtime.IProgressMonitor;
4
import org.eclipse.swt.SWT;
5
import org.eclipse.swt.layout.RowLayout;
6
import org.eclipse.swt.widgets.Composite;
7
import org.eclipse.swt.widgets.Label;
8
import org.eclipse.ui.IEditorInput;
9
import org.eclipse.ui.IEditorSite;
10
import org.eclipse.ui.IFileEditorInput;
11
import org.eclipse.ui.PartInitException;
12
import org.eclipse.ui.part.EditorPart;
13
14
/**
15
 * A test editor that does pretty-well nothing.  Activating it will
16
 * update the coolbar, and possibly eventually the outline as well.
17
 * 
18
 * @since 3.1
19
 *
20
 */
21
public class TestEditor extends EditorPart {
22
23
	private Composite fMainPanel;
24
25
	public TestEditor() {
26
		super();
27
		// TODO Auto-generated constructor stub
28
	}
29
30
	public void doSave(IProgressMonitor monitor) {
31
		// TODO Auto-generated method stub
32
33
	}
34
35
	public void doSaveAs() {
36
		// TODO Auto-generated method stub
37
38
	}
39
40
	public void init(IEditorSite site, IEditorInput input)
41
			throws PartInitException {
42
		if (!(input instanceof IFileEditorInput))
43
			throw new PartInitException(
44
					"Invalid Input: Must be IFileEditorInput");
45
		setSite(site);
46
		setInput(input);
47
48
	}
49
50
	public boolean isDirty() {
51
		// TODO Auto-generated method stub
52
		return false;
53
	}
54
55
	public boolean isSaveAsAllowed() {
56
		// TODO Auto-generated method stub
57
		return false;
58
	}
59
60
	public void createPartControl(Composite parent) {
61
		fMainPanel = new Composite(parent, SWT.NONE);
62
		fMainPanel.setLayout(new RowLayout(SWT.VERTICAL));
63
64
		Label l = new Label(fMainPanel, SWT.NONE);
65
		l.setText("Editor Title:");
66
67
		l = new Label(fMainPanel, SWT.BORDER);
68
		l.setText(getEditorInput().getName());
69
	}
70
71
	/*
72
	 * (non-Javadoc)
73
	 * 
74
	 * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
75
	 */
76
	public void setFocus() {
77
		fMainPanel.setFocus();
78
	}
79
80
}
(-)Eclipse (+162 lines)
Added Link Here
1
/*
2
 * (c) Copyright 2001 MyCorporation.
3
 * All Rights Reserved.
4
 */
5
package org.eclipse.ui.tests.multieditor;
6
7
import org.eclipse.swt.SWT;
8
import org.eclipse.swt.custom.CLabel;
9
import org.eclipse.swt.custom.SashForm;
10
import org.eclipse.swt.custom.ViewForm;
11
import org.eclipse.swt.graphics.Image;
12
import org.eclipse.swt.layout.FillLayout;
13
import org.eclipse.swt.widgets.Composite;
14
import org.eclipse.ui.IEditorInput;
15
import org.eclipse.ui.IEditorPart;
16
import org.eclipse.ui.IEditorSite;
17
import org.eclipse.ui.IPropertyListener;
18
import org.eclipse.ui.IWorkbenchPart;
19
import org.eclipse.ui.PartInitException;
20
import org.eclipse.ui.part.MultiEditor;
21
import org.eclipse.ui.part.MultiEditorInput;
22
import org.eclipse.ui.tests.util.CallHistory;
23
24
/**
25
 * Implementation of a TiledEditor.  This is the testable version
26
 * copied from bug 42641.
27
 */
28
public class TiledEditor extends MultiEditor {
29
	
30
	private CLabel innerEditorTitle[];
31
	public CallHistory callHistory;
32
	
33
	public TiledEditor() {
34
		super();
35
		callHistory = new CallHistory(this);
36
	}
37
	
38
	/*
39
	 * @see IWorkbenchPart#createPartControl(Composite)
40
	 */
41
	public void createPartControl(Composite parent) {
42
		callHistory.add("createPartControl");
43
		
44
		parent = new Composite(parent, SWT.BORDER);
45
46
		parent.setLayout(new FillLayout());
47
		SashForm sashForm = new SashForm(parent, SWT.HORIZONTAL);
48
		IEditorPart innerEditors[] = getInnerEditors();
49
		
50
		for (int i = 0; i < innerEditors.length; i++) {
51
			final IEditorPart e = innerEditors[i];
52
			ViewForm viewForm = new ViewForm(sashForm, SWT.NONE);
53
			viewForm.marginWidth = 0;
54
			viewForm.marginHeight = 0;
55
56
			createInnerEditorTitle(i, viewForm);
57
			
58
			Composite content = createInnerPartControl(viewForm,e);
59
			
60
			viewForm.setContent(content);
61
			updateInnerEditorTitle(e, innerEditorTitle[i]);
62
			
63
			final int index = i;
64
			e.addPropertyListener(new IPropertyListener() {
65
				public void propertyChanged(Object source, int property) {
66
					if (property == IEditorPart.PROP_DIRTY || property == IWorkbenchPart.PROP_TITLE)
67
						if (source instanceof IEditorPart)
68
							updateInnerEditorTitle((IEditorPart) source, innerEditorTitle[index]);
69
				}
70
			});
71
		}
72
	}
73
	
74
	/**
75
	 * Draw the gradient for the specified editor.
76
	 */
77
	protected void drawGradient(IEditorPart innerEditor, Gradient g) {
78
		CLabel label = innerEditorTitle[getIndex(innerEditor)];
79
		if((label == null) || label.isDisposed())
80
			return;
81
			
82
		label.setForeground(g.fgColor);
83
		label.setBackground(g.bgColors, g.bgPercents);
84
	}
85
	
86
	/*
87
	 * Create the label for each inner editor. 
88
	 */
89
	protected void createInnerEditorTitle(int index, ViewForm parent) {
90
		
91
		CLabel titleLabel = new CLabel(parent, SWT.SHADOW_NONE);
92
		//hookFocus(titleLabel);
93
		titleLabel.setAlignment(SWT.LEFT);
94
		titleLabel.setBackground(null, null);
95
		parent.setTopLeft(titleLabel);
96
		if (innerEditorTitle == null)
97
			innerEditorTitle = new CLabel[getInnerEditors().length];
98
		innerEditorTitle[index] = titleLabel;
99
	}
100
	
101
	/*
102
	 * Update the tab for an editor.  This is typically called
103
	 * by a site when the tab title changes.
104
	 */
105
	public void updateInnerEditorTitle(IEditorPart editor, CLabel label) {
106
		callHistory.add("updateInnerEditorTitle");
107
		
108
		if((label == null) || label.isDisposed())
109
			return;
110
		String title = editor.getTitle();
111
		if (editor.isDirty())
112
			title = "*" + title; //$NON-NLS-1$
113
		label.setText(title);
114
		Image image = editor.getTitleImage();
115
		if (image != null)
116
			if (!image.equals(label.getImage()))
117
				label.setImage(image);
118
		label.setToolTipText(editor.getTitleToolTip());
119
	}
120
	
121
	/*
122
	 * 
123
	 */
124
	protected int getIndex(IEditorPart editor) {
125
		IEditorPart innerEditors[] = getInnerEditors();
126
		for (int i = 0; i < innerEditors.length; i++) {
127
			if (innerEditors[i] == editor)
128
				return i;
129
		}
130
		return -1;
131
	}
132
133
	//
134
	// These are public methods from the parent that are overriden to
135
	// add them to the call history.
136
	//
137
	
138
	public Composite createInnerPartControl(Composite parent, IEditorPart e) {
139
		callHistory.add("createInnerPartControl");
140
		return super.createInnerPartControl(parent, e);
141
	}
142
143
	public void init(IEditorSite site, IEditorInput input) throws PartInitException {
144
		callHistory.add("init");
145
		super.init(site, input);
146
	}
147
148
	public void init(IEditorSite site, MultiEditorInput input) throws PartInitException {
149
		callHistory.add("init");
150
		super.init(site, input);
151
	}
152
153
	public void setFocus() {
154
		callHistory.add("setFocus");
155
		super.setFocus();
156
	}
157
158
	public void updateGradient(IEditorPart editor) {
159
		callHistory.add("updateGradient");
160
		super.updateGradient(editor);
161
	}
162
}
(-)Eclipse (+29 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!-- ====================================================================== 
3
     Jun 27, 2005 10:23:13 AM                                                        
4
5
     project    
6
     description
7
                   
8
     pwebster                                                                
9
     ====================================================================== -->
10
<project name="project" default="default">
11
    <description>
12
            description
13
    </description>
14
15
    <!-- ================================= 
16
          target: default              
17
         ================================= -->
18
    <target name="default" depends="depends" description="--> description">
19
        
20
    </target>
21
22
    <!-- - - - - - - - - - - - - - - - - - 
23
          target: depends                      
24
         - - - - - - - - - - - - - - - - - -->
25
    <target name="depends">
26
    </target>
27
28
</project>
29
(-)Eclipse (+3 lines)
Added Link Here
1
test file 01
2
3
test for MultiEditor
(-)Eclipse (+3 lines)
Added Link Here
1
test file 02
2
3
test for MultiEditor
(-)Eclipse (+3 lines)
Added Link Here
1
test file 03
2
3
test for MultiEditor
(-)Eclipse (+2 lines)
Added Link Here
1
org.eclipse.ui.tests.multieditor.good = MultiEditorTest
2
org.eclipse.ui.tests.multieditor.bad = TiledEditor
(-)icons/editor.gif (+2 lines)
Added Link Here
1
GIF89a�??�?��߿�߿����ߟ������___���!�	,G0�I+=8�SO1`hH'����
2
�el��t�a.��˗��6q��d�쩛�n˦�3�z��bL.[Ε;

Return to bug 96129