01: /*******************************************************************************
02: * Copyright (c) 2003, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.editor;
11:
12: import org.eclipse.pde.internal.ui.PDEPlugin;
13: import org.eclipse.pde.internal.ui.editor.context.InputContext;
14: import org.eclipse.ui.PartInitException;
15: import org.eclipse.ui.forms.editor.IFormPage;
16:
17: public abstract class MultiSourceEditor extends PDEFormEditor {
18: protected void addSourcePage(String contextId) {
19: InputContext context = fInputContextManager
20: .findContext(contextId);
21: if (context == null)
22: return;
23: PDESourcePage sourcePage;
24: // Don't duplicate
25: if (findPage(contextId) != null)
26: return;
27: sourcePage = createSourcePage(this , contextId, context
28: .getInput().getName(), context.getId());
29: sourcePage.setInputContext(context);
30: try {
31: addPage(sourcePage, context.getInput());
32: } catch (PartInitException e) {
33: PDEPlugin.logException(e);
34: }
35: }
36:
37: protected void removePage(String pageId) {
38: IFormPage page = findPage(pageId);
39: if (page == null)
40: return;
41: if (page.isDirty()) {
42: // need to ask the user about this
43: } else {
44: removePage(page.getIndex());
45: if (!page.isEditor())
46: page.dispose();
47: }
48: }
49:
50: protected PDESourcePage createSourcePage(PDEFormEditor editor,
51: String title, String name, String contextId) {
52: return new GenericSourcePage(editor, title, name);
53: }
54: }
|