001: /*******************************************************************************
002: * Copyright (c) 2004, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.ui.tests.performance.parts;
011:
012: import java.util.StringTokenizer;
013:
014: import org.eclipse.core.runtime.IConfigurationElement;
015: import org.eclipse.core.runtime.IProgressMonitor;
016: import org.eclipse.swt.SWT;
017: import org.eclipse.swt.widgets.Composite;
018: import org.eclipse.swt.widgets.Label;
019: import org.eclipse.ui.IEditorInput;
020: import org.eclipse.ui.IEditorSite;
021: import org.eclipse.ui.PartInitException;
022: import org.eclipse.ui.part.EditorPart;
023: import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
024: import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
025:
026: /**
027: * @since 3.1
028: */
029: public class PerformanceEditorPart extends EditorPart {
030:
031: private static final String PARAM_OUTLINE = "outline";
032:
033: private boolean dirty;
034: private Label control;
035: private boolean useOutline = false;
036:
037: /**
038: *
039: */
040: public PerformanceEditorPart() {
041: super ();
042: }
043:
044: /* (non-Javadoc)
045: * @see org.eclipse.ui.ISaveablePart#doSave(org.eclipse.core.runtime.IProgressMonitor)
046: */
047: public void doSave(IProgressMonitor monitor) {
048: }
049:
050: /* (non-Javadoc)
051: * @see org.eclipse.ui.ISaveablePart#doSaveAs()
052: */
053: public void doSaveAs() {
054: }
055:
056: /* (non-Javadoc)
057: * @see org.eclipse.ui.IEditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
058: */
059: public void init(IEditorSite site, IEditorInput input)
060: throws PartInitException {
061: super .setSite(site);
062: super .setInput(input);
063: }
064:
065: /* (non-Javadoc)
066: * @see org.eclipse.ui.ISaveablePart#isDirty()
067: */
068: public boolean isDirty() {
069: return dirty;
070: }
071:
072: public void setDirty(boolean dirty) {
073: this .dirty = dirty;
074: }
075:
076: /* (non-Javadoc)
077: * @see org.eclipse.ui.ISaveablePart#isSaveAsAllowed()
078: */
079: public boolean isSaveAsAllowed() {
080: return false;
081: }
082:
083: /* (non-Javadoc)
084: * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
085: */
086: public void createPartControl(Composite parent) {
087: control = new Label(parent, SWT.NONE);
088:
089: }
090:
091: /* (non-Javadoc)
092: * @see org.eclipse.ui.IWorkbenchPart#setFocus()
093: */
094: public void setFocus() {
095: control.setFocus();
096: }
097:
098: /* (non-Javadoc)
099: * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)
100: */
101: public void setInitializationData(IConfigurationElement cfig,
102: String propertyName, Object data) {
103: super .setInitializationData(cfig, propertyName, data);
104:
105: if (data instanceof String) {
106: for (StringTokenizer toker = new StringTokenizer(
107: (String) data, ","); toker.hasMoreTokens();) {
108: String token = toker.nextToken();
109: if (token.equals(PARAM_OUTLINE))
110: useOutline = true;
111: }
112:
113: }
114: }
115:
116: /* (non-Javadoc)
117: * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
118: */
119: public Object getAdapter(Class adapter) {
120: Object object = null;
121: if (useOutline && adapter.equals(IContentOutlinePage.class)) {
122: object = new ContentOutlinePage() {
123: };
124: }
125: if (object != null)
126: return object;
127: return super.getAdapter(adapter);
128: }
129: }
|