01: /*******************************************************************************
02: * Copyright (c) 2000, 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.ui.examples.propertysheet;
11:
12: import org.eclipse.jface.text.Document;
13: import org.eclipse.swt.widgets.Composite;
14: import org.eclipse.ui.editors.text.TextEditor;
15: import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
16: import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
17: import org.eclipse.ui.views.properties.IPropertySheetPage;
18: import org.eclipse.ui.views.properties.PropertySheetPage;
19:
20: /**
21: * This class implements the User editor.
22: */
23: public class UserEditor extends TextEditor {
24: private ContentOutlinePage userContentOutline;
25:
26: /**
27: * UserEditor default Constructor
28: */
29: public UserEditor() {
30: super ();
31: }
32:
33: /* (non-Javadoc)
34: * Method declared on WorkbenchPart
35: */
36: public void createPartControl(Composite parent) {
37: super .createPartControl(parent);
38: getSourceViewer().setDocument(
39: new Document(MessageUtil
40: .getString("Editor_instructions"))); //$NON-NLS-1$
41: }
42:
43: /* (non-Javadoc)
44: * Method declared on IAdaptable
45: */
46: public Object getAdapter(Class adapter) {
47: if (adapter.equals(IContentOutlinePage.class)) {
48: return getContentOutline();
49: }
50: if (adapter.equals(IPropertySheetPage.class)) {
51: return getPropertySheet();
52: }
53: return super .getAdapter(adapter);
54: }
55:
56: /**
57: * Returns the content outline.
58: */
59: protected ContentOutlinePage getContentOutline() {
60: if (userContentOutline == null) {
61: //Create a property outline page using the parsed result of passing in the document provider.
62: userContentOutline = new PropertySheetContentOutlinePage(
63: new UserFileParser().parse(getDocumentProvider()));
64: }
65: return userContentOutline;
66: }
67:
68: /**
69: * Returns the property sheet.
70: */
71: protected IPropertySheetPage getPropertySheet() {
72: return new PropertySheetPage();
73: }
74: }
|