KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > editor > MultiSourceEditor


1 /*******************************************************************************
2  * Copyright (c) 2003, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.ui.editor;
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 JavaDoc contextId) {
19         InputContext context = fInputContextManager.findContext(contextId);
20         if (context == null)
21             return;
22         PDESourcePage sourcePage;
23         // Don't duplicate
24
if (findPage(contextId)!=null) return;
25         sourcePage = createSourcePage(this, contextId, context.getInput().getName(), context.getId());
26         sourcePage.setInputContext(context);
27         try {
28             addPage(sourcePage, context.getInput());
29         } catch (PartInitException e) {
30             PDEPlugin.logException(e);
31         }
32     }
33     
34     protected void removePage(String JavaDoc pageId) {
35         IFormPage page = findPage(pageId);
36         if (page == null)
37             return;
38         if (page.isDirty()) {
39             // need to ask the user about this
40
} else {
41             removePage(page.getIndex());
42             if (!page.isEditor())
43                 page.dispose();
44         }
45     }
46     
47     protected PDESourcePage createSourcePage(PDEFormEditor editor, String JavaDoc title, String JavaDoc name, String JavaDoc contextId) {
48         return new GenericSourcePage(editor, title, name);
49     }
50 }
51
Popular Tags